aws-sdk-core 3.171.1 → 3.199.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +363 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +4 -4
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
- data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +106 -0
- data/lib/aws-sdk-core/client_stubs.rb +18 -14
- data/lib/aws-sdk-core/credential_provider.rb +4 -1
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +78 -11
- data/lib/aws-sdk-core/endpoints/matchers.rb +18 -10
- data/lib/aws-sdk-core/endpoints.rb +6 -2
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +3 -3
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +15 -10
- data/lib/aws-sdk-core/json/handler.rb +12 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +5 -3
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +109 -33
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +24 -13
- data/lib/aws-sdk-core/plugins/stub_responses.rb +1 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
- data/lib/aws-sdk-core/process_credentials.rb +45 -27
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +12 -12
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +6 -0
- data/lib/aws-sdk-core/shared_config.rb +48 -18
- data/lib/aws-sdk-core/sso_credentials.rb +1 -1
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +4 -2
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +7 -2
- data/lib/aws-sdk-sso/client.rb +94 -46
- data/lib/aws-sdk-sso/endpoint_provider.rb +30 -24
- data/lib/aws-sdk-sso/endpoints.rb +1 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +479 -74
- data/lib/aws-sdk-ssooidc/client_api.rb +78 -1
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +30 -24
- data/lib/aws-sdk-ssooidc/endpoints.rb +15 -0
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +6 -2
- data/lib/aws-sdk-ssooidc/types.rb +372 -51
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +219 -157
- data/lib/aws-sdk-sts/client_api.rb +20 -9
- data/lib/aws-sdk-sts/endpoint_provider.rb +81 -78
- data/lib/aws-sdk-sts/endpoints.rb +1 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +49 -11
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/async_base.rb +1 -1
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -7
- data/lib/seahorse/client/configuration.rb +0 -4
- data/lib/seahorse/client/h2/handler.rb +1 -0
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +3 -9
- data/lib/seahorse/client/net_http/patches.rb +1 -4
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +48 -16
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +3 -0
- data/lib/seahorse/model/shapes.rb +2 -2
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +44 -17
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
|
@@ -167,6 +167,26 @@ module Aws
|
|
|
167
167
|
token
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
# Source a custom configured endpoint from the shared configuration file
|
|
171
|
+
#
|
|
172
|
+
# @param [Hash] opts
|
|
173
|
+
# @option opts [String] :profile
|
|
174
|
+
# @option opts [String] :service_id
|
|
175
|
+
def configured_endpoint(opts = {})
|
|
176
|
+
# services section is only allowed in the shared config file (not credentials)
|
|
177
|
+
profile = opts[:profile] || @profile_name
|
|
178
|
+
service_id = opts[:service_id]&.gsub(" ", "_")&.downcase
|
|
179
|
+
if @parsed_config && (prof_config = @parsed_config[profile])
|
|
180
|
+
services_section_name = prof_config['services']
|
|
181
|
+
if (services_config = @parsed_config["services #{services_section_name}"]) &&
|
|
182
|
+
(service_config = services_config[service_id])
|
|
183
|
+
return service_config['endpoint_url'] if service_config['endpoint_url']
|
|
184
|
+
end
|
|
185
|
+
return prof_config['endpoint_url']
|
|
186
|
+
end
|
|
187
|
+
nil
|
|
188
|
+
end
|
|
189
|
+
|
|
170
190
|
# Add an accessor method (similar to attr_reader) to return a configuration value
|
|
171
191
|
# Uses the get_config_value below to control where
|
|
172
192
|
# values are loaded from
|
|
@@ -185,6 +205,7 @@ module Aws
|
|
|
185
205
|
:use_fips_endpoint,
|
|
186
206
|
:ec2_metadata_service_endpoint,
|
|
187
207
|
:ec2_metadata_service_endpoint_mode,
|
|
208
|
+
:ec2_metadata_v1_disabled,
|
|
188
209
|
:max_attempts,
|
|
189
210
|
:retry_mode,
|
|
190
211
|
:adaptive_retry_wait_to_fill,
|
|
@@ -197,7 +218,12 @@ module Aws
|
|
|
197
218
|
:s3_use_arn_region,
|
|
198
219
|
:s3_us_east_1_regional_endpoint,
|
|
199
220
|
:s3_disable_multiregion_access_points,
|
|
200
|
-
:
|
|
221
|
+
:s3_disable_express_session_auth,
|
|
222
|
+
:defaults_mode,
|
|
223
|
+
:sdk_ua_app_id,
|
|
224
|
+
:disable_request_compression,
|
|
225
|
+
:request_min_compression_size_bytes,
|
|
226
|
+
:ignore_configured_endpoint_urls
|
|
201
227
|
)
|
|
202
228
|
|
|
203
229
|
private
|
|
@@ -335,12 +361,8 @@ module Aws
|
|
|
335
361
|
!(prof_config.keys & SSO_CREDENTIAL_PROFILE_KEYS).empty?
|
|
336
362
|
|
|
337
363
|
if sso_session_name = prof_config['sso_session']
|
|
338
|
-
sso_session = cfg
|
|
339
|
-
|
|
340
|
-
raise ArgumentError,
|
|
341
|
-
"sso-session #{sso_session_name} must be defined in the config file. " \
|
|
342
|
-
"Referenced by profile #{profile}"
|
|
343
|
-
end
|
|
364
|
+
sso_session = sso_session(cfg, profile, sso_session_name)
|
|
365
|
+
|
|
344
366
|
sso_region = sso_session['sso_region']
|
|
345
367
|
sso_start_url = sso_session['sso_start_url']
|
|
346
368
|
|
|
@@ -365,7 +387,7 @@ module Aws
|
|
|
365
387
|
sso_role_name: prof_config['sso_role_name'],
|
|
366
388
|
sso_session: prof_config['sso_session'],
|
|
367
389
|
sso_region: sso_region,
|
|
368
|
-
sso_start_url:
|
|
390
|
+
sso_start_url: sso_start_url
|
|
369
391
|
)
|
|
370
392
|
end
|
|
371
393
|
end
|
|
@@ -378,16 +400,7 @@ module Aws
|
|
|
378
400
|
!(prof_config.keys & SSO_TOKEN_PROFILE_KEYS).empty?
|
|
379
401
|
|
|
380
402
|
sso_session_name = prof_config['sso_session']
|
|
381
|
-
sso_session = cfg
|
|
382
|
-
unless sso_session
|
|
383
|
-
raise ArgumentError,
|
|
384
|
-
"sso-session #{sso_session_name} must be defined in the config file." \
|
|
385
|
-
"Referenced by profile #{profile}"
|
|
386
|
-
end
|
|
387
|
-
|
|
388
|
-
unless sso_session['sso_region']
|
|
389
|
-
raise ArgumentError, "sso-session #{sso_session_name} missing required parameter: sso_region"
|
|
390
|
-
end
|
|
403
|
+
sso_session = sso_session(cfg, profile, sso_session_name)
|
|
391
404
|
|
|
392
405
|
SSOTokenProvider.new(
|
|
393
406
|
sso_session: sso_session_name,
|
|
@@ -445,5 +458,22 @@ module Aws
|
|
|
445
458
|
ret ||= 'default'
|
|
446
459
|
ret
|
|
447
460
|
end
|
|
461
|
+
|
|
462
|
+
def sso_session(cfg, profile, sso_session_name)
|
|
463
|
+
# aws sso-configure may add quotes around sso session names with whitespace
|
|
464
|
+
sso_session = cfg["sso-session #{sso_session_name}"] || cfg["sso-session '#{sso_session_name}'"]
|
|
465
|
+
|
|
466
|
+
unless sso_session
|
|
467
|
+
raise ArgumentError,
|
|
468
|
+
"sso-session #{sso_session_name} must be defined in the config file. " \
|
|
469
|
+
"Referenced by profile #{profile}"
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
unless sso_session['sso_region']
|
|
473
|
+
raise ArgumentError, "sso-session #{sso_session_name} missing required parameter: sso_region"
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
sso_session
|
|
477
|
+
end
|
|
448
478
|
end
|
|
449
479
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aws
|
|
4
|
+
module Stubbing
|
|
5
|
+
module Protocols
|
|
6
|
+
class RpcV2
|
|
7
|
+
|
|
8
|
+
def stub_data(api, operation, data)
|
|
9
|
+
resp = Seahorse::Client::Http::Response.new
|
|
10
|
+
resp.status_code = 200
|
|
11
|
+
resp.headers['Content-Type'] = content_type(api)
|
|
12
|
+
resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
|
|
13
|
+
resp.body = build_body(operation, data)
|
|
14
|
+
resp
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def stub_error(error_code)
|
|
18
|
+
http_resp = Seahorse::Client::Http::Response.new
|
|
19
|
+
http_resp.status_code = 400
|
|
20
|
+
http_resp.body = <<-JSON.strip
|
|
21
|
+
{
|
|
22
|
+
"code": #{error_code.inspect},
|
|
23
|
+
"message": "stubbed-response-error-message"
|
|
24
|
+
}
|
|
25
|
+
JSON
|
|
26
|
+
http_resp
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def content_type(api)
|
|
32
|
+
'application/cbor'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def build_body(operation, data)
|
|
36
|
+
Aws::RpcV2::Builder.new(operation.output).serialize(data)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -13,12 +13,23 @@ module Aws
|
|
|
13
13
|
def stub(data = {})
|
|
14
14
|
stub = EmptyStub.new(@rules).stub
|
|
15
15
|
remove_paging_tokens(stub)
|
|
16
|
+
remove_checksums(stub)
|
|
16
17
|
apply_data(data, stub)
|
|
17
18
|
stub
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
private
|
|
21
22
|
|
|
23
|
+
def remove_checksums(stub)
|
|
24
|
+
if @rules && @rules.shape.is_a?(Seahorse::Model::Shapes::StructureShape)
|
|
25
|
+
@rules.shape.members.each do |key, member|
|
|
26
|
+
if member.location == 'header' && member.location_name.start_with?('x-amz-checksum-')
|
|
27
|
+
stub[key] = nil
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
22
33
|
def remove_paging_tokens(stub)
|
|
23
34
|
if @pager
|
|
24
35
|
@pager.instance_variable_get("@tokens").keys.each do |path|
|
data/lib/aws-sdk-core/util.rb
CHANGED
|
@@ -67,6 +67,45 @@ module Aws
|
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# @param [Number] input
|
|
71
|
+
# @return [Number, String] The serialized number
|
|
72
|
+
def serialize_number(input)
|
|
73
|
+
if input == ::Float::INFINITY then 'Infinity'
|
|
74
|
+
elsif input == -::Float::INFINITY then '-Infinity'
|
|
75
|
+
elsif input&.nan? then 'NaN'
|
|
76
|
+
else
|
|
77
|
+
input
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @param [String] str
|
|
82
|
+
# @return [Number] The input as a number
|
|
83
|
+
def deserialize_number(str)
|
|
84
|
+
case str
|
|
85
|
+
when 'Infinity' then ::Float::INFINITY
|
|
86
|
+
when '-Infinity' then -::Float::INFINITY
|
|
87
|
+
when 'NaN' then ::Float::NAN
|
|
88
|
+
when nil then nil
|
|
89
|
+
else str.to_f
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @param [String] value
|
|
94
|
+
# @return [Time]
|
|
95
|
+
def deserialize_time(value)
|
|
96
|
+
case value
|
|
97
|
+
when nil then nil
|
|
98
|
+
when /^[\d.]+$/ then Time.at(value.to_f).utc
|
|
99
|
+
else
|
|
100
|
+
begin
|
|
101
|
+
fractional_time = Time.parse(value).to_f
|
|
102
|
+
Time.at(fractional_time).utc
|
|
103
|
+
rescue ArgumentError
|
|
104
|
+
raise "unhandled timestamp format `#{value}'"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
70
109
|
end
|
|
71
110
|
end
|
|
72
111
|
end
|
|
@@ -62,7 +62,9 @@ module Aws
|
|
|
62
62
|
def send_request(options)
|
|
63
63
|
req = options[:client].build_request(@operation_name, options[:params])
|
|
64
64
|
req.handlers.remove(RAISE_HANDLER)
|
|
65
|
-
|
|
65
|
+
Aws::Plugins::UserAgent.metric('WAITER') do
|
|
66
|
+
req.send_request
|
|
67
|
+
end
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def acceptor_matches?(acceptor, response)
|
|
@@ -95,7 +97,7 @@ module Aws
|
|
|
95
97
|
|
|
96
98
|
def matches_error?(acceptor, response)
|
|
97
99
|
Aws::Errors::ServiceError === response.error &&
|
|
98
|
-
response.error.code == acceptor['expected'].
|
|
100
|
+
response.error.code == acceptor['expected'].delete('.')
|
|
99
101
|
end
|
|
100
102
|
|
|
101
103
|
def path(acceptor)
|
|
@@ -10,6 +10,8 @@ module Aws
|
|
|
10
10
|
|
|
11
11
|
def initialize(rules, options = {})
|
|
12
12
|
@rules = rules
|
|
13
|
+
@location_name =
|
|
14
|
+
options[:location_name].nil? ? @rules.location_name : options[:location_name]
|
|
13
15
|
@xml = options[:target] || []
|
|
14
16
|
indent = options[:indent] || ''
|
|
15
17
|
pad = options[:pad] || ''
|
|
@@ -17,7 +19,7 @@ module Aws
|
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def to_xml(params)
|
|
20
|
-
structure(@
|
|
22
|
+
structure(@location_name, @rules, params)
|
|
21
23
|
@xml.join
|
|
22
24
|
end
|
|
23
25
|
alias serialize to_xml
|
|
@@ -50,7 +52,7 @@ module Aws
|
|
|
50
52
|
def list(name, ref, values)
|
|
51
53
|
if ref[:flattened] || ref.shape.flattened
|
|
52
54
|
values.each do |value|
|
|
53
|
-
member(
|
|
55
|
+
member(name, ref.shape.member, value)
|
|
54
56
|
end
|
|
55
57
|
else
|
|
56
58
|
node(name, ref) do
|
|
@@ -65,7 +67,7 @@ module Aws
|
|
|
65
67
|
def map(name, ref, hash)
|
|
66
68
|
key_ref = ref.shape.key
|
|
67
69
|
value_ref = ref.shape.value
|
|
68
|
-
if ref.shape.flattened
|
|
70
|
+
if ref[:flattened] || ref.shape.flattened
|
|
69
71
|
hash.each do |key, value|
|
|
70
72
|
node(name, ref) do
|
|
71
73
|
member(key_ref.location_name || 'key', key_ref, key)
|
|
@@ -75,7 +77,8 @@ module Aws
|
|
|
75
77
|
else
|
|
76
78
|
node(name, ref) do
|
|
77
79
|
hash.each do |key, value|
|
|
78
|
-
|
|
80
|
+
# Pass in a new ShapeRef to create an entry node
|
|
81
|
+
node('entry', ShapeRef.new) do
|
|
79
82
|
member(key_ref.location_name || 'key', key_ref, key)
|
|
80
83
|
member(value_ref.location_name || 'value', value_ref, value)
|
|
81
84
|
end
|
|
@@ -129,11 +132,16 @@ module Aws
|
|
|
129
132
|
end
|
|
130
133
|
|
|
131
134
|
def shape_attrs(ref)
|
|
132
|
-
if xmlns = ref['xmlNamespace']
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
if (xmlns = ref['xmlNamespace'])
|
|
136
|
+
case xmlns
|
|
137
|
+
when String
|
|
138
|
+
{ 'xmlns' => xmlns }
|
|
139
|
+
when Hash
|
|
140
|
+
if (prefix = xmlns['prefix'])
|
|
141
|
+
{ "xmlns:#{prefix}" => xmlns['uri'] }
|
|
142
|
+
else
|
|
143
|
+
{ 'xmlns' => xmlns['uri'] }
|
|
144
|
+
end
|
|
137
145
|
end
|
|
138
146
|
else
|
|
139
147
|
{}
|
|
@@ -4,7 +4,7 @@ require 'cgi'
|
|
|
4
4
|
|
|
5
5
|
module Aws
|
|
6
6
|
module Xml
|
|
7
|
-
class ErrorHandler <
|
|
7
|
+
class ErrorHandler < Aws::ErrorHandler
|
|
8
8
|
|
|
9
9
|
def call(context)
|
|
10
10
|
@handler.call(context).on(300..599) do |response|
|
|
@@ -15,42 +15,29 @@ module Aws
|
|
|
15
15
|
|
|
16
16
|
private
|
|
17
17
|
|
|
18
|
-
def error(context)
|
|
19
|
-
body = context.http_response.body_contents
|
|
20
|
-
if body.empty?
|
|
21
|
-
code = http_status_error_code(context)
|
|
22
|
-
message = ''
|
|
23
|
-
data = EmptyStructure.new
|
|
24
|
-
else
|
|
25
|
-
code, message, data = extract_error(body, context)
|
|
26
|
-
end
|
|
27
|
-
context[:request_id] = request_id(body)
|
|
28
|
-
errors_module = context.client.class.errors_module
|
|
29
|
-
error_class = errors_module.error_class(code).new(context, message, data)
|
|
30
|
-
error_class
|
|
31
|
-
end
|
|
32
|
-
|
|
33
18
|
def extract_error(body, context)
|
|
19
|
+
context[:request_id] = request_id(body)
|
|
34
20
|
code = error_code(body, context)
|
|
35
21
|
[
|
|
36
22
|
code,
|
|
37
23
|
error_message(body),
|
|
38
|
-
error_data(context, code)
|
|
24
|
+
error_data(context, body, code)
|
|
39
25
|
]
|
|
40
26
|
end
|
|
41
27
|
|
|
42
|
-
def error_data(context, code)
|
|
28
|
+
def error_data(context, body, code)
|
|
43
29
|
data = EmptyStructure.new
|
|
44
|
-
if error_rules = context.operation.errors
|
|
30
|
+
if (error_rules = context.operation.errors)
|
|
45
31
|
error_rules.each do |rule|
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
# match modeled shape name
|
|
32
|
+
# query protocol may have custom error code
|
|
33
|
+
# reference: https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#error-code-resolution
|
|
49
34
|
error_shape_code = rule.shape['error']['code'] if rule.shape['error']
|
|
50
35
|
match = (code == error_shape_code || code == rule.shape.name)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
next unless match && rule.shape.members.any?
|
|
37
|
+
|
|
38
|
+
data = parse_error_data(rule, body)
|
|
39
|
+
# supporting HTTP bindings
|
|
40
|
+
apply_error_headers(rule, context, data)
|
|
54
41
|
end
|
|
55
42
|
end
|
|
56
43
|
data
|
|
@@ -58,29 +45,32 @@ module Aws
|
|
|
58
45
|
EmptyStructure.new
|
|
59
46
|
end
|
|
60
47
|
|
|
48
|
+
def parse_error_data(rule, body)
|
|
49
|
+
# errors may nested under <Errors><Error>structure_data</Error></Errors>
|
|
50
|
+
# Or may be flat and under <Error>structure_data</Error>
|
|
51
|
+
body = body.tr("\n", '')
|
|
52
|
+
if (matches = body.match(/<Error>(.+?)<\/Error>/))
|
|
53
|
+
Parser.new(rule).parse("<#{rule.shape.name}>#{matches[1]}</#{rule.shape.name}>")
|
|
54
|
+
else
|
|
55
|
+
EmptyStructure.new
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def apply_error_headers(rule, context, data)
|
|
60
|
+
headers = Aws::Rest::Response::Headers.new(rule)
|
|
61
|
+
headers.apply(context.http_response, data)
|
|
62
|
+
end
|
|
63
|
+
|
|
61
64
|
def error_code(body, context)
|
|
62
|
-
if matches = body.match(/<Code>(.+?)<\/Code>/)
|
|
65
|
+
if (matches = body.match(/<Code>(.+?)<\/Code>/))
|
|
63
66
|
remove_prefix(unescape(matches[1]), context)
|
|
64
67
|
else
|
|
65
68
|
http_status_error_code(context)
|
|
66
69
|
end
|
|
67
70
|
end
|
|
68
71
|
|
|
69
|
-
def http_status_error_code(context)
|
|
70
|
-
status_code = context.http_response.status_code
|
|
71
|
-
{
|
|
72
|
-
302 => 'MovedTemporarily',
|
|
73
|
-
304 => 'NotModified',
|
|
74
|
-
400 => 'BadRequest',
|
|
75
|
-
403 => 'Forbidden',
|
|
76
|
-
404 => 'NotFound',
|
|
77
|
-
412 => 'PreconditionFailed',
|
|
78
|
-
413 => 'RequestEntityTooLarge',
|
|
79
|
-
}[status_code] || "Http#{status_code}Error"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
72
|
def remove_prefix(error_code, context)
|
|
83
|
-
if prefix = context.config.api.metadata['errorPrefix']
|
|
73
|
+
if (prefix = context.config.api.metadata['errorPrefix'])
|
|
84
74
|
error_code.sub(/^#{prefix}/, '')
|
|
85
75
|
else
|
|
86
76
|
error_code
|
|
@@ -88,7 +78,7 @@ module Aws
|
|
|
88
78
|
end
|
|
89
79
|
|
|
90
80
|
def error_message(body)
|
|
91
|
-
if matches = body.match(/<Message>(.+?)<\/Message>/m)
|
|
81
|
+
if (matches = body.match(/<Message>(.+?)<\/Message>/m))
|
|
92
82
|
unescape(matches[1])
|
|
93
83
|
else
|
|
94
84
|
''
|
|
@@ -96,7 +86,7 @@ module Aws
|
|
|
96
86
|
end
|
|
97
87
|
|
|
98
88
|
def request_id(body)
|
|
99
|
-
if matches = body.match(/<RequestId>(.+?)<\/RequestId>/m)
|
|
89
|
+
if (matches = body.match(/<RequestId>(.+?)<\/RequestId>/m))
|
|
100
90
|
matches[1]
|
|
101
91
|
end
|
|
102
92
|
end
|
|
@@ -138,11 +138,7 @@ module Aws
|
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
def xml_name(ref)
|
|
141
|
-
|
|
142
|
-
ref.shape.member.location_name || ref.location_name
|
|
143
|
-
else
|
|
144
|
-
ref.location_name
|
|
145
|
-
end
|
|
141
|
+
ref.location_name
|
|
146
142
|
end
|
|
147
143
|
|
|
148
144
|
def flattened_list?(ref)
|
|
@@ -266,7 +262,7 @@ module Aws
|
|
|
266
262
|
|
|
267
263
|
class BlobFrame < Frame
|
|
268
264
|
def result
|
|
269
|
-
@text.empty? ?
|
|
265
|
+
@text.empty? ? '' : Base64.decode64(@text.join)
|
|
270
266
|
end
|
|
271
267
|
end
|
|
272
268
|
|
|
@@ -278,7 +274,7 @@ module Aws
|
|
|
278
274
|
|
|
279
275
|
class FloatFrame < Frame
|
|
280
276
|
def result
|
|
281
|
-
@text.empty? ? nil : @text.join
|
|
277
|
+
@text.empty? ? nil : Aws::Util.deserialize_number(@text.join)
|
|
282
278
|
end
|
|
283
279
|
end
|
|
284
280
|
|
|
@@ -296,19 +292,7 @@ module Aws
|
|
|
296
292
|
|
|
297
293
|
class TimestampFrame < Frame
|
|
298
294
|
def result
|
|
299
|
-
@text.empty? ? nil :
|
|
300
|
-
end
|
|
301
|
-
def parse(value)
|
|
302
|
-
case value
|
|
303
|
-
when nil then nil
|
|
304
|
-
when /^\d+$/ then Time.at(value.to_i)
|
|
305
|
-
else
|
|
306
|
-
begin
|
|
307
|
-
Time.parse(value).utc
|
|
308
|
-
rescue ArgumentError
|
|
309
|
-
raise "unhandled timestamp format `#{value}'"
|
|
310
|
-
end
|
|
311
|
-
end
|
|
295
|
+
@text.empty? ? nil : Aws::Util.deserialize_time(@text.join)
|
|
312
296
|
end
|
|
313
297
|
end
|
|
314
298
|
|
|
@@ -24,6 +24,8 @@ module Aws
|
|
|
24
24
|
if name.to_s == 'encoding' && value.to_s == 'base64'
|
|
25
25
|
@frame = BlobFrame.new(name, @frame.parent, @frame.ref)
|
|
26
26
|
else
|
|
27
|
+
# don't try to parse shapes from xml namespace
|
|
28
|
+
return if name.to_s == 'xmlns'
|
|
27
29
|
start_element(name)
|
|
28
30
|
text(value)
|
|
29
31
|
end_element(name)
|
|
@@ -5,7 +5,6 @@ module Aws
|
|
|
5
5
|
module Xml
|
|
6
6
|
# A SAX-style XML parser that uses a shape context to handle types.
|
|
7
7
|
class Parser
|
|
8
|
-
|
|
9
8
|
# @param [Seahorse::Model::ShapeRef] rules
|
|
10
9
|
def initialize(rules, options = {})
|
|
11
10
|
@rules = rules
|
|
@@ -47,8 +46,7 @@ module Aws
|
|
|
47
46
|
# * :libxml
|
|
48
47
|
# * :nokogiri
|
|
49
48
|
# * :rexml
|
|
50
|
-
|
|
51
|
-
def engine= engine
|
|
49
|
+
def engine=(engine)
|
|
52
50
|
@engine = Class === engine ? engine : load_engine(engine)
|
|
53
51
|
end
|
|
54
52
|
|
|
@@ -60,7 +58,6 @@ module Aws
|
|
|
60
58
|
# * {LibxmlEngine}
|
|
61
59
|
# * {NokogiriEngine}
|
|
62
60
|
# * {RexmlEngine}
|
|
63
|
-
#
|
|
64
61
|
def engine
|
|
65
62
|
set_default_engine unless @engine
|
|
66
63
|
@engine
|
|
@@ -80,7 +77,7 @@ module Aws
|
|
|
80
77
|
private
|
|
81
78
|
|
|
82
79
|
def load_engine(name)
|
|
83
|
-
require "aws-sdk-core/xml/parser
|
|
80
|
+
require "aws-sdk-core/xml/parser/#{name}_engine"
|
|
84
81
|
const_name = name[0].upcase + name[1..-1] + 'Engine'
|
|
85
82
|
const_get(const_name)
|
|
86
83
|
end
|
|
@@ -94,7 +91,6 @@ module Aws
|
|
|
94
91
|
end
|
|
95
92
|
|
|
96
93
|
set_default_engine
|
|
97
|
-
|
|
98
94
|
end
|
|
99
95
|
end
|
|
100
96
|
end
|
data/lib/aws-sdk-core.rb
CHANGED
|
@@ -63,19 +63,23 @@ require_relative 'aws-sdk-core/stubbing/xml_error'
|
|
|
63
63
|
|
|
64
64
|
# stubbing protocols
|
|
65
65
|
|
|
66
|
-
require_relative 'aws-sdk-core/stubbing/protocols/ec2'
|
|
67
66
|
require_relative 'aws-sdk-core/stubbing/protocols/json'
|
|
68
|
-
require_relative 'aws-sdk-core/stubbing/protocols/query'
|
|
69
67
|
require_relative 'aws-sdk-core/stubbing/protocols/rest'
|
|
70
68
|
require_relative 'aws-sdk-core/stubbing/protocols/rest_json'
|
|
71
69
|
require_relative 'aws-sdk-core/stubbing/protocols/rest_xml'
|
|
70
|
+
require_relative 'aws-sdk-core/stubbing/protocols/query'
|
|
71
|
+
require_relative 'aws-sdk-core/stubbing/protocols/ec2'
|
|
72
|
+
require_relative 'aws-sdk-core/stubbing/protocols/rpc_v2'
|
|
72
73
|
require_relative 'aws-sdk-core/stubbing/protocols/api_gateway'
|
|
73
74
|
|
|
74
75
|
# protocols
|
|
75
76
|
|
|
77
|
+
require_relative 'aws-sdk-core/error_handler'
|
|
76
78
|
require_relative 'aws-sdk-core/rest'
|
|
77
79
|
require_relative 'aws-sdk-core/xml'
|
|
78
80
|
require_relative 'aws-sdk-core/json'
|
|
81
|
+
require_relative 'aws-sdk-core/query'
|
|
82
|
+
require_relative 'aws-sdk-core/rpc_v2'
|
|
79
83
|
|
|
80
84
|
# event stream
|
|
81
85
|
|
|
@@ -96,6 +100,7 @@ require_relative 'aws-sdk-core/client_side_monitoring/publisher'
|
|
|
96
100
|
require_relative 'aws-sdk-core/arn'
|
|
97
101
|
require_relative 'aws-sdk-core/arn_parser'
|
|
98
102
|
require_relative 'aws-sdk-core/ec2_metadata'
|
|
103
|
+
require_relative 'aws-sdk-core/lru_cache'
|
|
99
104
|
|
|
100
105
|
# dynamic endpoints
|
|
101
106
|
require_relative 'aws-sdk-core/endpoints'
|