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
@@ -117,7 +117,8 @@ module Aws
117
117
 
118
118
  def call(context)
119
119
  if should_calculate_request_checksum?(context)
120
- request_algorithm_input = ChecksumAlgorithm.request_algorithm_selection(context)
120
+ request_algorithm_input = ChecksumAlgorithm.request_algorithm_selection(context) ||
121
+ context[:default_request_checksum_algorithm]
121
122
  context[:checksum_algorithms] = request_algorithm_input
122
123
 
123
124
  request_checksum_property = {
@@ -140,7 +141,8 @@ module Aws
140
141
 
141
142
  def should_calculate_request_checksum?(context)
142
143
  context.operation.http_checksum &&
143
- ChecksumAlgorithm.request_algorithm_selection(context)
144
+ (ChecksumAlgorithm.request_algorithm_selection(context) ||
145
+ context[:default_request_checksum_algorithm])
144
146
  end
145
147
 
146
148
  def should_verify_response_checksum?(context)
@@ -236,7 +238,8 @@ module Aws
236
238
 
237
239
  # determine where (header vs trailer) a request checksum should be added
238
240
  def checksum_request_in(context)
239
- if context.operation['authtype'].eql?('v4-unsigned-body')
241
+ if context.operation['unsignedPayload'] ||
242
+ context.operation['authtype'] == 'v4-unsigned-body'
240
243
  'trailer'
241
244
  else
242
245
  'header'
@@ -40,6 +40,7 @@ side monitoring agent is running on, where client metrics will be published via
40
40
  option(:client_side_monitoring_publisher,
41
41
  default: ClientSideMonitoring::Publisher,
42
42
  doc_type: Aws::ClientSideMonitoring::Publisher,
43
+ rbs_type: 'untyped',
43
44
  docstring: <<-DOCS) do |cfg|
44
45
  Allows you to provide a custom client-side monitoring publisher class. By default,
45
46
  will use the Client Side Monitoring Agent Publisher.
@@ -11,6 +11,8 @@ module Aws
11
11
  # AttemptHandler comes just before we would retry an error.
12
12
  # Or before we would follow redirects.
13
13
  handlers.add(AttemptHandler, step: :sign, priority: 39)
14
+ # ErrorHandler comes after we have parsed an error.
15
+ handlers.add(ErrorHandler, step: :sign, priority: 95)
14
16
  # LatencyHandler is as close to sending as possible.
15
17
  handlers.add(LatencyHandler, step: :sign, priority: 0)
16
18
  end
@@ -62,17 +64,27 @@ module Aws
62
64
  call_attempt.x_amzn_request_id = headers["x-amzn-request-id"]
63
65
  end
64
66
  call_attempt.http_status_code = context.http_response.status_code
65
- if e = resp.error
67
+ context.metadata[:current_call_attempt] = call_attempt
68
+ request_metrics.add_call_attempt(call_attempt)
69
+ resp
70
+ end
71
+ end
72
+
73
+ class ErrorHandler < Seahorse::Client::Handler
74
+ def call(context)
75
+ resp = @handler.call(context)
76
+ call_attempt = context.metadata[:current_call_attempt]
77
+ if (e = resp.error)
66
78
  e_name = _extract_error_name(e)
67
79
  e_msg = e.message
68
80
  call_attempt.aws_exception = "#{e_name}"
69
81
  call_attempt.aws_exception_msg = "#{e_msg}"
70
82
  end
71
- request_metrics.add_call_attempt(call_attempt)
72
83
  resp
73
84
  end
74
85
 
75
86
  private
87
+
76
88
  def _extract_error_name(error)
77
89
  if error.is_a?(Aws::Errors::ServiceError)
78
90
  error.class.code
@@ -12,6 +12,8 @@ module Aws
12
12
 
13
13
  option(:session_token, doc_type: String, docstring: '')
14
14
 
15
+ option(:account_id, doc_type: String, docstring: '')
16
+
15
17
  option(:profile,
16
18
  doc_default: 'default',
17
19
  doc_type: String,
@@ -23,6 +25,7 @@ at HOME/.aws/credentials. When not specified, 'default' is used.
23
25
  option(:credentials,
24
26
  required: true,
25
27
  doc_type: 'Aws::CredentialProvider',
28
+ rbs_type: 'untyped',
26
29
  docstring: <<-DOCS
27
30
  Your AWS credentials. This can be an instance of any one of the
28
31
  following classes:
@@ -57,13 +60,15 @@ When `:credentials` are not configured directly, the following
57
60
  locations will be searched for credentials:
58
61
 
59
62
  * `Aws.config[:credentials]`
60
- * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
61
- * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
63
+ * The `:access_key_id`, `:secret_access_key`, `:session_token`, and
64
+ `:account_id` options.
65
+ * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'],
66
+ ENV['AWS_SESSION_TOKEN'], and ENV['AWS_ACCOUNT_ID']
62
67
  * `~/.aws/credentials`
63
68
  * `~/.aws/config`
64
69
  * EC2/ECS IMDS instance profile - When used by default, the timeouts
65
70
  are very aggressive. Construct and pass an instance of
66
- `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
71
+ `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
67
72
  enable retries and extended timeouts. Instance profile credential
68
73
  fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
69
74
  to true.
@@ -79,6 +84,7 @@ locations will be searched for credentials:
79
84
  option(:token_provider,
80
85
  required: false,
81
86
  doc_type: 'Aws::TokenProvider',
87
+ rbs_type: 'untyped',
82
88
  docstring: <<-DOCS
83
89
  A Bearer Token Provider. This can be an instance of any one of the
84
90
  following classes:
@@ -43,7 +43,7 @@ module Aws
43
43
  # @api private
44
44
  class GlobalConfiguration < Seahorse::Client::Plugin
45
45
 
46
- @identifiers = Set.new()
46
+ @identifiers = Set.new
47
47
 
48
48
  # @api private
49
49
  def before_initialize(client_class, options)
@@ -55,17 +55,18 @@ module Aws
55
55
  private
56
56
 
57
57
  def apply_service_defaults(client_class, options)
58
- if defaults = Aws.config[client_class.identifier]
59
- defaults.each do |option_name, default|
60
- options[option_name] = default unless options.key?(option_name)
61
- end
58
+ return unless (defaults = Aws.config[client_class.identifier])
59
+
60
+ defaults.each do |option_name, default|
61
+ options[option_name] = default unless options.key?(option_name)
62
62
  end
63
63
  end
64
64
 
65
- def apply_aws_defaults(client_class, options)
65
+ def apply_aws_defaults(_client_class, options)
66
66
  Aws.config.each do |option_name, default|
67
67
  next if self.class.identifiers.include?(option_name)
68
68
  next if options.key?(option_name)
69
+
69
70
  options[option_name] = default
70
71
  end
71
72
  end
@@ -80,9 +81,7 @@ module Aws
80
81
 
81
82
  # @return [Set<String>]
82
83
  # @api private
83
- def identifiers
84
- @identifiers
85
- end
84
+ attr_reader :identifiers
86
85
 
87
86
  end
88
87
  end
@@ -12,7 +12,8 @@ module Aws
12
12
 
13
13
  def call(context)
14
14
  if checksum_required?(context) &&
15
- !context[:checksum_algorithms] # skip in favor of flexible checksum
15
+ !context[:checksum_algorithms] && # skip in favor of flexible checksum
16
+ !context[:s3_express_endpoint] # s3 express endpoints do not support md5
16
17
  body = context.http_request.body
17
18
  context.http_request.headers['Content-Md5'] ||= md5(body)
18
19
  end
@@ -12,18 +12,8 @@ module Aws
12
12
  class Handler < Seahorse::Client::Handler
13
13
 
14
14
  def call(context)
15
- apply_invocation_id(context)
16
- @handler.call(context)
17
- end
18
-
19
- private
20
-
21
- def apply_invocation_id(context)
22
15
  context.http_request.headers['amz-sdk-invocation-id'] = SecureRandom.uuid
23
- if context[:input_event_emitter]
24
- # only used for eventstreaming at input
25
- context.http_request.headers['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
26
- end
16
+ @handler.call(context)
27
17
  end
28
18
 
29
19
  end
@@ -8,6 +8,7 @@ module Aws
8
8
 
9
9
  option(:logger,
10
10
  doc_type: 'Logger',
11
+ rbs_type: 'untyped',
11
12
  docstring: <<-DOCS
12
13
  The Logger instance to send log messages to. If this option
13
14
  is not set, logging will be disabled.
@@ -22,6 +23,7 @@ is not set, logging will be disabled.
22
23
 
23
24
  option(:log_formatter,
24
25
  doc_type: 'Aws::Log::Formatter',
26
+ rbs_type: 'untyped',
25
27
  doc_default: literal('Aws::Log::Formatter.default'),
26
28
  docstring: 'The log formatter.'
27
29
  ) do |config|
@@ -5,6 +5,8 @@ module Aws
5
5
  module Protocols
6
6
  class ApiGateway < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'api-gateway')
9
+
8
10
  class ContentTypeHandler < Seahorse::Client::Handler
9
11
  def call(context)
10
12
  body = context.http_request.body
@@ -22,8 +24,8 @@ module Aws
22
24
  handler(Rest::Handler)
23
25
  handler(ContentTypeHandler, priority: 30)
24
26
  handler(Json::ErrorHandler, step: :sign)
25
- end
26
27
 
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -1,35 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class EC2 < Seahorse::Client::Plugin
9
7
 
10
- class Handler < Aws::Query::Handler
11
-
12
- def apply_params(param_list, params, rules)
13
- Aws::Query::EC2ParamBuilder.new(param_list).apply(rules, params)
14
- end
15
-
16
- def parse_xml(context)
17
- if rules = context.operation.output
18
- parser = Xml::Parser.new(rules)
19
- data = parser.parse(xml(context)) do |path, value|
20
- if path.size == 2 && path.last == 'requestId'
21
- context.metadata[:request_id] = value
22
- end
23
- end
24
- data
25
- else
26
- EmptyStructure.new
27
- end
28
- end
29
-
30
- end
8
+ option(:protocol, 'ec2')
31
9
 
32
- handler(Handler)
10
+ handler(Aws::Query::EC2Handler)
33
11
  handler(Xml::ErrorHandler, step: :sign)
34
12
 
35
13
  end
@@ -5,18 +5,17 @@ module Aws
5
5
  module Protocols
6
6
  class JsonRpc < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'json')
9
+
8
10
  option(:simple_json,
9
11
  default: false,
10
12
  doc_type: 'Boolean',
11
13
  docstring: <<-DOCS)
12
14
  Disables request parameter conversion, validation, and formatting.
13
- Also disable response data type conversions. This option is useful
14
- when you want to ensure the highest level of performance by
15
- avoiding overhead of walking request parameters and response data
16
- structures.
17
-
18
- When `:simple_json` is enabled, the request parameters hash must
19
- be formatted exactly as the DynamoDB API expects.
15
+ Also disables response data type conversions. The request parameters
16
+ hash must be formatted exactly as the API expects.This option is useful
17
+ when you want to ensure the highest level of performance by avoiding
18
+ overhead of walking request parameters and response data structures.
20
19
  DOCS
21
20
 
22
21
  option(:validate_params) { |config| !config.simple_json }
@@ -24,7 +23,6 @@ be formatted exactly as the DynamoDB API expects.
24
23
  option(:convert_params) { |config| !config.simple_json }
25
24
 
26
25
  handler(Json::Handler)
27
-
28
26
  handler(Json::ErrorHandler, step: :sign)
29
27
 
30
28
  end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class Query < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'query')
9
+
9
10
  handler(Aws::Query::Handler)
10
11
  handler(Xml::ErrorHandler, step: :sign)
12
+
11
13
  end
12
14
  end
13
15
  end
@@ -5,25 +5,13 @@ module Aws
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
7
 
8
- class ContentTypeHandler < Seahorse::Client::Handler
9
- def call(context)
10
- body = context.http_request.body
11
- # Rest::Handler will set a default JSON body, so size can be checked
12
- # if this handler is run after serialization.
13
- if !body.respond_to?(:size) ||
14
- (body.respond_to?(:size) && body.size > 0)
15
- context.http_request.headers['Content-Type'] ||=
16
- 'application/json'
17
- end
18
- @handler.call(context)
19
- end
20
- end
8
+ option(:protocol, 'rest-json')
21
9
 
22
10
  handler(Rest::Handler)
23
- handler(ContentTypeHandler, priority: 30)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
24
12
  handler(Json::ErrorHandler, step: :sign)
25
- end
26
13
 
14
+ end
27
15
  end
28
16
  end
29
17
  end
@@ -5,7 +5,10 @@ module Aws
5
5
  module Protocols
6
6
  class RestXml < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'rest-xml')
9
+
8
10
  handler(Rest::Handler)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
9
12
  handler(Xml::ErrorHandler, step: :sign)
10
13
 
11
14
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ module Protocols
6
+ class RpcV2 < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'smithy-rpc-v2-cbor')
9
+
10
+ handler(Aws::RpcV2::Handler)
11
+ handler(Aws::RpcV2::ContentTypeHandler, priority: 30)
12
+ handler(Aws::RpcV2::ErrorHandler, step: :sign)
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -20,16 +20,31 @@ 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
- DOCS
23
+ DOCS
24
24
  resolve_region(cfg)
25
25
  end
26
26
 
27
+ option(:sigv4a_signing_region_set,
28
+ doc_type: Array,
29
+ rbs_type: 'Array[String]',
30
+ docstring: <<-DOCS) do |cfg|
31
+ A list of regions that should be signed with SigV4a signing. When
32
+ not passed, a default `:sigv4a_signing_region_set` is searched for
33
+ in the following locations:
34
+
35
+ * `Aws.config[:sigv4a_signing_region_set]`
36
+ * `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
37
+ * `~/.aws/config`
38
+ DOCS
39
+ resolve_sigv4a_signing_region_set(cfg)
40
+ end
41
+
27
42
  option(:use_dualstack_endpoint,
28
43
  doc_type: 'Boolean',
29
44
  docstring: <<-DOCS) do |cfg|
30
45
  When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
31
46
  will be used if available.
32
- DOCS
47
+ DOCS
33
48
  resolve_use_dualstack_endpoint(cfg)
34
49
  end
35
50
 
@@ -39,7 +54,7 @@ will be used if available.
39
54
  When set to `true`, fips compatible endpoints will be used if available.
40
55
  When a `fips` region is used, the region is normalized and this config
41
56
  is set to `true`.
42
- DOCS
57
+ DOCS
43
58
  resolve_use_fips_endpoint(cfg)
44
59
  end
45
60
 
@@ -52,7 +67,7 @@ is set to `true`.
52
67
  docstring: <<-DOCS) do |cfg|
53
68
  Setting to true disables use of endpoint URLs provided via environment
54
69
  variables and the shared configuration file.
55
- DOCS
70
+ DOCS
56
71
  resolve_ignore_configured_endpoint_urls(cfg)
57
72
  end
58
73
 
@@ -60,14 +75,58 @@ variables and the shared configuration file.
60
75
  The client endpoint is normally constructed from the `:region`
61
76
  option. You should only configure an `:endpoint` when connecting
62
77
  to test or custom endpoints. This should be a valid HTTP(S) URI.
63
- DOCS
78
+ DOCS
64
79
  resolve_endpoint(cfg)
65
80
  end
66
81
 
67
82
  def after_initialize(client)
68
- if client.config.region.nil? || client.config.region == ''
69
- raise Errors::MissingRegionError
83
+ region = client.config.region
84
+ raise Errors::MissingRegionError if region.nil? || region == ''
85
+
86
+ # resolve a default endpoint to preserve legacy behavior
87
+ initialize_default_endpoint(client) if client.config.endpoint.nil?
88
+
89
+ region_set = client.config.sigv4a_signing_region_set
90
+ return if region_set.nil?
91
+ raise Errors::InvalidRegionSetError unless region_set.is_a?(Array)
92
+
93
+ region_set = region_set.compact.reject(&:empty?)
94
+ raise Errors::InvalidRegionSetError if region_set.empty?
95
+
96
+ client.config.sigv4a_signing_region_set = region_set
97
+ end
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
70
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)
71
130
  end
72
131
 
73
132
  class << self
@@ -81,6 +140,12 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
81
140
  env_region || cfg_region
82
141
  end
83
142
 
143
+ def resolve_sigv4a_signing_region_set(cfg)
144
+ value = ENV['AWS_SIGV4A_SIGNING_REGION_SET']
145
+ value ||= Aws.shared_config.sigv4a_signing_region_set(profile: cfg.profile)
146
+ value.split(',') if value
147
+ end
148
+
84
149
  def resolve_use_dualstack_endpoint(cfg)
85
150
  value = ENV['AWS_USE_DUALSTACK_ENDPOINT']
86
151
  value ||= Aws.shared_config.use_dualstack_endpoint(
@@ -121,7 +186,8 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
121
186
  # that a custom endpoint has NOT been configured by the user
122
187
  cfg.override_config(:regional_endpoint, true)
123
188
 
124
- resolve_legacy_endpoint(cfg)
189
+ # a default endpoint is resolved in after_initialize
190
+ nil
125
191
  end
126
192
 
127
193
  # get a custom configured endpoint from ENV or configuration
@@ -176,23 +242,6 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
176
242
  cfg.override_config(:region, new_region)
177
243
  end
178
244
  end
179
- # set a default endpoint in config using legacy (endpoints.json) resolver
180
- def resolve_legacy_endpoint(cfg)
181
- endpoint_prefix = cfg.api.metadata['endpointPrefix']
182
- if cfg.respond_to?(:sts_regional_endpoints)
183
- sts_regional = cfg.sts_regional_endpoints
184
- end
185
-
186
- Aws::Partitions::EndpointProvider.resolve(
187
- cfg.region,
188
- endpoint_prefix,
189
- sts_regional,
190
- {
191
- dualstack: cfg.use_dualstack_endpoint,
192
- fips: cfg.use_fips_endpoint
193
- }
194
- )
195
- end
196
245
  end
197
246
  end
198
247
  end
@@ -91,11 +91,20 @@ and 10485780 bytes inclusive.
91
91
  end
92
92
  end
93
93
  end
94
- @handler.call(context)
94
+ with_metric(selected_encoding) { @handler.call(context) }
95
95
  end
96
96
 
97
97
  private
98
98
 
99
+ def with_metric(encoding, &block)
100
+ case encoding
101
+ when 'gzip'
102
+ Aws::Plugins::UserAgent.metric('GZIP_REQUEST_COMPRESSION', &block)
103
+ else
104
+ block.call
105
+ end
106
+ end
107
+
99
108
  def request_encoding_selection(context)
100
109
  encoding_list = context.operation.request_compression['encodings']
101
110
  encoding_list.find { |encoding| RequestCompression::SUPPORTED_ENCODINGS.include?(encoding) }
@@ -104,7 +113,7 @@ and 10485780 bytes inclusive.
104
113
  def update_content_encoding(encoding, context)
105
114
  headers = context.http_request.headers
106
115
  if headers['Content-Encoding']
107
- headers['Content-Encoding'] += ',' + encoding
116
+ headers['Content-Encoding'] += ", #{encoding}"
108
117
  else
109
118
  headers['Content-Encoding'] = encoding
110
119
  end
@@ -73,6 +73,7 @@ is only used in the `legacy` retry mode.
73
73
  :retry_jitter,
74
74
  default: :none,
75
75
  doc_type: Symbol,
76
+ rbs_type: '(:none | :equal | :full | ^(Integer) -> Integer)',
76
77
  docstring: <<-DOCS)
77
78
  A delay randomiser function used by the default backoff function.
78
79
  Some predefined functions can be referenced by name - :none, :equal, :full,
@@ -97,6 +98,7 @@ This option is only used in the `legacy` retry mode.
97
98
  :retry_mode,
98
99
  default: 'legacy',
99
100
  doc_type: String,
101
+ rbs_type: '("legacy" | "standard" | "adaptive")',
100
102
  docstring: <<-DOCS) do |cfg|
101
103
  Specifies which retry algorithm to use. Values are:
102
104
 
@@ -111,7 +113,6 @@ Specifies which retry algorithm to use. Values are:
111
113
  functionality of `standard` mode along with automatic client side
112
114
  throttling. This is a provisional mode that may change behavior
113
115
  in the future.
114
-
115
116
  DOCS
116
117
  resolve_retry_mode(cfg)
117
118
  end
@@ -233,7 +234,7 @@ a clock skew correction and retry requests with skewed client clocks.
233
234
 
234
235
  get_send_token(config)
235
236
  add_retry_headers(context)
236
- response = @handler.call(context)
237
+ response = with_metric(config.retry_mode) { @handler.call(context) }
237
238
  error_inspector = Retries::ErrorInspector.new(
238
239
  response.error, response.context.http_response.status_code
239
240
  )
@@ -270,6 +271,10 @@ a clock skew correction and retry requests with skewed client clocks.
270
271
 
271
272
  private
272
273
 
274
+ def with_metric(retry_mode, &block)
275
+ Aws::Plugins::UserAgent.metric("RETRY_MODE_#{retry_mode.upcase}", &block)
276
+ end
277
+
273
278
  def get_send_token(config)
274
279
  # either fail fast or block until a token becomes available
275
280
  # must be configurable
@@ -357,7 +362,7 @@ a clock skew correction and retry requests with skewed client clocks.
357
362
  class LegacyHandler < Seahorse::Client::Handler
358
363
 
359
364
  def call(context)
360
- response = @handler.call(context)
365
+ response = with_metric { @handler.call(context) }
361
366
  if response.error
362
367
  error_inspector = Retries::ErrorInspector.new(
363
368
  response.error, response.context.http_response.status_code
@@ -376,6 +381,10 @@ a clock skew correction and retry requests with skewed client clocks.
376
381
 
377
382
  private
378
383
 
384
+ def with_metric(&block)
385
+ Aws::Plugins::UserAgent.metric('RETRY_MODE_LEGACY', &block)
386
+ end
387
+
379
388
  def retry_if_possible(response, error_inspector)
380
389
  context = response.context
381
390
  if should_retry?(context, error_inspector)