aws-sdk-core 3.197.0 → 3.220.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.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +297 -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/arn.rb +1 -3
  7. data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -4
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  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 +308 -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 +8 -7
  18. data/lib/aws-sdk-core/credential_provider_chain.rb +13 -6
  19. data/lib/aws-sdk-core/credentials.rb +13 -6
  20. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  21. data/lib/aws-sdk-core/endpoints/matchers.rb +6 -9
  22. data/lib/aws-sdk-core/endpoints.rb +74 -18
  23. data/lib/aws-sdk-core/error_handler.rb +41 -0
  24. data/lib/aws-sdk-core/errors.rb +9 -0
  25. data/lib/aws-sdk-core/json/error_handler.rb +8 -9
  26. data/lib/aws-sdk-core/json/handler.rb +6 -6
  27. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  28. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  29. data/lib/aws-sdk-core/json/parser.rb +2 -0
  30. data/lib/aws-sdk-core/json.rb +43 -14
  31. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  32. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  33. data/lib/aws-sdk-core/log.rb +10 -0
  34. data/lib/aws-sdk-core/param_validator.rb +1 -1
  35. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  36. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -169
  37. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
  38. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  39. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
  40. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  41. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  42. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  43. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  44. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -3
  45. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +5 -1
  46. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  47. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -25
  48. data/lib/aws-sdk-core/plugins/retry_errors.rb +0 -1
  49. data/lib/aws-sdk-core/plugins/sign.rb +13 -11
  50. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  51. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  52. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  53. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  54. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  55. data/lib/aws-sdk-core/plugins/user_agent.rb +26 -8
  56. data/lib/aws-sdk-core/plugins.rb +39 -0
  57. data/lib/aws-sdk-core/process_credentials.rb +47 -28
  58. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  59. data/lib/aws-sdk-core/query/handler.rb +4 -4
  60. data/lib/aws-sdk-core/query.rb +2 -1
  61. data/lib/aws-sdk-core/resources.rb +8 -0
  62. data/lib/aws-sdk-core/rest/{request/content_type.rb → content_type_handler.rb} +1 -1
  63. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  64. data/lib/aws-sdk-core/rest/request/endpoint.rb +3 -1
  65. data/lib/aws-sdk-core/rest/request/headers.rb +2 -2
  66. data/lib/aws-sdk-core/rest.rb +1 -1
  67. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  68. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  69. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  70. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
  71. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  72. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  73. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  74. data/lib/aws-sdk-core/shared_config.rb +7 -2
  75. data/lib/aws-sdk-core/shared_credentials.rb +0 -7
  76. data/lib/aws-sdk-core/sso_credentials.rb +2 -1
  77. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  78. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  79. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  80. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  81. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  82. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  83. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  84. data/lib/aws-sdk-core/stubbing.rb +22 -0
  85. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  86. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  87. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  88. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  89. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  90. data/lib/aws-sdk-core/telemetry.rb +78 -0
  91. data/lib/aws-sdk-core/waiters/poller.rb +9 -4
  92. data/lib/aws-sdk-core/xml/error_handler.rb +11 -37
  93. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  94. data/lib/aws-sdk-core.rb +82 -108
  95. data/lib/aws-sdk-sso/client.rb +99 -37
  96. data/lib/aws-sdk-sso/client_api.rb +7 -0
  97. data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
  98. data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
  99. data/lib/aws-sdk-sso/endpoints.rb +2 -54
  100. data/lib/aws-sdk-sso/plugins/endpoints.rb +19 -20
  101. data/lib/aws-sdk-sso/types.rb +1 -0
  102. data/lib/aws-sdk-sso.rb +15 -11
  103. data/lib/aws-sdk-ssooidc/client.rb +123 -55
  104. data/lib/aws-sdk-ssooidc/client_api.rb +5 -0
  105. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
  106. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
  107. data/lib/aws-sdk-ssooidc/endpoints.rb +2 -54
  108. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +19 -20
  109. data/lib/aws-sdk-ssooidc/types.rb +21 -15
  110. data/lib/aws-sdk-ssooidc.rb +15 -11
  111. data/lib/aws-sdk-sts/client.rb +307 -89
  112. data/lib/aws-sdk-sts/client_api.rb +28 -2
  113. data/lib/aws-sdk-sts/customizations.rb +5 -1
  114. data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
  115. data/lib/aws-sdk-sts/endpoint_provider.rb +33 -38
  116. data/lib/aws-sdk-sts/endpoints.rb +2 -118
  117. data/lib/aws-sdk-sts/errors.rb +16 -0
  118. data/lib/aws-sdk-sts/plugins/endpoints.rb +19 -28
  119. data/lib/aws-sdk-sts/types.rb +171 -28
  120. data/lib/aws-sdk-sts.rb +15 -11
  121. data/lib/seahorse/client/base.rb +17 -7
  122. data/lib/seahorse/client/h2/handler.rb +13 -3
  123. data/lib/seahorse/client/handler.rb +1 -1
  124. data/lib/seahorse/client/net_http/connection_pool.rb +10 -2
  125. data/lib/seahorse/client/net_http/handler.rb +21 -9
  126. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  127. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  128. data/lib/seahorse/client/request_context.rb +8 -1
  129. data/lib/seahorse/client/response.rb +2 -0
  130. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  131. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  132. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  133. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  134. metadata +62 -18
  135. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  136. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  137. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  138. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  139. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -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
@@ -11,8 +11,8 @@ module Aws
11
11
  CHUNK_SIZE = 1 * 1024 * 1024 # one MB
12
12
 
13
13
  def call(context)
14
- if checksum_required?(context) &&
15
- !context[:checksum_algorithms] && # skip in favor of flexible checksum
14
+ if context.operation.http_checksum_required &&
15
+ !context[:http_checksum][:request_algorithm] && # skip in favor of flexible checksum
16
16
  !context[:s3_express_endpoint] # s3 express endpoints do not support md5
17
17
  body = context.http_request.body
18
18
  context.http_request.headers['Content-Md5'] ||= md5(body)
@@ -22,12 +22,6 @@ module Aws
22
22
 
23
23
  private
24
24
 
25
- def checksum_required?(context)
26
- context.operation.http_checksum_required ||
27
- (context.operation.http_checksum &&
28
- context.operation.http_checksum['requestChecksumRequired'])
29
- end
30
-
31
25
  # @param [File, Tempfile, IO#read, String] value
32
26
  # @return [String<MD5>]
33
27
  def md5(value)
@@ -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
@@ -4,13 +4,14 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'rest-json')
9
+
7
10
  handler(Rest::Handler)
8
- # Rest::Handler will set a default JSON body, so size can be checked
9
- # if this handler is run after serialization.
10
11
  handler(Rest::ContentTypeHandler, priority: 30)
11
12
  handler(Json::ErrorHandler, step: :sign)
12
- end
13
13
 
14
+ end
14
15
  end
15
16
  end
16
17
  end
@@ -4,9 +4,13 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class RestXml < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'rest-xml')
9
+
7
10
  handler(Rest::Handler)
8
- handler(Rest::ContentTypeHandler)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
9
12
  handler(Xml::ErrorHandler, step: :sign)
13
+
10
14
  end
11
15
  end
12
16
  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
@@ -113,7 +113,6 @@ Specifies which retry algorithm to use. Values are:
113
113
  functionality of `standard` mode along with automatic client side
114
114
  throttling. This is a provisional mode that may change behavior
115
115
  in the future.
116
-
117
116
  DOCS
118
117
  resolve_retry_mode(cfg)
119
118
  end
@@ -13,8 +13,7 @@ module Aws
13
13
  option(:sigv4_region)
14
14
  option(:unsigned_operations, default: [])
15
15
 
16
- supported_auth_types = %w[sigv4 bearer sigv4-s3express none]
17
- supported_auth_types += ['sigv4a'] if Aws::Sigv4::Signer.use_crt?
16
+ supported_auth_types = %w[sigv4 bearer sigv4-s3express sigv4a none]
18
17
  SUPPORTED_AUTH_TYPES = supported_auth_types.freeze
19
18
 
20
19
  def add_handlers(handlers, cfg)
@@ -102,19 +101,19 @@ module Aws
102
101
  end
103
102
 
104
103
  region = if scheme_name == 'sigv4a'
105
- auth_scheme['signingRegionSet'].first
104
+ auth_scheme['signingRegionSet'].join(',')
106
105
  else
107
106
  auth_scheme['signingRegion']
108
107
  end
109
108
  begin
110
- @signer = Aws::Sigv4::Signer.new(
109
+ @signer = config.sigv4_signer || Aws::Sigv4::Signer.new(
111
110
  service: config.sigv4_name || auth_scheme['signingName'],
112
111
  region: sigv4_overrides[:region] || config.sigv4_region || region,
113
112
  credentials_provider: sigv4_overrides[:credentials] || config.credentials,
114
113
  signing_algorithm: scheme_name.to_sym,
115
114
  uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
116
115
  normalize_path: !!!auth_scheme['disableNormalizePath'],
117
- unsigned_headers: %w[content-length user-agent x-amzn-trace-id]
116
+ unsigned_headers: %w[content-length user-agent x-amzn-trace-id expect transfer-encoding connection]
118
117
  )
119
118
  rescue Aws::Sigv4::Errors::MissingCredentialsError
120
119
  raise Aws::Errors::MissingCredentialsError
@@ -159,17 +158,20 @@ module Aws
159
158
  private
160
159
 
161
160
  def apply_authtype(context, req)
162
- # only used for eventstreaming at input
161
+ # only used for event streaming at input
163
162
  if context[:input_event_emitter]
164
163
  req.headers['X-Amz-Content-Sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
165
- else
166
- if context.operation['authtype'].eql?('v4-unsigned-body') &&
167
- req.endpoint.scheme.eql?('https')
168
- req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
169
- end
164
+ elsif unsigned_payload?(context, req)
165
+ req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
170
166
  end
171
167
  end
172
168
 
169
+ def unsigned_payload?(context, req)
170
+ (context.operation['unsignedPayload'] ||
171
+ context.operation['authtype'] == 'v4-unsigned-body') &&
172
+ req.endpoint.scheme == 'https'
173
+ end
174
+
173
175
  def reset_signature(req)
174
176
  # in case this request is being re-signed
175
177
  req.headers.delete('Authorization')
@@ -3,7 +3,8 @@
3
3
  module Aws
4
4
  module Plugins
5
5
  # @api private
6
- # Necessary to keep after Endpoints 2.0
6
+ # Deprecated - does not look at new traits like `auth` and `unsignedPayload`
7
+ # Necessary to exist after endpoints 2.0 for old service clients + new core
7
8
  class SignatureV2 < Seahorse::Client::Plugin
8
9
 
9
10
  option(:v2_signer) do |cfg|
@@ -5,7 +5,8 @@ require 'aws-sigv4'
5
5
  module Aws
6
6
  module Plugins
7
7
  # @api private
8
- # Necessary to exist after endpoints 2.0
8
+ # Deprecated - does not look at new traits like `auth` and `unsignedPayload`
9
+ # Necessary to exist after endpoints 2.0 for old service clients + new core
9
10
  class SignatureV4 < Seahorse::Client::Plugin
10
11
 
11
12
  V4_AUTH = %w[v4 v4-unsigned-payload v4-unsigned-body]
@@ -49,6 +49,14 @@ requests are made, and retries are disabled.
49
49
  class Handler < Seahorse::Client::Handler
50
50
 
51
51
  def call(context)
52
+ span_wrapper(context) do
53
+ stub_responses(context)
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def stub_responses(context)
52
60
  stub = context.client.next_stub(context)
53
61
  resp = Seahorse::Client::Response.new(context: context)
54
62
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
@@ -58,8 +66,15 @@ requests are made, and retries are disabled.
58
66
  apply_stub(stub, resp, async_mode)
59
67
  end
60
68
 
61
- async_mode ? Seahorse::Client::AsyncResponse.new(
62
- context: context, stream: context[:input_event_stream_handler].event_emitter.stream, sync_queue: Queue.new) : resp
69
+ if async_mode
70
+ Seahorse::Client::AsyncResponse.new(
71
+ context: context,
72
+ stream: context[:input_event_stream_handler].event_emitter.stream,
73
+ sync_queue: Queue.new
74
+ )
75
+ else
76
+ resp
77
+ end
63
78
  end
64
79
 
65
80
  def apply_stub(stub, response, async_mode = false)
@@ -99,6 +114,18 @@ requests are made, and retries are disabled.
99
114
  http_resp.signal_done
100
115
  end
101
116
 
117
+ def span_wrapper(context, &block)
118
+ context.tracer.in_span(
119
+ 'Handler.StubResponses',
120
+ attributes: Aws::Telemetry.http_request_attrs(context)
121
+ ) do |span|
122
+ block.call.tap do
123
+ span.add_attributes(
124
+ Aws::Telemetry.http_response_attrs(context)
125
+ )
126
+ end
127
+ end
128
+ end
102
129
  end
103
130
  end
104
131
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ # @api private
6
+ class Telemetry < Seahorse::Client::Plugin
7
+ option(
8
+ :telemetry_provider,
9
+ default: Aws::Telemetry::NoOpTelemetryProvider,
10
+ doc_type: Aws::Telemetry::TelemetryProviderBase,
11
+ rbs_type: Aws::Telemetry::TelemetryProviderBase,
12
+ docstring: <<-DOCS) do |_cfg|
13
+ Allows you to provide a telemetry provider, which is used to
14
+ emit telemetry data. By default, uses `NoOpTelemetryProvider` which
15
+ will not record or emit any telemetry data. The SDK supports the
16
+ following telemetry providers:
17
+
18
+ * OpenTelemetry (OTel) - To use the OTel provider, install and require the
19
+ `opentelemetry-sdk` gem and then, pass in an instance of a
20
+ `Aws::Telemetry::OTelProvider` for telemetry provider.
21
+ DOCS
22
+ Aws::Telemetry::NoOpTelemetryProvider.new
23
+ end
24
+
25
+ def after_initialize(client)
26
+ validate_telemetry_provider(client.config)
27
+ end
28
+
29
+ def validate_telemetry_provider(config)
30
+ unless config.telemetry_provider.is_a?(Aws::Telemetry::TelemetryProviderBase)
31
+ raise ArgumentError,
32
+ 'Must provide a telemetry provider for the '\
33
+ '`telemetry_provider` configuration option.'
34
+ end
35
+ end
36
+
37
+ class Handler < Seahorse::Client::Handler
38
+ def call(context)
39
+ span_wrapper(context) { @handler.call(context) }
40
+ end
41
+
42
+ private
43
+
44
+ def span_wrapper(context, &block)
45
+ service_id = service_id(context)
46
+ attributes = {
47
+ 'rpc.system' => 'aws-api',
48
+ 'rpc.service' => service_id,
49
+ 'rpc.method' => context.operation.name,
50
+ 'code.function' => context.operation_name.to_s,
51
+ 'code.namespace' => 'Aws::Plugins::Telemetry'
52
+ }
53
+ context.tracer.in_span(
54
+ parent_span_name(context, service_id),
55
+ attributes: attributes,
56
+ kind: Aws::Telemetry::SpanKind::CLIENT,
57
+ &block
58
+ )
59
+ end
60
+
61
+ def service_id(context)
62
+ context.config.api.metadata['serviceId'] ||
63
+ context.config.api.metadata['serviceAbbreviation'] ||
64
+ context.config.api.metadata['serviceFullName']
65
+ end
66
+
67
+ def parent_span_name(context, service_id)
68
+ "#{service_id}.#{context.operation.name}".delete(' ')
69
+ end
70
+ end
71
+
72
+ handler(Handler, step: :initialize, priority: 99)
73
+ end
74
+ end
75
+ end
@@ -5,7 +5,8 @@ module Aws
5
5
 
6
6
  # For Streaming Input Operations, when `requiresLength` is enabled
7
7
  # checking whether `Content-Length` header can be set,
8
- # for `v4-unsigned-body` operations, set `Transfer-Encoding` header
8
+ # for `unsignedPayload` and `v4-unsigned-body` operations,
9
+ # set `Transfer-Encoding` header.
9
10
  class TransferEncoding < Seahorse::Client::Plugin
10
11
 
11
12
  # @api private
@@ -16,8 +17,8 @@ module Aws
16
17
  unless context.http_request.body.respond_to?(:size)
17
18
  if requires_length?(context.operation.input)
18
19
  # if size of the IO is not available but required
19
- raise Aws::Errors::MissingContentLength.new
20
- elsif context.operation['authtype'] == "v4-unsigned-body"
20
+ raise Aws::Errors::MissingContentLength
21
+ elsif unsigned_payload?(context.operation)
21
22
  context.http_request.headers['Transfer-Encoding'] = 'chunked'
22
23
  end
23
24
  end
@@ -29,18 +30,24 @@ module Aws
29
30
  private
30
31
 
31
32
  def streaming?(ref)
32
- if payload = ref[:payload_member]
33
- payload["streaming"] || # checking ref and shape
34
- payload.shape["streaming"]
33
+ if (payload = ref[:payload_member])
34
+ payload['streaming'] || payload.shape['streaming']
35
35
  else
36
36
  false
37
37
  end
38
38
  end
39
39
 
40
+ def unsigned_payload?(operation)
41
+ operation['unsignedPayload'] ||
42
+ operation['authtype'] == 'v4-unsigned-body'
43
+ end
44
+
40
45
  def requires_length?(ref)
41
- payload = ref[:payload_member]
42
- payload["requiresLength"] || # checking ref and shape
43
- payload.shape["requiresLength"]
46
+ if (payload = ref[:payload_member])
47
+ payload['requiresLength'] || payload.shape['requiresLength']
48
+ else
49
+ false
50
+ end
44
51
  end
45
52
 
46
53
  end