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.
- data/lib/aws.rb +2 -0
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +563 -0
- data/lib/aws/auto_scaling.rb +162 -0
- data/lib/aws/auto_scaling/activity.rb +102 -0
- data/lib/aws/auto_scaling/activity_collection.rb +82 -0
- data/lib/aws/auto_scaling/client.rb +50 -0
- data/lib/aws/auto_scaling/client/xml.rb +32 -0
- data/lib/aws/auto_scaling/config.rb +18 -0
- data/lib/aws/auto_scaling/errors.rb +26 -0
- data/lib/aws/auto_scaling/group.rb +420 -0
- data/lib/aws/auto_scaling/group_collection.rb +96 -0
- data/lib/aws/auto_scaling/group_options.rb +146 -0
- data/lib/aws/auto_scaling/instance.rb +192 -0
- data/lib/aws/auto_scaling/instance_collection.rb +63 -0
- data/lib/aws/auto_scaling/launch_configuration.rb +150 -0
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +144 -0
- data/lib/aws/auto_scaling/notification_configuration.rb +89 -0
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +184 -0
- data/lib/aws/auto_scaling/request.rb +24 -0
- data/lib/aws/auto_scaling/scaling_policy.rb +125 -0
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +72 -0
- data/lib/aws/auto_scaling/scaling_policy_options.rb +61 -0
- data/lib/aws/auto_scaling/scheduled_action.rb +145 -0
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +195 -0
- data/lib/aws/auto_scaling/tag.rb +59 -0
- data/lib/aws/auto_scaling/tag_collection.rb +112 -0
- data/lib/aws/core.rb +40 -8
- data/lib/aws/core/client.rb +28 -3
- data/lib/aws/core/configuration.rb +38 -31
- data/lib/aws/core/http/request.rb +3 -3
- data/lib/aws/core/http/response.rb +2 -1
- data/lib/aws/core/log_formatter.rb +454 -0
- data/lib/aws/core/resource.rb +2 -1
- data/lib/aws/core/response.rb +5 -0
- data/lib/aws/core/uri_escape.rb +1 -1
- data/lib/aws/core/xml_grammar.rb +21 -0
- data/lib/aws/dynamo_db/request.rb +1 -1
- data/lib/aws/ec2/network_acl_collection.rb +1 -2
- data/lib/aws/ec2/route_table_collection.rb +1 -2
- data/lib/aws/ec2/vpn_gateway_collection.rb +1 -1
- data/lib/aws/elb/load_balancer.rb +0 -2
- data/lib/aws/errors.rb +2 -2
- data/lib/aws/s3/object_version_collection.rb +1 -1
- data/lib/aws/s3/s3_object.rb +4 -4
- data/lib/aws/sqs/queue.rb +2 -2
- metadata +52 -27
- data/lib/aws/core/client_logging.rb +0 -133
@@ -0,0 +1,59 @@
|
|
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
|
+
# Auto Scaling tags are hashes with two helper methods:
|
18
|
+
#
|
19
|
+
# * {#resource}
|
20
|
+
# * {#delete}
|
21
|
+
#
|
22
|
+
class Tag < Hash
|
23
|
+
|
24
|
+
# @private
|
25
|
+
def initialize options = {}
|
26
|
+
|
27
|
+
super()
|
28
|
+
|
29
|
+
@resource =
|
30
|
+
case options[:resource_type]
|
31
|
+
when 'auto-scaling-group'
|
32
|
+
group_name = options[:resource_id]
|
33
|
+
config = options.delete(:config)
|
34
|
+
Group.new(group_name, :config => config)
|
35
|
+
else
|
36
|
+
msg = "unhandled resource type: #{options[:resource_type]}"
|
37
|
+
raise ArgumentError, msg
|
38
|
+
end
|
39
|
+
|
40
|
+
merge!(options)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Group] Returns the tagged resource. Currently this is
|
45
|
+
# always an Auto Scaling group.
|
46
|
+
def resource
|
47
|
+
@resource
|
48
|
+
end
|
49
|
+
|
50
|
+
# Deletes the tag from the resource.
|
51
|
+
# @return [nil]
|
52
|
+
def delete
|
53
|
+
resource.delete_tags([self])
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,112 @@
|
|
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
|
+
# Provides an interface for enumerating tags defined in Auto Scaling.
|
18
|
+
#
|
19
|
+
# auto_scaling = AWS::AutoScaling.new
|
20
|
+
# auto_scaling.tags.each do |tag|
|
21
|
+
# puts "#{tag.key}:#{tag.value}"
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# == Filters
|
25
|
+
#
|
26
|
+
# You can filter the tags returned using {#filter}:
|
27
|
+
#
|
28
|
+
# # returns tags with the key "role"
|
29
|
+
# auto_scaling.filter(:key, 'role').to_a
|
30
|
+
#
|
31
|
+
# # returns tags with the key "role" and value "webserver"
|
32
|
+
# auto_scaling.filter(:key, 'role').filter(:value, 'webserver')to_a
|
33
|
+
#
|
34
|
+
# # returns tags with the Auto Scaling group name "group1"
|
35
|
+
# auto_scaling.filter(:auto_scaling_group, 'group1').to_a
|
36
|
+
#
|
37
|
+
# # returns all tags that propagate at launch
|
38
|
+
# auto_scaling.filter(:propagate_at_launch, true).to_a
|
39
|
+
#
|
40
|
+
# == Creating Tags
|
41
|
+
#
|
42
|
+
# You can create Auto Scaling tags when you:
|
43
|
+
#
|
44
|
+
# * [create]{GroupCollection#create} an Auto Scaling group
|
45
|
+
# * [update]{Group#update} an Auto Scaling group
|
46
|
+
#
|
47
|
+
# Both of these methods accept a +:tags+ option.
|
48
|
+
#
|
49
|
+
# tags = [
|
50
|
+
# { :key => 'auto-scaling-instance' }, # tag name only
|
51
|
+
# { :key => 'role', :value => 'webserver' }, # tag name and value
|
52
|
+
# ]
|
53
|
+
#
|
54
|
+
# # creating a group with tags
|
55
|
+
# group = auto_scaling.groups.create('group-name', :tags => tags, ...)
|
56
|
+
#
|
57
|
+
# # updating a group's tags
|
58
|
+
# group.update(:tags => tags)
|
59
|
+
#
|
60
|
+
class TagCollection
|
61
|
+
|
62
|
+
include Core::Collection::Limitable
|
63
|
+
|
64
|
+
# @private
|
65
|
+
def initialize options = {}
|
66
|
+
@filters = options.delete(:filters) || []
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
# Filters the tags by the given filter name and value(s).
|
71
|
+
#
|
72
|
+
# # return tags with the key "role" and the value "webserver"
|
73
|
+
# auto_scaling.tags.filter(:key, 'role').filer(:value, 'webserver')
|
74
|
+
#
|
75
|
+
# @param [Symbol] name Valid filter names include:
|
76
|
+
#
|
77
|
+
# * :key
|
78
|
+
# * :value
|
79
|
+
# * :propagate_at_launch
|
80
|
+
# * :auto_scaling_group
|
81
|
+
#
|
82
|
+
# @param [Array<String>] values
|
83
|
+
#
|
84
|
+
# @return [TagCollection]
|
85
|
+
#
|
86
|
+
def filter name, *values
|
87
|
+
name = name.to_s.gsub(/_/, '-')
|
88
|
+
values = values.flatten.map(&:to_s)
|
89
|
+
filter = { :name => name, :values => values }
|
90
|
+
TagCollection.new(:filters => @filters + [filter], :config => config)
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
|
95
|
+
def _each_item next_token, limit, options = {}, &block
|
96
|
+
|
97
|
+
options[:next_token] = next_token if next_token
|
98
|
+
options[:max_records] = limit if limit
|
99
|
+
options[:filters] = @filters unless @filters.empty?
|
100
|
+
|
101
|
+
resp = client.describe_tags(options)
|
102
|
+
resp.tags.each do |tag|
|
103
|
+
yield(Tag.new(tag.to_hash.merge(:config => config)))
|
104
|
+
end
|
105
|
+
|
106
|
+
resp.next_token if resp.respond_to?(:next_token)
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/aws/core.rb
CHANGED
@@ -20,6 +20,7 @@ require 'aws/core/autoloader'
|
|
20
20
|
#
|
21
21
|
# The currently supported services are:
|
22
22
|
#
|
23
|
+
# * {AWS::AutoScaling}
|
23
24
|
# * {AWS::DynamoDB}
|
24
25
|
# * {AWS::EC2}
|
25
26
|
# * {AWS::ELB}
|
@@ -59,7 +60,7 @@ require 'aws/core/autoloader'
|
|
59
60
|
module AWS
|
60
61
|
|
61
62
|
# Current version of the AWS SDK for Ruby
|
62
|
-
VERSION = "1.3.
|
63
|
+
VERSION = "1.3.9"
|
63
64
|
|
64
65
|
register_autoloads(self) do
|
65
66
|
autoload :Errors, 'errors'
|
@@ -76,7 +77,6 @@ module AWS
|
|
76
77
|
autoload :AuthorizeWithSessionToken, 'authorize_with_session_token'
|
77
78
|
autoload :Cacheable, 'cacheable'
|
78
79
|
autoload :Client, 'client'
|
79
|
-
autoload :ClientLogging, 'client_logging'
|
80
80
|
autoload :Collection, 'collection'
|
81
81
|
autoload :Configuration, 'configuration'
|
82
82
|
autoload :ConfiguredClientMethods, 'configured_client_methods'
|
@@ -90,6 +90,7 @@ module AWS
|
|
90
90
|
autoload :Inflection, 'inflection'
|
91
91
|
autoload :JsonClient, 'json_client'
|
92
92
|
autoload :LazyErrorClasses, 'lazy_error_classes'
|
93
|
+
autoload :LogFormatter, 'log_formatter'
|
93
94
|
autoload :MetaUtils, 'meta_utils'
|
94
95
|
autoload :Model, 'model'
|
95
96
|
autoload :Naming, 'naming'
|
@@ -167,8 +168,11 @@ module AWS
|
|
167
168
|
# @option options [String,nil] :session_token (nil) AWS secret token
|
168
169
|
# credential.
|
169
170
|
#
|
170
|
-
# @option options [String] :
|
171
|
-
# service endpoint for
|
171
|
+
# @option options [String] :auto_scaling_endpoint ('autoscaling.us-east-1.amazonaws.com')
|
172
|
+
# The service endpoint for Auto Scaling.
|
173
|
+
#
|
174
|
+
# @option options [String] :dynamo_db_endpoint ('dynamodb.amazonaws.com')
|
175
|
+
# The service endpoint for Amazon DynamoDB.
|
172
176
|
#
|
173
177
|
# @option options [String] :dynamo_db_retry_throughput_errors (true) When
|
174
178
|
# true, AWS::DynamoDB::Errors::ProvisionedThroughputExceededException
|
@@ -186,10 +190,38 @@ module AWS
|
|
186
190
|
# @option options [String] :iam_endpoint ('iam.amazonaws.com') The
|
187
191
|
# service endpoint for AWS Idenity Access Management (IAM).
|
188
192
|
#
|
189
|
-
# @option options [
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
+
# @option options [Logger,nil] :logger (nil) A logger to send
|
194
|
+
# log messages to. Here is an example that logs to standard out.
|
195
|
+
#
|
196
|
+
# require 'logger'
|
197
|
+
# AWS.config(:logger => Logger.new($stdout))
|
198
|
+
#
|
199
|
+
# @option options [Symbol] :log_level (:info) The level log messages are
|
200
|
+
# sent to the logger with (e.g. +:notice+, +:info+, +:warn+,
|
201
|
+
# +:debug+, etc).
|
202
|
+
#
|
203
|
+
# @option options [Object] :log_formatter The log formatter is responsible
|
204
|
+
# for building log messages from responses. You can quickly change
|
205
|
+
# log formats by providing a canned log formatter.
|
206
|
+
#
|
207
|
+
# AWS.config(:log_formatter => AWS::Core::LogFormatter.colored)
|
208
|
+
#
|
209
|
+
# Here is the complete list of canned log formatters:
|
210
|
+
#
|
211
|
+
# * +AWS::Core::LogFormatter.default+
|
212
|
+
# * +AWS::Core::LogFormatter.short+
|
213
|
+
# * +AWS::Core::LogFormatter.debug+
|
214
|
+
# * +AWS::Core::LogFormatter.colored+
|
215
|
+
#
|
216
|
+
# You can also create an instance of AWS::Core::LogFormatter
|
217
|
+
# with a custom log message pattern. See {Core::LogFormatter} for
|
218
|
+
# a complete list of pattern substituions.
|
219
|
+
#
|
220
|
+
# pattern = "[AWS :operation :duration] :error_message"
|
221
|
+
# AWS.config(:log_formatter => AWS::Core::LogFormatter.new(pattern))
|
222
|
+
#
|
223
|
+
# Lastly you can pass any object that responds to +#format+ accepting
|
224
|
+
# and instance of {Core::Response} and returns a string.
|
193
225
|
#
|
194
226
|
# @option options [Integer] :max_retries (3) The maximum number of times
|
195
227
|
# service errors (500) should be retried. There is an exponential
|
data/lib/aws/core/client.rb
CHANGED
@@ -22,8 +22,6 @@ module AWS
|
|
22
22
|
|
23
23
|
extend Naming
|
24
24
|
|
25
|
-
include ClientLogging
|
26
|
-
|
27
25
|
CACHEABLE_REQUESTS = Set.new
|
28
26
|
|
29
27
|
# Creates a new low-level client.
|
@@ -221,6 +219,8 @@ module AWS
|
|
221
219
|
|
222
220
|
@http_handler.handle(response.http_request, http_response)
|
223
221
|
|
222
|
+
populate_error(response)
|
223
|
+
|
224
224
|
populate_error(response)
|
225
225
|
response.signal_success unless response.error
|
226
226
|
response
|
@@ -278,6 +278,31 @@ module AWS
|
|
278
278
|
end
|
279
279
|
response
|
280
280
|
end
|
281
|
+
|
282
|
+
private
|
283
|
+
def log_client_request options
|
284
|
+
|
285
|
+
# time the request, retries and all
|
286
|
+
start = Time.now
|
287
|
+
response = yield
|
288
|
+
response.duration = Time.now - start
|
289
|
+
|
290
|
+
if config.logger
|
291
|
+
if options[:async]
|
292
|
+
response.on_complete { log_response(response) }
|
293
|
+
else
|
294
|
+
log_response(response)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
response
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
def log_response response
|
303
|
+
message = config.log_formatter.format(response)
|
304
|
+
config.logger.send(config.log_level, message)
|
305
|
+
end
|
281
306
|
|
282
307
|
protected
|
283
308
|
def populate_error response
|
@@ -335,7 +360,7 @@ module AWS
|
|
335
360
|
private
|
336
361
|
def client_request name, options, &block
|
337
362
|
return_or_raise(options) do
|
338
|
-
log_client_request(
|
363
|
+
log_client_request(options) do
|
339
364
|
|
340
365
|
if config.stub_requests?
|
341
366
|
|
@@ -63,6 +63,9 @@ module AWS
|
|
63
63
|
#
|
64
64
|
# @attr_reader [String,nil] session_token (nil) AWS secret token credential.
|
65
65
|
#
|
66
|
+
# @attr_reader [String] auto_scaling_endpoint ('autoscaling.us-east-1.amazonaws.com')
|
67
|
+
# The service endpoint for Auto Scaling.
|
68
|
+
#
|
66
69
|
# @attr_reader [String] dynamo_db_endpoint ('dynamodb.us-east-1.amazonaws.com')
|
67
70
|
# The service endpoint for Amazon DynamoDB.
|
68
71
|
#
|
@@ -82,10 +85,11 @@ module AWS
|
|
82
85
|
# @attr_reader [String] iam_endpoint ('iam.amazonaws.com')
|
83
86
|
# The service endpoint for AWS Idenity Access Management (IAM).
|
84
87
|
#
|
85
|
-
# @attr_reader [
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
88
|
+
# @attr_reader [Logger,nil] logger (nil) The logging interface.
|
89
|
+
#
|
90
|
+
# @attr_reader [Symbol] log_level (:info) The log level.
|
91
|
+
#
|
92
|
+
# @attr_reader [LogFormatter] log_formatter The log message formatter.
|
89
93
|
#
|
90
94
|
# @attr_reader [Integer] max_retries (3) The maximum number of times
|
91
95
|
# service errors (500) should be retried. There is an exponential
|
@@ -338,26 +342,6 @@ module AWS
|
|
338
342
|
|
339
343
|
def add_service name, ruby_name, default_endpoint
|
340
344
|
|
341
|
-
create_block = lambda do |config|
|
342
|
-
AWS.const_get(name)::Client.new(:config => config)
|
343
|
-
end
|
344
|
-
|
345
|
-
needs = [
|
346
|
-
:signer,
|
347
|
-
:http_handler,
|
348
|
-
:"#{ruby_name}_endpoint",
|
349
|
-
:"#{ruby_name}_port",
|
350
|
-
:max_retries,
|
351
|
-
:stub_requests?,
|
352
|
-
:proxy_uri,
|
353
|
-
:use_ssl?,
|
354
|
-
:ssl_verify_peer?,
|
355
|
-
:ssl_ca_file,
|
356
|
-
:user_agent_prefix,
|
357
|
-
:logger,
|
358
|
-
:logger_truncate_strings_at,
|
359
|
-
]
|
360
|
-
|
361
345
|
add_option :"#{ruby_name}_endpoint", default_endpoint
|
362
346
|
|
363
347
|
add_option(:"#{ruby_name}_port") do |config,value|
|
@@ -383,6 +367,27 @@ module AWS
|
|
383
367
|
end
|
384
368
|
end
|
385
369
|
|
370
|
+
needs = [
|
371
|
+
:signer,
|
372
|
+
:http_handler,
|
373
|
+
:"#{ruby_name}_endpoint",
|
374
|
+
:"#{ruby_name}_port",
|
375
|
+
:max_retries,
|
376
|
+
:stub_requests?,
|
377
|
+
:proxy_uri,
|
378
|
+
:use_ssl?,
|
379
|
+
:ssl_verify_peer?,
|
380
|
+
:ssl_ca_file,
|
381
|
+
:user_agent_prefix,
|
382
|
+
:logger,
|
383
|
+
:log_formatter,
|
384
|
+
:log_level,
|
385
|
+
]
|
386
|
+
|
387
|
+
create_block = lambda do |config|
|
388
|
+
AWS.const_get(name)::Client.new(:config => config)
|
389
|
+
end
|
390
|
+
|
386
391
|
add_option_with_needs :"#{ruby_name}_client", needs, &create_block
|
387
392
|
|
388
393
|
end
|
@@ -391,22 +396,24 @@ module AWS
|
|
391
396
|
|
392
397
|
add_option :access_key_id,
|
393
398
|
ENV['AWS_ACCESS_KEY_ID'] || ENV['AMAZON_ACCESS_KEY_ID']
|
399
|
+
|
400
|
+
add_option :secret_access_key,
|
401
|
+
ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY']
|
402
|
+
|
403
|
+
add_option :session_token
|
394
404
|
|
395
|
-
add_option :http_handler,
|
405
|
+
add_option :http_handler, Http::NetHttpHandler.new
|
396
406
|
|
397
407
|
add_option :logger
|
398
408
|
|
399
|
-
add_option :
|
409
|
+
add_option :log_level, :info
|
410
|
+
|
411
|
+
add_option :log_formatter, LogFormatter.default
|
400
412
|
|
401
413
|
add_option :max_retries, 3
|
402
414
|
|
403
415
|
add_option :proxy_uri do |config,uri| uri ? URI.parse(uri.to_s) : nil end
|
404
416
|
|
405
|
-
add_option :secret_access_key,
|
406
|
-
ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY']
|
407
|
-
|
408
|
-
add_option :session_token
|
409
|
-
|
410
417
|
add_option_with_needs :signer,
|
411
418
|
[:access_key_id, :secret_access_key, :session_token] do |config|
|
412
419
|
|
@@ -43,17 +43,17 @@ module AWS
|
|
43
43
|
attr_accessor :host
|
44
44
|
|
45
45
|
# @return [CaseInsensitiveHash] request headers
|
46
|
-
|
46
|
+
attr_accessor :headers
|
47
47
|
|
48
48
|
# @return [Array] An array of request params, each param responds to
|
49
49
|
# #name and #value.
|
50
|
-
|
50
|
+
attr_accessor :params
|
51
51
|
|
52
52
|
# @return [String] GET, PUT POST, HEAD or DELETE, defaults to POST
|
53
53
|
attr_accessor :http_method
|
54
54
|
|
55
55
|
# @return [String] path of the request URI, defaults to /
|
56
|
-
|
56
|
+
attr_accessor :path
|
57
57
|
|
58
58
|
# @return [String] the AWS access key ID used to authorize the
|
59
59
|
# request
|