aws-sdk-core 2.0.48 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apis/autoscaling/2011-01-01/api-2.json +636 -33
- data/apis/cloudhsm/2014-05-30/api-2.json +3 -6
- data/apis/ec2/2014-10-01/api-2.json +10267 -0
- data/apis/ec2/2014-10-01/paginators-1.json +125 -0
- data/apis/ec2/2014-10-01/resources-1.json +2289 -0
- data/apis/ec2/2014-10-01/waiters-2.json +453 -0
- data/apis/ec2/2015-03-01/api-2.json +11245 -0
- data/apis/ec2/2015-03-01/paginators-1.json +125 -0
- data/apis/ec2/2015-03-01/resources-1.json +2479 -0
- data/apis/ec2/2015-03-01/waiters-2.json +458 -0
- data/apis/ec2/2015-04-15/api-2.json +182 -2
- data/apis/ecs/2014-11-13/api-2.json +316 -7
- data/apis/ecs/2014-11-13/paginators-1.json +40 -0
- data/apis/ecs/2014-11-13/waiters-2.json +93 -0
- data/apis/redshift/2012-12-01/waiters-2.json +19 -0
- data/apis/s3/2006-03-01/api-2.json +1 -2
- data/apis/sqs/2012-11-05/api-2.json +5 -6
- data/ca-bundle.crt +3554 -0
- data/lib/aws-sdk-core.rb +127 -44
- data/lib/aws-sdk-core/api/builder.rb +95 -0
- data/lib/aws-sdk-core/api/customizations.rb +152 -0
- data/lib/aws-sdk-core/api/docs/builder.rb +220 -0
- data/lib/aws-sdk-core/api/docs/client_type_documenter.rb +109 -0
- data/lib/aws-sdk-core/api/docs/docstring_provider.rb +66 -0
- data/lib/aws-sdk-core/api/docs/operation_documenter.rb +107 -0
- data/lib/aws-sdk-core/api/docs/param_formatter.rb +163 -0
- data/lib/aws-sdk-core/api/docs/request_syntax_example.rb +22 -0
- data/lib/aws-sdk-core/api/docs/response_structure_example.rb +91 -0
- data/lib/aws-sdk-core/api/docs/utils.rb +133 -0
- data/lib/aws-sdk-core/api/shape_map.rb +140 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +9 -6
- data/lib/aws-sdk-core/client.rb +9 -6
- data/lib/aws-sdk-core/client_stubs.rb +127 -133
- data/lib/aws-sdk-core/client_waiters.rb +1 -1
- data/lib/aws-sdk-core/credential_provider.rb +44 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +3 -2
- data/lib/aws-sdk-core/credentials.rb +5 -0
- data/lib/aws-sdk-core/deprecations.rb +69 -0
- data/lib/aws-sdk-core/dynamodb.rb +12 -0
- data/lib/aws-sdk-core/eager_loader.rb +31 -0
- data/lib/aws-sdk-core/ecs.rb +2 -0
- data/lib/aws-sdk-core/empty_structure.rb +1 -82
- data/lib/aws-sdk-core/endpoint_provider.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +9 -10
- data/lib/aws-sdk-core/json.rb +56 -0
- data/lib/aws-sdk-core/json/builder.rb +33 -34
- data/lib/aws-sdk-core/json/error_handler.rb +2 -2
- data/lib/aws-sdk-core/json/handler.rb +67 -0
- data/lib/aws-sdk-core/json/json_engine.rb +15 -0
- data/lib/aws-sdk-core/json/oj_engine.rb +15 -0
- data/lib/aws-sdk-core/json/parser.rb +30 -38
- data/lib/aws-sdk-core/pageable_response.rb +9 -12
- data/lib/aws-sdk-core/pager.rb +69 -0
- data/lib/aws-sdk-core/param_converter.rb +203 -0
- data/lib/aws-sdk-core/param_validator.rb +148 -0
- data/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb +21 -18
- data/lib/aws-sdk-core/plugins/glacier_account_id.rb +9 -1
- data/lib/aws-sdk-core/plugins/glacier_checksums.rb +2 -3
- data/lib/aws-sdk-core/plugins/param_converter.rb +27 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +28 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +3 -7
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +1 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -1
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -1
- data/lib/aws-sdk-core/plugins/request_signer.rb +5 -5
- data/lib/aws-sdk-core/plugins/response_paging.rb +20 -11
- data/lib/aws-sdk-core/plugins/s3_get_bucket_location_fix.rb +1 -1
- data/lib/aws-sdk-core/plugins/s3_request_signer.rb +1 -2
- data/lib/aws-sdk-core/plugins/stub_responses.rb +25 -27
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +29 -34
- data/lib/aws-sdk-core/query/handler.rb +32 -18
- data/lib/aws-sdk-core/query/param_builder.rb +45 -53
- data/lib/aws-sdk-core/refreshing_credentials.rb +3 -15
- data/lib/aws-sdk-core/rest/handler.rb +22 -0
- data/lib/aws-sdk-core/rest/request/body.rb +58 -0
- data/lib/aws-sdk-core/rest/request/builder.rb +50 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +70 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +48 -0
- data/lib/aws-sdk-core/rest/response/body.rb +43 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +60 -0
- data/lib/aws-sdk-core/rest/response/parser.rb +47 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +24 -0
- data/lib/aws-sdk-core/shared_credentials.rb +11 -6
- data/lib/aws-sdk-core/signers/base.rb +1 -1
- data/lib/aws-sdk-core/signers/s3.rb +2 -3
- data/lib/aws-sdk-core/signers/v2.rb +7 -4
- data/lib/aws-sdk-core/signers/v4.rb +11 -22
- data/lib/aws-sdk-core/structure.rb +26 -145
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +46 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +53 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +49 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +67 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +25 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +38 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +34 -0
- data/lib/aws-sdk-core/version.rb +1 -1
- data/lib/aws-sdk-core/xml/builder.rb +58 -52
- data/lib/aws-sdk-core/xml/default_map.rb +10 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +86 -0
- data/lib/aws-sdk-core/xml/error_handler.rb +7 -2
- data/lib/aws-sdk-core/xml/parser.rb +4 -4
- data/lib/aws-sdk-core/xml/parser/frame.rb +75 -70
- data/lib/aws-sdk-core/xml/parser/stack.rb +4 -4
- data/lib/seahorse.rb +0 -11
- data/lib/seahorse/client/base.rb +3 -12
- data/lib/seahorse/client/http/request.rb +9 -5
- data/lib/seahorse/client/plugins/endpoint.rb +5 -56
- data/lib/seahorse/client/plugins/restful_bindings.rb +38 -31
- data/lib/seahorse/client/request_context.rb +2 -2
- data/lib/seahorse/client/response.rb +6 -5
- data/lib/seahorse/model/api.rb +18 -61
- data/lib/seahorse/model/operation.rb +24 -54
- data/lib/seahorse/model/shapes.rb +120 -364
- data/lib/seahorse/util.rb +2 -6
- metadata +56 -109
- data/apis/autoscaling/2011-01-01/docs-2.json +0 -1246
- data/apis/cloudformation/2010-05-15/docs-2.json +0 -725
- data/apis/cloudfront/2014-11-06/docs-2.json +0 -1125
- data/apis/cloudhsm/2014-05-30/docs-2.json +0 -472
- data/apis/cloudsearch/2013-01-01/docs-2.json +0 -865
- data/apis/cloudsearchdomain/2013-01-01/docs-2.json +0 -311
- data/apis/cloudtrail/2013-11-01/docs-2.json +0 -328
- data/apis/codedeploy/2014-10-06/docs-2.json +0 -1261
- data/apis/cognito-identity/2014-06-30/docs-2.json +0 -506
- data/apis/cognito-sync/2014-06-30/docs-2.json +0 -582
- data/apis/config/2014-10-17/docs-2.json +0 -513
- data/apis/config/2014-11-12/docs-2.json +0 -514
- data/apis/datapipeline/2012-10-29/docs-2.json +0 -607
- data/apis/directconnect/2012-10-25/docs-2.json +0 -494
- data/apis/ds/2015-04-16/docs-2.json +0 -753
- data/apis/dynamodb/2011-12-05/api-2.json +0 -949
- data/apis/dynamodb/2011-12-05/docs-2.json +0 -606
- data/apis/dynamodb/2011-12-05/paginators-1.json +0 -26
- data/apis/dynamodb/2011-12-05/waiters-2.json +0 -35
- data/apis/dynamodb/2012-08-10/docs-2.json +0 -977
- data/apis/ec2/2015-04-15/docs-2.json +0 -5368
- data/apis/ecs/2014-11-13/docs-2.json +0 -791
- data/apis/elasticache/2015-02-02/docs-2.json +0 -1390
- data/apis/elasticbeanstalk/2010-12-01/docs-2.json +0 -1114
- data/apis/elasticfilesystem/2015-02-01/docs-2.json +0 -414
- data/apis/elasticloadbalancing/2012-06-01/docs-2.json +0 -1078
- data/apis/elasticmapreduce/2009-03-31/docs-2.json +0 -969
- data/apis/elastictranscoder/2012-09-25/docs-2.json +0 -1152
- data/apis/email/2010-12-01/docs-2.json +0 -441
- data/apis/glacier/2012-06-01/docs-2.json +0 -575
- data/apis/iam/2010-05-08/docs-2.json +0 -2138
- data/apis/importexport/2010-06-01/docs-2.json +0 -432
- data/apis/kinesis/2013-12-02/docs-2.json +0 -424
- data/apis/kms/2014-11-01/docs-2.json +0 -628
- data/apis/lambda/2014-11-11/docs-2.json +0 -303
- data/apis/lambda/2015-03-31/docs-2.json +0 -490
- data/apis/logs/2014-03-28/docs-2.json +0 -599
- data/apis/machinelearning/2014-12-12/docs-2.json +0 -1034
- data/apis/monitoring/2010-08-01/docs-2.json +0 -514
- data/apis/opsworks/2013-02-18/docs-2.json +0 -1592
- data/apis/rds/2014-10-31/docs-2.json +0 -2074
- data/apis/redshift/2012-12-01/docs-2.json +0 -1890
- data/apis/route53/2013-04-01/docs-2.json +0 -1159
- data/apis/route53domains/2014-05-15/docs-2.json +0 -620
- data/apis/s3/2006-03-01/docs-2.json +0 -2213
- data/apis/sdb/2009-04-15/docs-2.json +0 -339
- data/apis/sns/2010-03-31/docs-2.json +0 -564
- data/apis/sqs/2012-11-05/docs-2.json +0 -503
- data/apis/ssm/2014-11-06/docs-2.json +0 -440
- data/apis/storagegateway/2013-06-30/docs-2.json +0 -1331
- data/apis/sts/2011-06-15/docs-2.json +0 -351
- data/apis/support/2013-04-15/docs-2.json +0 -680
- data/apis/swf/2012-01-25/docs-2.json +0 -1569
- data/apis/workspaces/2015-04-08/docs-2.json +0 -457
- data/lib/aws-sdk-core/api/customizer.rb +0 -75
- data/lib/aws-sdk-core/api/docstrings.rb +0 -38
- data/lib/aws-sdk-core/api/documenter.rb +0 -241
- data/lib/aws-sdk-core/api/operation_documenter.rb +0 -173
- data/lib/aws-sdk-core/api/operation_example.rb +0 -133
- data/lib/aws-sdk-core/api/service_customizations.rb +0 -140
- data/lib/aws-sdk-core/client_paging.rb +0 -31
- data/lib/aws-sdk-core/json/rest_handler.rb +0 -20
- data/lib/aws-sdk-core/json/rpc_body_handler.rb +0 -38
- data/lib/aws-sdk-core/json/rpc_headers_handler.rb +0 -34
- data/lib/aws-sdk-core/json/simple_body_handler.rb +0 -34
- data/lib/aws-sdk-core/paging/null_pager.rb +0 -20
- data/lib/aws-sdk-core/paging/null_provider.rb +0 -13
- data/lib/aws-sdk-core/paging/pager.rb +0 -70
- data/lib/aws-sdk-core/paging/provider.rb +0 -22
- data/lib/aws-sdk-core/rest_body_handler.rb +0 -111
- data/lib/aws-sdk-core/signers/handler.rb +0 -18
- data/lib/aws-sdk-core/xml/rest_handler.rb +0 -20
- data/lib/seahorse/client/param_converter.rb +0 -207
- data/lib/seahorse/client/param_validator.rb +0 -139
- data/lib/seahorse/client/plugins/json_simple.rb +0 -33
- data/lib/seahorse/client/plugins/param_conversion.rb +0 -29
- data/lib/seahorse/client/plugins/param_validation.rb +0 -30
- data/lib/seahorse/client/xml/builder.rb +0 -91
- data/lib/seahorse/model/shape_map.rb +0 -47
@@ -13,8 +13,9 @@ module Aws
|
|
13
13
|
#
|
14
14
|
# If you omit `:client` option, a new {STS::Client} object will be
|
15
15
|
# constructed.
|
16
|
-
class AssumeRoleCredentials
|
16
|
+
class AssumeRoleCredentials
|
17
17
|
|
18
|
+
include CredentialProvider
|
18
19
|
include RefreshingCredentials
|
19
20
|
|
20
21
|
# @option options [required, String] :role_arn
|
@@ -35,11 +36,13 @@ module Aws
|
|
35
36
|
private
|
36
37
|
|
37
38
|
def refresh
|
38
|
-
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
c = @client.assume_role(@options).credentials
|
40
|
+
@credentials = Credentials.new(
|
41
|
+
c.access_key_id,
|
42
|
+
c.secret_access_key,
|
43
|
+
c.session_token
|
44
|
+
)
|
45
|
+
@expiration = c.expiration
|
43
46
|
end
|
44
47
|
|
45
48
|
end
|
data/lib/aws-sdk-core/client.rb
CHANGED
@@ -5,16 +5,18 @@ module Aws
|
|
5
5
|
# @api private
|
6
6
|
DEFAULT_PLUGINS = [
|
7
7
|
'Seahorse::Client::Plugins::Logging',
|
8
|
-
'Seahorse::Client::Plugins::RestfulBindings',
|
9
8
|
'Seahorse::Client::Plugins::ContentLength',
|
9
|
+
'Aws::Plugins::ParamConverter',
|
10
|
+
'Aws::Plugins::ParamValidator',
|
10
11
|
'Aws::Plugins::UserAgent',
|
11
12
|
'Aws::Plugins::RetryErrors',
|
12
13
|
'Aws::Plugins::GlobalConfiguration',
|
13
14
|
'Aws::Plugins::RegionalEndpoint',
|
14
15
|
'Aws::Plugins::RequestSigner',
|
16
|
+
'Aws::Plugins::ResponsePaging',
|
17
|
+
'Aws::Plugins::StubResponses',
|
15
18
|
]
|
16
19
|
|
17
|
-
include ClientPaging
|
18
20
|
include ClientStubs
|
19
21
|
include ClientWaiters
|
20
22
|
|
@@ -28,11 +30,12 @@ module Aws
|
|
28
30
|
def define(svc_name, options)
|
29
31
|
client_class = Class.new(self)
|
30
32
|
client_class.identifier = svc_name.downcase.to_sym
|
31
|
-
[:api,
|
32
|
-
|
33
|
+
client_class.set_api(Api::Builder.build(options[:api], options))
|
34
|
+
client_class.set_waiters(options[:waiters])
|
35
|
+
DEFAULT_PLUGINS.each do |plugin|
|
36
|
+
client_class.add_plugin(plugin)
|
33
37
|
end
|
34
|
-
|
35
|
-
Api::ServiceCustomizations.apply(client_class)
|
38
|
+
Api::Customizations.apply_plugins(client_class)
|
36
39
|
client_class
|
37
40
|
end
|
38
41
|
|
@@ -8,15 +8,16 @@ module Aws
|
|
8
8
|
# behavior.
|
9
9
|
module ClientStubs
|
10
10
|
|
11
|
-
# @api private
|
12
|
-
def self.included(subclass)
|
13
|
-
subclass.add_plugin('Aws::Plugins::StubResponses')
|
14
|
-
end
|
15
|
-
|
16
11
|
def initialize(*args)
|
17
12
|
@stubs = {}
|
18
13
|
@stub_mutex = Mutex.new
|
19
14
|
super
|
15
|
+
if Hash === @config.stub_responses
|
16
|
+
@config.stub_responses.each do |operation_name, stubs|
|
17
|
+
apply_stubs(operation_name, Array === stubs ? stubs : [stubs])
|
18
|
+
end
|
19
|
+
@config.stub_responses = true
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
22
23
|
# Configures what data / errors should be returned from the named operation
|
@@ -24,19 +25,45 @@ module Aws
|
|
24
25
|
#
|
25
26
|
# ## Basic usage
|
26
27
|
#
|
27
|
-
#
|
28
|
-
#
|
28
|
+
# When you enable response stubbing, the client will generate fake
|
29
|
+
# responses and will not make any HTTP requests.
|
29
30
|
#
|
30
|
-
# # enable response stubbing in the client constructor
|
31
31
|
# client = Aws::S3::Client.new(stub_responses: true)
|
32
|
+
# client.list_buckets
|
33
|
+
# #=> #<struct Aws::S3::Types::ListBucketsOutput buckets=[], owner=nil>
|
32
34
|
#
|
33
|
-
#
|
34
|
-
# client.stub_responses(:list_buckets, buckets:[{name:'aws-sdk'}])
|
35
|
+
# You can provide stub data that will be returned by the client.
|
35
36
|
#
|
36
|
-
# #
|
37
|
-
# client.
|
37
|
+
# # stub data in the constructor
|
38
|
+
# client = Aws::S3::Client.new(stub_responses: {
|
39
|
+
# list_buckets: { bukets: [{name: 'my-bucket' }] },
|
40
|
+
# get_object: { body: 'data' },
|
41
|
+
# })
|
42
|
+
#
|
43
|
+
# client.list_buckets.buckets.map(&:name) #=> ['my-bucket']
|
44
|
+
# client.get_object(bucket:'name', key:'key').body.read #=> 'data'
|
45
|
+
#
|
46
|
+
# You can also specify the stub data using {#stub_responses}
|
47
|
+
#
|
48
|
+
# client = Aws::S3::Client.new(stub_responses: true)
|
49
|
+
# client.stub_resposnes(:list_buckets, {
|
50
|
+
# buckets: [{ name: 'my-bucket' }]
|
51
|
+
# })
|
52
|
+
#
|
53
|
+
# client.list_buckets.buckets.map(&:name) #=> ['my-bucket']
|
38
54
|
# #=> ['aws-sdk']
|
39
55
|
#
|
56
|
+
# Lastly, default stubs can be configured via `Aws.config`:
|
57
|
+
#
|
58
|
+
# Aws.config[:s3] = {
|
59
|
+
# stub_responses: {
|
60
|
+
# list_buckets: { bukets: [{name: 'my-bucket' }] }
|
61
|
+
# }
|
62
|
+
# }
|
63
|
+
#
|
64
|
+
# Aws::S3::Client.new.list_buckets.buckets.map(&:name)
|
65
|
+
# #=> ['my-bucket']
|
66
|
+
#
|
40
67
|
# ## Stubbing Errors
|
41
68
|
#
|
42
69
|
# When stubbing is enabled, the SDK will default to generate
|
@@ -55,12 +82,29 @@ module Aws
|
|
55
82
|
# client.get_object(bucket:'aws-sdk', key:'foo')
|
56
83
|
# #=> raises the given runtime error object
|
57
84
|
#
|
85
|
+
# ## Stubbing HTTP Responses
|
86
|
+
#
|
87
|
+
# As an alternative to providing the response data, you can provide
|
88
|
+
# an HTTP response.
|
89
|
+
#
|
90
|
+
# client.stub_responses(:get_object, {
|
91
|
+
# status_code: 200,
|
92
|
+
# headers: { 'header-name' => 'header-value' },
|
93
|
+
# body: "...",
|
94
|
+
# })
|
95
|
+
#
|
96
|
+
# To stub a HTTP response, pass a Hash with all three of the following
|
97
|
+
# keys set:
|
98
|
+
#
|
99
|
+
# * **`:status_code`** - <Integer> - The HTTP status code
|
100
|
+
# * **`:headers`** - Hash<String,String> - A hash of HTTP header keys and values
|
101
|
+
# * **`:body`** - <String,IO> - The HTTP response body.
|
102
|
+
#
|
58
103
|
# ## Stubbing Multiple Responses
|
59
104
|
#
|
60
105
|
# Calling an operation multiple times will return similar responses.
|
61
106
|
# You can configure multiple stubs and they will be returned in sequence.
|
62
107
|
#
|
63
|
-
#
|
64
108
|
# client.stub_responses(:head_object, [
|
65
109
|
# 'NotFound',
|
66
110
|
# { content_length: 150 },
|
@@ -73,12 +117,16 @@ module Aws
|
|
73
117
|
# resp.content_length #=> 150
|
74
118
|
#
|
75
119
|
# @param [Symbol] operation_name
|
120
|
+
#
|
76
121
|
# @param [Mixed] stubs One or more responses to return from the named
|
77
122
|
# operation.
|
123
|
+
#
|
78
124
|
# @return [void]
|
125
|
+
#
|
79
126
|
# @raise [RuntimeError] Raises a runtime error when called
|
80
127
|
# on a client that has not enabled response stubbing via
|
81
128
|
# `:stub_responses => true`.
|
129
|
+
#
|
82
130
|
def stub_responses(operation_name, *stubs)
|
83
131
|
if config.stub_responses
|
84
132
|
apply_stubs(operation_name, stubs.flatten)
|
@@ -89,12 +137,35 @@ module Aws
|
|
89
137
|
end
|
90
138
|
end
|
91
139
|
|
140
|
+
# Generates and returns stubbed response data from the named operation.
|
141
|
+
#
|
142
|
+
# s3 = Aws::S3::Client.new
|
143
|
+
# s3.stub_data(:list_buckets)
|
144
|
+
# #=> #<struct Aws::S3::Types::ListBucketsOutput buckets=[], owner=#<struct Aws::S3::Types::Owner display_name="DisplayName", id="ID">>
|
145
|
+
#
|
146
|
+
# In addition to generating default stubs, you can provide data to
|
147
|
+
# apply to the response stub.
|
148
|
+
#
|
149
|
+
# s3.stub_data(:list_buckets, buckets:[{name:'aws-sdk'}])
|
150
|
+
# #=> #<struct Aws::S3::Types::ListBucketsOutput
|
151
|
+
# buckets=[#<struct Aws::S3::Types::Bucket name="aws-sdk", creation_date=nil>],
|
152
|
+
# owner=#<struct Aws::S3::Types::Owner display_name="DisplayName", id="ID">>
|
153
|
+
#
|
154
|
+
# @param [Symbol] operation_name
|
155
|
+
# @param [Hash] data
|
156
|
+
# @return [Structure] Returns a stubbed response data structure. The
|
157
|
+
# actual class returned will depend on the given `operation_name`.
|
158
|
+
def stub_data(operation_name, data = {})
|
159
|
+
Stubbing::StubData.new(operation(operation_name)).stub(data)
|
160
|
+
end
|
161
|
+
|
92
162
|
# @api private
|
93
163
|
def next_stub(operation_name)
|
164
|
+
operation_name = operation_name.to_sym
|
94
165
|
@stub_mutex.synchronize do
|
95
|
-
stubs = @stubs[operation_name
|
166
|
+
stubs = @stubs[operation_name] || []
|
96
167
|
case stubs.length
|
97
|
-
when 0 then
|
168
|
+
when 0 then default_stub(operation_name)
|
98
169
|
when 1 then stubs.first
|
99
170
|
else stubs.shift
|
100
171
|
end
|
@@ -103,141 +174,64 @@ module Aws
|
|
103
174
|
|
104
175
|
private
|
105
176
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
def new_stub(operation_name, data = nil)
|
110
|
-
Stub.new(operation(operation_name).output).format(data || {})
|
177
|
+
def default_stub(operation_name)
|
178
|
+
stub = stub_data(operation_name)
|
179
|
+
http_response_stub(operation_name, stub)
|
111
180
|
end
|
112
181
|
|
182
|
+
# This method converts the given stub data and converts it to a
|
183
|
+
# HTTP response (when possible). This enables the response stubbing
|
184
|
+
# plugin to provide a HTTP response that triggers all normal events
|
185
|
+
# during response handling.
|
113
186
|
def apply_stubs(operation_name, stubs)
|
114
187
|
@stub_mutex.synchronize do
|
115
188
|
@stubs[operation_name.to_sym] = stubs.map do |stub|
|
116
189
|
case stub
|
117
|
-
when Exception then stub
|
118
|
-
when String then
|
119
|
-
when Hash then
|
120
|
-
else stub
|
190
|
+
when Exception, Class then { error: stub }
|
191
|
+
when String then service_error_stub(stub)
|
192
|
+
when Hash then http_response_stub(operation_name, stub)
|
193
|
+
else { data: stub }
|
121
194
|
end
|
122
195
|
end
|
123
196
|
end
|
124
197
|
end
|
125
198
|
|
126
|
-
def
|
127
|
-
|
128
|
-
svc_module.const_get(:Errors).const_get(name)
|
199
|
+
def service_error_stub(error_code)
|
200
|
+
{ http: protocol_helper.stub_error(error_code) }
|
129
201
|
end
|
130
202
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@shape = output_shape
|
137
|
-
end
|
138
|
-
|
139
|
-
# @param [Hash] data An optional hash of data to format into the stubbed
|
140
|
-
# object.
|
141
|
-
def format(data = {})
|
142
|
-
if @shape.nil?
|
143
|
-
empty_stub(data)
|
144
|
-
else
|
145
|
-
validate_data(data)
|
146
|
-
stub(@shape, data)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
private
|
151
|
-
|
152
|
-
def stub(shape, value)
|
153
|
-
case shape
|
154
|
-
when Seahorse::Model::Shapes::Structure then stub_structure(shape, value)
|
155
|
-
when Seahorse::Model::Shapes::List then stub_list(shape, value || [])
|
156
|
-
when Seahorse::Model::Shapes::Map then stub_map(shape, value || {})
|
157
|
-
else stub_scalar(shape, value)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def stub_structure(shape, hash)
|
162
|
-
if hash
|
163
|
-
structure_obj(shape, hash)
|
164
|
-
else
|
165
|
-
nil
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def structure_obj(shape, hash)
|
170
|
-
stubs = Structure.new(shape.member_names)
|
171
|
-
shape.members.each do |member_name, member_shape|
|
172
|
-
if hash.key?(member_name) && hash[member_name].nil?
|
173
|
-
stubs[member_name] = nil
|
174
|
-
else
|
175
|
-
value = structure_value(shape, member_name, member_shape, hash)
|
176
|
-
stubs[member_name] = stub(member_shape, value)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
stubs
|
180
|
-
end
|
181
|
-
|
182
|
-
def structure_value(shape, member_name, member_shape, hash)
|
183
|
-
if hash.key?(member_name)
|
184
|
-
hash[member_name]
|
185
|
-
elsif
|
186
|
-
Seahorse::Model::Shapes::Structure === member_shape &&
|
187
|
-
shape.required.include?(member_name)
|
188
|
-
then
|
189
|
-
{}
|
190
|
-
else
|
191
|
-
nil
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def stub_list(shape, array)
|
196
|
-
stubs = []
|
197
|
-
array.each do |value|
|
198
|
-
stubs << stub(shape.member, value)
|
199
|
-
end
|
200
|
-
stubs
|
201
|
-
end
|
202
|
-
|
203
|
-
def stub_map(shape, value)
|
204
|
-
stubs = {}
|
205
|
-
value.each do |key, value|
|
206
|
-
stubs[key] = stub(shape.value, value)
|
207
|
-
end
|
208
|
-
stubs
|
209
|
-
end
|
210
|
-
|
211
|
-
def stub_scalar(shape, value)
|
212
|
-
if value.nil?
|
213
|
-
case shape
|
214
|
-
when Seahorse::Model::Shapes::String then shape.name
|
215
|
-
when Seahorse::Model::Shapes::Integer then 0
|
216
|
-
when Seahorse::Model::Shapes::Float then 0.0
|
217
|
-
when Seahorse::Model::Shapes::Boolean then false
|
218
|
-
when Seahorse::Model::Shapes::Timestamp then Time.now
|
219
|
-
else nil
|
220
|
-
end
|
221
|
-
else
|
222
|
-
value
|
223
|
-
end
|
203
|
+
def http_response_stub(operation_name, data)
|
204
|
+
if Hash === data && data.keys.sort == [:body, :headers, :status_code]
|
205
|
+
{ http: hash_to_http_resp(data) }
|
206
|
+
else
|
207
|
+
{ http: data_to_http_resp(operation_name, data) }
|
224
208
|
end
|
209
|
+
end
|
225
210
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
end
|
234
|
-
end
|
211
|
+
def hash_to_http_resp(data)
|
212
|
+
http_resp = Seahorse::Client::Http::Response.new
|
213
|
+
http_resp.status_code = data[:status_code]
|
214
|
+
http_resp.headers.update(data[:headers])
|
215
|
+
http_resp.body = data[:body]
|
216
|
+
http_resp
|
217
|
+
end
|
235
218
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
219
|
+
def data_to_http_resp(operation_name, data)
|
220
|
+
api = config.api
|
221
|
+
operation = api.operation(operation_name)
|
222
|
+
ParamValidator.validate!(operation.output, data)
|
223
|
+
protocol_helper.stub_data(api, operation, data)
|
224
|
+
end
|
240
225
|
|
226
|
+
def protocol_helper
|
227
|
+
case config.api.metadata['protocol']
|
228
|
+
when 'json' then Stubbing::Protocols::Json
|
229
|
+
when 'query' then Stubbing::Protocols::Query
|
230
|
+
when 'ec2' then Stubbing::Protocols::EC2
|
231
|
+
when 'rest-json' then Stubbing::Protocols::RestJson
|
232
|
+
when 'rest-xml' then Stubbing::Protocols::RestXml
|
233
|
+
else raise "unsupported protocol"
|
234
|
+
end.new
|
241
235
|
end
|
242
236
|
end
|
243
237
|
end
|
@@ -10,7 +10,7 @@ module Aws
|
|
10
10
|
case waiters
|
11
11
|
when Waiters::Provider then waiters
|
12
12
|
when Hash then Waiters::Provider.new(waiters)
|
13
|
-
when String, Pathname then Waiters::Provider.new(
|
13
|
+
when String, Pathname then Waiters::Provider.new(Json.load_file(waiters))
|
14
14
|
when nil then Waiters::NullProvider.new
|
15
15
|
else raise ArgumentError, 'invalid waiters'
|
16
16
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Aws
|
2
|
+
module CredentialProvider
|
3
|
+
|
4
|
+
extend Deprecations
|
5
|
+
|
6
|
+
# @return [Credentials]
|
7
|
+
def credentials
|
8
|
+
@credentials
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Boolean]
|
12
|
+
def set?
|
13
|
+
!!@credentials && @credentials.set?
|
14
|
+
end
|
15
|
+
|
16
|
+
# @deprecated Deprecated in 2.1.0. This method is subject to errors
|
17
|
+
# from a race condition when called against refreshable credential
|
18
|
+
# objects. Will be removed in 2.2.0.
|
19
|
+
# @see #credentials
|
20
|
+
def access_key_id
|
21
|
+
@credentials ? @credentials.access_key_id : nil
|
22
|
+
end
|
23
|
+
deprecated(:access_key_id, use: '#credentials')
|
24
|
+
|
25
|
+
# @deprecated Deprecated in 2.1.0. This method is subject to errors
|
26
|
+
# from a race condition when called against refreshable credential
|
27
|
+
# objects. Will be removed in 2.2.0.
|
28
|
+
# @see #credentials
|
29
|
+
def secret_access_key
|
30
|
+
@credentials ? @credentials.secret_access_key : nil
|
31
|
+
end
|
32
|
+
deprecated(:secret_access_key, use: '#credentials')
|
33
|
+
|
34
|
+
# @deprecated Deprecated in 2.1.0. This method is subject to errors
|
35
|
+
# from a race condition when called against refreshable credential
|
36
|
+
# objects. Will be removed in 2.2.0.
|
37
|
+
# @see #credentials
|
38
|
+
def session_token
|
39
|
+
@credentials ? @credentials.session_token : nil
|
40
|
+
end
|
41
|
+
deprecated(:session_token, use: '#credentials')
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|