aws-sdk 1.3.8 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/lib/aws.rb +2 -0
  2. data/lib/aws/api_config/AutoScaling-2011-01-01.yml +563 -0
  3. data/lib/aws/auto_scaling.rb +162 -0
  4. data/lib/aws/auto_scaling/activity.rb +102 -0
  5. data/lib/aws/auto_scaling/activity_collection.rb +82 -0
  6. data/lib/aws/auto_scaling/client.rb +50 -0
  7. data/lib/aws/auto_scaling/client/xml.rb +32 -0
  8. data/lib/aws/auto_scaling/config.rb +18 -0
  9. data/lib/aws/auto_scaling/errors.rb +26 -0
  10. data/lib/aws/auto_scaling/group.rb +420 -0
  11. data/lib/aws/auto_scaling/group_collection.rb +96 -0
  12. data/lib/aws/auto_scaling/group_options.rb +146 -0
  13. data/lib/aws/auto_scaling/instance.rb +192 -0
  14. data/lib/aws/auto_scaling/instance_collection.rb +63 -0
  15. data/lib/aws/auto_scaling/launch_configuration.rb +150 -0
  16. data/lib/aws/auto_scaling/launch_configuration_collection.rb +144 -0
  17. data/lib/aws/auto_scaling/notification_configuration.rb +89 -0
  18. data/lib/aws/auto_scaling/notification_configuration_collection.rb +184 -0
  19. data/lib/aws/auto_scaling/request.rb +24 -0
  20. data/lib/aws/auto_scaling/scaling_policy.rb +125 -0
  21. data/lib/aws/auto_scaling/scaling_policy_collection.rb +72 -0
  22. data/lib/aws/auto_scaling/scaling_policy_options.rb +61 -0
  23. data/lib/aws/auto_scaling/scheduled_action.rb +145 -0
  24. data/lib/aws/auto_scaling/scheduled_action_collection.rb +195 -0
  25. data/lib/aws/auto_scaling/tag.rb +59 -0
  26. data/lib/aws/auto_scaling/tag_collection.rb +112 -0
  27. data/lib/aws/core.rb +40 -8
  28. data/lib/aws/core/client.rb +28 -3
  29. data/lib/aws/core/configuration.rb +38 -31
  30. data/lib/aws/core/http/request.rb +3 -3
  31. data/lib/aws/core/http/response.rb +2 -1
  32. data/lib/aws/core/log_formatter.rb +454 -0
  33. data/lib/aws/core/resource.rb +2 -1
  34. data/lib/aws/core/response.rb +5 -0
  35. data/lib/aws/core/uri_escape.rb +1 -1
  36. data/lib/aws/core/xml_grammar.rb +21 -0
  37. data/lib/aws/dynamo_db/request.rb +1 -1
  38. data/lib/aws/ec2/network_acl_collection.rb +1 -2
  39. data/lib/aws/ec2/route_table_collection.rb +1 -2
  40. data/lib/aws/ec2/vpn_gateway_collection.rb +1 -1
  41. data/lib/aws/elb/load_balancer.rb +0 -2
  42. data/lib/aws/errors.rb +2 -2
  43. data/lib/aws/s3/object_version_collection.rb +1 -1
  44. data/lib/aws/s3/s3_object.rb +4 -4
  45. data/lib/aws/sqs/queue.rb +2 -2
  46. metadata +52 -27
  47. data/lib/aws/core/client_logging.rb +0 -133
@@ -0,0 +1,162 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ require 'aws/core'
15
+ require 'aws/auto_scaling/config'
16
+
17
+ module AWS
18
+
19
+ # This class is the starting point for working with Auto Scaling.
20
+ #
21
+ # To use Auto Scaling you must first
22
+ # {sign up here}[http://aws.amazon.com/autoscaling/].
23
+ #
24
+ # For more information about Auto Scaling:
25
+ #
26
+ # * {Auto Scaling}[http://aws.amazon.com/autoscaling/]
27
+ # * {Auto Scaling Documentation}[http://aws.amazon.com/documentation/autoscaling/]
28
+ #
29
+ # = Credentials
30
+ #
31
+ # You can setup default credentials for all AWS services via
32
+ # AWS.config:
33
+ #
34
+ # AWS.config(
35
+ # :access_key_id => 'YOUR_ACCESS_KEY_ID',
36
+ # :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')
37
+ #
38
+ # Or you can set them directly on the AWS::AutoSclaing interface:
39
+ #
40
+ # auto_scaling = AWS::AutoScaling.new(
41
+ # :access_key_id => 'YOUR_ACCESS_KEY_ID',
42
+ # :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')
43
+ #
44
+ # = Launch Configurations
45
+ #
46
+ # You need to create a launch configuration before you can create
47
+ # an Auto Scaling Group.
48
+ #
49
+ # # needs a name, image id, and instance type
50
+ # launch_config = auto_scaling.launch_configurations.create(
51
+ # 'launch-config-name', 'ami-12345', 'm1-small')
52
+ #
53
+ # If you have previously created a launch configuration you can
54
+ # reference using the {LaunchConfigurationCollection}.
55
+ #
56
+ # launch_config = auto_scaling.launch_configurations['launch-config-name']
57
+ #
58
+ # = Auto Scaling Groups
59
+ #
60
+ # Given a launch configuration, you can now create an Auto Scaling {Group}.
61
+ #
62
+ # group = auto_scaling.groups.create('group-name',
63
+ # :launch_configuration => launch_config,
64
+ # :availability_zones => %(us-east-1a us-east-1b),
65
+ # :min_size => 1,
66
+ # :max_size => 4)
67
+ #
68
+ class AutoScaling
69
+
70
+ AWS.register_autoloads(self, 'aws/auto_scaling') do
71
+ autoload :Activity, 'activity'
72
+ autoload :ActivityCollection, 'activity_collection'
73
+ autoload :Client, 'client'
74
+ autoload :Errors, 'errors'
75
+ autoload :Group, 'group'
76
+ autoload :GroupCollection, 'group_collection'
77
+ autoload :GroupOptions, 'group_options'
78
+ autoload :Instance, 'instance'
79
+ autoload :InstanceCollection, 'instance_collection'
80
+ autoload :LaunchConfiguration, 'launch_configuration'
81
+ autoload :LaunchConfigurationCollection, 'launch_configuration_collection'
82
+ autoload :NotificationConfiguration, 'notification_configuration'
83
+ autoload :NotificationConfigurationCollection, 'notification_configuration_collection'
84
+ autoload :Request, 'request'
85
+ autoload :ScalingPolicy, 'scaling_policy'
86
+ autoload :ScalingPolicyCollection, 'scaling_policy_collection'
87
+ autoload :ScalingPolicyOptions, 'scaling_policy_options'
88
+ autoload :ScheduledAction, 'scheduled_action'
89
+ autoload :ScheduledActionCollection, 'scheduled_action_collection'
90
+ autoload :Tag, 'tag'
91
+ autoload :TagCollection, 'tag_collection'
92
+ end
93
+
94
+ include Core::ServiceInterface
95
+
96
+ # @return [LaunchConfigurationCollection]
97
+ def launch_configurations
98
+ LaunchConfigurationCollection.new(:config => config)
99
+ end
100
+
101
+ # @return [GroupCollection]
102
+ def groups
103
+ GroupCollection.new(:config => config)
104
+ end
105
+
106
+ # @return [TagCollection]
107
+ def tags
108
+ TagCollection.new(:config => config)
109
+ end
110
+
111
+ # @return [NotificationConfigurationCollection]
112
+ def notification_configurations
113
+ NotificationConfigurationCollection.new(:config => config)
114
+ end
115
+
116
+ # @return [AutoScaling::InstancesCollection] Returns a collection of
117
+ # {AutoScaling::Instance} objects. Each of these is a small
118
+ # wrapper around an {EC::Instance} with additional attributes.
119
+ def instances
120
+ InstanceCollection.new(:config => config)
121
+ end
122
+
123
+ # @return [ActivityCollection]
124
+ def activities
125
+ ActivityCollection.new(:config => config)
126
+ end
127
+
128
+ # @return [ScheduledActionCollection]
129
+ def scheduled_actions
130
+ ScheduledActionCollection.new(:config => config)
131
+ end
132
+
133
+ # Returns a list of all notification types that are supported by
134
+ # Auto Scaling.
135
+ # @return [Array<String>]
136
+ def notification_types
137
+ resp = client.describe_auto_scaling_notification_types
138
+ resp.auto_scaling_notification_types
139
+ end
140
+
141
+ # @return [Array<String>] Returns the list of valid adjustmet types.
142
+ def adjustment_types
143
+ client.describe_adjustment_types.adjustment_types.map(&:adjustment_type)
144
+ end
145
+
146
+ # @return [Array<String>] Returns the list of valid scaling process types.
147
+ def scaling_process_types
148
+ client.describe_scaling_process_types.processes.map(&:process_name)
149
+ end
150
+
151
+ # @return [Array<String>] Returns the list of valid metric collection types.
152
+ def metric_collection_types
153
+ client.describe_metric_collection_types.metrics.map(&:metric)
154
+ end
155
+
156
+ # @return [Array<String>] Returns the list of valid metric granularities.
157
+ def metric_collection_granularities
158
+ client.describe_metric_collection_types.granularities.map(&:granularity)
159
+ end
160
+
161
+ end
162
+ end
@@ -0,0 +1,102 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #.kkk:w
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
+ #
8
+ # http://aws.amazon.com/apache2.0/
9
+ #
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
+
15
+ module AWS
16
+ class AutoScaling
17
+
18
+ # @attr_reader [String] auto_scaling_group_name
19
+ #
20
+ # @attr_reader [String] cause
21
+ #
22
+ # @attr_reader [nil,String] description
23
+ #
24
+ # @attr_reader [String] details
25
+ #
26
+ # @attr_reader [Time] start_time
27
+ #
28
+ # @attr_reader [nil,Time] end_time
29
+ #
30
+ # @attr_reader [Integer] progress
31
+ #
32
+ # @attr_reader [nil,String] status_code
33
+ #
34
+ # @attr_reader [nil,String] status_message
35
+ #
36
+ class Activity < Core::Resource
37
+
38
+ # @private
39
+ def initialize activity_id, options = {}
40
+ @activity_id = activity_id
41
+ super
42
+ end
43
+
44
+ # @return [String]
45
+ attr_reader :activity_id
46
+
47
+ alias_method :id, :activity_id
48
+
49
+ attribute :auto_scaling_group_name, :static => true
50
+
51
+ attribute :cause, :static => true
52
+
53
+ attribute :description, :static => true
54
+
55
+ attribute :details
56
+
57
+ attribute :start_time, :static => true
58
+
59
+ attribute :end_time
60
+
61
+ attribute :progress
62
+
63
+ attribute :status_code
64
+
65
+ attribute :status_message
66
+
67
+ populates_from(:describe_scaling_activities) do |resp|
68
+ resp.activities.find {|a| a.activity_id == activity_id }
69
+ end
70
+
71
+ populates_from(:terminate_instance_in_auto_scaling_group) do |resp|
72
+ resp.activity if resp.activity.activity_id == activity_id
73
+ end
74
+
75
+ # @return [Group]
76
+ def group
77
+ Group.new(auto_scaling_group_name, :config => config)
78
+ end
79
+
80
+ # @return [Boolean]
81
+ def exists?
82
+ client_opts = {}
83
+ client_opts[:activity_ids] = [activity_id]
84
+ resp = client.describe_scaling_activities(client_opts)
85
+ !resp.activities.empty?
86
+ end
87
+
88
+ protected
89
+
90
+ def get_resource attr_name = nil
91
+ client_opts = {}
92
+ client_opts[:activity_ids] = [activity_id]
93
+ client.describe_scaling_activities(client_opts)
94
+ end
95
+
96
+ def resource_identifiers
97
+ [[:activity_id, activity_id]]
98
+ end
99
+
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,82 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class AutoScaling
16
+
17
+ # Allows you to enumerate Auto Scaling activities
18
+ #
19
+ # Enumerating ALL activities:
20
+ #
21
+ # auto_scaling = AWS::AutoScaling.new
22
+ # auto_scaling.activities.each do |activity|
23
+ # # ...
24
+ # end
25
+ #
26
+ # Enumerating activities for a single Auto Scaling group:
27
+ #
28
+ # group = auto_scaling.groups['group-name']
29
+ # group.activities.each do |activity|
30
+ # # ...
31
+ # end
32
+ #
33
+ # If you know the id of an activity you can get a refernce to it:
34
+ #
35
+ # activity = auto_scaling.activities['activity-id']
36
+ #
37
+ class ActivityCollection
38
+
39
+ include Core::Collection::Limitable
40
+
41
+ # @private
42
+ def initialize options = {}
43
+ @group = options[:group]
44
+ if @group
45
+ super(@group, options)
46
+ else
47
+ super
48
+ end
49
+ end
50
+
51
+ # @param [String] activity_id
52
+ # @return [Activity]
53
+ def [] activity_id
54
+ Activity.new(activity_id, :config => config)
55
+ end
56
+
57
+ protected
58
+
59
+ def _each_item next_token, limit, options = {}, &block
60
+
61
+ options[:next_token] = next_token if next_token
62
+ options[:max_records] = limit if limit
63
+ options[:auto_scaling_group_name] = @group.name if @group
64
+
65
+ resp = client.describe_scaling_activities(options)
66
+ resp.activities.each do |details|
67
+
68
+ activity = Activity.new_from(
69
+ :describe_scaling_activities, details,
70
+ details.activity_id, :config => config)
71
+
72
+ yield(activity)
73
+
74
+ end
75
+
76
+ resp.next_token if resp.respond_to?(:next_token)
77
+
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,50 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class AutoScaling
16
+
17
+ # @private
18
+ class Client < Core::Client
19
+
20
+ AWS.register_autoloads(self, 'aws/auto_scaling/client') do
21
+ autoload :XML, 'xml'
22
+ end
23
+
24
+ include Core::ConfiguredClientMethods
25
+
26
+ API_VERSION = '2011-01-01'
27
+
28
+ REQUEST_CLASS = AutoScaling::Request
29
+
30
+ # @private
31
+ CACHEABLE_REQUESTS = Set[
32
+ :describe_adjustment_types,
33
+ :describe_auto_scaling_groups,
34
+ :describe_auto_scaling_instances,
35
+ :describe_auto_scaling_notification_types,
36
+ :describe_launch_configurations,
37
+ :describe_metric_collection_types,
38
+ :describe_notification_configurations,
39
+ :describe_policies,
40
+ :describe_scaling_activities,
41
+ :describe_scaling_process_types,
42
+ :describe_scheduled_actions,
43
+ :describe_tags,
44
+ ]
45
+
46
+ configure_client
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ module AWS
15
+ class AutoScaling
16
+ class Client < Core::Client
17
+ module XML
18
+
19
+ include Core::ConfiguredXmlGrammars
20
+
21
+ extend Core::IgnoreResultElement
22
+
23
+ BaseError = Core::XmlGrammar.customize do
24
+ element("Error") { ignore }
25
+ end
26
+
27
+ define_configured_grammars
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ AWS::Core::Configuration.module_eval do
15
+
16
+ add_service 'AutoScaling', 'auto_scaling', 'autoscaling.us-east-1.amazonaws.com'
17
+
18
+ end