aws-sdk-core 3.209.0 → 3.211.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-core/assume_role_credentials.rb +8 -9
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +8 -9
- data/lib/aws-sdk-core/cbor.rb +3 -56
- data/lib/aws-sdk-core/client_stubs.rb +7 -7
- data/lib/aws-sdk-core/endpoints/matchers.rb +1 -8
- data/lib/aws-sdk-core/json/error_handler.rb +2 -1
- data/lib/aws-sdk-core/json/handler.rb +1 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +44 -25
- data/lib/aws-sdk-core/plugins.rb +29 -1
- data/lib/aws-sdk-core/rest/request/headers.rb +2 -2
- data/lib/aws-sdk-core/rpc_v2/builder.rb +1 -1
- data/lib/aws-sdk-core/{cbor → rpc_v2}/cbor_engine.rb +4 -5
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +3 -1
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +3 -2
- data/lib/aws-sdk-core/rpc_v2/handler.rb +2 -1
- data/lib/aws-sdk-core/rpc_v2/parser.rb +1 -1
- data/lib/aws-sdk-core/rpc_v2.rb +65 -2
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +13 -15
- data/lib/aws-sdk-core/stubbing.rb +2 -2
- data/lib/aws-sdk-core.rb +1 -0
- data/lib/aws-sdk-sso/client.rb +1 -1
- data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-sso/endpoints.rb +2 -42
- data/lib/aws-sdk-sso/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +1 -1
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-ssooidc/endpoints.rb +2 -42
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +1 -1
- data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
- data/lib/aws-sdk-sts/endpoints.rb +2 -94
- data/lib/aws-sdk-sts/plugins/endpoints.rb +1 -22
- data/lib/aws-sdk-sts.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d418a930974fa0612c72b4f3b79447d118c609226d9e831f88a816b528079da3
|
4
|
+
data.tar.gz: fcd0a2ac8ca0e4bea771931e2b7da2c094437deeae84de781df5dfc23fb7561b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d428f5d83ef0890bd1153b762b5ca47a5f8ee67f8c796fd53d3067419ccc792d13210de5d3eeadd0ee118bac060b9a887a2ae638e7fb8b1bc80936760fa69a49
|
7
|
+
data.tar.gz: 1a9138f97f8c85c1acdb67aabf9866fcab95ac770684b817a9d2be39fd757ca0457aa219d168cfe9d5c5d8b0513bc9cd96aa2fcc96525e5fce350d8db602c259
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
3.211.0 (2024-10-21)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Feature - Support functionality for services that migrate from AWS Query to AWS JSON or CBOR.
|
8
|
+
|
9
|
+
* Issue - Fix RPCv2 protocol to always send an Accept header for CBOR.
|
10
|
+
|
11
|
+
3.210.0 (2024-10-18)
|
12
|
+
------------------
|
13
|
+
|
14
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
15
|
+
|
16
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
17
|
+
|
18
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
19
|
+
|
20
|
+
* Feature - reduce memory usage by not using legacy endpoint data unless required.
|
21
|
+
|
22
|
+
3.209.1 (2024-09-25)
|
23
|
+
------------------
|
24
|
+
|
25
|
+
* Issue - Add all core plugins to autoloads.
|
26
|
+
|
4
27
|
3.209.0 (2024-09-24)
|
5
28
|
------------------
|
6
29
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.211.0
|
@@ -62,23 +62,22 @@ module Aws
|
|
62
62
|
private
|
63
63
|
|
64
64
|
def refresh
|
65
|
-
|
66
|
-
creds =
|
67
|
-
account_id =
|
68
|
-
begin
|
69
|
-
ARNParser.parse(c.assumed_role_user.arn).account_id
|
70
|
-
rescue Aws::Errors::InvalidARNError
|
71
|
-
nil
|
72
|
-
end
|
65
|
+
resp = @client.assume_role(@assume_role_params)
|
66
|
+
creds = resp.credentials
|
73
67
|
@credentials = Credentials.new(
|
74
68
|
creds.access_key_id,
|
75
69
|
creds.secret_access_key,
|
76
70
|
creds.session_token,
|
77
|
-
account_id:
|
71
|
+
account_id: parse_account_id(resp)
|
78
72
|
)
|
79
73
|
@expiration = creds.expiration
|
80
74
|
end
|
81
75
|
|
76
|
+
def parse_account_id(resp)
|
77
|
+
arn = resp.assumed_role_user&.arn
|
78
|
+
ARNParser.parse(arn).account_id if ARNParser.arn?(arn)
|
79
|
+
end
|
80
|
+
|
82
81
|
class << self
|
83
82
|
|
84
83
|
# @api private
|
@@ -73,19 +73,13 @@ module Aws
|
|
73
73
|
# read from token file everytime it refreshes
|
74
74
|
@assume_role_web_identity_params[:web_identity_token] = _token_from_file(@token_file)
|
75
75
|
|
76
|
-
|
77
|
-
creds =
|
78
|
-
account_id =
|
79
|
-
begin
|
80
|
-
ARNParser.parse(c.assumed_role_user.arn).account_id
|
81
|
-
rescue Aws::Errors::InvalidARNError
|
82
|
-
nil
|
83
|
-
end
|
76
|
+
resp = @client.assume_role_with_web_identity(@assume_role_web_identity_params)
|
77
|
+
creds = resp.credentials
|
84
78
|
@credentials = Credentials.new(
|
85
79
|
creds.access_key_id,
|
86
80
|
creds.secret_access_key,
|
87
81
|
creds.session_token,
|
88
|
-
account_id:
|
82
|
+
account_id: parse_account_id(resp)
|
89
83
|
)
|
90
84
|
@expiration = creds.expiration
|
91
85
|
end
|
@@ -101,6 +95,11 @@ module Aws
|
|
101
95
|
Base64.strict_encode64(SecureRandom.uuid)
|
102
96
|
end
|
103
97
|
|
98
|
+
def parse_account_id(resp)
|
99
|
+
arn = resp.assumed_role_user&.arn
|
100
|
+
ARNParser.parse(arn).account_id if ARNParser.arn?(arn)
|
101
|
+
end
|
102
|
+
|
104
103
|
class << self
|
105
104
|
|
106
105
|
# @api private
|
data/lib/aws-sdk-core/cbor.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'cbor/encoder'
|
4
|
+
require_relative 'cbor/decoder'
|
5
|
+
|
3
6
|
module Aws
|
4
7
|
# @api private
|
5
8
|
module Cbor
|
@@ -46,61 +49,5 @@ module Aws
|
|
46
49
|
super("Unexpected additional information: #{add_info}")
|
47
50
|
end
|
48
51
|
end
|
49
|
-
|
50
|
-
class << self
|
51
|
-
# @param [Symbol,Class] engine
|
52
|
-
# Must be one of the following values:
|
53
|
-
#
|
54
|
-
# * :cbor
|
55
|
-
#
|
56
|
-
def engine=(engine)
|
57
|
-
@engine = Class === engine ? engine : load_engine(engine)
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [Class] Returns the default engine.
|
61
|
-
# One of:
|
62
|
-
#
|
63
|
-
# * {CborEngine}
|
64
|
-
#
|
65
|
-
def engine
|
66
|
-
set_default_engine unless @engine
|
67
|
-
@engine
|
68
|
-
end
|
69
|
-
|
70
|
-
def encode(data)
|
71
|
-
@engine.encode(data)
|
72
|
-
end
|
73
|
-
|
74
|
-
def decode(bytes)
|
75
|
-
bytes.force_encoding(Encoding::BINARY)
|
76
|
-
@engine.decode(bytes)
|
77
|
-
end
|
78
|
-
|
79
|
-
def set_default_engine
|
80
|
-
[:cbor].each do |name|
|
81
|
-
@engine ||= try_load_engine(name)
|
82
|
-
end
|
83
|
-
|
84
|
-
unless @engine
|
85
|
-
raise 'Unable to find a compatible cbor library.'
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def load_engine(name)
|
92
|
-
require "aws-sdk-core/cbor/#{name}_engine"
|
93
|
-
const_name = name[0].upcase + name[1..-1] + 'Engine'
|
94
|
-
const_get(const_name)
|
95
|
-
end
|
96
|
-
|
97
|
-
def try_load_engine(name)
|
98
|
-
load_engine(name)
|
99
|
-
rescue LoadError
|
100
|
-
false
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
set_default_engine
|
105
52
|
end
|
106
53
|
end
|
@@ -307,14 +307,14 @@ module Aws
|
|
307
307
|
|
308
308
|
def protocol_helper
|
309
309
|
case config.api.metadata['protocol']
|
310
|
-
when 'json'
|
311
|
-
when 'rest-json'
|
312
|
-
when 'rest-xml'
|
313
|
-
when 'query'
|
314
|
-
when 'ec2'
|
310
|
+
when 'json' then Stubbing::Protocols::Json
|
311
|
+
when 'rest-json' then Stubbing::Protocols::RestJson
|
312
|
+
when 'rest-xml' then Stubbing::Protocols::RestXml
|
313
|
+
when 'query' then Stubbing::Protocols::Query
|
314
|
+
when 'ec2' then Stubbing::Protocols::EC2
|
315
315
|
when 'smithy-rpc-v2-cbor' then Stubbing::Protocols::RpcV2
|
316
|
-
when 'api-gateway'
|
317
|
-
else raise
|
316
|
+
when 'api-gateway' then Stubbing::Protocols::ApiGateway
|
317
|
+
else raise 'unsupported protocol'
|
318
318
|
end.new
|
319
319
|
end
|
320
320
|
end
|
@@ -94,14 +94,7 @@ module Aws
|
|
94
94
|
|
95
95
|
# aws.partition(value: string) Option<Partition>
|
96
96
|
def self.aws_partition(value)
|
97
|
-
partition
|
98
|
-
Aws::Partitions.find { |p| p.region?(value) } ||
|
99
|
-
Aws::Partitions.find { |p| value.match(p.region_regex) } ||
|
100
|
-
Aws::Partitions.find { |p| p.name == 'aws' }
|
101
|
-
|
102
|
-
return nil unless partition
|
103
|
-
|
104
|
-
partition.metadata
|
97
|
+
Aws::Partitions::Metadata.partition(value)
|
105
98
|
end
|
106
99
|
|
107
100
|
# aws.parseArn(value: string) Option<ARN>
|
@@ -26,7 +26,8 @@ module Aws
|
|
26
26
|
def error_code(json, context)
|
27
27
|
code =
|
28
28
|
if aws_query_error?(context)
|
29
|
-
|
29
|
+
query_header = context.http_response.headers['x-amzn-query-error']
|
30
|
+
error, _type = query_header.split(';') # type not supported
|
30
31
|
remove_prefix(error, context)
|
31
32
|
else
|
32
33
|
json['__type']
|
@@ -21,6 +21,7 @@ module Aws
|
|
21
21
|
context.http_request.http_method = 'POST'
|
22
22
|
context.http_request.headers['Content-Type'] = content_type(context)
|
23
23
|
context.http_request.headers['X-Amz-Target'] = target(context)
|
24
|
+
context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
|
24
25
|
context.http_request.body = build_body(context)
|
25
26
|
end
|
26
27
|
|
@@ -20,7 +20,7 @@ a default `:region` is searched for in the following locations:
|
|
20
20
|
* `ENV['AWS_DEFAULT_REGION']`
|
21
21
|
* `~/.aws/credentials`
|
22
22
|
* `~/.aws/config`
|
23
|
-
|
23
|
+
DOCS
|
24
24
|
resolve_region(cfg)
|
25
25
|
end
|
26
26
|
|
@@ -35,7 +35,7 @@ in the following locations:
|
|
35
35
|
* `Aws.config[:sigv4a_signing_region_set]`
|
36
36
|
* `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
|
37
37
|
* `~/.aws/config`
|
38
|
-
|
38
|
+
DOCS
|
39
39
|
resolve_sigv4a_signing_region_set(cfg)
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ in the following locations:
|
|
44
44
|
docstring: <<-DOCS) do |cfg|
|
45
45
|
When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
|
46
46
|
will be used if available.
|
47
|
-
|
47
|
+
DOCS
|
48
48
|
resolve_use_dualstack_endpoint(cfg)
|
49
49
|
end
|
50
50
|
|
@@ -54,7 +54,7 @@ will be used if available.
|
|
54
54
|
When set to `true`, fips compatible endpoints will be used if available.
|
55
55
|
When a `fips` region is used, the region is normalized and this config
|
56
56
|
is set to `true`.
|
57
|
-
|
57
|
+
DOCS
|
58
58
|
resolve_use_fips_endpoint(cfg)
|
59
59
|
end
|
60
60
|
|
@@ -67,7 +67,7 @@ is set to `true`.
|
|
67
67
|
docstring: <<-DOCS) do |cfg|
|
68
68
|
Setting to true disables use of endpoint URLs provided via environment
|
69
69
|
variables and the shared configuration file.
|
70
|
-
|
70
|
+
DOCS
|
71
71
|
resolve_ignore_configured_endpoint_urls(cfg)
|
72
72
|
end
|
73
73
|
|
@@ -75,7 +75,7 @@ variables and the shared configuration file.
|
|
75
75
|
The client endpoint is normally constructed from the `:region`
|
76
76
|
option. You should only configure an `:endpoint` when connecting
|
77
77
|
to test or custom endpoints. This should be a valid HTTP(S) URI.
|
78
|
-
|
78
|
+
DOCS
|
79
79
|
resolve_endpoint(cfg)
|
80
80
|
end
|
81
81
|
|
@@ -83,6 +83,9 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
|
|
83
83
|
region = client.config.region
|
84
84
|
raise Errors::MissingRegionError if region.nil? || region == ''
|
85
85
|
|
86
|
+
# resolve a default endpoint to preserve legacy behavior
|
87
|
+
initialize_default_endpoint(client) if client.config.endpoint.nil?
|
88
|
+
|
86
89
|
region_set = client.config.sigv4a_signing_region_set
|
87
90
|
return if region_set.nil?
|
88
91
|
raise Errors::InvalidRegionSetError unless region_set.is_a?(Array)
|
@@ -93,6 +96,39 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
|
|
93
96
|
client.config.sigv4a_signing_region_set = region_set
|
94
97
|
end
|
95
98
|
|
99
|
+
private
|
100
|
+
|
101
|
+
def initialize_default_endpoint(client)
|
102
|
+
client_module = Object.const_get(client.class.name.rpartition('::').first)
|
103
|
+
param_class = client_module.const_get(:EndpointParameters)
|
104
|
+
endpoint_provider = client.config.endpoint_provider
|
105
|
+
params = param_class.create(client.config)
|
106
|
+
endpoint = endpoint_provider.resolve_endpoint(params)
|
107
|
+
client.config.endpoint = endpoint.url
|
108
|
+
rescue ArgumentError, NameError
|
109
|
+
# fallback to legacy
|
110
|
+
client.config.endpoint = resolve_legacy_endpoint(client.config)
|
111
|
+
end
|
112
|
+
|
113
|
+
# set a default endpoint in config using legacy (endpoints.json) resolver
|
114
|
+
def resolve_legacy_endpoint(cfg)
|
115
|
+
endpoint_prefix = cfg.api.metadata['endpointPrefix']
|
116
|
+
if cfg.respond_to?(:sts_regional_endpoints)
|
117
|
+
sts_regional = cfg.sts_regional_endpoints
|
118
|
+
end
|
119
|
+
|
120
|
+
endpoint = Aws::Partitions::EndpointProvider.resolve(
|
121
|
+
cfg.region,
|
122
|
+
endpoint_prefix,
|
123
|
+
sts_regional,
|
124
|
+
{
|
125
|
+
dualstack: cfg.use_dualstack_endpoint,
|
126
|
+
fips: cfg.use_fips_endpoint
|
127
|
+
}
|
128
|
+
)
|
129
|
+
URI(endpoint)
|
130
|
+
end
|
131
|
+
|
96
132
|
class << self
|
97
133
|
private
|
98
134
|
|
@@ -150,7 +186,8 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
|
|
150
186
|
# that a custom endpoint has NOT been configured by the user
|
151
187
|
cfg.override_config(:regional_endpoint, true)
|
152
188
|
|
153
|
-
|
189
|
+
# a default endpoint is resolved in after_initialize
|
190
|
+
nil
|
154
191
|
end
|
155
192
|
|
156
193
|
# get a custom configured endpoint from ENV or configuration
|
@@ -205,24 +242,6 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
|
|
205
242
|
cfg.override_config(:region, new_region)
|
206
243
|
end
|
207
244
|
end
|
208
|
-
|
209
|
-
# set a default endpoint in config using legacy (endpoints.json) resolver
|
210
|
-
def resolve_legacy_endpoint(cfg)
|
211
|
-
endpoint_prefix = cfg.api.metadata['endpointPrefix']
|
212
|
-
if cfg.respond_to?(:sts_regional_endpoints)
|
213
|
-
sts_regional = cfg.sts_regional_endpoints
|
214
|
-
end
|
215
|
-
|
216
|
-
Aws::Partitions::EndpointProvider.resolve(
|
217
|
-
cfg.region,
|
218
|
-
endpoint_prefix,
|
219
|
-
sts_regional,
|
220
|
-
{
|
221
|
-
dualstack: cfg.use_dualstack_endpoint,
|
222
|
-
fips: cfg.use_fips_endpoint
|
223
|
-
}
|
224
|
-
)
|
225
|
-
end
|
226
245
|
end
|
227
246
|
end
|
228
247
|
end
|
data/lib/aws-sdk-core/plugins.rb
CHANGED
@@ -3,9 +3,37 @@
|
|
3
3
|
module Aws
|
4
4
|
# setup autoloading for Plugins
|
5
5
|
# Most plugins are required explicitly from service clients
|
6
|
+
# but users may reference them outside of client usage.
|
6
7
|
module Plugins
|
8
|
+
autoload :ApiKey, 'aws-sdk-core/plugins/api_key'
|
7
9
|
autoload :BearerAuthorization, 'aws-sdk-core/plugins/bearer_authorization'
|
8
|
-
autoload :
|
10
|
+
autoload :ChecksumAlgorithm, 'aws-sdk-core/plugins/checksum_algorithm'
|
11
|
+
autoload :ClientMetricsPlugin, 'aws-sdk-core/plugins/client_metrics_plugin'
|
12
|
+
autoload :ClientMetricsSendPlugin, 'aws-sdk-core/plugins/client_metrics_send_plugin'
|
13
|
+
autoload :CredentialsConfiguration, 'aws-sdk-core/plugins/credentials_configuration'
|
14
|
+
autoload :DefaultsMode, 'aws-sdk-core/plugins/defaults_mode'
|
15
|
+
autoload :EndpointDiscovery, 'aws-sdk-core/plugins/endpoint_discovery'
|
16
|
+
autoload :EndpointPattern, 'aws-sdk-core/plugins/endpoint_pattern'
|
17
|
+
autoload :EventStreamConfiguration, 'aws-sdk-core/plugins/event_stream_configuration'
|
9
18
|
autoload :GlobalConfiguration, 'aws-sdk-core/plugins/global_configuration'
|
19
|
+
autoload :HelpfulSocketErrors, 'aws-sdk-core/plugins/helpful_socket_errors'
|
20
|
+
autoload :HttpChecksum, 'aws-sdk-core/plugins/http_checksum'
|
21
|
+
autoload :IdempotencyToken, 'aws-sdk-core/plugins/idempotency_token'
|
22
|
+
autoload :InvocationId, 'aws-sdk-core/plugins/invocation_id'
|
23
|
+
autoload :JsonvalueConverter, 'aws-sdk-core/plugins/jsonvalue_converter'
|
24
|
+
autoload :Logging, 'aws-sdk-core/plugins/logging'
|
25
|
+
autoload :ParamConverter, 'aws-sdk-core/plugins/param_converter'
|
26
|
+
autoload :ParamValidator, 'aws-sdk-core/plugins/param_validator'
|
27
|
+
autoload :RecursionDetection, 'aws-sdk-core/plugins/recursion_detection'
|
28
|
+
autoload :RegionalEndpoint, 'aws-sdk-core/plugins/regional_endpoint'
|
29
|
+
autoload :RequestCompression, 'aws-sdk-core/plugins/request_compression'
|
30
|
+
autoload :ResponsePaging, 'aws-sdk-core/plugins/response_paging'
|
31
|
+
autoload :RetryErrors, 'aws-sdk-core/plugins/retry_errors'
|
32
|
+
autoload :Sign, 'aws-sdk-core/plugins/sign'
|
33
|
+
autoload :SignatureV4, 'aws-sdk-core/plugins/signature_v4'
|
34
|
+
autoload :StubResponses, 'aws-sdk-core/plugins/stub_responses'
|
35
|
+
autoload :Telemetry, 'aws-sdk-core/plugins/telemetry'
|
36
|
+
autoload :TransferEncoding, 'aws-sdk-core/plugins/transfer_encoding'
|
37
|
+
autoload :UserAgent, 'aws-sdk-core/plugins/user_agent'
|
10
38
|
end
|
11
39
|
end
|
@@ -20,7 +20,7 @@ module Aws
|
|
20
20
|
def apply(http_req, params)
|
21
21
|
@rules.shape.members.each do |name, ref|
|
22
22
|
value = params[name]
|
23
|
-
next if value.nil?
|
23
|
+
next if value.nil?
|
24
24
|
|
25
25
|
case ref.location
|
26
26
|
when 'header' then apply_header_value(http_req.headers, ref, value)
|
@@ -51,7 +51,7 @@ module Aws
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def list(headers, ref, values)
|
54
|
-
return if
|
54
|
+
return if values.nil?
|
55
55
|
|
56
56
|
member_ref = ref.shape.member
|
57
57
|
values = values.collect do |value|
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative 'decoder'
|
3
|
+
require_relative '../cbor'
|
5
4
|
|
6
5
|
module Aws
|
7
|
-
module
|
6
|
+
module RpcV2
|
8
7
|
# Pure Ruby implementation of CBOR encode and decode
|
9
8
|
module CborEngine
|
10
9
|
def self.encode(data)
|
11
|
-
Encoder.new.add(data).bytes
|
10
|
+
Cbor::Encoder.new.add(data).bytes
|
12
11
|
end
|
13
12
|
|
14
13
|
def self.decode(bytes)
|
15
|
-
Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
14
|
+
Cbor::Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -13,11 +13,13 @@ module Aws
|
|
13
13
|
accept =
|
14
14
|
if eventstream_output?(context)
|
15
15
|
'application/vnd.amazon.eventstream'
|
16
|
+
else
|
17
|
+
'application/cbor'
|
16
18
|
end
|
17
19
|
|
18
20
|
headers = context.http_request.headers
|
19
21
|
headers['Content-Type'] ||= content_type if content_type
|
20
|
-
headers['Accept'] ||= accept
|
22
|
+
headers['Accept'] ||= accept
|
21
23
|
@handler.call(context)
|
22
24
|
end
|
23
25
|
|
@@ -27,7 +27,7 @@ module Aws
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def extract_error(body, context)
|
30
|
-
data =
|
30
|
+
data = RpcV2.decode(body)
|
31
31
|
code = error_code(data, context)
|
32
32
|
message = data['message']
|
33
33
|
data = parse_error_data(context, body, code)
|
@@ -39,7 +39,8 @@ module Aws
|
|
39
39
|
def error_code(data, context)
|
40
40
|
code =
|
41
41
|
if aws_query_error?(context)
|
42
|
-
|
42
|
+
query_header = context.http_response.headers['x-amzn-query-error']
|
43
|
+
error, _type = query_header.split(';') # type not supported
|
43
44
|
remove_prefix(error, context)
|
44
45
|
else
|
45
46
|
data['__type']
|
@@ -20,7 +20,8 @@ module Aws
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def build_request(context)
|
23
|
-
context.http_request.headers['
|
23
|
+
context.http_request.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
|
24
|
+
context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
|
24
25
|
context.http_request.http_method = 'POST'
|
25
26
|
context.http_request.body = build_body(context)
|
26
27
|
build_url(context)
|
data/lib/aws-sdk-core/rpc_v2.rb
CHANGED
@@ -1,6 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'cbor'
|
2
|
-
require_relative 'rpc_v2/
|
4
|
+
require_relative 'rpc_v2/builder'
|
3
5
|
require_relative 'rpc_v2/content_type_handler'
|
4
6
|
require_relative 'rpc_v2/error_handler'
|
5
|
-
require_relative 'rpc_v2/
|
7
|
+
require_relative 'rpc_v2/handler'
|
6
8
|
require_relative 'rpc_v2/parser'
|
9
|
+
|
10
|
+
module Aws
|
11
|
+
# @api private
|
12
|
+
module RpcV2
|
13
|
+
class << self
|
14
|
+
# @param [Symbol,Class] engine
|
15
|
+
# Must be one of the following values:
|
16
|
+
#
|
17
|
+
# * :cbor
|
18
|
+
#
|
19
|
+
def engine=(engine)
|
20
|
+
@engine = Class === engine ? engine : load_engine(engine)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Class] Returns the default engine.
|
24
|
+
# One of:
|
25
|
+
#
|
26
|
+
# * {CborEngine}
|
27
|
+
#
|
28
|
+
def engine
|
29
|
+
set_default_engine unless @engine
|
30
|
+
@engine
|
31
|
+
end
|
32
|
+
|
33
|
+
def encode(data)
|
34
|
+
@engine.encode(data)
|
35
|
+
end
|
36
|
+
|
37
|
+
def decode(bytes)
|
38
|
+
bytes.force_encoding(Encoding::BINARY)
|
39
|
+
@engine.decode(bytes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_default_engine
|
43
|
+
[:cbor].each do |name|
|
44
|
+
@engine ||= try_load_engine(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless @engine
|
48
|
+
raise 'Unable to find a compatible cbor library.'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def load_engine(name)
|
55
|
+
require "aws-sdk-core/rpc_v2/#{name}_engine"
|
56
|
+
const_name = name[0].upcase + name[1..-1] + 'Engine'
|
57
|
+
const_get(const_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def try_load_engine(name)
|
61
|
+
load_engine(name)
|
62
|
+
rescue LoadError
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
set_default_engine
|
68
|
+
end
|
69
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class EC2
|
7
8
|
|
8
9
|
def stub_data(api, operation, data)
|
@@ -16,17 +17,17 @@ module Aws
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def stub_error(error_code)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<ErrorResponse>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
</ErrorResponse>
|
20
|
+
resp = Seahorse::Client::Http::Response.new
|
21
|
+
resp.status_code = 400
|
22
|
+
resp.body = <<~XML.strip
|
23
|
+
<ErrorResponse>
|
24
|
+
<Error>
|
25
|
+
<Code>#{error_code}</Code>
|
26
|
+
<Message>stubbed-response-error-message</Message>
|
27
|
+
</Error>
|
28
|
+
</ErrorResponse>
|
28
29
|
XML
|
29
|
-
|
30
|
+
resp
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
@@ -37,7 +38,7 @@ module Aws
|
|
37
38
|
xml.shift
|
38
39
|
xml.pop
|
39
40
|
xmlns = "http://ec2.amazonaws.com/doc/#{api.version}/".inspect
|
40
|
-
xml.unshift(
|
41
|
+
xml.unshift(' <requestId>stubbed-request-id</requestId>')
|
41
42
|
xml.unshift("<#{operation.name}Response xmlns=#{xmlns}>\n")
|
42
43
|
xml.push("</#{operation.name}Response>\n")
|
43
44
|
xml.join
|