aws-sdk 1.5.8 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws.rb +2 -0
- data/lib/aws/api_config/Route53-2012-02-29.yml +348 -0
- data/lib/aws/auto_scaling/client.rb +362 -588
- data/lib/aws/cloud_formation/client.rb +155 -224
- data/lib/aws/cloud_watch/client.rb +156 -229
- data/lib/aws/core.rb +67 -52
- data/lib/aws/core/client.rb +81 -82
- data/lib/aws/core/collection/with_limit_and_next_token.rb +2 -2
- data/lib/aws/core/configuration.rb +75 -72
- data/lib/aws/core/http/net_http_handler.rb +3 -3
- data/lib/aws/core/http/request.rb +107 -138
- data/lib/aws/core/inflection.rb +3 -3
- data/lib/aws/core/json_client.rb +106 -0
- data/lib/aws/core/option_grammar.rb +10 -1
- data/lib/aws/core/options/validator.rb +140 -0
- data/lib/aws/core/options/xml_serializer.rb +98 -0
- data/lib/aws/core/query_client.rb +131 -0
- data/lib/aws/core/rest_client.rb +90 -0
- data/lib/aws/core/rest_client/input_handler.rb +145 -0
- data/lib/aws/core/rest_client/output_handler.rb +43 -0
- data/lib/aws/core/signature/version_2.rb +7 -7
- data/lib/aws/core/signature/version_3.rb +5 -1
- data/lib/aws/core/signature/version_3_https.rb +51 -0
- data/lib/aws/core/signature/version_4.rb +5 -22
- data/lib/aws/core/signer.rb +1 -1
- data/lib/aws/core/uri_escape.rb +2 -0
- data/lib/aws/core/xml/frame.rb +8 -8
- data/lib/aws/core/xml/grammar.rb +8 -3
- data/lib/aws/dynamo_db/client.rb +600 -662
- data/lib/aws/ec2/client.rb +2688 -3492
- data/lib/aws/ec2/request.rb +0 -1
- data/lib/aws/elb/client.rb +280 -407
- data/lib/aws/emr/client.rb +7 -7
- data/lib/aws/iam/client.rb +822 -1268
- data/lib/aws/route_53.rb +71 -0
- data/lib/aws/route_53/client.rb +272 -0
- data/lib/aws/route_53/config.rb +18 -0
- data/lib/aws/route_53/errors.rb +22 -0
- data/lib/aws/route_53/request.rb +23 -0
- data/lib/aws/s3/object_version_collection.rb +6 -6
- data/lib/aws/s3/paginated_collection.rb +1 -1
- data/lib/aws/s3/request.rb +10 -5
- data/lib/aws/simple_db/client.rb +184 -234
- data/lib/aws/simple_email_service/client.rb +147 -238
- data/lib/aws/simple_workflow/client.rb +997 -1191
- data/lib/aws/sns/client.rb +176 -264
- data/lib/aws/sqs/client.rb +162 -253
- data/lib/aws/sqs/queue.rb +1 -1
- data/lib/aws/sqs/request.rb +4 -0
- data/lib/aws/sts/client.rb +57 -66
- metadata +95 -71
- data/lib/aws/core/client/query_json.rb +0 -112
- data/lib/aws/core/client/query_xml.rb +0 -122
data/lib/aws/core.rb
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
|
14
14
|
require 'aws/core/autoloader'
|
15
15
|
|
16
|
-
# AWS is the root module for all of the Amazon Web Services. It is also
|
17
|
-
# where you can configure you access to AWS.
|
16
|
+
# AWS is the root module for all of the Amazon Web Services. It is also
|
17
|
+
# where you can configure you access to AWS.
|
18
18
|
#
|
19
19
|
# = Supported Services
|
20
20
|
#
|
@@ -28,6 +28,7 @@ require 'aws/core/autoloader'
|
|
28
28
|
# * {AWS::ELB}
|
29
29
|
# * {AWS::EMR}
|
30
30
|
# * {AWS::IAM}
|
31
|
+
# * {AWS::Route53}
|
31
32
|
# * {AWS::S3}
|
32
33
|
# * {AWS::SNS}
|
33
34
|
# * {AWS::SQS}
|
@@ -43,24 +44,24 @@ require 'aws/core/autoloader'
|
|
43
44
|
#
|
44
45
|
# = Configuration
|
45
46
|
#
|
46
|
-
# You call {AWS.config} with a hash of options to configure your
|
47
|
-
# access to the Amazon Web Services.
|
47
|
+
# You call {AWS.config} with a hash of options to configure your
|
48
|
+
# access to the Amazon Web Services.
|
48
49
|
#
|
49
|
-
# At a minimum you need to set your access credentials. See {AWS.config}
|
50
|
+
# At a minimum you need to set your access credentials. See {AWS.config}
|
50
51
|
# for additional configuration options.
|
51
52
|
#
|
52
53
|
# AWS.config(
|
53
54
|
# :access_key_id => 'ACCESS_KEY_ID',
|
54
|
-
# :secret_access_key => 'SECRET_ACCESS_KEY')
|
55
|
+
# :secret_access_key => 'SECRET_ACCESS_KEY')
|
55
56
|
#
|
56
57
|
# == Rails
|
57
|
-
#
|
58
|
-
# If you are loading AWS inside a Rails web application, it is recomended to
|
58
|
+
#
|
59
|
+
# If you are loading AWS inside a Rails web application, it is recomended to
|
59
60
|
# place your configuration inside:
|
60
61
|
#
|
61
62
|
# config/initializers/aws-sdk.rb
|
62
63
|
#
|
63
|
-
# Optionally you can create a Yaml configuration file at
|
64
|
+
# Optionally you can create a Yaml configuration file at
|
64
65
|
# RAILS_ROOT/config/aws.yaml; This should be formatted in the same manor
|
65
66
|
# as the default RAILS_ROOT/config/database.yml file (one section for
|
66
67
|
# each Rails environment).
|
@@ -68,7 +69,7 @@ require 'aws/core/autoloader'
|
|
68
69
|
module AWS
|
69
70
|
|
70
71
|
# Current version of the AWS SDK for Ruby
|
71
|
-
VERSION = "1.
|
72
|
+
VERSION = "1.6.0"
|
72
73
|
|
73
74
|
register_autoloads(self) do
|
74
75
|
autoload :Errors, 'errors'
|
@@ -86,6 +87,9 @@ module AWS
|
|
86
87
|
autoload :Data, 'data'
|
87
88
|
autoload :IndifferentHash, 'indifferent_hash'
|
88
89
|
autoload :Inflection, 'inflection'
|
90
|
+
autoload :JSONClient, 'json_client'
|
91
|
+
autoload :QueryClient, 'query_client'
|
92
|
+
autoload :RESTClient, 'rest_client'
|
89
93
|
autoload :LazyErrorClasses, 'lazy_error_classes'
|
90
94
|
autoload :LogFormatter, 'log_formatter'
|
91
95
|
autoload :MetaUtils, 'meta_utils'
|
@@ -103,14 +107,22 @@ module AWS
|
|
103
107
|
autoload :UriEscape, 'uri_escape'
|
104
108
|
end
|
105
109
|
|
110
|
+
module Options
|
111
|
+
AWS.register_autoloads(self) do
|
112
|
+
autoload :XMLSerializer, 'xml_serializer'
|
113
|
+
autoload :Validator, 'validator'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
106
117
|
module Signature
|
107
118
|
AWS.register_autoloads(self) do
|
108
|
-
autoload :Version2,
|
109
|
-
autoload :Version3,
|
110
|
-
autoload :
|
119
|
+
autoload :Version2, 'version_2'
|
120
|
+
autoload :Version3, 'version_3'
|
121
|
+
autoload :Version3HTTPS, 'version_3_https'
|
122
|
+
autoload :Version4, 'version_4'
|
111
123
|
end
|
112
124
|
end
|
113
|
-
|
125
|
+
|
114
126
|
module XML
|
115
127
|
AWS.register_autoloads(self) do
|
116
128
|
autoload :Parser, 'parser'
|
@@ -155,7 +167,7 @@ module AWS
|
|
155
167
|
@@config = nil
|
156
168
|
|
157
169
|
# The global configuration for AWS. Generally you set your prefered
|
158
|
-
# configuration operations once after loading the aws-sdk gem.
|
170
|
+
# configuration operations once after loading the aws-sdk gem.
|
159
171
|
#
|
160
172
|
# AWS.config({
|
161
173
|
# :access_key_id => 'ACCESS_KEY_ID',
|
@@ -182,35 +194,35 @@ module AWS
|
|
182
194
|
#
|
183
195
|
# @param [Hash] options
|
184
196
|
#
|
185
|
-
# @option options [String] :access_key_id AWS access key id
|
197
|
+
# @option options [String] :access_key_id AWS access key id
|
186
198
|
# credential.
|
187
199
|
#
|
188
|
-
# @option options [String] :secret_access_key AWS secret access
|
200
|
+
# @option options [String] :secret_access_key AWS secret access
|
189
201
|
# key credential.
|
190
202
|
#
|
191
|
-
# @option options [String,nil] :session_token AWS secret token
|
203
|
+
# @option options [String,nil] :session_token AWS secret token
|
192
204
|
# credential.
|
193
205
|
#
|
194
206
|
# @option options [String] :auto_scaling_endpoint ('autoscaling.us-east-1.amazonaws.com')
|
195
207
|
# The service endpoint for Auto Scaling.
|
196
208
|
#
|
197
|
-
# @option options [String] :cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
|
209
|
+
# @option options [String] :cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
|
198
210
|
# The service endpoint for AWS CloudFormation.
|
199
211
|
#
|
200
|
-
# @option options [String] :dynamo_db_endpoint ('dynamodb.amazonaws.com')
|
212
|
+
# @option options [String] :dynamo_db_endpoint ('dynamodb.amazonaws.com')
|
201
213
|
# The service endpoint for Amazon DynamoDB.
|
202
214
|
#
|
203
215
|
# @option options [String] :dynamo_db_retry_throughput_errors (true) When
|
204
216
|
# true, AWS::DynamoDB::Errors::ProvisionedThroughputExceededException
|
205
217
|
# errors will be retried.
|
206
218
|
#
|
207
|
-
# @option options [String] :ec2_endpoint ('ec2.amazonaws.com') The
|
219
|
+
# @option options [String] :ec2_endpoint ('ec2.amazonaws.com') The
|
208
220
|
# service endpoint for Amazon EC2.
|
209
221
|
#
|
210
222
|
# @option options [String] :elb_endpoint ('elasticloadbalancing.us-east-1.amazonaws.com')
|
211
223
|
# The service endpoint for Elastic Load Balancing.
|
212
224
|
#
|
213
|
-
# @option options [Object] :http_handler (AWS::Core::Http::NetHttpHandler)
|
225
|
+
# @option options [Object] :http_handler (AWS::Core::Http::NetHttpHandler)
|
214
226
|
# The http handler that sends requests to AWS.
|
215
227
|
#
|
216
228
|
# @option options [Integer] :http_idle_timeout (60) The number of seconds
|
@@ -222,33 +234,33 @@ module AWS
|
|
222
234
|
# HTTP sesssion.
|
223
235
|
#
|
224
236
|
# @option options [Integer] :http_read_timeout (60) The number of seconds
|
225
|
-
# before the +:http_handler+ should timeout while waiting for a HTTP
|
237
|
+
# before the +:http_handler+ should timeout while waiting for a HTTP
|
226
238
|
# response.
|
227
239
|
#
|
228
|
-
# @option options [Boolean] :http_wire_trace (false) When +true+, the
|
229
|
-
# http handler will log all wire traces to the +:logger+. If a
|
230
|
-
# +:logger+ is not configured, then wire traces will be sent to
|
240
|
+
# @option options [Boolean] :http_wire_trace (false) When +true+, the
|
241
|
+
# http handler will log all wire traces to the +:logger+. If a
|
242
|
+
# +:logger+ is not configured, then wire traces will be sent to
|
231
243
|
# standard out.
|
232
244
|
#
|
233
|
-
# @option options [String] :iam_endpoint ('iam.amazonaws.com') The
|
245
|
+
# @option options [String] :iam_endpoint ('iam.amazonaws.com') The
|
234
246
|
# service endpoint for AWS Idenity Access Management (IAM).
|
235
247
|
#
|
236
|
-
# @option options [Logger,nil] :logger (nil) A logger to send
|
248
|
+
# @option options [Logger,nil] :logger (nil) A logger to send
|
237
249
|
# log messages to. Here is an example that logs to standard out.
|
238
250
|
#
|
239
251
|
# require 'logger'
|
240
252
|
# AWS.config(:logger => Logger.new($stdout))
|
241
253
|
#
|
242
254
|
# @option options [Symbol] :log_level (:info) The level log messages are
|
243
|
-
# sent to the logger with (e.g. +:notice+, +:info+, +:warn+,
|
255
|
+
# sent to the logger with (e.g. +:notice+, +:info+, +:warn+,
|
244
256
|
# +:debug+, etc).
|
245
257
|
#
|
246
258
|
# @option options [Object] :log_formatter The log formatter is responsible
|
247
|
-
# for building log messages from responses. You can quickly change
|
259
|
+
# for building log messages from responses. You can quickly change
|
248
260
|
# log formats by providing a pre-configured log formatter.
|
249
261
|
#
|
250
262
|
# AWS.config(:log_formatter => AWS::Core::LogFormatter.colored)
|
251
|
-
#
|
263
|
+
#
|
252
264
|
# Here is a list of pre-configured log formatters:
|
253
265
|
#
|
254
266
|
# * +AWS::Core::LogFormatter.default+
|
@@ -257,7 +269,7 @@ module AWS
|
|
257
269
|
# * +AWS::Core::LogFormatter.colored+
|
258
270
|
#
|
259
271
|
# You can also create an instance of AWS::Core::LogFormatter
|
260
|
-
# with a custom log message pattern. See {Core::LogFormatter} for
|
272
|
+
# with a custom log message pattern. See {Core::LogFormatter} for
|
261
273
|
# a complete list of pattern substituions.
|
262
274
|
#
|
263
275
|
# pattern = "[AWS :operation :duration] :error_message"
|
@@ -267,34 +279,37 @@ module AWS
|
|
267
279
|
# and instance of {Core::Response} and returns a string.
|
268
280
|
#
|
269
281
|
# @option options [Integer] :max_retries (3) The maximum number of times
|
270
|
-
# service errors (500) should be retried. There is an exponential
|
282
|
+
# service errors (500) should be retried. There is an exponential
|
271
283
|
# backoff in between service request retries, so the more retries the
|
272
284
|
# longer it can take to fail.
|
273
285
|
#
|
274
|
-
# @option options [String, URI, nil] :proxy_uri (nil) The URI of the proxy
|
275
|
-
# to send service requests through. You can pass a URI object or a
|
286
|
+
# @option options [String, URI, nil] :proxy_uri (nil) The URI of the proxy
|
287
|
+
# to send service requests through. You can pass a URI object or a
|
276
288
|
# URI string:
|
277
289
|
#
|
278
290
|
# AWS.config(:proxy_uri => 'https://user:password@my.proxy:443/path?query')
|
279
291
|
#
|
280
|
-
# @option options [String] :s3_endpoint ('s3.amazonaws.com') The
|
292
|
+
# @option options [String] :s3_endpoint ('s3.amazonaws.com') The
|
281
293
|
# service endpoint for Amazon S3.
|
282
294
|
#
|
295
|
+
# @option options [String] :route_53_endpoint ('route53.amazonaws.com')
|
296
|
+
# The service endpoint for Amazon Route 53.
|
297
|
+
#
|
283
298
|
# @option options [Boolean] :s3_force_path_style (false) When
|
284
299
|
# +true+, requests will always use path style. This can be useful
|
285
300
|
# for testing environments.
|
286
301
|
#
|
287
|
-
# @option options [Integer] :s3_multipart_max_parts (1000) The maximum
|
302
|
+
# @option options [Integer] :s3_multipart_max_parts (1000) The maximum
|
288
303
|
# number of parts to split a file into when uploading in parts to S3.
|
289
304
|
#
|
290
|
-
# @option options [Integer] :s3_multipart_threshold (16777216) When
|
291
|
-
# uploading data to S3, if the number of bytes to send exceedes
|
305
|
+
# @option options [Integer] :s3_multipart_threshold (16777216) When
|
306
|
+
# uploading data to S3, if the number of bytes to send exceedes
|
292
307
|
# +:s3_multipart_threshold+ then a multi part session is automatically
|
293
308
|
# started and the data is sent up in chunks. The size of each part
|
294
|
-
# is specified by +:s3_multipart_min_part_size+. Defaults to
|
309
|
+
# is specified by +:s3_multipart_min_part_size+. Defaults to
|
295
310
|
# 16777216 (16MB).
|
296
311
|
#
|
297
|
-
# @option options [Integer] :s3_multipart_min_part_size (5242880) The
|
312
|
+
# @option options [Integer] :s3_multipart_min_part_size (5242880) The
|
298
313
|
# absolute minimum size (in bytes) each S3 multipart segment should be.
|
299
314
|
# Defaults to 5242880 (5MB).
|
300
315
|
#
|
@@ -313,25 +328,25 @@ module AWS
|
|
313
328
|
# * {S3::S3Object#presigned_post}
|
314
329
|
# * {S3::Bucket#presigned_post}
|
315
330
|
#
|
316
|
-
# @option options [String] :simple_db_endpoint ('sdb.amazonaws.com')
|
331
|
+
# @option options [String] :simple_db_endpoint ('sdb.amazonaws.com')
|
317
332
|
# The service endpoint for Amazon SimpleDB.
|
318
333
|
#
|
319
334
|
# @option options [Boolean] :simple_db_consistent_reads (false) Determines
|
320
335
|
# if all SimpleDB read requests should be done consistently.
|
321
336
|
# Consistent reads are slower, but reflect all changes to SDB.
|
322
337
|
#
|
323
|
-
# @option options [String] :simple_email_service_endpoint ('email.us-east-1.amazonaws.com')
|
338
|
+
# @option options [String] :simple_email_service_endpoint ('email.us-east-1.amazonaws.com')
|
324
339
|
# The service endpoint for Amazon Simple Email Service.
|
325
340
|
#
|
326
341
|
# @option options [String] :simple_workflow_service ('swf.us-east-1.amazonaws.com')
|
327
342
|
# The service endpoint for Amazon Simple Workflow Service.
|
328
343
|
#
|
329
|
-
# @option options [CredentialProviders::Provider] :credential_provider (AWS::Core::CredentialProviders::DefaultProvider.new)
|
344
|
+
# @option options [CredentialProviders::Provider] :credential_provider (AWS::Core::CredentialProviders::DefaultProvider.new)
|
330
345
|
# Returns the credential provider. The default credential provider
|
331
346
|
# attempts to check for statically assigned credentials, ENV credentials
|
332
347
|
# and credentials in the metadata service of EC2.
|
333
348
|
#
|
334
|
-
# @option options [String] :ssl_ca_file The path to a CA cert bundle in
|
349
|
+
# @option options [String] :ssl_ca_file The path to a CA cert bundle in
|
335
350
|
# PEM format.
|
336
351
|
#
|
337
352
|
# If +:ssl_verify_peer+ is +true+ (the default) this bundle will be
|
@@ -339,10 +354,10 @@ module AWS
|
|
339
354
|
# The AWS SDK for Ruby ships with a CA cert bundle, which is the
|
340
355
|
# default value for this option.
|
341
356
|
#
|
342
|
-
# @option options [String] :ssl_ca_path (nil)
|
357
|
+
# @option options [String] :ssl_ca_path (nil)
|
343
358
|
# The path the a CA cert directory.
|
344
359
|
#
|
345
|
-
# @option options [Boolean] :ssl_verify_peer (true) When +true+
|
360
|
+
# @option options [Boolean] :ssl_verify_peer (true) When +true+
|
346
361
|
# the HTTP handler validate server certificates for HTTPS requests.
|
347
362
|
#
|
348
363
|
# This option should only be disabled for diagnostic purposes;
|
@@ -350,8 +365,8 @@ module AWS
|
|
350
365
|
# man-in-the-middle attacks and can pose a serious security
|
351
366
|
# risk.
|
352
367
|
#
|
353
|
-
# @option options [Boolean] :stub_requests (false) When +true+ requests
|
354
|
-
# are not sent to AWS, instead empty reponses are generated and
|
368
|
+
# @option options [Boolean] :stub_requests (false) When +true+ requests
|
369
|
+
# are not sent to AWS, instead empty reponses are generated and
|
355
370
|
# returned to each service request.
|
356
371
|
#
|
357
372
|
# @option options [String] :sns_endpoint ('sns.us-east-1.amazonaws.com') The
|
@@ -360,16 +375,16 @@ module AWS
|
|
360
375
|
# @option options [String] :sqs_endpoint ('sqs.us-east-1.amazonaws.com') The
|
361
376
|
# service endpoint for Amazon SQS.
|
362
377
|
#
|
363
|
-
# @option options [String] :sts_endpoint ('sts.amazonaws.com') The
|
378
|
+
# @option options [String] :sts_endpoint ('sts.amazonaws.com') The
|
364
379
|
# service endpoint for AWS Security Token Service.
|
365
380
|
#
|
366
381
|
# @option options [Boolean] :use_ssl (true) When +true+, all requests
|
367
382
|
# to AWS are sent using HTTPS instead vanilla HTTP.
|
368
383
|
#
|
369
|
-
# @option options [String] :user_agent_prefix (nil) A string prefix to
|
384
|
+
# @option options [String] :user_agent_prefix (nil) A string prefix to
|
370
385
|
# append to all requets against AWS services. This should be set
|
371
386
|
# for clients and applications built ontop of the aws-sdk gem.
|
372
|
-
#
|
387
|
+
#
|
373
388
|
# @return [Core::Configuration] Returns the new configuration.
|
374
389
|
#
|
375
390
|
def config options = {}
|
data/lib/aws/core/client.rb
CHANGED
@@ -11,25 +11,24 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require '
|
15
|
-
require 'aws/core/client/query_json'
|
14
|
+
require 'json'
|
16
15
|
require 'set'
|
17
16
|
require 'yaml'
|
18
17
|
|
19
18
|
module AWS
|
20
19
|
module Core
|
21
|
-
|
20
|
+
|
22
21
|
# Base client class for all of the Amazon AWS service clients.
|
23
22
|
class Client
|
24
|
-
|
23
|
+
|
25
24
|
extend Naming
|
26
|
-
|
25
|
+
|
27
26
|
# @private
|
28
27
|
CACHEABLE_REQUESTS = Set[]
|
29
|
-
|
30
|
-
# Creates a new low-level client.
|
28
|
+
|
29
|
+
# Creates a new low-level client.
|
31
30
|
# @param [Hash] options
|
32
|
-
# @option options [Core::Configuration] :config (AWS.config)
|
31
|
+
# @option options [Core::Configuration] :config (AWS.config)
|
33
32
|
# The base configuration object to use. All other options
|
34
33
|
# are merged with this. Defaults to the AWS.config.
|
35
34
|
# @option (see AWS.config)
|
@@ -38,7 +37,7 @@ module AWS
|
|
38
37
|
options = options.dup # so we don't modify the options passed in
|
39
38
|
|
40
39
|
@service_ruby_name = self.class.service_ruby_name
|
41
|
-
|
40
|
+
|
42
41
|
# translate these into service specific configuration options,
|
43
42
|
# e.g. :endpoint into :s3_endpoint
|
44
43
|
[:endpoint, :region, :port].each do |opt|
|
@@ -46,7 +45,7 @@ module AWS
|
|
46
45
|
options[:"#{service_ruby_name}_#{opt}"] = options.delete(opt)
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
48
|
+
|
50
49
|
@config = (options.delete(:config) || AWS.config)
|
51
50
|
@config = @config.with(options)
|
52
51
|
|
@@ -57,10 +56,10 @@ module AWS
|
|
57
56
|
@http_read_timeout = @config.http_read_timeout
|
58
57
|
|
59
58
|
end
|
60
|
-
|
59
|
+
|
61
60
|
# @return [Configuration] This clients configuration.
|
62
61
|
attr_reader :config
|
63
|
-
|
62
|
+
|
64
63
|
# @return [CredentialProviders::Provider] Returns the credentail
|
65
64
|
# provider for this client.
|
66
65
|
# @private
|
@@ -88,7 +87,7 @@ module AWS
|
|
88
87
|
def operations
|
89
88
|
self.class.operations
|
90
89
|
end
|
91
|
-
|
90
|
+
|
92
91
|
# Returns a copy of the client with a different HTTP handler.
|
93
92
|
# You can pass an object like BuiltinHttpHandler or you can
|
94
93
|
# use a block; for example:
|
@@ -114,7 +113,7 @@ module AWS
|
|
114
113
|
handler ||= Http::Handler.new(@http_handler, &blk)
|
115
114
|
with_options(:http_handler => handler)
|
116
115
|
end
|
117
|
-
|
116
|
+
|
118
117
|
# Returns a new client with the passed configuration options
|
119
118
|
# merged with the current configuration options.
|
120
119
|
#
|
@@ -126,7 +125,7 @@ module AWS
|
|
126
125
|
def with_options options
|
127
126
|
with_config(config.with(options))
|
128
127
|
end
|
129
|
-
|
128
|
+
|
130
129
|
# @param [Configuration] config The configuration object to use.
|
131
130
|
# @return [Core::Client] Returns a new client object with the given
|
132
131
|
# configuration.
|
@@ -134,7 +133,7 @@ module AWS
|
|
134
133
|
def with_config config
|
135
134
|
self.class.new(:config => config)
|
136
135
|
end
|
137
|
-
|
136
|
+
|
138
137
|
# The stub returned is memoized.
|
139
138
|
# @see new_stub_for
|
140
139
|
# @private
|
@@ -142,8 +141,8 @@ module AWS
|
|
142
141
|
@stubs ||= {}
|
143
142
|
@stubs[method_name] ||= new_stub_for(method_name)
|
144
143
|
end
|
145
|
-
|
146
|
-
# Primarily used for testing, this method returns an empty psuedo
|
144
|
+
|
145
|
+
# Primarily used for testing, this method returns an empty psuedo
|
147
146
|
# service response without making a request. Its used primarily for
|
148
147
|
# testing the ligher level service interfaces.
|
149
148
|
# @private
|
@@ -155,29 +154,29 @@ module AWS
|
|
155
154
|
response.signal_success
|
156
155
|
response
|
157
156
|
end
|
158
|
-
|
157
|
+
|
159
158
|
protected
|
160
159
|
|
161
160
|
def new_request
|
162
161
|
eval(self.class.name.sub(/::Client$/, ''))::Request.new
|
163
162
|
end
|
164
|
-
|
163
|
+
|
165
164
|
def new_response(*args, &block)
|
166
165
|
Response.new(*args, &block)
|
167
166
|
end
|
168
|
-
|
167
|
+
|
169
168
|
def make_async_request response
|
170
|
-
|
169
|
+
|
171
170
|
pauses = async_request_with_retries(response, response.http_request)
|
172
|
-
|
171
|
+
|
173
172
|
response
|
174
|
-
|
173
|
+
|
175
174
|
end
|
176
|
-
|
175
|
+
|
177
176
|
def async_request_with_retries response, http_request, retry_delays = nil
|
178
|
-
|
177
|
+
|
179
178
|
response.http_response = Http::Response.new
|
180
|
-
|
179
|
+
|
181
180
|
handle = Object.new
|
182
181
|
handle.extend AsyncHandle
|
183
182
|
handle.on_complete do |status|
|
@@ -200,30 +199,30 @@ module AWS
|
|
200
199
|
end
|
201
200
|
end
|
202
201
|
end
|
203
|
-
|
202
|
+
|
204
203
|
@http_handler.handle_async(http_request, response.http_response, handle)
|
205
|
-
|
204
|
+
|
206
205
|
end
|
207
|
-
|
206
|
+
|
208
207
|
def make_sync_request response
|
209
208
|
retry_server_errors do
|
210
|
-
|
209
|
+
|
211
210
|
response.http_response = http_response =
|
212
211
|
Http::Response.new
|
213
|
-
|
212
|
+
|
214
213
|
@http_handler.handle(response.http_request, http_response)
|
215
214
|
|
216
215
|
populate_error(response)
|
217
216
|
response.signal_success unless response.error
|
218
217
|
response
|
219
|
-
|
218
|
+
|
220
219
|
end
|
221
220
|
end
|
222
|
-
|
221
|
+
|
223
222
|
def retry_server_errors &block
|
224
|
-
|
223
|
+
|
225
224
|
response = yield
|
226
|
-
|
225
|
+
|
227
226
|
sleeps = sleep_durations(response)
|
228
227
|
while should_retry?(response)
|
229
228
|
break if sleeps.empty?
|
@@ -232,9 +231,9 @@ module AWS
|
|
232
231
|
rebuild_http_request(response)
|
233
232
|
response = yield
|
234
233
|
end
|
235
|
-
|
234
|
+
|
236
235
|
response
|
237
|
-
|
236
|
+
|
238
237
|
end
|
239
238
|
|
240
239
|
def rebuild_http_request response
|
@@ -242,7 +241,7 @@ module AWS
|
|
242
241
|
response.rebuild_request
|
243
242
|
response.retry_count += 1
|
244
243
|
end
|
245
|
-
|
244
|
+
|
246
245
|
def sleep_durations response
|
247
246
|
if expired_credentials?(response)
|
248
247
|
[0]
|
@@ -251,11 +250,11 @@ module AWS
|
|
251
250
|
Array.new(config.max_retries) {|n| (2 ** n) * factor }
|
252
251
|
end
|
253
252
|
end
|
254
|
-
|
253
|
+
|
255
254
|
def scaling_factor response
|
256
255
|
response.throttled? ? (0.5 + Kernel.rand * 0.1) : 0.3
|
257
256
|
end
|
258
|
-
|
257
|
+
|
259
258
|
def should_retry? response
|
260
259
|
expired_credentials?(response) or
|
261
260
|
response.timeout? or
|
@@ -266,11 +265,11 @@ module AWS
|
|
266
265
|
# @return [Boolean] Returns +true+ if the response contains an
|
267
266
|
# error message that indicates credentials have expired.
|
268
267
|
def expired_credentials? response
|
269
|
-
response.error and
|
268
|
+
response.error and
|
270
269
|
response.error.respond_to?(:code) and
|
271
270
|
response.error.code == 'ExpiredTokenException'
|
272
271
|
end
|
273
|
-
|
272
|
+
|
274
273
|
def return_or_raise options, &block
|
275
274
|
response = yield
|
276
275
|
unless options[:async]
|
@@ -279,10 +278,10 @@ module AWS
|
|
279
278
|
response
|
280
279
|
end
|
281
280
|
|
282
|
-
# Yields to the given block (which should be making a
|
283
|
-
# request and returning a {Response} object). The results of the
|
281
|
+
# Yields to the given block (which should be making a
|
282
|
+
# request and returning a {Response} object). The results of the
|
284
283
|
# request/response are logged.
|
285
|
-
#
|
284
|
+
#
|
286
285
|
# @param [Hash] options
|
287
286
|
# @option options [Boolean] :async
|
288
287
|
# @return [Response]
|
@@ -293,12 +292,12 @@ module AWS
|
|
293
292
|
response = yield
|
294
293
|
response.duration = Time.now - start
|
295
294
|
|
296
|
-
if options[:async]
|
297
|
-
response.on_complete { log_response(response) }
|
295
|
+
if options[:async]
|
296
|
+
response.on_complete { log_response(response) }
|
298
297
|
else
|
299
298
|
log_response(response)
|
300
299
|
end
|
301
|
-
|
300
|
+
|
302
301
|
response
|
303
302
|
|
304
303
|
end
|
@@ -313,13 +312,13 @@ module AWS
|
|
313
312
|
end
|
314
313
|
nil
|
315
314
|
end
|
316
|
-
|
315
|
+
|
317
316
|
def populate_error response
|
318
317
|
response.error = extract_error(response)
|
319
318
|
end
|
320
319
|
|
321
320
|
# If the response contains error, this method will construct
|
322
|
-
# and return an error object. If no error is contained in the
|
321
|
+
# and return an error object. If no error is contained in the
|
323
322
|
# response, then nil is returned.
|
324
323
|
# @param [Response] response
|
325
324
|
# @return [Errors::Base,nil]
|
@@ -352,7 +351,7 @@ module AWS
|
|
352
351
|
# #=> AWS::EC2::Errors::InvalidInstanceId
|
353
352
|
#
|
354
353
|
# @param [String] error_code The error code string as returned by
|
355
|
-
# the service. If this class contains periods, they will be
|
354
|
+
# the service. If this class contains periods, they will be
|
356
355
|
# converted into namespaces (e.g. 'Foo.Bar' becomes Errors::Foo::Bar).
|
357
356
|
#
|
358
357
|
# @return [Class]
|
@@ -371,26 +370,26 @@ module AWS
|
|
371
370
|
def errors_module
|
372
371
|
AWS.const_get(self.class.to_s[/(\w+)::Client/, 1])::Errors
|
373
372
|
end
|
374
|
-
|
373
|
+
|
375
374
|
def client_request name, options, &block
|
376
375
|
return_or_raise(options) do
|
377
376
|
log_client_request(options) do
|
378
|
-
|
377
|
+
|
379
378
|
if config.stub_requests?
|
380
|
-
|
379
|
+
|
381
380
|
response = stub_for(name)
|
382
381
|
response.http_request = build_request(name, options, &block)
|
383
382
|
response.request_options = options
|
384
383
|
response
|
385
|
-
|
384
|
+
|
386
385
|
else
|
387
|
-
|
386
|
+
|
388
387
|
client = self
|
389
388
|
response = new_response { client.send(:build_request, name, options, &block) }
|
390
389
|
response.request_type = name
|
391
390
|
response.request_options = options
|
392
|
-
|
393
|
-
if
|
391
|
+
|
392
|
+
if
|
394
393
|
cacheable_request?(name, options) and
|
395
394
|
cache = AWS.response_cache and
|
396
395
|
cached_response = cache.cached(response)
|
@@ -402,7 +401,7 @@ module AWS
|
|
402
401
|
options[:async] ?
|
403
402
|
make_async_request(response) :
|
404
403
|
make_sync_request(response)
|
405
|
-
|
404
|
+
|
406
405
|
# process the http response
|
407
406
|
response.on_success do
|
408
407
|
send("process_#{name}_response", response)
|
@@ -410,13 +409,13 @@ module AWS
|
|
410
409
|
cache.add(response)
|
411
410
|
end
|
412
411
|
end
|
413
|
-
|
412
|
+
|
414
413
|
response
|
415
|
-
|
414
|
+
|
416
415
|
end
|
417
|
-
|
416
|
+
|
418
417
|
end
|
419
|
-
|
418
|
+
|
420
419
|
end
|
421
420
|
end
|
422
421
|
end
|
@@ -424,16 +423,16 @@ module AWS
|
|
424
423
|
def cacheable_request? name, options
|
425
424
|
self.class::CACHEABLE_REQUESTS.include?(name)
|
426
425
|
end
|
427
|
-
|
426
|
+
|
428
427
|
def build_request(name, options, &block)
|
429
428
|
|
430
429
|
# we dont want to pass the async option to the configure block
|
431
430
|
opts = options.dup
|
432
431
|
opts.delete(:async)
|
433
|
-
|
432
|
+
|
434
433
|
http_request = new_request
|
435
434
|
http_request.access_key_id = credential_provider.access_key_id
|
436
|
-
|
435
|
+
|
437
436
|
# configure the http request
|
438
437
|
http_request.service_ruby_name = service_ruby_name
|
439
438
|
http_request.default_read_timeout = http_read_timeout
|
@@ -445,7 +444,7 @@ module AWS
|
|
445
444
|
http_request.ssl_verify_peer = config.ssl_verify_peer?
|
446
445
|
http_request.ssl_ca_file = config.ssl_ca_file if config.ssl_ca_file
|
447
446
|
http_request.ssl_ca_path = config.ssl_ca_path if config.ssl_ca_path
|
448
|
-
|
447
|
+
|
449
448
|
send("configure_#{name}_request", http_request, opts, &block)
|
450
449
|
|
451
450
|
http_request.headers["user-agent"] = user_agent_string
|
@@ -454,7 +453,7 @@ module AWS
|
|
454
453
|
http_request
|
455
454
|
|
456
455
|
end
|
457
|
-
|
456
|
+
|
458
457
|
def user_agent_string
|
459
458
|
engine = (RUBY_ENGINE rescue nil or "ruby")
|
460
459
|
user_agent = "%s aws-sdk-ruby/#{VERSION} %s/%s %s" %
|
@@ -465,7 +464,7 @@ module AWS
|
|
465
464
|
end
|
466
465
|
user_agent
|
467
466
|
end
|
468
|
-
|
467
|
+
|
469
468
|
# Adds a single method to the current client class. This method
|
470
469
|
# yields a request method builder that allows you to specify how:
|
471
470
|
#
|
@@ -476,24 +475,24 @@ module AWS
|
|
476
475
|
def self.add_client_request_method method_name, options = {}, &block
|
477
476
|
|
478
477
|
self.operations << method_name
|
479
|
-
|
478
|
+
|
480
479
|
ClientRequestMethodBuilder.new(self, method_name, &block)
|
481
|
-
|
480
|
+
|
482
481
|
module_eval <<-END
|
483
482
|
def #{method_name}(*args, &block)
|
484
483
|
options = args.first ? args.first : {}
|
485
484
|
client_request(#{method_name.inspect}, options, &block)
|
486
485
|
end
|
487
486
|
END
|
488
|
-
|
487
|
+
|
489
488
|
end
|
490
489
|
|
491
490
|
# Parses the service's API configuration yaml file. This file has
|
492
491
|
# configuration that drives the request and response DSLs.
|
493
492
|
# @return [Hash]
|
494
493
|
def self.api_config
|
495
|
-
config_file =
|
496
|
-
File.dirname(File.dirname(__FILE__)) +
|
494
|
+
config_file =
|
495
|
+
File.dirname(File.dirname(__FILE__)) +
|
497
496
|
"/api_config/#{service_name}-#{self::API_VERSION}.yml"
|
498
497
|
YAML.load(File.read(config_file))
|
499
498
|
end
|
@@ -503,10 +502,10 @@ module AWS
|
|
503
502
|
def self.operations
|
504
503
|
@operations ||= []
|
505
504
|
end
|
506
|
-
|
505
|
+
|
507
506
|
# @private
|
508
507
|
class ClientRequestMethodBuilder
|
509
|
-
|
508
|
+
|
510
509
|
def initialize client_class, method_name, &block
|
511
510
|
@client_class = client_class
|
512
511
|
@method_name = method_name
|
@@ -515,7 +514,7 @@ module AWS
|
|
515
514
|
simulate_response {|response|}
|
516
515
|
instance_eval(&block)
|
517
516
|
end
|
518
|
-
|
517
|
+
|
519
518
|
def configure_request options = {}, &block
|
520
519
|
name = "configure_#{@method_name}_request"
|
521
520
|
MetaUtils.class_extend_method(@client_class, name, &block)
|
@@ -529,19 +528,19 @@ module AWS
|
|
529
528
|
@client_class.send(:include, m)
|
530
529
|
end
|
531
530
|
end
|
532
|
-
|
531
|
+
|
533
532
|
def process_response &block
|
534
533
|
name = "process_#{@method_name}_response"
|
535
534
|
MetaUtils.class_extend_method(@client_class, name, &block)
|
536
535
|
end
|
537
|
-
|
536
|
+
|
538
537
|
def simulate_response &block
|
539
538
|
name = "simulate_#{@method_name}_response"
|
540
539
|
MetaUtils.class_extend_method(@client_class, name, &block)
|
541
540
|
end
|
542
|
-
|
541
|
+
|
543
542
|
end
|
544
|
-
|
543
|
+
|
545
544
|
end
|
546
545
|
end
|
547
546
|
end
|