aws-sdk-core 3.117.0 → 3.197.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +836 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +13 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +21 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -10
- data/lib/aws-sdk-core/binary/decode_handler.rb +0 -5
- data/lib/aws-sdk-core/binary/encode_handler.rb +12 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/client_stubs.rb +20 -13
- data/lib/aws-sdk-core/credential_provider.rb +4 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
- data/lib/aws-sdk-core/ec2_metadata.rb +4 -3
- data/lib/aws-sdk-core/ecs_credentials.rb +187 -52
- data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
- data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
- data/lib/aws-sdk-core/endpoints/function.rb +80 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +135 -0
- data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
- data/lib/aws-sdk-core/endpoints/url.rb +60 -0
- data/lib/aws-sdk-core/endpoints.rb +78 -0
- data/lib/aws-sdk-core/errors.rb +17 -4
- 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 +127 -33
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +30 -4
- data/lib/aws-sdk-core/json/handler.rb +8 -1
- data/lib/aws-sdk-core/json/json_engine.rb +10 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +33 -6
- data/lib/aws-sdk-core/json/parser.rb +38 -2
- data/lib/aws-sdk-core/json.rb +8 -26
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/log/param_filter.rb +9 -1
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +81 -32
- data/lib/aws-sdk-core/param_validator.rb +36 -2
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +342 -0
- 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 +29 -1
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
- data/lib/aws-sdk-core/plugins/http_checksum.rb +9 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +34 -6
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +17 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -2
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +144 -17
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +1 -1
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +7 -4
- data/lib/aws-sdk-core/plugins/retry_errors.rb +33 -7
- data/lib/aws-sdk-core/plugins/sign.rb +211 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +1 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +28 -31
- data/lib/aws-sdk-core/plugins/stub_responses.rb +6 -1
- data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
- data/lib/aws-sdk-core/process_credentials.rb +50 -34
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/refreshing_credentials.rb +49 -18
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/rest/handler.rb +1 -1
- data/lib/aws-sdk-core/rest/request/body.rb +49 -4
- data/lib/aws-sdk-core/rest/request/content_type.rb +60 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +23 -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 +10 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/shared_config.rb +112 -12
- data/lib/aws-sdk-core/sso_credentials.rb +92 -51
- data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
- data/lib/aws-sdk-core/static_token_provider.rb +14 -0
- data/lib/aws-sdk-core/structure.rb +16 -5
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/token.rb +31 -0
- data/lib/aws-sdk-core/token_provider.rb +15 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +51 -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 +31 -8
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +1 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +0 -8
- data/lib/aws-sdk-core/xml/parser/frame.rb +27 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core.rb +21 -0
- data/lib/aws-sdk-sso/client.rb +157 -50
- data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-sso/endpoints.rb +72 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-sso/types.rb +8 -43
- data/lib/aws-sdk-sso.rb +5 -1
- data/lib/aws-sdk-ssooidc/client.rb +1008 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +293 -0
- data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
- data/lib/aws-sdk-ssooidc/errors.rb +342 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +823 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +472 -398
- data/lib/aws-sdk-sts/client_api.rb +20 -9
- data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
- data/lib/aws-sdk-sts/endpoints.rb +136 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +5 -1
- data/lib/aws-sdk-sts/presigner.rb +14 -10
- data/lib/aws-sdk-sts/types.rb +168 -227
- data/lib/aws-sdk-sts.rb +5 -1
- data/lib/seahorse/client/async_base.rb +1 -2
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +1 -0
- data/lib/seahorse/client/configuration.rb +5 -5
- data/lib/seahorse/client/h2/connection.rb +15 -16
- data/lib/seahorse/client/h2/handler.rb +5 -5
- data/lib/seahorse/client/net_http/connection_pool.rb +10 -9
- data/lib/seahorse/client/net_http/handler.rb +15 -7
- data/lib/seahorse/client/net_http/patches.rb +12 -86
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/content_length.rb +11 -5
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +73 -10
- data/lib/seahorse/client/plugins/request_callback.rb +40 -9
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +6 -0
- data/lib/seahorse/model/shapes.rb +27 -2
- data/lib/seahorse/util.rb +4 -0
- 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 +82 -17
- data/lib/aws-sdk-sso/plugins/content_type.rb +0 -25
@@ -28,18 +28,20 @@ module Aws
|
|
28
28
|
# in stdlib Struct.
|
29
29
|
#
|
30
30
|
# @return [Hash]
|
31
|
-
def to_h(obj = self)
|
31
|
+
def to_h(obj = self, options = {})
|
32
32
|
case obj
|
33
33
|
when Struct
|
34
34
|
obj.each_pair.with_object({}) do |(member, value), hash|
|
35
|
-
|
35
|
+
member = member.to_s if options[:as_json]
|
36
|
+
hash[member] = to_hash(value, options) unless value.nil?
|
36
37
|
end
|
37
38
|
when Hash
|
38
39
|
obj.each.with_object({}) do |(key, value), hash|
|
39
|
-
|
40
|
+
key = key.to_s if options[:as_json]
|
41
|
+
hash[key] = to_hash(value, options)
|
40
42
|
end
|
41
43
|
when Array
|
42
|
-
obj.collect { |value| to_hash(value) }
|
44
|
+
obj.collect { |value| to_hash(value, options) }
|
43
45
|
else
|
44
46
|
obj
|
45
47
|
end
|
@@ -70,11 +72,20 @@ module Aws
|
|
70
72
|
end
|
71
73
|
|
72
74
|
end
|
75
|
+
|
76
|
+
module Union
|
77
|
+
def member
|
78
|
+
self.members.select { |k| self[k] != nil }.first
|
79
|
+
end
|
80
|
+
|
81
|
+
def value
|
82
|
+
self[member] if member
|
83
|
+
end
|
84
|
+
end
|
73
85
|
end
|
74
86
|
|
75
87
|
# @api private
|
76
88
|
class EmptyStructure < Struct.new('AwsEmptyStructure')
|
77
89
|
include(Aws::Structure)
|
78
90
|
end
|
79
|
-
|
80
91
|
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|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
class Token
|
5
|
+
|
6
|
+
# @param [String] token
|
7
|
+
# @param [Time] expiration
|
8
|
+
def initialize(token, expiration=nil)
|
9
|
+
@token = token
|
10
|
+
@expiration = expiration
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String, nil]
|
14
|
+
attr_reader :token
|
15
|
+
|
16
|
+
# @return [Time, nil]
|
17
|
+
attr_reader :expiration
|
18
|
+
|
19
|
+
# @return [Boolean] Returns `true` if token is set
|
20
|
+
def set?
|
21
|
+
!token.nil? && !token.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
# Removing the token from the default inspect string.
|
25
|
+
# @api private
|
26
|
+
def inspect
|
27
|
+
"#<#{self.class.name} token=[FILTERED]> expiration=#{expiration}>"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
# @api private
|
5
|
+
class TokenProviderChain
|
6
|
+
def initialize(config = nil)
|
7
|
+
@config = config
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [TokenProvider, nil]
|
11
|
+
def resolve
|
12
|
+
providers.each do |method_name, options|
|
13
|
+
provider = send(method_name, options.merge(config: @config))
|
14
|
+
return provider if provider && provider.set?
|
15
|
+
end
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def providers
|
22
|
+
[
|
23
|
+
[:static_profile_sso_token, {}],
|
24
|
+
[:sso_token, {}]
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def static_profile_sso_token(options)
|
29
|
+
if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
|
30
|
+
Aws.shared_config.sso_token_from_config(
|
31
|
+
profile: options[:config].profile
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def sso_token(options)
|
38
|
+
profile_name = determine_profile_name(options)
|
39
|
+
if Aws.shared_config.config_enabled?
|
40
|
+
Aws.shared_config.sso_token_from_config(profile: profile_name)
|
41
|
+
end
|
42
|
+
rescue Errors::NoSuchProfileError
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def determine_profile_name(options)
|
47
|
+
(options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
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
|
{}
|
@@ -24,9 +24,9 @@ module Aws
|
|
24
24
|
else
|
25
25
|
code, message, data = extract_error(body, context)
|
26
26
|
end
|
27
|
+
context[:request_id] = request_id(body)
|
27
28
|
errors_module = context.client.class.errors_module
|
28
|
-
|
29
|
-
error_class
|
29
|
+
errors_module.error_class(code).new(context, message, data)
|
30
30
|
end
|
31
31
|
|
32
32
|
def extract_error(body, context)
|
@@ -42,14 +42,15 @@ module Aws
|
|
42
42
|
data = EmptyStructure.new
|
43
43
|
if error_rules = context.operation.errors
|
44
44
|
error_rules.each do |rule|
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# match modeled shape name
|
45
|
+
# query protocol may have custom error code
|
46
|
+
# reference: https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#error-code-resolution
|
48
47
|
error_shape_code = rule.shape['error']['code'] if rule.shape['error']
|
49
48
|
match = (code == error_shape_code || code == rule.shape.name)
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
next unless match && rule.shape.members.any?
|
50
|
+
|
51
|
+
data = parse_error_data(rule, context.http_response.body_contents)
|
52
|
+
# supporting HTTP bindings
|
53
|
+
apply_error_headers(rule, context, data)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
data
|
@@ -57,6 +58,22 @@ module Aws
|
|
57
58
|
EmptyStructure.new
|
58
59
|
end
|
59
60
|
|
61
|
+
def parse_error_data(rule, body)
|
62
|
+
# errors may nested under <Errors><Error>structure_data</Error></Errors>
|
63
|
+
# Or may be flat and under <Error>structure_data</Error>
|
64
|
+
body = body.tr("\n", '')
|
65
|
+
if matches = body.match(/<Error>(.+?)<\/Error>/)
|
66
|
+
Parser.new(rule).parse("<#{rule.shape.name}>#{matches[1]}</#{rule.shape.name}>")
|
67
|
+
else
|
68
|
+
EmptyStructure.new
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def apply_error_headers(rule, context, data)
|
73
|
+
headers = Aws::Rest::Response::Headers.new(rule)
|
74
|
+
headers.apply(context.http_response, data)
|
75
|
+
end
|
76
|
+
|
60
77
|
def error_code(body, context)
|
61
78
|
if matches = body.match(/<Code>(.+?)<\/Code>/)
|
62
79
|
remove_prefix(unescape(matches[1]), context)
|
@@ -94,6 +111,12 @@ module Aws
|
|
94
111
|
end
|
95
112
|
end
|
96
113
|
|
114
|
+
def request_id(body)
|
115
|
+
if matches = body.match(/<RequestId>(.+?)<\/RequestId>/m)
|
116
|
+
matches[1]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
97
120
|
def unescape(str)
|
98
121
|
CGI.unescapeHTML(str)
|
99
122
|
end
|
@@ -1,16 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
use_system_rexml = ((RUBY_VERSION <=> "2.0.0") < 0)
|
4
|
-
if use_system_rexml
|
5
|
-
require "rbconfig"
|
6
|
-
$LOAD_PATH.unshift(RbConfig::CONFIG["rubylibdir"])
|
7
|
-
end
|
8
|
-
|
9
3
|
require 'rexml/document'
|
10
4
|
require 'rexml/streamlistener'
|
11
5
|
|
12
|
-
$LOAD_PATH.shift if use_system_rexml
|
13
|
-
|
14
6
|
module Aws
|
15
7
|
module Xml
|
16
8
|
class Parser
|
@@ -95,6 +95,8 @@ module Aws
|
|
95
95
|
def child_frame(xml_name)
|
96
96
|
if @member = @members[xml_name]
|
97
97
|
Frame.new(xml_name, self, @member[:ref])
|
98
|
+
elsif @ref.shape.union
|
99
|
+
UnknownMemberFrame.new(xml_name, self, nil, @result)
|
98
100
|
else
|
99
101
|
NullFrame.new(xml_name, self)
|
100
102
|
end
|
@@ -106,10 +108,24 @@ module Aws
|
|
106
108
|
@result[@member[:name]][child.key.result] = child.value.result
|
107
109
|
when FlatListFrame
|
108
110
|
@result[@member[:name]] << child.result
|
111
|
+
when UnknownMemberFrame
|
112
|
+
@result[:unknown] = { 'name' => child.path.last, 'value' => child.result }
|
109
113
|
when NullFrame
|
110
114
|
else
|
111
115
|
@result[@member[:name]] = child.result
|
112
116
|
end
|
117
|
+
|
118
|
+
if @ref.shape.union
|
119
|
+
# a union may only have one member set
|
120
|
+
# convert to the union subclass
|
121
|
+
# The default Struct created will have defaults set for all values
|
122
|
+
# This also sets only one of the values leaving everything else nil
|
123
|
+
# as required for unions
|
124
|
+
set_member_name = @member ? @member[:name] : :unknown
|
125
|
+
member_subclass = @ref.shape.member_subclass(set_member_name).new # shape.member_subclass(target.member).new
|
126
|
+
member_subclass[set_member_name] = @result[set_member_name]
|
127
|
+
@result = member_subclass
|
128
|
+
end
|
113
129
|
end
|
114
130
|
|
115
131
|
private
|
@@ -122,11 +138,7 @@ module Aws
|
|
122
138
|
end
|
123
139
|
|
124
140
|
def xml_name(ref)
|
125
|
-
|
126
|
-
ref.shape.member.location_name || ref.location_name
|
127
|
-
else
|
128
|
-
ref.location_name
|
129
|
-
end
|
141
|
+
ref.location_name
|
130
142
|
end
|
131
143
|
|
132
144
|
def flattened_list?(ref)
|
@@ -242,9 +254,15 @@ module Aws
|
|
242
254
|
end
|
243
255
|
end
|
244
256
|
|
257
|
+
class UnknownMemberFrame < Frame
|
258
|
+
def result
|
259
|
+
@text.join
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
245
263
|
class BlobFrame < Frame
|
246
264
|
def result
|
247
|
-
@text.empty? ?
|
265
|
+
@text.empty? ? '' : Base64.decode64(@text.join)
|
248
266
|
end
|
249
267
|
end
|
250
268
|
|
@@ -256,7 +274,7 @@ module Aws
|
|
256
274
|
|
257
275
|
class FloatFrame < Frame
|
258
276
|
def result
|
259
|
-
@text.empty? ? nil : @text.join
|
277
|
+
@text.empty? ? nil : Aws::Util.deserialize_number(@text.join)
|
260
278
|
end
|
261
279
|
end
|
262
280
|
|
@@ -274,19 +292,7 @@ module Aws
|
|
274
292
|
|
275
293
|
class TimestampFrame < Frame
|
276
294
|
def result
|
277
|
-
@text.empty? ? nil :
|
278
|
-
end
|
279
|
-
def parse(value)
|
280
|
-
case value
|
281
|
-
when nil then nil
|
282
|
-
when /^\d+$/ then Time.at(value.to_i)
|
283
|
-
else
|
284
|
-
begin
|
285
|
-
Time.parse(value).utc
|
286
|
-
rescue ArgumentError
|
287
|
-
raise "unhandled timestamp format `#{value}'"
|
288
|
-
end
|
289
|
-
end
|
295
|
+
@text.empty? ? nil : Aws::Util.deserialize_time(@text.join)
|
290
296
|
end
|
291
297
|
end
|
292
298
|
|
@@ -302,6 +308,7 @@ module Aws
|
|
302
308
|
MapShape => MapFrame,
|
303
309
|
StringShape => StringFrame,
|
304
310
|
StructureShape => StructureFrame,
|
311
|
+
UnionShape => StructureFrame,
|
305
312
|
TimestampShape => TimestampFrame,
|
306
313
|
}
|
307
314
|
|
@@ -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)
|
data/lib/aws-sdk-core.rb
CHANGED
@@ -20,6 +20,15 @@ require_relative 'aws-sdk-core/shared_credentials'
|
|
20
20
|
require_relative 'aws-sdk-core/process_credentials'
|
21
21
|
require_relative 'aws-sdk-core/sso_credentials'
|
22
22
|
|
23
|
+
# tokens and token providers
|
24
|
+
require_relative 'aws-sdk-core/token'
|
25
|
+
require_relative 'aws-sdk-core/token_provider'
|
26
|
+
require_relative 'aws-sdk-core/static_token_provider'
|
27
|
+
require_relative 'aws-sdk-core/refreshing_token'
|
28
|
+
require_relative 'aws-sdk-core/sso_token_provider'
|
29
|
+
require_relative 'aws-sdk-core/token_provider_chain'
|
30
|
+
require_relative 'aws-sdk-core/plugins/bearer_authorization'
|
31
|
+
|
23
32
|
# client modules
|
24
33
|
|
25
34
|
require_relative 'aws-sdk-core/client_stubs'
|
@@ -87,12 +96,24 @@ require_relative 'aws-sdk-core/client_side_monitoring/publisher'
|
|
87
96
|
require_relative 'aws-sdk-core/arn'
|
88
97
|
require_relative 'aws-sdk-core/arn_parser'
|
89
98
|
require_relative 'aws-sdk-core/ec2_metadata'
|
99
|
+
require_relative 'aws-sdk-core/lru_cache'
|
100
|
+
|
101
|
+
# dynamic endpoints
|
102
|
+
require_relative 'aws-sdk-core/endpoints'
|
103
|
+
require_relative 'aws-sdk-core/plugins/signature_v4'
|
104
|
+
|
105
|
+
# defaults
|
106
|
+
require_relative 'aws-defaults'
|
107
|
+
|
108
|
+
# plugins
|
109
|
+
# loaded through building STS or SSO ..
|
90
110
|
|
91
111
|
# aws-sdk-sts is included to support Aws::AssumeRoleCredentials
|
92
112
|
require_relative 'aws-sdk-sts'
|
93
113
|
|
94
114
|
# aws-sdk-sso is included to support Aws::SSOCredentials
|
95
115
|
require_relative 'aws-sdk-sso'
|
116
|
+
require_relative 'aws-sdk-ssooidc'
|
96
117
|
|
97
118
|
module Aws
|
98
119
|
|