Class: Fog::AWS::ElasticBeanstalk::Environment
- Defined in:
- lib/fog/aws/models/beanstalk/environment.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#events ⇒ Object
Return events related to this version.
- #healthy? ⇒ Boolean
-
#live_resources ⇒ Object
Returns the current live resources for this environment.
-
#load_balancer(elb_connection = Fog::AWS[:elb]) ⇒ Object
Returns the load balancer object associated with the environment.
- #ready? ⇒ Boolean
-
#rebuild ⇒ Object
Rebuilds the environment.
-
#restart_app_server ⇒ Object
Restarts the app servers in this environment.
- #save ⇒ Object
- #terminated? ⇒ Boolean
-
#version ⇒ Object
Return the version object for this environment.
-
#version=(new_version) ⇒ Object
Update the running version of this environment.
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Fog::Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#destroy ⇒ Object
103 104 105 106 107 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 103 def destroy requires :id connection.terminate_environment({'EnvironmentId' => id}) true end |
#events ⇒ Object
Return events related to this version
55 56 57 58 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 55 def events requires :id connection.events.all({'EnvironmentId' => id}) end |
#healthy? ⇒ Boolean
28 29 30 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 28 def healthy? health == 'Green' end |
#live_resources ⇒ Object
Returns the current live resources for this environment
41 42 43 44 45 46 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 41 def live_resources requires :id data = connection.describe_environment_resources({'EnvironmentId' => id}).body['DescribeEnvironmentResourcesResult']['EnvironmentResources'] data.delete('EnvironmentName') # Delete the environment name from the result, only return actual resources data end |
#load_balancer(elb_connection = Fog::AWS[:elb]) ⇒ Object
Returns the load balancer object associated with the environment.
49 50 51 52 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 49 def load_balancer(elb_connection = Fog::AWS[:elb]) requires :resources elb_connection.load_balancers.get(resources['LoadBalancer']['LoadBalancerName']) end |
#ready? ⇒ Boolean
32 33 34 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 32 def ready? status == 'Ready' end |
#rebuild ⇒ Object
Rebuilds the environment
68 69 70 71 72 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 68 def rebuild requires :id connection.rebuild_environment({'EnvironmentId' => id}) reload end |
#restart_app_server ⇒ Object
Restarts the app servers in this environment
61 62 63 64 65 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 61 def restart_app_server requires :id connection.restart_app_server({'EnvironmentId' => id}) reload end |
#save ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 109 def save requires :name, :application_name requires_one :template_name, :solution_stack_name = { 'ApplicationName' => application_name, 'CNAMEPrefix' => cname_prefix, 'Description' => description, 'EnvironmentName' => name, 'OptionSettings' => option_settings, 'OptionsToRemove' => , 'SolutionStackName' => solution_stack_name, 'TemplateName' => template_name, 'VersionLabel' => version_label } .delete_if {|key, value| value.nil?} data = connection.create_environment().body['CreateEnvironmentResult'] merge_attributes(data) true end |
#terminated? ⇒ Boolean
36 37 38 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 36 def terminated? status == 'Terminated' end |
#version ⇒ Object
Return the version object for this environment
75 76 77 78 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 75 def version requires :application_name, :version_label connection.versions.get(application_name, version_label) end |
#version=(new_version) ⇒ Object
Update the running version of this environment
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fog/aws/models/beanstalk/environment.rb', line 81 def version=(new_version) requires :id if new_version.is_a?(String) new_version_label = new_version elsif new_version.is_a?(Fog::AWS::ElasticBeanstalk::Version) new_version_label = new_version.label else raise "Unknown type for new_version, must be either String or Fog::AWS::ElasticBeanstalk::Version" end if new_version.nil? raise "Version label not specified." end data = connection.update_environment({ 'EnvironmentId' => id, 'VersionLabel' => new_version_label }).body['UpdateEnvironmentResult'] merge_attributes(data) end |