Class: Fog::AWS::ElasticBeanstalk::Templates
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::ElasticBeanstalk::Templates
- Defined in:
- lib/fog/aws/models/beanstalk/templates.rb
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Describes all configuration templates, may optionally pass an ApplicationName filter.
- #get(application_name, template_name) ⇒ Object
Methods inherited from Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Fog::Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Fog::Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all(options = {}) ⇒ Object
Describes all configuration templates, may optionally pass an ApplicationName filter
Note: This is currently an expensive operation requiring multiple API calls due to a lack of a describe configuration templates call in the AWS API.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/aws/models/beanstalk/templates.rb', line 15 def all(={}) application_filter = [] if .has_key?('ApplicationName') application_filter << ['ApplicationName'] end # Initialize with empty array data = [] applications = service.describe_applications(application_filter).body['DescribeApplicationsResult']['Applications'] applications.each { |application| application['ConfigurationTemplates'].each { |template_name| begin = { 'ApplicationName' => application['ApplicationName'], 'TemplateName' => template_name } settings = service.describe_configuration_settings().body['DescribeConfigurationSettingsResult']['ConfigurationSettings'] if settings.length == 1 # Add to data data << settings.first end rescue Fog::AWS::ElasticBeanstalk::InvalidParameterError # Ignore end } } load(data) # data is an array of attribute hashes end |
#get(application_name, template_name) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fog/aws/models/beanstalk/templates.rb', line 47 def get(application_name, template_name) = { 'ApplicationName' => application_name, 'TemplateName' => template_name } result = nil # There is no describe call for templates, so we must use describe_configuration_settings. Unfortunately, # it throws an exception if template name doesn't exist, which is inconsistent, catch and return nil begin data = service.describe_configuration_settings().body['DescribeConfigurationSettingsResult']['ConfigurationSettings'] if data.length == 1 result = new(data.first) end rescue Fog::AWS::ElasticBeanstalk::InvalidParameterError end result end |