aws-sdk 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +772 -544
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +284 -185
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +458 -738
- data/lib/aws/api_config/EC2-2011-12-15.yml +3502 -2653
- data/lib/aws/api_config/ELB-2011-08-15.yml +484 -352
- data/lib/aws/api_config/IAM-2010-05-08.yml +899 -711
- data/lib/aws/api_config/SNS-2010-03-31.yml +235 -167
- data/lib/aws/api_config/SQS-2011-10-01.yml +290 -251
- data/lib/aws/api_config/STS-2011-06-15.yml +35 -41
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +290 -263
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +144 -130
- data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +697 -1139
- data/lib/aws/auto_scaling/activity_collection.rb +1 -1
- data/lib/aws/auto_scaling/client.rb +724 -9
- data/lib/aws/auto_scaling/errors.rb +1 -5
- data/lib/aws/auto_scaling/group.rb +1 -1
- data/lib/aws/auto_scaling/group_collection.rb +1 -1
- data/lib/aws/auto_scaling/instance_collection.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/request.rb +1 -2
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +1 -1
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +3 -3
- data/lib/aws/auto_scaling/tag_collection.rb +1 -1
- data/lib/aws/cloud_formation.rb +1 -18
- data/lib/aws/cloud_formation/client.rb +314 -8
- data/lib/aws/cloud_formation/errors.rb +1 -5
- data/lib/aws/cloud_formation/request.rb +1 -2
- data/lib/aws/cloud_formation/stack.rb +4 -3
- data/lib/aws/cloud_formation/stack_collection.rb +2 -2
- data/lib/aws/cloud_formation/stack_resource_collection.rb +1 -1
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +2 -2
- data/lib/aws/cloud_formation/stack_summary_collection.rb +1 -1
- data/lib/aws/core.rb +29 -14
- data/lib/aws/core/async_handle.rb +11 -12
- data/lib/aws/core/client.rb +112 -102
- data/lib/aws/core/client/query_json.rb +110 -0
- data/lib/aws/core/client/query_xml.rb +122 -0
- data/lib/aws/core/data.rb +242 -0
- data/lib/aws/core/http/request.rb +7 -4
- data/lib/aws/core/lazy_error_classes.rb +60 -38
- data/lib/aws/core/option_grammar.rb +1 -0
- data/lib/aws/core/policy.rb +2 -1
- data/lib/aws/core/resource.rb +38 -33
- data/lib/aws/core/response.rb +109 -44
- data/lib/aws/core/signature/version_2.rb +42 -0
- data/lib/aws/core/signature/version_3.rb +73 -0
- data/lib/aws/core/signature/version_3_http.rb +72 -0
- data/lib/aws/core/signature/version_4.rb +138 -0
- data/lib/aws/core/uri_escape.rb +6 -9
- data/lib/aws/core/xml/frame.rb +242 -0
- data/lib/aws/core/xml/frame_stack.rb +85 -0
- data/lib/aws/core/xml/grammar.rb +299 -0
- data/lib/aws/core/xml/parser.rb +70 -0
- data/lib/aws/core/xml/root_frame.rb +65 -0
- data/lib/aws/core/{configured_xml_grammars.rb → xml/sax_handlers/libxml.rb} +22 -20
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +55 -0
- data/lib/aws/core/{authorize_with_session_token.rb → xml/sax_handlers/ox.rb} +19 -7
- data/lib/aws/core/{configured_option_grammars.rb → xml/sax_handlers/rexml.rb} +22 -23
- data/lib/aws/core/xml/stub.rb +123 -0
- data/lib/aws/dynamo_db/batch_get.rb +1 -1
- data/lib/aws/dynamo_db/client.rb +796 -14
- data/lib/aws/dynamo_db/errors.rb +1 -38
- data/lib/aws/dynamo_db/item_collection.rb +29 -28
- data/lib/aws/dynamo_db/request.rb +3 -53
- data/lib/aws/dynamo_db/table.rb +6 -2
- data/lib/aws/ec2/attachment.rb +1 -1
- data/lib/aws/ec2/client.rb +3954 -9
- data/lib/aws/ec2/dhcp_options.rb +3 -3
- data/lib/aws/ec2/errors.rb +10 -4
- data/lib/aws/ec2/instance.rb +7 -6
- data/lib/aws/ec2/instance_collection.rb +2 -2
- data/lib/aws/ec2/key_pair_collection.rb +3 -3
- data/lib/aws/ec2/network_acl.rb +4 -2
- data/lib/aws/ec2/network_acl/entry.rb +10 -10
- data/lib/aws/ec2/network_interface.rb +2 -3
- data/lib/aws/ec2/network_interface/attachment.rb +8 -8
- data/lib/aws/ec2/permission_collection.rb +3 -3
- data/lib/aws/ec2/request.rb +1 -3
- data/lib/aws/ec2/resource_tag_collection.rb +4 -8
- data/lib/aws/ec2/route_table.rb +3 -2
- data/lib/aws/ec2/route_table/route.rb +7 -7
- data/lib/aws/ec2/security_group.rb +2 -2
- data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +16 -5
- data/lib/aws/ec2/security_group/ingress_ip_permission_collection.rb +4 -3
- data/lib/aws/ec2/security_group/ip_permission.rb +1 -2
- data/lib/aws/ec2/snapshot_collection.rb +6 -3
- data/lib/aws/ec2/subnet.rb +1 -1
- data/lib/aws/ec2/volume.rb +1 -3
- data/lib/aws/ec2/volume_collection.rb +2 -0
- data/lib/aws/elb/availability_zone_collection.rb +2 -2
- data/lib/aws/elb/backend_server_policy_collection.rb +1 -1
- data/lib/aws/elb/client.rb +513 -9
- data/lib/aws/elb/errors.rb +2 -6
- data/lib/aws/elb/instance_collection.rb +2 -2
- data/lib/aws/elb/request.rb +1 -1
- data/lib/aws/errors.rb +61 -74
- data/lib/aws/iam.rb +2 -3
- data/lib/aws/iam/client.rb +1178 -10
- data/lib/aws/iam/collection.rb +2 -1
- data/lib/aws/iam/errors.rb +1 -6
- data/lib/aws/iam/group.rb +8 -9
- data/lib/aws/iam/request.rb +1 -1
- data/lib/aws/iam/server_certificate_collection.rb +8 -5
- data/lib/aws/iam/signing_certificate.rb +1 -1
- data/lib/aws/iam/user.rb +2 -2
- data/lib/aws/iam/user_policy.rb +3 -2
- data/lib/aws/rails.rb +1 -2
- data/lib/aws/record.rb +3 -3
- data/lib/aws/record/abstract_base.rb +0 -3
- data/lib/aws/record/attributes.rb +7 -7
- data/lib/aws/record/model.rb +19 -19
- data/lib/aws/record/model/finder_methods.rb +7 -7
- data/lib/aws/s3/bucket.rb +7 -2
- data/lib/aws/s3/client.rb +391 -398
- data/lib/aws/s3/client/xml.rb +44 -71
- data/lib/aws/s3/data_options.rb +3 -2
- data/lib/aws/s3/errors.rb +8 -11
- data/lib/aws/s3/multipart_upload_collection.rb +1 -3
- data/lib/aws/s3/object_collection.rb +2 -1
- data/lib/aws/s3/object_metadata.rb +2 -2
- data/lib/aws/s3/paginated_collection.rb +2 -2
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +1 -1
- data/lib/aws/s3/presigned_post.rb +18 -17
- data/lib/aws/s3/request.rb +4 -3
- data/lib/aws/s3/s3_object.rb +8 -10
- data/lib/aws/simple_db/attribute.rb +2 -2
- data/lib/aws/simple_db/attribute_collection.rb +14 -4
- data/lib/aws/simple_db/client.rb +313 -14
- data/lib/aws/simple_db/domain.rb +1 -1
- data/lib/aws/simple_db/domain_collection.rb +4 -4
- data/lib/aws/simple_db/domain_metadata.rb +1 -1
- data/lib/aws/simple_db/errors.rb +14 -2
- data/lib/aws/simple_db/expect_condition_option.rb +1 -1
- data/lib/aws/simple_db/item.rb +1 -1
- data/lib/aws/simple_db/item_collection.rb +9 -9
- data/lib/aws/simple_db/item_data.rb +9 -6
- data/lib/aws/simple_db/request.rb +1 -1
- data/lib/aws/simple_email_service.rb +8 -7
- data/lib/aws/simple_email_service/client.rb +174 -9
- data/lib/aws/simple_email_service/email_address_collection.rb +0 -1
- data/lib/aws/simple_email_service/errors.rb +1 -5
- data/lib/aws/simple_email_service/quotas.rb +8 -6
- data/lib/aws/simple_email_service/request.rb +7 -1
- data/lib/aws/simple_workflow/client.rb +1383 -6
- data/lib/aws/simple_workflow/decision_task.rb +1 -3
- data/lib/aws/simple_workflow/errors.rb +1 -38
- data/lib/aws/simple_workflow/history_event_collection.rb +2 -2
- data/lib/aws/simple_workflow/request.rb +5 -49
- data/lib/aws/simple_workflow/type.rb +1 -1
- data/lib/aws/simple_workflow/type_collection.rb +4 -3
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +2 -2
- data/lib/aws/sns/client.rb +345 -9
- data/lib/aws/sns/errors.rb +1 -5
- data/lib/aws/sns/request.rb +1 -2
- data/lib/aws/sns/subscription_collection.rb +2 -2
- data/lib/aws/sns/topic.rb +15 -14
- data/lib/aws/sns/topic_collection.rb +1 -1
- data/lib/aws/sqs/client.rb +334 -9
- data/lib/aws/sqs/errors.rb +1 -6
- data/lib/aws/sqs/queue.rb +20 -21
- data/lib/aws/sqs/queue_collection.rb +3 -3
- data/lib/aws/sqs/request.rb +2 -2
- data/lib/aws/sts.rb +8 -10
- data/lib/aws/sts/client.rb +67 -10
- data/lib/aws/sts/errors.rb +1 -5
- data/lib/aws/sts/request.rb +1 -1
- data/lib/user.rb +49 -0
- metadata +21 -28
- data/lib/aws/auto_scaling/client/xml.rb +0 -32
- data/lib/aws/cloud_formation/client/xml.rb +0 -32
- data/lib/aws/core/api_config.rb +0 -44
- data/lib/aws/core/authorize_v2.rb +0 -39
- data/lib/aws/core/authorize_v3.rb +0 -38
- data/lib/aws/core/authorize_v4.rb +0 -149
- data/lib/aws/core/configured_client_methods.rb +0 -76
- data/lib/aws/core/configured_grammars.rb +0 -63
- data/lib/aws/core/configured_json_client_methods.rb +0 -74
- data/lib/aws/core/ignore_result_element.rb +0 -34
- data/lib/aws/core/json_client.rb +0 -41
- data/lib/aws/core/xml_grammar.rb +0 -957
- data/lib/aws/ec2/client/xml.rb +0 -175
- data/lib/aws/elb/client/xml.rb +0 -33
- data/lib/aws/elb/listener_spec.rb +0 -14
- data/lib/aws/iam/client/xml.rb +0 -34
- data/lib/aws/simple_db/client/options.rb +0 -32
- data/lib/aws/simple_db/client/xml.rb +0 -63
- data/lib/aws/simple_email_service/client/xml.rb +0 -34
- data/lib/aws/sns/client/xml.rb +0 -34
- data/lib/aws/sqs/client/xml.rb +0 -33
- data/lib/aws/sts/client/xml.rb +0 -34
@@ -99,7 +99,7 @@ module AWS
|
|
99
99
|
describe_attribute :parameters do
|
100
100
|
translates_output do |params|
|
101
101
|
params.inject({}) do |hash,param|
|
102
|
-
hash.merge(param
|
102
|
+
hash.merge(param[:parameter_key] => param[:parameter_value])
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -112,7 +112,7 @@ module AWS
|
|
112
112
|
|
113
113
|
provider(:describe_stacks) do |provider|
|
114
114
|
provider.find do |resp|
|
115
|
-
resp.stacks.find{|stack| stack
|
115
|
+
resp.data[:stacks].find{|stack| stack[:stack_name] == name }
|
116
116
|
end
|
117
117
|
provider.provides *describe_attributes.keys
|
118
118
|
end
|
@@ -127,7 +127,8 @@ module AWS
|
|
127
127
|
# @return [Array<StackOutput>]
|
128
128
|
def outputs
|
129
129
|
output_details.collect do |o|
|
130
|
-
|
130
|
+
key, value, desc = o.values_at(:output_key, :output_value, :description)
|
131
|
+
StackOutput.new(self, key, value, desc)
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
@@ -188,12 +188,12 @@ module AWS
|
|
188
188
|
protected
|
189
189
|
|
190
190
|
def _each_item options = {}
|
191
|
-
client.describe_stacks.stacks.each do |summary|
|
191
|
+
client.describe_stacks.data[:stacks].each do |summary|
|
192
192
|
|
193
193
|
stack = Stack.new_from(
|
194
194
|
:describe_stacks,
|
195
195
|
summary,
|
196
|
-
summary
|
196
|
+
summary[:stack_name],
|
197
197
|
:config => config)
|
198
198
|
|
199
199
|
yield(stack)
|
@@ -23,7 +23,7 @@ module AWS
|
|
23
23
|
# = Other Ways to Get Resource Details
|
24
24
|
#
|
25
25
|
# If you want to get a {StackResource} by its physical resource
|
26
|
-
# id, then you should use {CloudFormation#
|
26
|
+
# id, then you should use {CloudFormation#stack_resource}.
|
27
27
|
#
|
28
28
|
# You can also take a look at {Stack#resource_summaries} for
|
29
29
|
# light-weight hashes of stack resource details.
|
@@ -38,7 +38,7 @@ module AWS
|
|
38
38
|
include Core::Collection::Simple
|
39
39
|
|
40
40
|
# @param [Stack] stack
|
41
|
-
# @param [Hash
|
41
|
+
# @param [Hash] options
|
42
42
|
def initialize stack, options = {}
|
43
43
|
@stack = stack
|
44
44
|
super
|
@@ -62,7 +62,7 @@ module AWS
|
|
62
62
|
yield(summary.to_hash)
|
63
63
|
end
|
64
64
|
|
65
|
-
next_token = resp.
|
65
|
+
next_token = resp.data[:next_token]
|
66
66
|
|
67
67
|
end while next_token
|
68
68
|
end
|
data/lib/aws/core.rb
CHANGED
@@ -61,7 +61,7 @@ require 'aws/core/autoloader'
|
|
61
61
|
module AWS
|
62
62
|
|
63
63
|
# Current version of the AWS SDK for Ruby
|
64
|
-
VERSION = "1.
|
64
|
+
VERSION = "1.5.0"
|
65
65
|
|
66
66
|
register_autoloads(self) do
|
67
67
|
autoload :Errors, 'errors'
|
@@ -70,26 +70,15 @@ module AWS
|
|
70
70
|
module Core
|
71
71
|
|
72
72
|
AWS.register_autoloads(self) do
|
73
|
-
autoload :ApiConfig, 'api_config'
|
74
73
|
autoload :AsyncHandle, 'async_handle'
|
75
|
-
autoload :AuthorizeV2, 'authorize_v2'
|
76
|
-
autoload :AuthorizeV3, 'authorize_v3'
|
77
|
-
autoload :AuthorizeV4, 'authorize_v4'
|
78
|
-
autoload :AuthorizeWithSessionToken, 'authorize_with_session_token'
|
79
74
|
autoload :Cacheable, 'cacheable'
|
80
75
|
autoload :Client, 'client'
|
81
76
|
autoload :Collection, 'collection'
|
82
77
|
autoload :Configuration, 'configuration'
|
83
|
-
autoload :
|
84
|
-
autoload :ConfiguredGrammars, 'configured_grammars'
|
85
|
-
autoload :ConfiguredJsonClientMethods, 'configured_json_client_methods'
|
86
|
-
autoload :ConfiguredOptionGrammars, 'configured_option_grammars'
|
87
|
-
autoload :ConfiguredXmlGrammars, 'configured_xml_grammars'
|
78
|
+
autoload :Data, 'data'
|
88
79
|
autoload :DefaultSigner, 'default_signer'
|
89
|
-
autoload :IgnoreResultElement, 'ignore_result_element'
|
90
80
|
autoload :IndifferentHash, 'indifferent_hash'
|
91
81
|
autoload :Inflection, 'inflection'
|
92
|
-
autoload :JsonClient, 'json_client'
|
93
82
|
autoload :LazyErrorClasses, 'lazy_error_classes'
|
94
83
|
autoload :LogFormatter, 'log_formatter'
|
95
84
|
autoload :MetaUtils, 'meta_utils'
|
@@ -105,7 +94,33 @@ module AWS
|
|
105
94
|
autoload :ServiceInterface, 'service_interface'
|
106
95
|
autoload :SessionSigner, 'session_signer'
|
107
96
|
autoload :UriEscape, 'uri_escape'
|
108
|
-
|
97
|
+
end
|
98
|
+
|
99
|
+
module Signature
|
100
|
+
AWS.register_autoloads(self) do
|
101
|
+
autoload :Version2, 'version_2'
|
102
|
+
autoload :Version3, 'version_3'
|
103
|
+
autoload :Version4, 'version_4'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
module XML
|
108
|
+
AWS.register_autoloads(self) do
|
109
|
+
autoload :Parser, 'parser'
|
110
|
+
autoload :Grammar, 'grammar'
|
111
|
+
autoload :Stub, 'stub'
|
112
|
+
autoload :Frame, 'frame'
|
113
|
+
autoload :RootFrame, 'root_frame'
|
114
|
+
autoload :FrameStack, 'frame_stack'
|
115
|
+
end
|
116
|
+
|
117
|
+
module SaxHandlers
|
118
|
+
AWS.register_autoloads(self, 'aws/core/xml/sax_handlers') do
|
119
|
+
autoload :Nokogiri, 'nokogiri'
|
120
|
+
autoload :REXML, 'rexml'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
109
124
|
end
|
110
125
|
|
111
126
|
module Http
|
@@ -16,7 +16,6 @@ module AWS
|
|
16
16
|
|
17
17
|
# Mixin that provides a generic callback facility for asynchronous
|
18
18
|
# tasks that can either succeed or fail.
|
19
|
-
# @private
|
20
19
|
module AsyncHandle
|
21
20
|
|
22
21
|
# Called to signal success and fire off the success and complete callbacks.
|
@@ -36,11 +35,11 @@ module AWS
|
|
36
35
|
#
|
37
36
|
# If this is called when the task has already completed
|
38
37
|
# successfully, it will call the callback immediately.
|
39
|
-
def on_success(&
|
38
|
+
def on_success(&block)
|
40
39
|
if @_async_status == :success
|
41
|
-
|
40
|
+
block.call
|
42
41
|
else
|
43
|
-
(@_async_callbacks ||= []) << { :success =>
|
42
|
+
(@_async_callbacks ||= []) << { :success => block }
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -50,11 +49,11 @@ module AWS
|
|
50
49
|
#
|
51
50
|
# If this is called when the task has already failed, it will
|
52
51
|
# call the callback immediately.
|
53
|
-
def on_failure(&
|
52
|
+
def on_failure(&block)
|
54
53
|
if @_async_status == :failure
|
55
|
-
|
54
|
+
block.call
|
56
55
|
else
|
57
|
-
(@_async_callbacks ||= []) << { :failure =>
|
56
|
+
(@_async_callbacks ||= []) << { :failure => block }
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
@@ -67,13 +66,13 @@ module AWS
|
|
67
66
|
#
|
68
67
|
# If this is called when the task has already completed, it will
|
69
68
|
# call the callback immediately.
|
70
|
-
def on_complete(&
|
69
|
+
def on_complete(&block)
|
71
70
|
if !@_async_status.nil?
|
72
|
-
|
71
|
+
block.call(@_async_status)
|
73
72
|
else
|
74
73
|
(@_async_callbacks ||= []) << {
|
75
|
-
:failure => lambda {
|
76
|
-
:success => lambda {
|
74
|
+
:failure => lambda { block.call(:failure) },
|
75
|
+
:success => lambda { block.call(:success) }
|
77
76
|
}
|
78
77
|
end
|
79
78
|
end
|
@@ -83,7 +82,7 @@ module AWS
|
|
83
82
|
@_async_status = kind
|
84
83
|
@_async_callbacks.map do |cb|
|
85
84
|
cb[kind]
|
86
|
-
end.compact.each {
|
85
|
+
end.compact.each {|block| block.call } if @_async_callbacks
|
87
86
|
end
|
88
87
|
|
89
88
|
end
|
data/lib/aws/core/client.rb
CHANGED
@@ -12,17 +12,19 @@
|
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
14
|
require 'set'
|
15
|
+
require 'aws/core/client/query_xml'
|
16
|
+
require 'aws/core/client/query_json'
|
15
17
|
|
16
18
|
module AWS
|
17
19
|
module Core
|
18
20
|
|
19
|
-
# Base class for all of the Amazon AWS service clients.
|
20
|
-
# @private
|
21
|
+
# Base client class for all of the Amazon AWS service clients.
|
21
22
|
class Client
|
22
23
|
|
23
24
|
extend Naming
|
24
25
|
|
25
|
-
|
26
|
+
# @private
|
27
|
+
CACHEABLE_REQUESTS = Set[]
|
26
28
|
|
27
29
|
# Creates a new low-level client.
|
28
30
|
#
|
@@ -82,18 +84,27 @@ module AWS
|
|
82
84
|
# @return [DefaultSigner,Object] Returns the signer for this client.
|
83
85
|
# This is normally a DefaultSigner, but it can be configured to
|
84
86
|
# an other object.
|
87
|
+
# @private
|
85
88
|
attr_reader :signer
|
86
89
|
|
87
90
|
# @return [String] The snake-cased ruby name for the service
|
88
91
|
# (e.g. 's3', 'iam', 'dynamo_db', etc).
|
92
|
+
# @private
|
89
93
|
attr_reader :service_ruby_name
|
90
94
|
|
91
95
|
# @return [Integer] What port this client makes requests via.
|
96
|
+
# @private
|
92
97
|
attr_reader :port
|
93
98
|
|
94
99
|
# @return [String] Returns the service endpoint (hostname) this client
|
95
100
|
# makes requests against.
|
101
|
+
# @private
|
96
102
|
attr_reader :endpoint
|
103
|
+
|
104
|
+
# @return (see Client.operations)
|
105
|
+
def operations
|
106
|
+
self.class.operations
|
107
|
+
end
|
97
108
|
|
98
109
|
# Returns a copy of the client with a different HTTP handler.
|
99
110
|
# You can pass an object like BuiltinHttpHandler or you can
|
@@ -126,7 +137,7 @@ module AWS
|
|
126
137
|
with_config(config.with(options))
|
127
138
|
end
|
128
139
|
|
129
|
-
# @param [Configuration] The configuration object to use.
|
140
|
+
# @param [Configuration] config The configuration object to use.
|
130
141
|
# @return [Core::Client] Returns a new client object with the given
|
131
142
|
# configuration.
|
132
143
|
def with_config config
|
@@ -155,21 +166,15 @@ module AWS
|
|
155
166
|
end
|
156
167
|
|
157
168
|
protected
|
169
|
+
|
158
170
|
def new_request
|
159
|
-
|
160
|
-
req.http_method = 'POST'
|
161
|
-
req.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
|
162
|
-
req.add_param 'Timestamp', Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
163
|
-
req.add_param 'Version', self.class::API_VERSION
|
164
|
-
req
|
171
|
+
eval(self.class.name.sub(/::Client$/, ''))::Request.new
|
165
172
|
end
|
166
173
|
|
167
|
-
protected
|
168
174
|
def new_response(*args, &block)
|
169
175
|
Response.new(*args, &block)
|
170
176
|
end
|
171
177
|
|
172
|
-
private
|
173
178
|
def make_async_request response
|
174
179
|
|
175
180
|
pauses = async_request_with_retries(response, response.http_request)
|
@@ -178,7 +183,6 @@ module AWS
|
|
178
183
|
|
179
184
|
end
|
180
185
|
|
181
|
-
private
|
182
186
|
def async_request_with_retries response, http_request, retry_delays = nil
|
183
187
|
|
184
188
|
response.http_response = Http::Response.new
|
@@ -210,7 +214,6 @@ module AWS
|
|
210
214
|
|
211
215
|
end
|
212
216
|
|
213
|
-
private
|
214
217
|
def make_sync_request response
|
215
218
|
retry_server_errors do
|
216
219
|
|
@@ -218,8 +221,6 @@ module AWS
|
|
218
221
|
Http::Response.new
|
219
222
|
|
220
223
|
@http_handler.handle(response.http_request, http_response)
|
221
|
-
|
222
|
-
populate_error(response)
|
223
224
|
|
224
225
|
populate_error(response)
|
225
226
|
response.signal_success unless response.error
|
@@ -228,7 +229,6 @@ module AWS
|
|
228
229
|
end
|
229
230
|
end
|
230
231
|
|
231
|
-
private
|
232
232
|
def retry_server_errors &block
|
233
233
|
|
234
234
|
response = yield
|
@@ -246,31 +246,26 @@ module AWS
|
|
246
246
|
|
247
247
|
end
|
248
248
|
|
249
|
-
private
|
250
249
|
def rebuild_http_request response
|
251
250
|
response.rebuild_request
|
252
251
|
response.retry_count += 1
|
253
252
|
end
|
254
253
|
|
255
|
-
private
|
256
254
|
def sleep_durations response
|
257
255
|
factor = scaling_factor(response)
|
258
256
|
Array.new(config.max_retries) {|n| (2 ** n) * factor }
|
259
257
|
end
|
260
258
|
|
261
|
-
private
|
262
259
|
def scaling_factor response
|
263
260
|
response.throttled? ? (0.5 + Kernel.rand * 0.1) : 0.3
|
264
261
|
end
|
265
262
|
|
266
|
-
private
|
267
263
|
def should_retry? response
|
268
264
|
response.timeout? or
|
269
265
|
response.throttled? or
|
270
266
|
response.error.kind_of?(Errors::ServerError)
|
271
267
|
end
|
272
268
|
|
273
|
-
private
|
274
269
|
def return_or_raise options, &block
|
275
270
|
response = yield
|
276
271
|
unless options[:async]
|
@@ -279,85 +274,99 @@ module AWS
|
|
279
274
|
response
|
280
275
|
end
|
281
276
|
|
282
|
-
|
283
|
-
|
277
|
+
# Yields to the given block (which should be making a
|
278
|
+
# request and returning a {Response} object). The results of the
|
279
|
+
# request/response are logged.
|
280
|
+
#
|
281
|
+
# @param [Hash] options
|
282
|
+
# @option options [Boolean] :async
|
283
|
+
# @return [Response]
|
284
|
+
def log_client_request options, &block
|
284
285
|
|
285
286
|
# time the request, retries and all
|
286
287
|
start = Time.now
|
287
288
|
response = yield
|
288
289
|
response.duration = Time.now - start
|
289
290
|
|
290
|
-
if
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
log_response(response)
|
295
|
-
end
|
291
|
+
if options[:async]
|
292
|
+
response.on_complete { log_response(response) }
|
293
|
+
else
|
294
|
+
log_response(response)
|
296
295
|
end
|
297
296
|
|
298
297
|
response
|
299
298
|
|
300
299
|
end
|
301
300
|
|
301
|
+
# Logs the response to the configured logger.
|
302
|
+
# @param [Resposne] response
|
303
|
+
# @return [nil]
|
302
304
|
def log_response response
|
303
|
-
|
304
|
-
|
305
|
+
if config.logger
|
306
|
+
message = config.log_formatter.format(response)
|
307
|
+
config.logger.send(config.log_level, message)
|
308
|
+
end
|
309
|
+
nil
|
305
310
|
end
|
306
311
|
|
307
|
-
protected
|
308
312
|
def populate_error response
|
309
|
-
|
310
|
-
|
311
|
-
|
313
|
+
response.error = extract_error(response)
|
314
|
+
end
|
315
|
+
|
316
|
+
# If the response contains error, this method will construct
|
317
|
+
# and return an error object. If no error is contained in the
|
318
|
+
# response, then nil is returned.
|
319
|
+
# @param [Response] response
|
320
|
+
# @return [Errors::Base,nil]
|
321
|
+
def extract_error response
|
322
|
+
|
312
323
|
status = response.http_response.status
|
313
|
-
|
314
|
-
|
324
|
+
|
325
|
+
error_code, error_message = extract_error_details(response)
|
326
|
+
|
327
|
+
error_args = [
|
328
|
+
response.http_request,
|
329
|
+
response.http_response,
|
330
|
+
error_code,
|
331
|
+
error_message
|
332
|
+
]
|
315
333
|
|
316
334
|
case
|
317
|
-
when response.timeout?
|
318
|
-
|
319
|
-
|
320
|
-
when
|
321
|
-
|
322
|
-
service_module::Errors.error_class(code).new(response.http_request,
|
323
|
-
response.http_response)
|
324
|
-
when status >= 500
|
325
|
-
response.error =
|
326
|
-
Errors::ServerError.new(response.http_request, response.http_response)
|
327
|
-
|
328
|
-
when status >= 300
|
329
|
-
response.error =
|
330
|
-
Errors::ClientError.new(response.http_request, response.http_response)
|
331
|
-
end
|
332
|
-
|
333
|
-
end
|
334
|
-
|
335
|
-
protected
|
336
|
-
def extract_error_code response
|
337
|
-
if response.http_response.status >= 300 and
|
338
|
-
body = response.http_response.body and
|
339
|
-
parse = xml_error_grammar.parse(body) and
|
340
|
-
parse.respond_to?(:code)
|
341
|
-
parse.code
|
335
|
+
when response.timeout? then TimeoutError.new
|
336
|
+
when error_code then error_class(error_code).new(*error_args)
|
337
|
+
when status >= 500 then Errors::ServerError.new(*error_args)
|
338
|
+
when status >= 300 then Errors::ClientError.new(*error_args)
|
339
|
+
else nil # no error
|
342
340
|
end
|
341
|
+
|
343
342
|
end
|
344
343
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
344
|
+
# Given an error code string, this method will return an error class.
|
345
|
+
#
|
346
|
+
# AWS::EC2::Client.new.send(:error_code, 'InvalidInstanceId')
|
347
|
+
# #=> AWS::EC2::Errors::InvalidInstanceId
|
348
|
+
#
|
349
|
+
# @param [String] error_code The error code string as returned by
|
350
|
+
# the service. If this class contains periods, they will be
|
351
|
+
# converted into namespaces (e.g. 'Foo.Bar' becomes Errors::Foo::Bar).
|
352
|
+
#
|
353
|
+
# @return [Class]
|
354
|
+
#
|
355
|
+
def error_class error_code
|
356
|
+
errors_module.error_class(error_code)
|
353
357
|
end
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
+
|
359
|
+
# Returns the ::Errors module for the current client.
|
360
|
+
#
|
361
|
+
# AWS::S3::Client.new.errors_module
|
362
|
+
# #=> AWS::S3::Errors
|
363
|
+
#
|
364
|
+
# @return [Module]
|
365
|
+
#
|
366
|
+
def errors_module
|
367
|
+
AWS.const_get(self.class.to_s[/(\w+)::Client/, 1])::Errors
|
358
368
|
end
|
359
369
|
|
360
|
-
private
|
361
370
|
def client_request name, options, &block
|
362
371
|
return_or_raise(options) do
|
363
372
|
log_client_request(options) do
|
@@ -407,13 +416,12 @@ module AWS
|
|
407
416
|
end
|
408
417
|
end
|
409
418
|
|
410
|
-
private
|
411
419
|
def cacheable_request? name, options
|
412
420
|
self.class::CACHEABLE_REQUESTS.include?(name)
|
413
421
|
end
|
414
422
|
|
415
|
-
private
|
416
423
|
def build_request(name, options, &block)
|
424
|
+
|
417
425
|
# we dont want to pass the async option to the configure block
|
418
426
|
opts = options.dup
|
419
427
|
opts.delete(:async)
|
@@ -432,12 +440,14 @@ module AWS
|
|
432
440
|
http_request.ssl_ca_path = config.ssl_ca_path if config.ssl_ca_path
|
433
441
|
|
434
442
|
send("configure_#{name}_request", http_request, opts, &block)
|
443
|
+
|
435
444
|
http_request.headers["user-agent"] = user_agent_string
|
436
445
|
http_request.add_authorization!(signer)
|
446
|
+
|
437
447
|
http_request
|
448
|
+
|
438
449
|
end
|
439
450
|
|
440
|
-
private
|
441
451
|
def user_agent_string
|
442
452
|
engine = (RUBY_ENGINE rescue nil or "ruby")
|
443
453
|
user_agent = "%s aws-sdk-ruby/#{VERSION} %s/%s %s" %
|
@@ -449,24 +459,18 @@ module AWS
|
|
449
459
|
user_agent
|
450
460
|
end
|
451
461
|
|
452
|
-
|
462
|
+
# Adds a single method to the current client class. This method
|
463
|
+
# yields a request method builder that allows you to specify how:
|
464
|
+
#
|
465
|
+
# * the request is built
|
466
|
+
# * the response is processed
|
467
|
+
# * the response is stubbed for testing
|
468
|
+
#
|
453
469
|
def self.add_client_request_method method_name, options = {}, &block
|
470
|
+
|
471
|
+
self.operations << method_name
|
454
472
|
|
455
|
-
|
456
|
-
|
457
|
-
if xml_grammar = options[:xml_grammar]
|
458
|
-
|
459
|
-
method.process_response do |resp|
|
460
|
-
xml_grammar.parse(resp.http_response.body, :context => resp)
|
461
|
-
super(resp)
|
462
|
-
end
|
463
|
-
|
464
|
-
method.simulate_response do |resp|
|
465
|
-
xml_grammar.simulate(resp)
|
466
|
-
super(resp)
|
467
|
-
end
|
468
|
-
|
469
|
-
end
|
473
|
+
ClientRequestMethodBuilder.new(self, method_name, &block)
|
470
474
|
|
471
475
|
module_eval <<-END
|
472
476
|
def #{method_name}(*args, &block)
|
@@ -476,13 +480,19 @@ module AWS
|
|
476
480
|
END
|
477
481
|
|
478
482
|
end
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
483
|
+
|
484
|
+
# Parses the service's API configuration yaml file. This file has
|
485
|
+
# configuration that drives the request and response DSLs.
|
486
|
+
# @return [Hash]
|
487
|
+
def self.api_config
|
488
|
+
path = "lib/aws/api_config/#{service_name}-#{self::API_VERSION}.yml"
|
489
|
+
YAML.load(File.read(path))
|
490
|
+
end
|
491
|
+
|
492
|
+
# @return [Array<Symbol>] Returns a list of service operations as
|
493
|
+
# method names supported by this client.
|
494
|
+
def self.operations
|
495
|
+
@operations ||= []
|
486
496
|
end
|
487
497
|
|
488
498
|
# @private
|