aws-sdk-core 3.185.1 → 3.214.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +409 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +1 -2
  5. data/lib/aws-defaults.rb +4 -1
  6. data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
  7. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
  8. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  9. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  10. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  11. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  12. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  13. data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
  14. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  15. data/lib/aws-sdk-core/cbor.rb +53 -0
  16. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  17. data/lib/aws-sdk-core/client_stubs.rb +23 -19
  18. data/lib/aws-sdk-core/credential_provider.rb +1 -1
  19. data/lib/aws-sdk-core/credential_provider_chain.rb +13 -6
  20. data/lib/aws-sdk-core/credentials.rb +13 -6
  21. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  22. data/lib/aws-sdk-core/ecs_credentials.rb +78 -11
  23. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  24. data/lib/aws-sdk-core/endpoints/matchers.rb +6 -9
  25. data/lib/aws-sdk-core/endpoints.rb +74 -18
  26. data/lib/aws-sdk-core/error_handler.rb +41 -0
  27. data/lib/aws-sdk-core/errors.rb +11 -2
  28. data/lib/aws-sdk-core/event_emitter.rb +0 -16
  29. data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
  30. data/lib/aws-sdk-core/json/builder.rb +8 -1
  31. data/lib/aws-sdk-core/json/error_handler.rb +17 -11
  32. data/lib/aws-sdk-core/json/handler.rb +13 -6
  33. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  34. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  35. data/lib/aws-sdk-core/json/parser.rb +32 -2
  36. data/lib/aws-sdk-core/json.rb +43 -14
  37. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  38. data/lib/aws-sdk-core/log.rb +10 -0
  39. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  40. data/lib/aws-sdk-core/pageable_response.rb +1 -1
  41. data/lib/aws-sdk-core/param_validator.rb +7 -2
  42. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  43. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +6 -3
  44. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
  45. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  46. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +9 -3
  47. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  48. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
  49. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  50. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  51. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  52. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  53. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  54. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  55. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  56. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  57. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  58. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -25
  59. data/lib/aws-sdk-core/plugins/request_compression.rb +11 -2
  60. data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
  61. data/lib/aws-sdk-core/plugins/sign.rb +27 -15
  62. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  63. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  64. data/lib/aws-sdk-core/plugins/stub_responses.rb +30 -2
  65. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  66. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  67. data/lib/aws-sdk-core/plugins/user_agent.rb +70 -26
  68. data/lib/aws-sdk-core/plugins.rb +39 -0
  69. data/lib/aws-sdk-core/process_credentials.rb +47 -28
  70. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  71. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  72. data/lib/aws-sdk-core/query/handler.rb +4 -4
  73. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  74. data/lib/aws-sdk-core/query.rb +2 -1
  75. data/lib/aws-sdk-core/refreshing_credentials.rb +12 -6
  76. data/lib/aws-sdk-core/resources.rb +8 -0
  77. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  78. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  79. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  80. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  81. data/lib/aws-sdk-core/rest/request/headers.rb +14 -6
  82. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
  83. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  84. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  85. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  86. data/lib/aws-sdk-core/rest.rb +1 -0
  87. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  88. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  89. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  90. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
  91. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  92. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  93. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  94. data/lib/aws-sdk-core/shared_config.rb +7 -2
  95. data/lib/aws-sdk-core/shared_credentials.rb +0 -7
  96. data/lib/aws-sdk-core/sso_credentials.rb +2 -1
  97. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  98. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  99. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  100. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  101. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  102. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  103. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  104. data/lib/aws-sdk-core/stubbing.rb +22 -0
  105. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  106. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  107. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  108. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  109. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  110. data/lib/aws-sdk-core/telemetry.rb +78 -0
  111. data/lib/aws-sdk-core/util.rb +39 -0
  112. data/lib/aws-sdk-core/waiters/poller.rb +10 -5
  113. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  114. data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
  115. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  116. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  117. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  118. data/lib/aws-sdk-core.rb +82 -107
  119. data/lib/aws-sdk-sso/client.rb +119 -55
  120. data/lib/aws-sdk-sso/client_api.rb +7 -0
  121. data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
  122. data/lib/aws-sdk-sso/endpoints.rb +2 -54
  123. data/lib/aws-sdk-sso/plugins/endpoints.rb +23 -22
  124. data/lib/aws-sdk-sso/types.rb +1 -0
  125. data/lib/aws-sdk-sso.rb +15 -11
  126. data/lib/aws-sdk-ssooidc/client.rb +504 -83
  127. data/lib/aws-sdk-ssooidc/client_api.rb +83 -1
  128. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
  129. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +2 -2
  130. data/lib/aws-sdk-ssooidc/endpoints.rb +2 -40
  131. data/lib/aws-sdk-ssooidc/errors.rb +52 -0
  132. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +23 -20
  133. data/lib/aws-sdk-ssooidc/types.rb +373 -51
  134. data/lib/aws-sdk-ssooidc.rb +15 -11
  135. data/lib/aws-sdk-sts/client.rb +334 -105
  136. data/lib/aws-sdk-sts/client_api.rb +36 -10
  137. data/lib/aws-sdk-sts/customizations.rb +5 -1
  138. data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
  139. data/lib/aws-sdk-sts/endpoint_provider.rb +2 -2
  140. data/lib/aws-sdk-sts/endpoints.rb +2 -118
  141. data/lib/aws-sdk-sts/plugins/endpoints.rb +23 -30
  142. data/lib/aws-sdk-sts/presigner.rb +1 -1
  143. data/lib/aws-sdk-sts/types.rb +188 -30
  144. data/lib/aws-sdk-sts.rb +15 -11
  145. data/lib/seahorse/client/async_base.rb +1 -1
  146. data/lib/seahorse/client/async_response.rb +19 -0
  147. data/lib/seahorse/client/base.rb +18 -7
  148. data/lib/seahorse/client/h2/handler.rb +14 -3
  149. data/lib/seahorse/client/handler.rb +1 -1
  150. data/lib/seahorse/client/net_http/connection_pool.rb +11 -11
  151. data/lib/seahorse/client/net_http/handler.rb +21 -9
  152. data/lib/seahorse/client/net_http/patches.rb +1 -4
  153. data/lib/seahorse/client/plugin.rb +9 -0
  154. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  155. data/lib/seahorse/client/plugins/h2.rb +3 -3
  156. data/lib/seahorse/client/plugins/net_http.rb +57 -16
  157. data/lib/seahorse/client/request_context.rb +8 -1
  158. data/lib/seahorse/model/shapes.rb +2 -2
  159. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  160. data/sig/aws-sdk-core/errors.rbs +22 -0
  161. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  162. data/sig/aws-sdk-core/structure.rbs +4 -0
  163. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  164. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  165. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  166. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  167. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  168. data/sig/aws-sdk-core.rbs +7 -0
  169. data/sig/seahorse/client/base.rbs +25 -0
  170. data/sig/seahorse/client/handler_builder.rbs +16 -0
  171. data/sig/seahorse/client/response.rbs +61 -0
  172. metadata +61 -19
  173. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  174. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  175. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  176. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  177. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+
5
+ module Aws
6
+ module RpcV2
7
+ class Builder
8
+ include Seahorse::Model::Shapes
9
+
10
+ def initialize(rules, _options = {})
11
+ @rules = rules
12
+ end
13
+
14
+ def serialize(params)
15
+ # If the input shape is empty, do not set a body. This is
16
+ # different than if the input shape is a structure with no members.
17
+ return nil if @rules.shape.struct_class == EmptyStructure
18
+
19
+ RpcV2.encode(format(@rules, params))
20
+ end
21
+
22
+ private
23
+
24
+ def structure(ref, values)
25
+ shape = ref.shape
26
+ values.each_pair.with_object({}) do |(key, value), data|
27
+ if shape.member?(key) && !value.nil?
28
+ member_ref = shape.member(key)
29
+ member_name = member_ref.location_name || key
30
+ data[member_name] = format(member_ref, value)
31
+ end
32
+ end
33
+ end
34
+
35
+ def list(ref, values)
36
+ member_ref = ref.shape.member
37
+ values.collect { |value| format(member_ref, value) }
38
+ end
39
+
40
+ def map(ref, values)
41
+ value_ref = ref.shape.value
42
+ values.each.with_object({}) do |(key, value), data|
43
+ data[key] = format(value_ref, value)
44
+ end
45
+ end
46
+
47
+ def blob(value)
48
+ (String === value ? value : value.read).force_encoding(Encoding::BINARY)
49
+ end
50
+
51
+ def format(ref, value)
52
+ case ref.shape
53
+ when StructureShape then structure(ref, value)
54
+ when ListShape then list(ref, value)
55
+ when MapShape then map(ref, value)
56
+ when BlobShape then blob(value)
57
+ else value
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../cbor'
4
+
5
+ module Aws
6
+ module RpcV2
7
+ # Pure Ruby implementation of CBOR encode and decode
8
+ module CborEngine
9
+ def self.encode(data)
10
+ Cbor::Encoder.new.add(data).bytes
11
+ end
12
+
13
+ def self.decode(bytes)
14
+ Cbor::Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module RpcV2
5
+ class ContentTypeHandler < Seahorse::Client::Handler
6
+ def call(context)
7
+ content_type =
8
+ if eventstream_input?(context)
9
+ 'application/vnd.amazon.eventstream'
10
+ elsif !empty_input_structure?(context)
11
+ 'application/cbor'
12
+ end
13
+ accept =
14
+ if eventstream_output?(context)
15
+ 'application/vnd.amazon.eventstream'
16
+ else
17
+ 'application/cbor'
18
+ end
19
+
20
+ headers = context.http_request.headers
21
+ headers['Content-Type'] ||= content_type if content_type
22
+ headers['Accept'] ||= accept
23
+ @handler.call(context)
24
+ end
25
+
26
+ private
27
+
28
+ def eventstream_input?(context)
29
+ context.operation.input.shape.members.each do |_, ref|
30
+ return true if ref.eventstream
31
+ end
32
+ false
33
+ end
34
+
35
+ def eventstream_output?(context)
36
+ context.operation.output.shape.members.each do |_, ref|
37
+ return true if ref.eventstream
38
+ end
39
+ false
40
+ end
41
+
42
+ def empty_input_structure?(context)
43
+ context.operation.input.shape.struct_class == EmptyStructure
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module RpcV2
5
+ class ErrorHandler < Aws::ErrorHandler
6
+
7
+ def call(context)
8
+ # Malformed responses should throw an http based error, so we check
9
+ # 200 range for error handling only for this case.
10
+ @handler.call(context).on(200..599) do |response|
11
+ if !valid_response?(context)
12
+ code, message, data = http_status_error(context)
13
+ response.error = build_error(context, code, message, data)
14
+ elsif (300..599).cover?(context.http_response.status_code)
15
+ response.error = error(context)
16
+ end
17
+ response.data = nil
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def valid_response?(context)
24
+ req_header = context.http_request.headers['smithy-protocol']
25
+ resp_header = context.http_response.headers['smithy-protocol']
26
+ req_header == resp_header
27
+ end
28
+
29
+ def extract_error(body, context)
30
+ data = RpcV2.decode(body)
31
+ code = error_code(data, context)
32
+ message = data['message']
33
+ data = parse_error_data(context, body, code)
34
+ [code, message, data]
35
+ rescue Cbor::Error
36
+ [http_status_error_code(context), '', EmptyStructure.new]
37
+ end
38
+
39
+ def error_code(data, context)
40
+ code =
41
+ if aws_query_error?(context)
42
+ query_header = context.http_response.headers['x-amzn-query-error']
43
+ error, _type = query_header.split(';') # type not supported
44
+ remove_prefix(error, context)
45
+ else
46
+ data['__type']
47
+ end
48
+ if code
49
+ code.split('#').last
50
+ else
51
+ http_status_error_code(context)
52
+ end
53
+ end
54
+
55
+ def parse_error_data(context, body, code)
56
+ data = EmptyStructure.new
57
+ if (error_rules = context.operation.errors)
58
+ error_rules.each do |rule|
59
+ # match modeled shape name with the type(code) only
60
+ # some type(code) might contains invalid characters
61
+ # such as ':' (efs) etc
62
+ match = rule.shape.name == code.gsub(/[^^a-zA-Z0-9]/, '')
63
+ next unless match && rule.shape.members.any?
64
+
65
+ data = Parser.new(rule).parse(body)
66
+ end
67
+ end
68
+ data
69
+ end
70
+
71
+ def aws_query_error?(context)
72
+ context.config.api.metadata['awsQueryCompatible'] &&
73
+ context.http_response.headers['x-amzn-query-error']
74
+ end
75
+
76
+ def remove_prefix(error_code, context)
77
+ if (prefix = context.config.api.metadata['errorPrefix'])
78
+ error_code.sub(/^#{prefix}/, '')
79
+ else
80
+ error_code
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module RpcV2
5
+ class Handler < Seahorse::Client::Handler
6
+ # @param [Seahorse::Client::RequestContext] context
7
+ # @return [Seahorse::Client::Response]
8
+ def call(context)
9
+ build_request(context)
10
+ response = with_metric { @handler.call(context) }
11
+ response.on(200..299) { |resp| resp.data = parse_body(context) }
12
+ response.on(200..599) { |_resp| apply_request_id(context) }
13
+ response
14
+ end
15
+
16
+ private
17
+
18
+ def with_metric(&block)
19
+ Aws::Plugins::UserAgent.metric('PROTOCOL_RPC_V2_CBOR', &block)
20
+ end
21
+
22
+ def build_request(context)
23
+ context.http_request.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
24
+ context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
25
+ context.http_request.http_method = 'POST'
26
+ context.http_request.body = build_body(context)
27
+ build_url(context)
28
+ end
29
+
30
+ def build_url(context)
31
+ base = context.http_request.endpoint
32
+ service_name = context.config.api.metadata['targetPrefix']
33
+ base.path += "/service/#{service_name}/operation/#{context.operation.name}"
34
+ end
35
+
36
+ def build_body(context)
37
+ Builder.new(context.operation.input).serialize(context.params)
38
+ end
39
+
40
+ def parse_body(context)
41
+ cbor = context.http_response.body_contents
42
+ if (rules = context.operation.output)
43
+ if cbor.is_a?(Array)
44
+ # an array of emitted events
45
+ if cbor[0].respond_to?(:response)
46
+ # initial response exists
47
+ # it must be the first event arrived
48
+ resp_struct = cbor.shift.response
49
+ else
50
+ resp_struct = context.operation.output.shape.struct_class.new
51
+ end
52
+
53
+ rules.shape.members.each do |name, ref|
54
+ if ref.eventstream
55
+ resp_struct.send("#{name}=", cbor.to_enum)
56
+ end
57
+ end
58
+ resp_struct
59
+ else
60
+ Parser.new(
61
+ rules,
62
+ query_compatible: query_compatible?(context)
63
+ ).parse(cbor)
64
+ end
65
+ else
66
+ EmptyStructure.new
67
+ end
68
+ end
69
+
70
+ def apply_request_id(context)
71
+ context[:request_id] = context.http_response.headers['x-amzn-requestid']
72
+ end
73
+
74
+ def query_compatible?(context)
75
+ context.config.api.metadata.key?('awsQueryCompatible')
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Aws
6
+ module RpcV2
7
+ class Parser
8
+ include Seahorse::Model::Shapes
9
+
10
+ # @param [Seahorse::Model::ShapeRef] rules
11
+ def initialize(rules, query_compatible: false)
12
+ @rules = rules
13
+ @query_compatible = query_compatible
14
+ end
15
+
16
+ def parse(cbor, target = nil)
17
+ return {} if cbor.empty?
18
+
19
+ parse_ref(@rules, RpcV2.decode(cbor), target)
20
+ end
21
+
22
+ private
23
+
24
+ def structure(ref, values, target = nil)
25
+ shape = ref.shape
26
+ target = ref.shape.struct_class.new if target.nil?
27
+ values.each do |key, value|
28
+ member_name, member_ref = shape.member_by_location_name(key)
29
+ if member_ref
30
+ target[member_name] = parse_ref(member_ref, value)
31
+ elsif shape.union && key != '__type'
32
+ target[:unknown] = { 'name' => key, 'value' => value }
33
+ end
34
+ end
35
+ # In services that were previously Query/XML, members that were
36
+ # "flattened" defaulted to empty lists. In JSON, these values are nil,
37
+ # which is backwards incompatible. To preserve backwards compatibility,
38
+ # we set a default value of [] for these members.
39
+ if @query_compatible
40
+ ref.shape.members.each do |member_name, member_target|
41
+ next unless target[member_name].nil?
42
+
43
+ if flattened_list?(member_target.shape)
44
+ target[member_name] = []
45
+ elsif flattened_map?(member_target.shape)
46
+ target[member_name] = {}
47
+ end
48
+ end
49
+ end
50
+
51
+ if shape.union
52
+ # convert to subclass
53
+ member_subclass = shape.member_subclass(target.member).new
54
+ member_subclass[target.member] = target.value
55
+ target = member_subclass
56
+ end
57
+ target
58
+ end
59
+
60
+ def list(ref, values, target = nil)
61
+ target = [] if target.nil?
62
+ values.each do |value|
63
+ target << parse_ref(ref.shape.member, value)
64
+ end
65
+ target
66
+ end
67
+
68
+ def map(ref, values, target = nil)
69
+ target = {} if target.nil?
70
+ values.each do |key, value|
71
+ target[key] = parse_ref(ref.shape.value, value) unless value.nil?
72
+ end
73
+ target
74
+ end
75
+
76
+ def parse_ref(ref, value, target = nil)
77
+ if value.nil?
78
+ nil
79
+ else
80
+ case ref.shape
81
+ when StructureShape then structure(ref, value, target)
82
+ when ListShape then list(ref, value, target)
83
+ when MapShape then map(ref, value, target)
84
+ else value
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cbor'
4
+ require_relative 'rpc_v2/builder'
5
+ require_relative 'rpc_v2/content_type_handler'
6
+ require_relative 'rpc_v2/error_handler'
7
+ require_relative 'rpc_v2/handler'
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
@@ -198,6 +198,8 @@ module Aws
198
198
 
199
199
  config_reader(
200
200
  :region,
201
+ :account_id_endpoint_mode,
202
+ :sigv4a_signing_region_set,
201
203
  :ca_bundle,
202
204
  :credential_process,
203
205
  :endpoint_discovery_enabled,
@@ -205,6 +207,7 @@ module Aws
205
207
  :use_fips_endpoint,
206
208
  :ec2_metadata_service_endpoint,
207
209
  :ec2_metadata_service_endpoint_mode,
210
+ :ec2_metadata_v1_disabled,
208
211
  :max_attempts,
209
212
  :retry_mode,
210
213
  :adaptive_retry_wait_to_fill,
@@ -217,6 +220,7 @@ module Aws
217
220
  :s3_use_arn_region,
218
221
  :s3_us_east_1_regional_endpoint,
219
222
  :s3_disable_multiregion_access_points,
223
+ :s3_disable_express_session_auth,
220
224
  :defaults_mode,
221
225
  :sdk_ua_app_id,
222
226
  :disable_request_compression,
@@ -336,7 +340,7 @@ module Aws
336
340
  if @parsed_config
337
341
  credential_process ||= @parsed_config.fetch(profile, {})['credential_process']
338
342
  end
339
- ProcessCredentials.new(credential_process) if credential_process
343
+ ProcessCredentials.new([credential_process]) if credential_process
340
344
  end
341
345
 
342
346
  def credentials_from_shared(profile, _opts)
@@ -411,7 +415,8 @@ module Aws
411
415
  creds = Credentials.new(
412
416
  prof_config['aws_access_key_id'],
413
417
  prof_config['aws_secret_access_key'],
414
- prof_config['aws_session_token']
418
+ prof_config['aws_session_token'],
419
+ account_id: prof_config['aws_account_id']
415
420
  )
416
421
  creds if creds.set?
417
422
  end
@@ -7,13 +7,6 @@ module Aws
7
7
 
8
8
  include CredentialProvider
9
9
 
10
- # @api private
11
- KEY_MAP = {
12
- 'aws_access_key_id' => 'access_key_id',
13
- 'aws_secret_access_key' => 'secret_access_key',
14
- 'aws_session_token' => 'session_token',
15
- }
16
-
17
10
  # Constructs a new SharedCredentials object. This will load static
18
11
  # (access_key_id, secret_access_key and session_token) AWS access
19
12
  # credentials from an ini file, which supports profiles. The default
@@ -156,7 +156,8 @@ module Aws
156
156
  @credentials = Credentials.new(
157
157
  c.access_key_id,
158
158
  c.secret_access_key,
159
- c.session_token
159
+ c.session_token,
160
+ account_id: @sso_account_id
160
161
  )
161
162
  @expiration = Time.at(c.expiration / 1000.0)
162
163
  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
- http_resp = Seahorse::Client::Http::Response.new
20
- http_resp.status_code = 400
21
- http_resp.body = <<-XML.strip
22
- <ErrorResponse>
23
- <Error>
24
- <Code>#{error_code}</Code>
25
- <Message>stubbed-response-error-message</Message>
26
- </Error>
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
- http_resp
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(" <requestId>stubbed-request-id</requestId>")
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
@@ -3,27 +3,28 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class Json
7
8
 
8
9
  def stub_data(api, operation, data)
9
10
  resp = Seahorse::Client::Http::Response.new
10
11
  resp.status_code = 200
11
- resp.headers["Content-Type"] = content_type(api)
12
- resp.headers["x-amzn-RequestId"] = "stubbed-request-id"
12
+ resp.headers['Content-Type'] = content_type(api)
13
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
13
14
  resp.body = build_body(operation, data)
14
15
  resp
15
16
  end
16
17
 
17
18
  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
- }
19
+ resp = Seahorse::Client::Http::Response.new
20
+ resp.status_code = 400
21
+ resp.body = <<~JSON.strip
22
+ {
23
+ "code": #{error_code.inspect},
24
+ "message": "stubbed-response-error-message"
25
+ }
25
26
  JSON
26
- http_resp
27
+ resp
27
28
  end
28
29
 
29
30
  private
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class Query
7
8
 
8
9
  def stub_data(api, operation, data)
@@ -13,10 +14,10 @@ module Aws
13
14
  end
14
15
 
15
16
  def stub_error(error_code)
16
- http_resp = Seahorse::Client::Http::Response.new
17
- http_resp.status_code = 400
18
- http_resp.body = XmlError.new(error_code).to_xml
19
- http_resp
17
+ resp = Seahorse::Client::Http::Response.new
18
+ resp.status_code = 400
19
+ resp.body = XmlError.new(error_code).to_xml
20
+ resp
20
21
  end
21
22
 
22
23
  private
@@ -24,9 +25,9 @@ module Aws
24
25
  def build_body(api, operation, data)
25
26
  xml = []
26
27
  builder = Aws::Xml::DocBuilder.new(target: xml, indent: ' ')
27
- builder.node(operation.name + 'Response', xmlns: xmlns(api)) do
28
+ builder.node("#{operation.name}Response", xmlns: xmlns(api)) do
28
29
  if (rules = operation.output)
29
- rules.location_name = operation.name + 'Result'
30
+ rules.location_name = "#{operation.name}Result"
30
31
  Xml::Builder.new(rules, target: xml, pad:' ').to_xml(data)
31
32
  end
32
33
  builder.node('ResponseMetadata') do
@@ -5,6 +5,7 @@ require 'aws-eventstream'
5
5
  module Aws
6
6
  module Stubbing
7
7
  module Protocols
8
+ # @api private
8
9
  class Rest
9
10
 
10
11
  include Seahorse::Model::Shapes
@@ -22,7 +23,7 @@ module Aws
22
23
  def new_http_response
23
24
  resp = Seahorse::Client::Http::Response.new
24
25
  resp.status_code = 200
25
- resp.headers["x-amzn-RequestId"] = "stubbed-request-id"
26
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
26
27
  resp
27
28
  end
28
29
 
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class RestJson < Rest
7
8
 
8
9
  def body_for(_a, _b, rules, data)
@@ -14,15 +15,15 @@ module Aws
14
15
  end
15
16
 
16
17
  def stub_error(error_code)
17
- http_resp = Seahorse::Client::Http::Response.new
18
- http_resp.status_code = 400
19
- http_resp.body = <<-JSON.strip
20
- {
21
- "code": #{error_code.inspect},
22
- "message": "stubbed-response-error-message"
23
- }
18
+ resp = Seahorse::Client::Http::Response.new
19
+ resp.status_code = 400
20
+ resp.body = <<~JSON.strip
21
+ {
22
+ "code": #{error_code.inspect},
23
+ "message": "stubbed-response-error-message"
24
+ }
24
25
  JSON
25
- http_resp
26
+ resp
26
27
  end
27
28
 
28
29
  end