aws-sdk-core 3.217.1 → 3.224.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/assume_role_credentials.rb +1 -0
  5. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +1 -0
  6. data/lib/aws-sdk-core/client_stubs.rb +22 -48
  7. data/lib/aws-sdk-core/credential_provider.rb +4 -0
  8. data/lib/aws-sdk-core/credential_provider_chain.rb +27 -7
  9. data/lib/aws-sdk-core/credentials.rb +6 -0
  10. data/lib/aws-sdk-core/ecs_credentials.rb +1 -0
  11. data/lib/aws-sdk-core/errors.rb +2 -2
  12. data/lib/aws-sdk-core/instance_profile_credentials.rb +1 -0
  13. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +0 -1
  14. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
  15. data/lib/aws-sdk-core/plugins/sign.rb +15 -1
  16. data/lib/aws-sdk-core/plugins/stub_responses.rb +24 -8
  17. data/lib/aws-sdk-core/plugins/user_agent.rb +23 -2
  18. data/lib/aws-sdk-core/process_credentials.rb +1 -1
  19. data/lib/aws-sdk-core/rest/request/headers.rb +1 -1
  20. data/lib/aws-sdk-core/shared_config.rb +72 -21
  21. data/lib/aws-sdk-core/shared_credentials.rb +1 -0
  22. data/lib/aws-sdk-core/sso_credentials.rb +2 -0
  23. data/lib/aws-sdk-sso/client.rb +30 -31
  24. data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
  25. data/lib/aws-sdk-sso.rb +1 -1
  26. data/lib/aws-sdk-ssooidc/client.rb +43 -33
  27. data/lib/aws-sdk-ssooidc/client_api.rb +6 -0
  28. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
  29. data/lib/aws-sdk-ssooidc/types.rb +28 -1
  30. data/lib/aws-sdk-ssooidc.rb +1 -1
  31. data/lib/aws-sdk-sts/client.rb +31 -32
  32. data/lib/aws-sdk-sts/client_api.rb +8 -8
  33. data/lib/aws-sdk-sts/endpoint_provider.rb +50 -55
  34. data/lib/aws-sdk-sts/errors.rb +16 -0
  35. data/lib/aws-sdk-sts.rb +1 -1
  36. data/lib/seahorse/client/async_base.rb +4 -5
  37. data/lib/seahorse/client/base.rb +0 -14
  38. data/lib/seahorse/client/h2/connection.rb +18 -28
  39. data/lib/seahorse/client/http/response.rb +1 -1
  40. data/lib/seahorse/client/net_http/connection_pool.rb +2 -0
  41. data/lib/seahorse/client/networking_error.rb +1 -1
  42. data/lib/seahorse/client/plugins/h2.rb +4 -4
  43. data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
  44. data/sig/seahorse/client/async_base.rbs +18 -0
  45. metadata +39 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13c7508d3fe8738d7cf214927f7ce2c56291b98bd48140df95f9b870f4d47b22
4
- data.tar.gz: b02761bcdae833ec72bde159bfbdebeaf31cbe6d1a133218b2431fcbb9678bef
3
+ metadata.gz: c0504743f3e3a403f83f5ee206527bedd7e65670b2398299eb608e9808694ced
4
+ data.tar.gz: 4fd94bb6f4e7f33f2b7e81b77e09fede47ef0385aab7002448dadbe2b569c91e
5
5
  SHA512:
6
- metadata.gz: 97147bdd4fd7e610d78e9b058cc8b0db1b4dc88dcb7ec16aa4c9f08819d3c4e6acc965ddc8591b8e52f0f34b33c2beec1a76bdf39bbb6e34b405dd8c63fbe348
7
- data.tar.gz: 8290e9fae3593b24ae2247882bdaced352fb4f86989b20493473ffa84685ede8c6ff7c4e46397a5711a0eeeedbd8bee5b3b8205571babb937f25f9b9e38e35bf
6
+ metadata.gz: b746c5749870287501ea3d1d0cdf968913d3c95331c520f62518a2bf17a7caa21c9c2454098feb42fba3f38d5db11f5e7835076f8b81c47dd284d4b428c447bb
7
+ data.tar.gz: 95695ed0514d2ed18fd9c9acdd14c975118fb2e3fced14f4c96274e357b7da3f59400e5ea8872bec9d1faba89212e638cd08178dfff3b2e27b9fda0ef9be8e69
data/CHANGELOG.md CHANGED
@@ -1,6 +1,94 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.224.1 (2025-05-28)
5
+ ------------------
6
+
7
+ * Issue - Signal data in http response listeners prior to writing, so that data can be inspected or verified before potential mutation.
8
+
9
+ 3.224.0 (2025-05-12)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
15
+
16
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
17
+
18
+ * Feature - Support `ENV['AWS_DISABLE_HOST_PREFIX_INJECTION']` and `disable_host_prefix_injection` shared config to disable host prefix injection for all services.
19
+
20
+ 3.223.0 (2025-05-01)
21
+ ------------------
22
+
23
+ * Feature - Updated Aws::STS::Client with the latest API changes.
24
+
25
+ 3.222.3 (2025-04-28)
26
+ ------------------
27
+
28
+ * Issue - Do not dynamically create operation methods from the API. (#3234)
29
+
30
+ 3.222.2 (2025-04-16)
31
+ ------------------
32
+
33
+ * Issue - Additional metrics collection for credentials in the User-Agent plugin.
34
+
35
+ 3.222.1 (2025-03-28)
36
+ ------------------
37
+
38
+ * Issue - Allow explicit modeled headers to override prefixed headers for `rest` protocols.
39
+
40
+ 3.222.0 (2025-03-27)
41
+ ------------------
42
+
43
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
44
+
45
+ * Feature - This release adds AwsAdditionalDetails in the CreateTokenWithIAM API response.
46
+
47
+ 3.221.0 (2025-03-24)
48
+ ------------------
49
+
50
+ * Feature - Add `logger` as an explicit dependency for Ruby 3.5.
51
+ * Issue - Enable ALPN over TLS for H2 Connection by default.
52
+ * Issue - Fix HTTP-2 connections to properly use config values configured on the client.
53
+
54
+ 3.220.2 (2025-03-20)
55
+ ------------------
56
+
57
+ * Issue - Enable ALPN over TLS for H2 by default.
58
+
59
+ 3.220.1 (2025-03-06)
60
+ ------------------
61
+
62
+ * Issue - Convert stubs at request time.
63
+
64
+ 3.220.0 (2025-03-04)
65
+ ------------------
66
+
67
+ * Feature - Updated Aws::STS::Client with the latest API changes.
68
+
69
+ 3.219.0 (2025-02-18)
70
+ ------------------
71
+
72
+ * Feature - Updated Aws::STS::Client with the latest API changes.
73
+
74
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
75
+
76
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
77
+
78
+ 3.218.1 (2025-02-07)
79
+ ------------------
80
+
81
+ * Issue - Add handling of block in ExtendedSession delegation (#3178).
82
+
83
+ 3.218.0 (2025-02-06)
84
+ ------------------
85
+
86
+ * Feature - Updated Aws::STS::Client with the latest API changes.
87
+
88
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
89
+
90
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
91
+
4
92
  3.217.1 (2025-01-30)
5
93
  ------------------
6
94
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.217.1
1
+ 3.224.1
@@ -50,6 +50,7 @@ module Aws
50
50
  end
51
51
  @client = client_opts[:client] || STS::Client.new(client_opts)
52
52
  @async_refresh = true
53
+ @metrics = ['CREDENTIALS_STS_ASSUME_ROLE']
53
54
  super
54
55
  end
55
56
 
@@ -61,6 +61,7 @@ module Aws
61
61
  @assume_role_web_identity_params[:role_session_name] = _session_name
62
62
  end
63
63
  @client = client_opts[:client] || STS::Client.new(client_opts.merge(credentials: nil))
64
+ @metrics = ['CREDENTIALS_STS_ASSUME_ROLE_WEB_ID']
64
65
  super
65
66
  end
66
67
 
@@ -15,27 +15,11 @@ module Aws
15
15
 
16
16
  # @api private
17
17
  def setup_stubbing
18
- @stubs = {}
19
- @stub_mutex = Mutex.new
20
18
  if Hash === @config.stub_responses
21
19
  @config.stub_responses.each do |operation_name, stubs|
22
20
  apply_stubs(operation_name, Array === stubs ? stubs : [stubs])
23
21
  end
24
22
  end
25
-
26
- # When a client is stubbed allow the user to access the requests made
27
- requests = @api_requests = []
28
- requests_mutex = @requests_mutex = Mutex.new
29
- self.handle do |context|
30
- requests_mutex.synchronize do
31
- requests << {
32
- operation_name: context.operation_name,
33
- params: context.params,
34
- context: context
35
- }
36
- end
37
- @handler.call(context)
38
- end
39
23
  end
40
24
 
41
25
  # Configures what data / errors should be returned from the named operation
@@ -175,7 +159,7 @@ module Aws
175
159
  # on a client that has not enabled response stubbing via
176
160
  # `:stub_responses => true`.
177
161
  def stub_responses(operation_name, *stubs)
178
- if config.stub_responses
162
+ if @config.stub_responses
179
163
  apply_stubs(operation_name, stubs.flatten)
180
164
  else
181
165
  msg = 'stubbing is not enabled; enable stubbing in the constructor '\
@@ -194,12 +178,12 @@ module Aws
194
178
  # @raise [NotImplementedError] Raises `NotImplementedError` when the client
195
179
  # is not stubbed.
196
180
  def api_requests(options = {})
197
- if config.stub_responses
198
- @requests_mutex.synchronize do
181
+ if @config.stub_responses
182
+ @config.api_requests_mutex.synchronize do
199
183
  if options[:exclude_presign]
200
- @api_requests.reject {|req| req[:context][:presigned_url] }
184
+ @config.api_requests.reject {|req| req[:context][:presigned_url] }
201
185
  else
202
- @api_requests
186
+ @config.api_requests
203
187
  end
204
188
  end
205
189
  else
@@ -228,54 +212,44 @@ module Aws
228
212
  # @return [Structure] Returns a stubbed response data structure. The
229
213
  # actual class returned will depend on the given `operation_name`.
230
214
  def stub_data(operation_name, data = {})
231
- Stubbing::StubData.new(config.api.operation(operation_name)).stub(data)
215
+ Stubbing::StubData.new(@config.api.operation(operation_name)).stub(data)
232
216
  end
233
217
 
234
218
  # @api private
235
219
  def next_stub(context)
236
220
  operation_name = context.operation_name.to_sym
237
- stub = @stub_mutex.synchronize do
238
- stubs = @stubs[operation_name] || []
221
+ stub = @config.stubs_mutex.synchronize do
222
+ stubs = @config.stubs[operation_name] || []
239
223
  case stubs.length
240
- when 0 then default_stub(operation_name)
224
+ when 0 then stub_data(operation_name)
241
225
  when 1 then stubs.first
242
226
  else stubs.shift
243
227
  end
244
228
  end
245
- Proc === stub ? convert_stub(operation_name, stub.call(context)) : stub
229
+ stub = convert_stub(operation_name, stub, context)
230
+ stub[:mutex] = Mutex.new
231
+ stub
246
232
  end
247
233
 
248
234
  private
249
235
 
250
- def default_stub(operation_name)
251
- stub = stub_data(operation_name)
252
- http_response_stub(operation_name, stub)
236
+ def apply_stubs(operation_name, stubs)
237
+ @config.stubs_mutex.synchronize do
238
+ @config.stubs[operation_name.to_sym] = stubs
239
+ end
253
240
  end
254
241
 
255
242
  # This method converts the given stub data and converts it to a
256
243
  # HTTP response (when possible). This enables the response stubbing
257
244
  # plugin to provide a HTTP response that triggers all normal events
258
245
  # during response handling.
259
- def apply_stubs(operation_name, stubs)
260
- @stub_mutex.synchronize do
261
- @stubs[operation_name.to_sym] = stubs.map do |stub|
262
- convert_stub(operation_name, stub)
263
- end
264
- end
265
- end
266
-
267
- def convert_stub(operation_name, stub)
268
- stub = case stub
269
- when Proc then stub
246
+ def convert_stub(operation_name, stub, context)
247
+ case stub
248
+ when Proc then convert_stub(operation_name, stub.call(context), context)
270
249
  when Exception, Class then { error: stub }
271
250
  when String then service_error_stub(stub)
272
- when Hash then http_response_stub(operation_name, stub)
273
- else { data: stub }
274
- end
275
- if Hash === stub
276
- stub[:mutex] = Mutex.new
251
+ else http_response_stub(operation_name, stub)
277
252
  end
278
- stub
279
253
  end
280
254
 
281
255
  def service_error_stub(error_code)
@@ -299,14 +273,14 @@ module Aws
299
273
  end
300
274
 
301
275
  def data_to_http_resp(operation_name, data)
302
- api = config.api
276
+ api = @config.api
303
277
  operation = api.operation(operation_name)
304
278
  ParamValidator.new(operation.output, input: false).validate!(data)
305
279
  protocol_helper.stub_data(api, operation, data)
306
280
  end
307
281
 
308
282
  def protocol_helper
309
- case config.api.metadata['protocol']
283
+ case @config.api.metadata['protocol']
310
284
  when 'json' then Stubbing::Protocols::Json
311
285
  when 'rest-json' then Stubbing::Protocols::RestJson
312
286
  when 'rest-xml' then Stubbing::Protocols::RestXml
@@ -9,6 +9,10 @@ module Aws
9
9
  # @return [Time]
10
10
  attr_reader :expiration
11
11
 
12
+ # @api private
13
+ # Returns UserAgent metrics for credentials.
14
+ attr_accessor :metrics
15
+
12
16
  # @return [Boolean]
13
17
  def set?
14
18
  !!@credentials && @credentials.set?
@@ -42,12 +42,14 @@ module Aws
42
42
 
43
43
  def static_credentials(options)
44
44
  if options[:config]
45
- Credentials.new(
45
+ creds = Credentials.new(
46
46
  options[:config].access_key_id,
47
47
  options[:config].secret_access_key,
48
48
  options[:config].session_token,
49
49
  account_id: options[:config].account_id
50
50
  )
51
+ creds.metrics = ['CREDENTIALS_PROFILE']
52
+ creds
51
53
  end
52
54
  end
53
55
 
@@ -76,7 +78,9 @@ module Aws
76
78
 
77
79
  def static_profile_credentials(options)
78
80
  if options[:config] && options[:config].profile
79
- SharedCredentials.new(profile_name: options[:config].profile)
81
+ creds = SharedCredentials.new(profile_name: options[:config].profile)
82
+ creds.metrics = ['CREDENTIALS_PROFILE']
83
+ creds
80
84
  end
81
85
  rescue Errors::NoSuchProfileError
82
86
  nil
@@ -85,7 +89,11 @@ module Aws
85
89
  def static_profile_process_credentials(options)
86
90
  if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
87
91
  process_provider = Aws.shared_config.credential_process(profile: options[:config].profile)
88
- ProcessCredentials.new([process_provider]) if process_provider
92
+ if process_provider
93
+ creds = ProcessCredentials.new([process_provider])
94
+ creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
95
+ creds
96
+ end
89
97
  end
90
98
  rescue Errors::NoSuchProfileError
91
99
  nil
@@ -96,12 +104,14 @@ module Aws
96
104
  secret = %w[AWS_SECRET_ACCESS_KEY AMAZON_SECRET_ACCESS_KEY AWS_SECRET_KEY]
97
105
  token = %w[AWS_SESSION_TOKEN AMAZON_SESSION_TOKEN]
98
106
  account_id = %w[AWS_ACCOUNT_ID]
99
- Credentials.new(
107
+ creds = Credentials.new(
100
108
  envar(key),
101
109
  envar(secret),
102
110
  envar(token),
103
111
  account_id: envar(account_id)
104
112
  )
113
+ creds.metrics = ['CREDENTIALS_ENV_VARS']
114
+ creds
105
115
  end
106
116
 
107
117
  def envar(keys)
@@ -117,7 +127,9 @@ module Aws
117
127
 
118
128
  def shared_credentials(options)
119
129
  profile_name = determine_profile_name(options)
120
- SharedCredentials.new(profile_name: profile_name)
130
+ creds = SharedCredentials.new(profile_name: profile_name)
131
+ creds.metrics = ['CREDENTIALS_PROFILE']
132
+ creds
121
133
  rescue Errors::NoSuchProfileError
122
134
  nil
123
135
  end
@@ -126,7 +138,11 @@ module Aws
126
138
  profile_name = determine_profile_name(options)
127
139
  if Aws.shared_config.config_enabled?
128
140
  process_provider = Aws.shared_config.credential_process(profile: profile_name)
129
- ProcessCredentials.new([process_provider]) if process_provider
141
+ if process_provider
142
+ creds = ProcessCredentials.new([process_provider])
143
+ creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
144
+ creds
145
+ end
130
146
  end
131
147
  rescue Errors::NoSuchProfileError
132
148
  nil
@@ -156,7 +172,11 @@ module Aws
156
172
  role_session_name: ENV['AWS_ROLE_SESSION_NAME']
157
173
  }
158
174
  cfg[:region] = region if region
159
- AssumeRoleWebIdentityCredentials.new(cfg)
175
+ Aws::Plugins::UserAgent.metric('CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN') do
176
+ creds = AssumeRoleWebIdentityCredentials.new(cfg)
177
+ creds.metrics << 'CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN'
178
+ creds
179
+ end
160
180
  elsif Aws.shared_config.config_enabled?
161
181
  profile = options[:config].profile if options[:config]
162
182
  Aws.shared_config.assume_role_web_identity_credentials_from_config(
@@ -14,6 +14,7 @@ module Aws
14
14
  @secret_access_key = secret_access_key
15
15
  @session_token = session_token
16
16
  @account_id = kwargs[:account_id]
17
+ @metrics = ['CREDENTIALS_CODE']
17
18
  end
18
19
 
19
20
  # @return [String]
@@ -28,6 +29,11 @@ module Aws
28
29
  # @return [String, nil]
29
30
  attr_reader :account_id
30
31
 
32
+ # @api private
33
+ # Returns the credentials source. Used for tracking credentials
34
+ # related UserAgent metrics.
35
+ attr_accessor :metrics
36
+
31
37
  # @return [Credentials]
32
38
  def credentials
33
39
  self
@@ -77,6 +77,7 @@ module Aws
77
77
  @http_debug_output = options[:http_debug_output]
78
78
  @backoff = backoff(options[:backoff])
79
79
  @async_refresh = false
80
+ @metrics = ['CREDENTIALS_HTTP']
80
81
  super
81
82
  end
82
83
 
@@ -68,7 +68,7 @@ module Aws
68
68
  end
69
69
  end
70
70
 
71
- # Rasied when endpoint discovery failed for operations
71
+ # Raised when endpoint discovery failed for operations
72
72
  # that requires endpoints from endpoint discovery
73
73
  class EndpointDiscoveryError < RuntimeError
74
74
  def initialize(*args)
@@ -78,7 +78,7 @@ module Aws
78
78
  end
79
79
  end
80
80
 
81
- # raised when hostLabel member is not provided
81
+ # Raised when hostLabel member is not provided
82
82
  # at operation input when endpoint trait is available
83
83
  # with 'hostPrefix' requirement
84
84
  class MissingEndpointHostLabelValue < RuntimeError
@@ -90,6 +90,7 @@ module Aws
90
90
  @token = nil
91
91
  @no_refresh_until = nil
92
92
  @async_refresh = false
93
+ @metrics = ['CREDENTIALS_IMDS']
93
94
  super
94
95
  end
95
96
 
@@ -180,7 +180,6 @@ all generated client side metrics. Defaults to an empty string.
180
180
  complete_opts = {
181
181
  latency: end_time - start_time,
182
182
  attempt_count: context.retries + 1,
183
- user_agent: context.http_request.headers["user-agent"],
184
183
  final_error_retryable: final_error_retryable,
185
184
  final_http_status_code: context.http_response.status_code,
186
185
  final_aws_exception: final_aws_exception,
@@ -4,62 +4,70 @@ module Aws
4
4
  module Plugins
5
5
  # @api private
6
6
  class EndpointPattern < Seahorse::Client::Plugin
7
-
8
- option(:disable_host_prefix_injection,
7
+ option(
8
+ :disable_host_prefix_injection,
9
9
  default: false,
10
10
  doc_type: 'Boolean',
11
- docstring: <<-DOCS
12
- Set to true to disable SDK automatically adding host prefix
13
- to default service endpoint when available.
14
- DOCS
15
- )
11
+ docstring: 'When `true`, the SDK will not prepend the modeled host prefix to the endpoint.'
12
+ ) do |cfg|
13
+ resolve_disable_host_prefix_injection(cfg)
14
+ end
16
15
 
17
- def add_handlers(handlers, config)
16
+ def add_handlers(handlers, _config)
18
17
  handlers.add(Handler, priority: 10)
19
18
  end
20
19
 
21
- class Handler < Seahorse::Client::Handler
20
+ class << self
21
+ private
22
+
23
+ def resolve_disable_host_prefix_injection(cfg)
24
+ value = ENV['AWS_DISABLE_HOST_PREFIX_INJECTION'] ||
25
+ Aws.shared_config.disable_host_prefix_injection(profile: cfg.profile) ||
26
+ 'false'
27
+ value = Aws::Util.str_2_bool(value)
28
+ unless [true, false].include?(value)
29
+ raise ArgumentError,
30
+ 'Must provide either `true` or `false` for '\
31
+ 'disable_host_prefix_injection profile option or for '\
32
+ 'ENV[\'AWS_DISABLE_HOST_PREFIX_INJECTION\']'
33
+ end
34
+ value
35
+ end
36
+ end
22
37
 
38
+ # @api private
39
+ class Handler < Seahorse::Client::Handler
23
40
  def call(context)
24
- if !context.config.disable_host_prefix_injection
41
+ unless context.config.disable_host_prefix_injection
25
42
  endpoint_trait = context.operation.endpoint_pattern
26
- if endpoint_trait && !endpoint_trait.empty?
27
- _apply_endpoint_trait(context, endpoint_trait)
28
- end
43
+ apply_endpoint_trait(context, endpoint_trait) if endpoint_trait && !endpoint_trait.empty?
29
44
  end
30
45
  @handler.call(context)
31
46
  end
32
47
 
33
48
  private
34
49
 
35
- def _apply_endpoint_trait(context, trait)
36
- # currently only support host pattern
37
- ori_host = context.http_request.endpoint.host
38
- if pattern = trait['hostPrefix']
39
- host_prefix = pattern.gsub(/\{.+?\}/) do |label|
40
- label = label.delete("{}")
41
- _replace_label_value(
42
- ori_host, label, context.operation.input, context.params)
43
- end
44
- context.http_request.endpoint.host = host_prefix + context.http_request.endpoint.host
50
+ def apply_endpoint_trait(context, trait)
51
+ pattern = trait['hostPrefix']
52
+ return unless pattern
53
+
54
+ host_prefix = pattern.gsub(/\{.+?}/) do |label|
55
+ label = label.delete('{}')
56
+ replace_label_value(label, context.operation.input, context.params)
45
57
  end
58
+ context.http_request.endpoint.host = host_prefix + context.http_request.endpoint.host
46
59
  end
47
60
 
48
- def _replace_label_value(ori, label, input_ref, params)
61
+ def replace_label_value(label, input_ref, params)
49
62
  name = nil
50
63
  input_ref.shape.members.each do |m_name, ref|
51
- if ref['hostLabel'] && ref['hostLabelName'] == label
52
- name = m_name
53
- end
54
- end
55
- if name.nil? || params[name].nil?
56
- raise Errors::MissingEndpointHostLabelValue.new(name)
64
+ name = m_name if ref['hostLabel'] && ref['hostLabelName'] == label
57
65
  end
66
+ raise Errors::MissingEndpointHostLabelValue, name if name.nil? || params[name].nil?
67
+
58
68
  params[name]
59
69
  end
60
-
61
70
  end
62
-
63
71
  end
64
72
  end
65
73
  end
@@ -41,6 +41,7 @@ module Aws
41
41
  class Handler < Seahorse::Client::Handler
42
42
  def call(context)
43
43
  # Skip signing if using sigv2 signing from s3_signer in S3
44
+ credentials = nil
44
45
  unless v2_signing?(context.config)
45
46
  signer = Sign.signer_for(
46
47
  context[:auth_scheme],
@@ -48,13 +49,20 @@ module Aws
48
49
  context[:sigv4_region],
49
50
  context[:sigv4_credentials]
50
51
  )
52
+ credentials = signer.credentials if signer.is_a?(SignatureV4)
51
53
  signer.sign(context)
52
54
  end
53
- @handler.call(context)
55
+ with_metrics(credentials) { @handler.call(context) }
54
56
  end
55
57
 
56
58
  private
57
59
 
60
+ def with_metrics(credentials, &block)
61
+ return block.call unless credentials&.respond_to?(:metrics)
62
+
63
+ Aws::Plugins::UserAgent.metric(*credentials.metrics, &block)
64
+ end
65
+
58
66
  def v2_signing?(config)
59
67
  # 's3' is legacy signing, 'v4' is default
60
68
  config.respond_to?(:signature_version) &&
@@ -92,6 +100,8 @@ module Aws
92
100
 
93
101
  # @api private
94
102
  class SignatureV4
103
+ attr_reader :signer
104
+
95
105
  def initialize(auth_scheme, config, sigv4_overrides = {})
96
106
  scheme_name = auth_scheme['name']
97
107
 
@@ -155,6 +165,10 @@ module Aws
155
165
  @signer.sign_event(*args)
156
166
  end
157
167
 
168
+ def credentials
169
+ @signer.credentials_provider
170
+ end
171
+
158
172
  private
159
173
 
160
174
  def apply_authtype(context, req)
@@ -29,8 +29,16 @@ requests are made, and retries are disabled.
29
29
  end
30
30
  end
31
31
 
32
+ option(:stubs) { {} }
33
+ option(:stubs_mutex) { Mutex.new }
34
+ option(:api_requests) { [] }
35
+ option(:api_requests_mutex) { Mutex.new }
36
+
32
37
  def add_handlers(handlers, config)
33
- handlers.add(Handler, step: :send) if config.stub_responses
38
+ return unless config.stub_responses
39
+
40
+ handlers.add(ApiRequestsHandler)
41
+ handlers.add(StubbingHandler, step: :send)
34
42
  end
35
43
 
36
44
  def after_initialize(client)
@@ -46,8 +54,20 @@ requests are made, and retries are disabled.
46
54
  end
47
55
  end
48
56
 
49
- class Handler < Seahorse::Client::Handler
57
+ class ApiRequestsHandler < Seahorse::Client::Handler
58
+ def call(context)
59
+ context.config.api_requests_mutex.synchronize do
60
+ context.config.api_requests << {
61
+ operation_name: context.operation_name,
62
+ params: context.params,
63
+ context: context
64
+ }
65
+ end
66
+ @handler.call(context)
67
+ end
68
+ end
50
69
 
70
+ class StubbingHandler < Seahorse::Client::Handler
51
71
  def call(context)
52
72
  span_wrapper(context) do
53
73
  stub_responses(context)
@@ -57,14 +77,10 @@ requests are made, and retries are disabled.
57
77
  private
58
78
 
59
79
  def stub_responses(context)
60
- stub = context.client.next_stub(context)
61
80
  resp = Seahorse::Client::Response.new(context: context)
62
81
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
63
- if Hash === stub && stub[:mutex]
64
- stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) }
65
- else
66
- apply_stub(stub, resp, async_mode)
67
- end
82
+ stub = context.client.next_stub(context)
83
+ stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) }
68
84
 
69
85
  if async_mode
70
86
  Seahorse::Client::AsyncResponse.new(