aws-sdk 1.5.8 → 1.6.0
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/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
@@ -14,11 +14,11 @@
|
|
14
14
|
module AWS
|
15
15
|
module Core
|
16
16
|
module Collection
|
17
|
-
|
17
|
+
|
18
18
|
# = Collection::WithLimitAndNextToken
|
19
19
|
#
|
20
20
|
# This module is used by collections where the service may truncate
|
21
|
-
# responses but that also accept a upper limit of results to
|
21
|
+
# responses but that also accept a upper limit of results to
|
22
22
|
# return in a single request.
|
23
23
|
#
|
24
24
|
# See {AWS::Core::Collection} for documentation on the available
|
@@ -55,7 +55,7 @@ module AWS
|
|
55
55
|
#
|
56
56
|
# The global default configuration can be found at {AWS.config}
|
57
57
|
#
|
58
|
-
# @attr_reader [String,nil] access_key_id (nil)
|
58
|
+
# @attr_reader [String,nil] access_key_id (nil)
|
59
59
|
# AWS access key id credential.
|
60
60
|
#
|
61
61
|
# @attr_reader [String,nil] secret_access_key (nil)
|
@@ -70,7 +70,7 @@ module AWS
|
|
70
70
|
# The service endpoint for AWS CloudFormation.
|
71
71
|
#
|
72
72
|
# @attr_reader [String] dynamo_db_endpoint ('dynamodb.us-east-1.amazonaws.com')
|
73
|
-
# The service endpoint for Amazon DynamoDB.
|
73
|
+
# The service endpoint for Amazon DynamoDB.
|
74
74
|
#
|
75
75
|
# @attr_reader [String] dynamo_db_retry_throughput_errors (true) When
|
76
76
|
# true, AWS::DynamoDB::Errors::ProvisionedThroughputExceededException
|
@@ -80,7 +80,7 @@ module AWS
|
|
80
80
|
# The service endpoint for Amazon EC2.
|
81
81
|
#
|
82
82
|
# @attr_reader [String] elb_endpoint ('elasticloadbalancing.us-east-1.amazonaws.com')
|
83
|
-
# The service endpoint for Elastic Load Balancing.
|
83
|
+
# The service endpoint for Elastic Load Balancing.
|
84
84
|
#
|
85
85
|
# @attr_reader [Object] http_handler The http handler that sends requests
|
86
86
|
# to AWS. Defaults to an HTTP handler built on net/http.
|
@@ -90,11 +90,11 @@ module AWS
|
|
90
90
|
# longer be used.
|
91
91
|
#
|
92
92
|
# @attr_reader [Integer] http_open_timeout The number of seconds before
|
93
|
-
# the +http_handler+ should timeout while trying to open a new HTTP
|
93
|
+
# the +http_handler+ should timeout while trying to open a new HTTP
|
94
94
|
# sesssion.
|
95
95
|
#
|
96
96
|
# @attr_reader [Integer] http_read_timeout The number of seconds before
|
97
|
-
# the +http_handler+ should timeout while waiting for a HTTP
|
97
|
+
# the +http_handler+ should timeout while waiting for a HTTP
|
98
98
|
# response.
|
99
99
|
#
|
100
100
|
# @attr_reader [Boolean] http_wire_trace When +true+, the http handler
|
@@ -111,13 +111,16 @@ module AWS
|
|
111
111
|
# @attr_reader [LogFormatter] log_formatter The log message formatter.
|
112
112
|
#
|
113
113
|
# @attr_reader [Integer] max_retries (3) The maximum number of times
|
114
|
-
# service errors (500) should be retried. There is an exponential
|
114
|
+
# service errors (500) should be retried. There is an exponential
|
115
115
|
# backoff in between service request retries, so the more retries the
|
116
116
|
# longer it can take to fail.
|
117
117
|
#
|
118
|
-
# @attr_reader [URI,nil] proxy_uri (nil) The URI of the proxy
|
118
|
+
# @attr_reader [URI,nil] proxy_uri (nil) The URI of the proxy
|
119
119
|
# to send service requests through.
|
120
120
|
#
|
121
|
+
# @attr_reader [URI,nil] route_53_endpoint ('route53.amazonaws.com')
|
122
|
+
# The service endpoint for Amazon Route 53.
|
123
|
+
#
|
121
124
|
# @attr_reader [String] s3_endpoint ('s3.amazonaws.com')
|
122
125
|
# The service endpoint for Amazon S3.
|
123
126
|
#
|
@@ -125,19 +128,19 @@ module AWS
|
|
125
128
|
# +true+, requests will always use path style. This can be useful
|
126
129
|
# for testing environments.
|
127
130
|
#
|
128
|
-
# @attr_reader [Integer] s3_multipart_max_parts (1000)
|
129
|
-
# The maximum number of parts to split a file into when uploading
|
131
|
+
# @attr_reader [Integer] s3_multipart_max_parts (1000)
|
132
|
+
# The maximum number of parts to split a file into when uploading
|
130
133
|
# in parts to S3.
|
131
134
|
#
|
132
135
|
# @attr_reader [Integer] s3_multipart_threshold (16777216) When uploading
|
133
|
-
# data to S3, if the number of bytes to send exceedes
|
136
|
+
# data to S3, if the number of bytes to send exceedes
|
134
137
|
# +:s3_multipart_threshold+ then a multi part session is automatically
|
135
138
|
# started and the data is sent up in chunks. The size of each part
|
136
|
-
# is specified by +:s3_multipart_min_part_size+. Defaults to
|
139
|
+
# is specified by +:s3_multipart_min_part_size+. Defaults to
|
137
140
|
# 16777216 (16MB).
|
138
141
|
#
|
139
|
-
# @attr_reader [Integer] s3_multipart_min_part_size (5242880)
|
140
|
-
# The absolute minimum size (in bytes) each S3 multipart
|
142
|
+
# @attr_reader [Integer] s3_multipart_min_part_size (5242880)
|
143
|
+
# The absolute minimum size (in bytes) each S3 multipart
|
141
144
|
# segment should be defaults to 5242880 (5MB).
|
142
145
|
#
|
143
146
|
# @attr_reader [Symbol] s3_server_side_encryption The algorithm to
|
@@ -161,7 +164,7 @@ module AWS
|
|
161
164
|
# s3 = AWS::S3.new(:s3_server_side_encryption => :aes256)
|
162
165
|
#
|
163
166
|
# @attr_reader [String] simple_db_endpoint ('sdb.amazonaws.com')
|
164
|
-
# The service endpoint for Amazon SimpleDB.
|
167
|
+
# The service endpoint for Amazon SimpleDB.
|
165
168
|
#
|
166
169
|
# @attr_reader [Boolean] simple_db_consistent_reads (false) Determines
|
167
170
|
# if all SimpleDB read requests should be done consistently.
|
@@ -173,10 +176,10 @@ module AWS
|
|
173
176
|
# @attr_reader [String] simple_workflow_endpoint ('swf.us-east-1.amazonaws.com')
|
174
177
|
# The service endpoint for Amazon Simple Workflow Service.
|
175
178
|
#
|
176
|
-
# @attr_reader [CredentialProvider::Provider] credential_provider
|
179
|
+
# @attr_reader [CredentialProvider::Provider] credential_provider
|
177
180
|
# Returns the object that is responsible for loading credentials.
|
178
181
|
#
|
179
|
-
# @attr_reader [String] ssl_ca_file The path to a CA cert bundle in
|
182
|
+
# @attr_reader [String] ssl_ca_file The path to a CA cert bundle in
|
180
183
|
# PEM format.
|
181
184
|
#
|
182
185
|
# If +ssl_verify_peer+ is true (the default) this bundle will be
|
@@ -184,10 +187,10 @@ module AWS
|
|
184
187
|
# The AWS SDK for Ruby ships with a CA cert bundle, which is the
|
185
188
|
# default value for this option.
|
186
189
|
#
|
187
|
-
# @attr_reader [String] ssl_ca_path (nil)
|
190
|
+
# @attr_reader [String] ssl_ca_path (nil)
|
188
191
|
# The path the a CA cert directory.
|
189
192
|
#
|
190
|
-
# @attr_reader [Boolean] ssl_verify_peer (true) When +true+
|
193
|
+
# @attr_reader [Boolean] ssl_verify_peer (true) When +true+
|
191
194
|
# the HTTP handler validate server certificates for HTTPS requests.
|
192
195
|
#
|
193
196
|
# This option should only be disabled for diagnostic purposes;
|
@@ -206,22 +209,22 @@ module AWS
|
|
206
209
|
# The service endpoint for Amazon SQS.
|
207
210
|
#
|
208
211
|
# @attr_reader [String] sts_endpoint ('sts.amazonaws.com')
|
209
|
-
# The service endpoint for AWS Security Token Service.
|
212
|
+
# The service endpoint for AWS Security Token Service.
|
210
213
|
#
|
211
214
|
# @attr_reader [Boolean] use_ssl (true) When +true+, all requests
|
212
215
|
# to AWS are sent using HTTPS instead vanilla HTTP.
|
213
216
|
#
|
214
|
-
# @attr_reader [String] user_agent_prefix (nil) A string prefix to
|
217
|
+
# @attr_reader [String] user_agent_prefix (nil) A string prefix to
|
215
218
|
# append to all requets against AWS services. This should be set
|
216
219
|
# for clients and applications built ontop of the aws-sdk gem.
|
217
220
|
#
|
218
221
|
class Configuration
|
219
|
-
|
222
|
+
|
220
223
|
# Creates a new Configuration object.
|
221
224
|
# @param options (see AWS.config)
|
222
225
|
# @option options (see AWS.config)
|
223
226
|
def initialize options = {}
|
224
|
-
|
227
|
+
|
225
228
|
@created = options.delete(:__created__) || {}
|
226
229
|
|
227
230
|
# :signer is now a deprecated option, this ensures it will still
|
@@ -237,7 +240,7 @@ module AWS
|
|
237
240
|
supplied[opt_name] = value
|
238
241
|
end
|
239
242
|
end
|
240
|
-
|
243
|
+
|
241
244
|
end
|
242
245
|
|
243
246
|
# @return [Hash] Returns a hash with your configured credentials.
|
@@ -250,7 +253,7 @@ module AWS
|
|
250
253
|
end
|
251
254
|
credentials
|
252
255
|
end
|
253
|
-
|
256
|
+
|
254
257
|
# Used to create a new Configuration object with the given modifications.
|
255
258
|
# The current configuration object is not modified.
|
256
259
|
#
|
@@ -272,20 +275,20 @@ module AWS
|
|
272
275
|
# @return [Configuration] Copies the current configuration and returns
|
273
276
|
# a new one with modifications as provided in +:options+.
|
274
277
|
def with options = {}
|
275
|
-
|
278
|
+
|
276
279
|
# symbolize option keys
|
277
280
|
options = options.inject({}) {|h,kv| h[kv.first.to_sym] = kv.last; h }
|
278
|
-
|
281
|
+
|
279
282
|
values = supplied.merge(options)
|
280
|
-
|
283
|
+
|
281
284
|
if supplied == values
|
282
285
|
self # nothing changed
|
283
286
|
else
|
284
287
|
self.class.new(values.merge(:__created__ => @created.dup))
|
285
288
|
end
|
286
|
-
|
289
|
+
|
287
290
|
end
|
288
|
-
|
291
|
+
|
289
292
|
# @return [Hash] Returns a hash of all configuration values.
|
290
293
|
def to_h
|
291
294
|
self.class.accepted_options.inject({}) do |h,k|
|
@@ -293,40 +296,40 @@ module AWS
|
|
293
296
|
end
|
294
297
|
end
|
295
298
|
alias_method :to_hash, :to_h
|
296
|
-
|
299
|
+
|
297
300
|
# @return [Boolean] Returns true if the two configuration objects have
|
298
301
|
# the same values.
|
299
302
|
def eql? other
|
300
303
|
other.is_a?(self.class) and self.supplied == other.supplied
|
301
304
|
end
|
302
305
|
alias_method :==, :eql?
|
303
|
-
|
306
|
+
|
304
307
|
# @private
|
305
308
|
def inspect
|
306
309
|
"<#{self.class.name}>"
|
307
310
|
end
|
308
|
-
|
311
|
+
|
309
312
|
protected
|
310
313
|
|
311
314
|
def supplied
|
312
315
|
@supplied ||= {}
|
313
316
|
end
|
314
|
-
|
317
|
+
|
315
318
|
class << self
|
316
|
-
|
319
|
+
|
317
320
|
# @private
|
318
321
|
def accepted_options
|
319
322
|
@options ||= Set.new
|
320
323
|
end
|
321
|
-
|
324
|
+
|
322
325
|
# @private
|
323
326
|
def add_option name, default_value = nil, options = {}, &transform
|
324
|
-
|
327
|
+
|
325
328
|
accepted_options << name
|
326
|
-
|
329
|
+
|
327
330
|
define_method(name) do |&default_override|
|
328
331
|
|
329
|
-
value =
|
332
|
+
value =
|
330
333
|
if supplied.has_key?(name)
|
331
334
|
supplied[name]
|
332
335
|
elsif default_override
|
@@ -338,35 +341,35 @@ module AWS
|
|
338
341
|
transform ? transform.call(self, value) : value
|
339
342
|
|
340
343
|
end
|
341
|
-
|
344
|
+
|
342
345
|
alias_method("#{name}?", name) if options[:boolean]
|
343
|
-
|
346
|
+
|
344
347
|
end
|
345
|
-
|
348
|
+
|
346
349
|
# Configuration options that have dependencies are re-recreated
|
347
350
|
# anytime one of their dependendent configuration values are
|
348
351
|
# changed.
|
349
352
|
# @private
|
350
353
|
def add_option_with_needs name, needs, &create_block
|
351
|
-
|
354
|
+
|
352
355
|
accepted_options << name
|
353
|
-
|
356
|
+
|
354
357
|
define_method(name) do
|
355
|
-
|
358
|
+
|
356
359
|
return supplied[name] if supplied.has_key?(name)
|
357
|
-
|
360
|
+
|
358
361
|
needed = needs.inject({}) {|h,need| h.merge(need => send(need)) }
|
359
|
-
|
362
|
+
|
360
363
|
unless @created.key?(name) and @created[name][:needed] == needed
|
361
364
|
@created[name] = {}
|
362
365
|
@created[name][:object] = create_block.call(self,needed)
|
363
366
|
@created[name][:needed] = needed
|
364
367
|
end
|
365
|
-
|
368
|
+
|
366
369
|
@created[name][:object]
|
367
|
-
|
370
|
+
|
368
371
|
end
|
369
|
-
|
372
|
+
|
370
373
|
end
|
371
374
|
|
372
375
|
def add_service name, ruby_name, default_endpoint
|
@@ -389,7 +392,7 @@ module AWS
|
|
389
392
|
'us-gov-west-1' # e.g. iam.us-gov.amazonaws.com
|
390
393
|
end
|
391
394
|
elsif matches = endpoint.match(/^.+\.(.+)\.amazonaws.com$/)
|
392
|
-
matches[1]
|
395
|
+
matches[1]
|
393
396
|
else
|
394
397
|
'us-east-1'
|
395
398
|
end
|
@@ -400,8 +403,8 @@ module AWS
|
|
400
403
|
:"#{ruby_name}_endpoint",
|
401
404
|
:"#{ruby_name}_port",
|
402
405
|
:"#{ruby_name}_region",
|
403
|
-
:credential_provider,
|
404
|
-
:http_handler,
|
406
|
+
:credential_provider,
|
407
|
+
:http_handler,
|
405
408
|
:http_read_timeout,
|
406
409
|
:log_formatter,
|
407
410
|
:log_level,
|
@@ -416,27 +419,27 @@ module AWS
|
|
416
419
|
:user_agent_prefix,
|
417
420
|
]
|
418
421
|
|
419
|
-
create_block = lambda do |config,client_options|
|
422
|
+
create_block = lambda do |config,client_options|
|
420
423
|
AWS.const_get(name)::Client.new(:config => config)
|
421
424
|
end
|
422
425
|
|
423
426
|
add_option_with_needs :"#{ruby_name}_client", needs, &create_block
|
424
427
|
|
425
428
|
end
|
426
|
-
|
429
|
+
|
427
430
|
end
|
428
431
|
|
429
432
|
add_option :access_key_id
|
430
|
-
|
433
|
+
|
431
434
|
add_option :secret_access_key
|
432
|
-
|
435
|
+
|
433
436
|
add_option :session_token
|
434
|
-
|
437
|
+
|
435
438
|
add_option_with_needs :credential_provider,
|
436
439
|
[:access_key_id, :secret_access_key, :session_token] do |cfg,static_creds|
|
437
440
|
|
438
441
|
CredentialProviders::DefaultProvider.new(static_creds)
|
439
|
-
|
442
|
+
|
440
443
|
end
|
441
444
|
|
442
445
|
add_option :http_open_timeout, 15
|
@@ -447,41 +450,41 @@ module AWS
|
|
447
450
|
|
448
451
|
add_option :http_wire_trace, false, :boolean => true
|
449
452
|
|
450
|
-
add_option_with_needs :http_handler,
|
453
|
+
add_option_with_needs :http_handler,
|
451
454
|
[
|
452
|
-
:http_open_timeout,
|
455
|
+
:http_open_timeout,
|
453
456
|
:http_idle_timeout,
|
454
|
-
:http_wire_trace,
|
455
|
-
:logger,
|
457
|
+
:http_wire_trace,
|
458
|
+
:logger,
|
456
459
|
] do |config,handler_options|
|
457
460
|
|
458
461
|
Http::NetHttpHandler.new(handler_options)
|
459
462
|
|
460
463
|
end
|
461
|
-
|
464
|
+
|
462
465
|
add_option :logger
|
463
466
|
|
464
467
|
add_option :log_level, :info
|
465
468
|
|
466
469
|
add_option :log_formatter, LogFormatter.default
|
467
|
-
|
470
|
+
|
468
471
|
add_option :max_retries, 3
|
469
|
-
|
472
|
+
|
470
473
|
add_option :proxy_uri do |config,uri| uri ? URI.parse(uri.to_s) : nil end
|
471
|
-
|
474
|
+
|
472
475
|
add_option :ssl_verify_peer, true, :boolean => true
|
473
|
-
|
474
|
-
add_option :ssl_ca_file,
|
476
|
+
|
477
|
+
add_option :ssl_ca_file,
|
475
478
|
File.expand_path(File.dirname(__FILE__) + "/../../../ca-bundle.crt")
|
476
479
|
|
477
480
|
add_option :ssl_ca_path
|
478
|
-
|
481
|
+
|
479
482
|
add_option :stub_requests, false, :boolean => true
|
480
|
-
|
483
|
+
|
481
484
|
add_option :use_ssl, true, :boolean => true
|
482
|
-
|
485
|
+
|
483
486
|
add_option :user_agent_prefix
|
484
|
-
|
487
|
+
|
485
488
|
end
|
486
489
|
end
|
487
490
|
end
|
@@ -16,7 +16,7 @@ require 'net/http/connection_pool'
|
|
16
16
|
module AWS
|
17
17
|
module Core
|
18
18
|
module Http
|
19
|
-
|
19
|
+
|
20
20
|
# = NetHttpHandler
|
21
21
|
#
|
22
22
|
# This is the default HTTP handler for the aws-sdk gem. It uses
|
@@ -32,9 +32,9 @@ module AWS
|
|
32
32
|
|
33
33
|
# @return [Net::HTTP::ConnectionPool]
|
34
34
|
attr_reader :pool
|
35
|
-
|
35
|
+
|
36
36
|
# Given a populated request object and an empty response object,
|
37
|
-
# this method will make the request and them populate the
|
37
|
+
# this method will make the request and them populate the
|
38
38
|
# response.
|
39
39
|
# @param [Request] request
|
40
40
|
# @param [Response] response
|
@@ -14,53 +14,44 @@
|
|
14
14
|
module AWS
|
15
15
|
module Core
|
16
16
|
module Http
|
17
|
-
|
17
|
+
|
18
18
|
# Base class for all service reqeusts. This class describes
|
19
19
|
# a basic HTTP request, but will not make one. It is consumed
|
20
20
|
# by a HTTP handler class that sends the actual request
|
21
21
|
# and parses the actual response.
|
22
22
|
class Request
|
23
|
-
|
23
|
+
|
24
24
|
# Returns a new empty http request object.
|
25
25
|
def initialize
|
26
|
-
@
|
26
|
+
@default_read_timeout = 60
|
27
27
|
@http_method = 'POST'
|
28
|
-
@
|
28
|
+
@use_ssl = true
|
29
29
|
@headers = CaseInsensitiveHash.new
|
30
|
+
@uri = '/'
|
30
31
|
@params = []
|
31
|
-
@use_ssl = true
|
32
|
-
@port = nil
|
33
|
-
@default_read_timeout = 60
|
34
32
|
end
|
35
33
|
|
36
34
|
# @return [Integer] The number of seconds the service has to respond
|
37
|
-
# before a timeout error is raised on the request. Defaults to
|
35
|
+
# before a timeout error is raised on the request. Defaults to
|
38
36
|
# 60 seconds.
|
39
37
|
attr_accessor :default_read_timeout
|
40
38
|
|
41
|
-
# @return [String]
|
42
|
-
# (e.g. 's3', 'iam', 'dynamo_db', etc).
|
43
|
-
attr_accessor :service_ruby_name
|
44
|
-
|
45
|
-
# @return [String] hostname of the request
|
39
|
+
# @return [String] Returns hostname of the request.
|
46
40
|
attr_accessor :host
|
47
|
-
|
48
|
-
# @return [
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
# @return [String] GET, PUT POST, HEAD or DELETE, defaults to POST
|
41
|
+
|
42
|
+
# @return [Integer] Returns the port number this request will be
|
43
|
+
# made via (usually 443 or 80).
|
44
|
+
attr_accessor :port
|
45
|
+
|
46
|
+
# @return [String] Returns the HTTP request method (e.g. 'GET', 'PUT',
|
47
|
+
# 'POST', 'HEAD' or 'DELETE'). Defaults to 'POST'.
|
56
48
|
attr_accessor :http_method
|
57
|
-
|
58
|
-
# @return [
|
59
|
-
attr_accessor :
|
60
|
-
|
61
|
-
# @return [
|
62
|
-
|
63
|
-
attr_accessor :proxy_uri
|
49
|
+
|
50
|
+
# @return [Hash] Returns a hash of header values.
|
51
|
+
attr_accessor :headers
|
52
|
+
|
53
|
+
# @return [String] Returns the request URI (path + querystring).
|
54
|
+
attr_accessor :uri
|
64
55
|
|
65
56
|
# @return [String] The region name this request is for. Only needs
|
66
57
|
# to be populated for requests against signature v4 endpoints.
|
@@ -70,77 +61,85 @@ module AWS
|
|
70
61
|
# @private
|
71
62
|
attr_accessor :access_key_id
|
72
63
|
|
73
|
-
# Some subclasses override this method to obseve requirements
|
74
|
-
# set by the services (e.q. SimpleWorlfow and SQS have special
|
75
|
-
# long-pulling requirements and require special read timeouts).
|
76
64
|
# @private
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
def use_ssl= state
|
83
|
-
@use_ssl = state
|
84
|
-
end
|
85
|
-
|
86
|
-
# @return [Boolean] If this request should be sent over ssl or not.
|
87
|
-
def use_ssl?
|
88
|
-
@use_ssl
|
89
|
-
end
|
65
|
+
# @return [Array<Param>] Returns an array of request params. Requests
|
66
|
+
# that use signature version 2 add params to the request and then
|
67
|
+
# sign those before building the {#body}. Normally the {#body}
|
68
|
+
# should be set directly with the HTTP payload.
|
69
|
+
attr_accessor :params
|
90
70
|
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
71
|
+
# @return [String] Returns the HTTP request payload (body).
|
72
|
+
attr_accessor :body
|
73
|
+
|
74
|
+
# @return [String] Returns the AWS access key ID used to authorize the
|
75
|
+
# request.
|
76
|
+
attr_accessor :access_key_id
|
77
|
+
|
78
|
+
# @return [String] The name of the service for Signature v4 signing.
|
79
|
+
# This does not always match the ruby name (e.g.
|
80
|
+
# simple_email_service and ses do not match).
|
81
|
+
attr_accessor :service_ruby_name
|
82
|
+
|
83
|
+
# @return [nil, URI] The URI to the proxy server requests are
|
84
|
+
# sent through if configured. Returns nil if there is no proxy.
|
85
|
+
attr_accessor :proxy_uri
|
86
|
+
|
87
|
+
# @return [Integer] The number of seconds the service has to respond
|
88
|
+
# before a timeout error is raised on the request. Defaults to
|
89
|
+
# 60 seconds.
|
90
|
+
attr_accessor :read_timeout
|
91
|
+
|
92
|
+
# @return [Boolean] Returns +true+ if this request should be made
|
93
|
+
# with SSL enabled.
|
94
|
+
attr_accessor :use_ssl
|
95
|
+
|
96
|
+
alias_method :use_ssl?, :use_ssl
|
97
|
+
|
98
|
+
# @return [Boolean] Returns +true+ if the client should verify
|
99
|
+
# the peer certificate.
|
100
|
+
attr_accessor :ssl_verify_peer
|
101
|
+
|
102
|
+
alias_method :ssl_verify_peer?, :ssl_verify_peer
|
103
|
+
|
104
|
+
# @return [String] Returns the path to a bundle of CA certs in PEM
|
105
|
+
# format; the HTTP handler should use this to verify all HTTPS
|
106
|
+
# requests if {#ssl_verify_peer?} is true.
|
107
|
+
attr_accessor :ssl_ca_file
|
108
|
+
|
109
|
+
# @return [String] Returns the path to a directory of CA certs.
|
110
|
+
# The HTTP handler should use these to verify all HTTPS
|
111
|
+
# requests if {#ssl_verify_peer?} is true.
|
112
|
+
attr_accessor :ssl_ca_path
|
97
113
|
|
98
114
|
# @return [Integer] Returns the port the request will be made over.
|
99
115
|
# Defaults to 443 for SSL requests and 80 for non-SSL requests.
|
100
116
|
def port
|
101
117
|
@port || (use_ssl? ? 443 : 80)
|
102
118
|
end
|
103
|
-
|
104
|
-
#
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
# @return [Boolean] If the client should verify the peer
|
111
|
-
# certificate or not.
|
112
|
-
def ssl_verify_peer?
|
113
|
-
@ssl_verify_peer
|
114
|
-
end
|
115
|
-
|
116
|
-
# @param [String] ca_file Path to a bundle of CA certs in PEM
|
117
|
-
# format; the HTTP handler should use this to verify all HTTPS
|
118
|
-
# requests if {#ssl_verify_peer?} is true.
|
119
|
-
def ssl_ca_file=(ca_file)
|
120
|
-
@ssl_ca_file = ca_file
|
119
|
+
|
120
|
+
# Some subclasses override this method to obseve requirements
|
121
|
+
# set by the services (e.q. SimpleWorlfow and SQS have special
|
122
|
+
# long-pulling requirements and require special read timeouts).
|
123
|
+
# @private
|
124
|
+
def read_timeout
|
125
|
+
default_read_timeout
|
121
126
|
end
|
122
|
-
|
123
|
-
# @return [String]
|
124
|
-
|
125
|
-
|
126
|
-
def ssl_ca_file
|
127
|
-
@ssl_ca_file
|
127
|
+
|
128
|
+
# @return [String,nil] Returns the request body (payload).
|
129
|
+
def body
|
130
|
+
@body || url_encoded_params
|
128
131
|
end
|
129
|
-
|
130
|
-
# @
|
131
|
-
|
132
|
-
|
133
|
-
def ssl_ca_path=(ca_path)
|
134
|
-
@ssl_ca_path = ca_path
|
132
|
+
|
133
|
+
# @return [String] Returns the HTTP request path.
|
134
|
+
def path
|
135
|
+
uri.split(/\?/)[0]
|
135
136
|
end
|
136
|
-
|
137
|
-
# @return [String]
|
138
|
-
|
139
|
-
|
140
|
-
def ssl_ca_path
|
141
|
-
@ssl_ca_path
|
137
|
+
|
138
|
+
# @return [String] Returns the HTTP request querystring.
|
139
|
+
def querystring
|
140
|
+
uri.split(/\?/)[1]
|
142
141
|
end
|
143
|
-
|
142
|
+
|
144
143
|
# Adds a request param.
|
145
144
|
#
|
146
145
|
# @overload add_param(param_name, param_value = nil)
|
@@ -152,6 +151,7 @@ module AWS
|
|
152
151
|
# Add a param (object)
|
153
152
|
# @param [Param] param_obj
|
154
153
|
#
|
154
|
+
# @private
|
155
155
|
def add_param name_or_param, value = nil
|
156
156
|
if name_or_param.kind_of?(Param)
|
157
157
|
@params << name_or_param
|
@@ -159,99 +159,68 @@ module AWS
|
|
159
159
|
@params << Param.new(name_or_param, value)
|
160
160
|
end
|
161
161
|
end
|
162
|
-
|
163
|
-
|
164
|
-
# @private
|
165
|
-
def get_param param_name
|
166
|
-
@params.detect{|p| p.name == param_name } ||
|
167
|
-
raise("undefined param #{param_name}")
|
168
|
-
end
|
169
|
-
|
162
|
+
|
170
163
|
# @private
|
171
|
-
|
172
|
-
|
173
|
-
param ? param.value : nil
|
174
|
-
end
|
175
|
-
|
176
|
-
# @return [String] the request uri
|
177
|
-
def uri
|
178
|
-
querystring ? "#{path}?#{querystring}" : path
|
179
|
-
end
|
180
|
-
|
181
|
-
# @return [String] Returns the request params url encoded, or nil if
|
182
|
-
# this request has no params.
|
164
|
+
# @return [String,nil] Returns the url encoded request params. If there
|
165
|
+
# are no params, then nil is returned.
|
183
166
|
def url_encoded_params
|
184
|
-
|
185
|
-
nil
|
186
|
-
else
|
187
|
-
@params.sort.collect{|p| p.encoded }.join('&')
|
188
|
-
end
|
167
|
+
params.empty? ? nil : params.sort.collect(&:encoded).join('&')
|
189
168
|
end
|
190
|
-
|
191
|
-
# @return [String, nil] Returns the requesty querystring.
|
192
|
-
def querystring
|
193
|
-
nil
|
194
|
-
end
|
195
|
-
|
196
|
-
# @return [String, nil] Returns the request body.
|
197
|
-
def body
|
198
|
-
url_encoded_params
|
199
|
-
end
|
200
|
-
|
169
|
+
|
201
170
|
# @private
|
202
171
|
class CaseInsensitiveHash < Hash
|
203
|
-
|
172
|
+
|
204
173
|
def []= key, value
|
205
174
|
super(key.to_s.downcase, value)
|
206
175
|
end
|
207
|
-
|
176
|
+
|
208
177
|
def [] key
|
209
178
|
super(key.to_s.downcase)
|
210
179
|
end
|
211
|
-
|
180
|
+
|
212
181
|
def has_key?(key)
|
213
182
|
super(key.to_s.downcase)
|
214
183
|
end
|
215
184
|
alias_method :key?, :has_key?
|
216
185
|
alias_method :include?, :has_key?
|
217
186
|
alias_method :member?, :has_key?
|
218
|
-
|
187
|
+
|
219
188
|
end
|
220
|
-
|
189
|
+
|
221
190
|
# Represents a single request paramater. Some services accept this
|
222
191
|
# in a form encoded body string, others as query parameters.
|
223
192
|
# It is up to each service's Request class to determine how to
|
224
193
|
# consume these params.
|
225
194
|
# @private
|
226
195
|
class Param
|
227
|
-
|
196
|
+
|
228
197
|
include UriEscape
|
229
|
-
|
198
|
+
|
230
199
|
attr_accessor :name, :value
|
231
|
-
|
200
|
+
|
232
201
|
def initialize name, value = nil
|
233
202
|
@name = name
|
234
203
|
@value = value
|
235
204
|
end
|
236
|
-
|
205
|
+
|
237
206
|
def <=> other
|
238
207
|
name <=> other.name
|
239
208
|
end
|
240
|
-
|
209
|
+
|
241
210
|
def to_s
|
242
211
|
value ? "#{name}=#{value}" : name
|
243
212
|
end
|
244
|
-
|
213
|
+
|
245
214
|
def ==(other)
|
246
215
|
other.kind_of?(Param) and to_s == other.to_s
|
247
216
|
end
|
248
|
-
|
217
|
+
|
249
218
|
def encoded
|
250
219
|
value ? "#{escape(name)}=#{escape(value)}" : escape(name)
|
251
220
|
end
|
252
|
-
|
221
|
+
|
253
222
|
end
|
254
|
-
|
223
|
+
|
255
224
|
end
|
256
225
|
end
|
257
226
|
end
|