aws-sdk-core 3.209.1 → 3.228.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +231 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +1 -2
- data/lib/aws-sdk-core/arn.rb +1 -3
- data/lib/aws-sdk-core/assume_role_credentials.rb +1 -0
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +1 -0
- data/lib/aws-sdk-core/cbor/decoder.rb +0 -2
- data/lib/aws-sdk-core/cbor/encoder.rb +2 -2
- data/lib/aws-sdk-core/cbor.rb +3 -56
- data/lib/aws-sdk-core/client_stubs.rb +29 -55
- data/lib/aws-sdk-core/credential_provider.rb +4 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +28 -8
- data/lib/aws-sdk-core/credentials.rb +6 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +1 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +3 -9
- data/lib/aws-sdk-core/endpoints.rb +37 -13
- data/lib/aws-sdk-core/error_handler.rb +5 -0
- data/lib/aws-sdk-core/errors.rb +2 -2
- data/lib/aws-sdk-core/event_emitter.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +147 -157
- data/lib/aws-sdk-core/json/error_handler.rb +14 -3
- data/lib/aws-sdk-core/json/handler.rb +1 -0
- data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -170
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +0 -1
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +85 -70
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +44 -25
- data/lib/aws-sdk-core/plugins/sign.rb +30 -21
- data/lib/aws-sdk-core/plugins/stub_responses.rb +30 -8
- data/lib/aws-sdk-core/plugins/user_agent.rb +33 -2
- data/lib/aws-sdk-core/process_credentials.rb +1 -1
- data/lib/aws-sdk-core/rest/request/headers.rb +3 -3
- data/lib/aws-sdk-core/rpc_v2/builder.rb +1 -1
- data/lib/aws-sdk-core/{cbor → rpc_v2}/cbor_engine.rb +4 -5
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +3 -1
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +27 -16
- data/lib/aws-sdk-core/rpc_v2/handler.rb +2 -1
- data/lib/aws-sdk-core/rpc_v2/parser.rb +9 -1
- data/lib/aws-sdk-core/rpc_v2.rb +65 -2
- data/lib/aws-sdk-core/shared_config.rb +75 -21
- data/lib/aws-sdk-core/shared_credentials.rb +1 -0
- data/lib/aws-sdk-core/sso_credentials.rb +2 -0
- data/lib/aws-sdk-core/static_token_provider.rb +1 -2
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +13 -15
- data/lib/aws-sdk-core/stubbing.rb +2 -2
- data/lib/aws-sdk-core/token.rb +3 -3
- data/lib/aws-sdk-core/token_provider.rb +4 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
- data/lib/aws-sdk-core/util.rb +2 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +3 -1
- data/lib/aws-sdk-sso/client.rb +71 -39
- data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
- data/lib/aws-sdk-sso/endpoints.rb +2 -42
- data/lib/aws-sdk-sso/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +108 -59
- data/lib/aws-sdk-ssooidc/client_api.rb +6 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
- data/lib/aws-sdk-ssooidc/endpoints.rb +2 -42
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +1 -14
- data/lib/aws-sdk-ssooidc/types.rb +48 -16
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +279 -91
- data/lib/aws-sdk-sts/client_api.rb +33 -8
- data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
- data/lib/aws-sdk-sts/endpoint_provider.rb +50 -55
- data/lib/aws-sdk-sts/endpoints.rb +2 -94
- data/lib/aws-sdk-sts/errors.rb +15 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +1 -22
- data/lib/aws-sdk-sts/presigner.rb +2 -6
- data/lib/aws-sdk-sts/types.rb +170 -28
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/async_base.rb +4 -5
- data/lib/seahorse/client/base.rb +0 -14
- data/lib/seahorse/client/h2/connection.rb +18 -28
- data/lib/seahorse/client/http/response.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +4 -1
- data/lib/seahorse/client/networking_error.rb +1 -1
- data/lib/seahorse/client/plugins/h2.rb +4 -4
- data/lib/seahorse/client/request_context.rb +2 -2
- data/lib/seahorse/client/response.rb +2 -0
- data/lib/seahorse/util.rb +2 -1
- data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
- data/sig/seahorse/client/async_base.rbs +18 -0
- metadata +57 -17
@@ -20,7 +20,7 @@ module Aws
|
|
20
20
|
def apply(http_req, params)
|
21
21
|
@rules.shape.members.each do |name, ref|
|
22
22
|
value = params[name]
|
23
|
-
next if value.nil?
|
23
|
+
next if value.nil?
|
24
24
|
|
25
25
|
case ref.location
|
26
26
|
when 'header' then apply_header_value(http_req.headers, ref, value)
|
@@ -51,7 +51,7 @@ module Aws
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def list(headers, ref, values)
|
54
|
-
return if
|
54
|
+
return if values.nil?
|
55
55
|
|
56
56
|
member_ref = ref.shape.member
|
57
57
|
values = values.collect do |value|
|
@@ -68,7 +68,7 @@ module Aws
|
|
68
68
|
def apply_header_map(headers, ref, values)
|
69
69
|
prefix = ref.location_name || ''
|
70
70
|
values.each_pair do |name, value|
|
71
|
-
headers["#{prefix}#{name}"]
|
71
|
+
headers["#{prefix}#{name}"] ||= value.to_s
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative 'decoder'
|
3
|
+
require_relative '../cbor'
|
5
4
|
|
6
5
|
module Aws
|
7
|
-
module
|
6
|
+
module RpcV2
|
8
7
|
# Pure Ruby implementation of CBOR encode and decode
|
9
8
|
module CborEngine
|
10
9
|
def self.encode(data)
|
11
|
-
Encoder.new.add(data).bytes
|
10
|
+
Cbor::Encoder.new.add(data).bytes
|
12
11
|
end
|
13
12
|
|
14
13
|
def self.decode(bytes)
|
15
|
-
Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
14
|
+
Cbor::Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -13,11 +13,13 @@ module Aws
|
|
13
13
|
accept =
|
14
14
|
if eventstream_output?(context)
|
15
15
|
'application/vnd.amazon.eventstream'
|
16
|
+
else
|
17
|
+
'application/cbor'
|
16
18
|
end
|
17
19
|
|
18
20
|
headers = context.http_request.headers
|
19
21
|
headers['Content-Type'] ||= content_type if content_type
|
20
|
-
headers['Accept'] ||= accept
|
22
|
+
headers['Accept'] ||= accept
|
21
23
|
@handler.call(context)
|
22
24
|
end
|
23
25
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Aws
|
4
4
|
module RpcV2
|
5
|
+
# @api private
|
5
6
|
class ErrorHandler < Aws::ErrorHandler
|
6
7
|
|
7
8
|
def call(context)
|
@@ -27,7 +28,7 @@ module Aws
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def extract_error(body, context)
|
30
|
-
data =
|
31
|
+
data = RpcV2.decode(body)
|
31
32
|
code = error_code(data, context)
|
32
33
|
message = data['message']
|
33
34
|
data = parse_error_data(context, body, code)
|
@@ -37,10 +38,14 @@ module Aws
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def error_code(data, context)
|
41
|
+
# This is not correct per protocol tests. awsQueryError is intended to populate the
|
42
|
+
# error code of the error class. The error class should come from __type. Query and
|
43
|
+
# query compatible services currently have dynamic errors raised from error codes instead
|
44
|
+
# of the modeled error class. However, changing this in this major version would break
|
45
|
+
# existing usage.
|
40
46
|
code =
|
41
47
|
if aws_query_error?(context)
|
42
|
-
|
43
|
-
remove_prefix(error, context)
|
48
|
+
aws_query_error_code(context)
|
44
49
|
else
|
45
50
|
data['__type']
|
46
51
|
end
|
@@ -51,6 +56,25 @@ module Aws
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
59
|
+
def aws_query_error?(context)
|
60
|
+
context.config.api.metadata['awsQueryCompatible'] &&
|
61
|
+
context.http_response.headers['x-amzn-query-error']
|
62
|
+
end
|
63
|
+
|
64
|
+
def aws_query_error_code(context)
|
65
|
+
query_header = context.http_response.headers['x-amzn-query-error']
|
66
|
+
error, _type = query_header.split(';') # type not supported
|
67
|
+
remove_prefix(error, context)
|
68
|
+
end
|
69
|
+
|
70
|
+
def remove_prefix(error_code, context)
|
71
|
+
if (prefix = context.config.api.metadata['errorPrefix'])
|
72
|
+
error_code.sub(/^#{prefix}/, '')
|
73
|
+
else
|
74
|
+
error_code
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
54
78
|
def parse_error_data(context, body, code)
|
55
79
|
data = EmptyStructure.new
|
56
80
|
if (error_rules = context.operation.errors)
|
@@ -66,19 +90,6 @@ module Aws
|
|
66
90
|
end
|
67
91
|
data
|
68
92
|
end
|
69
|
-
|
70
|
-
def aws_query_error?(context)
|
71
|
-
context.config.api.metadata['awsQueryCompatible'] &&
|
72
|
-
context.http_response.headers['x-amzn-query-error']
|
73
|
-
end
|
74
|
-
|
75
|
-
def remove_prefix(error_code, context)
|
76
|
-
if (prefix = context.config.api.metadata['errorPrefix'])
|
77
|
-
error_code.sub(/^#{prefix}/, '')
|
78
|
-
else
|
79
|
-
error_code
|
80
|
-
end
|
81
|
-
end
|
82
93
|
end
|
83
94
|
end
|
84
95
|
end
|
@@ -20,7 +20,8 @@ module Aws
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def build_request(context)
|
23
|
-
context.http_request.headers['
|
23
|
+
context.http_request.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
|
24
|
+
context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
|
24
25
|
context.http_request.http_method = 'POST'
|
25
26
|
context.http_request.body = build_body(context)
|
26
27
|
build_url(context)
|
@@ -16,7 +16,7 @@ module Aws
|
|
16
16
|
def parse(cbor, target = nil)
|
17
17
|
return {} if cbor.empty?
|
18
18
|
|
19
|
-
parse_ref(@rules,
|
19
|
+
parse_ref(@rules, RpcV2.decode(cbor), target)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -85,6 +85,14 @@ module Aws
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
+
|
89
|
+
def flattened_list?(shape)
|
90
|
+
shape.is_a?(ListShape) && shape.flattened
|
91
|
+
end
|
92
|
+
|
93
|
+
def flattened_map?(shape)
|
94
|
+
shape.is_a?(MapShape) && shape.flattened
|
95
|
+
end
|
88
96
|
end
|
89
97
|
end
|
90
98
|
end
|
data/lib/aws-sdk-core/rpc_v2.rb
CHANGED
@@ -1,6 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'cbor'
|
2
|
-
require_relative 'rpc_v2/
|
4
|
+
require_relative 'rpc_v2/builder'
|
3
5
|
require_relative 'rpc_v2/content_type_handler'
|
4
6
|
require_relative 'rpc_v2/error_handler'
|
5
|
-
require_relative 'rpc_v2/
|
7
|
+
require_relative 'rpc_v2/handler'
|
6
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
|
@@ -138,7 +138,11 @@ module Aws
|
|
138
138
|
role_session_name: entry['role_session_name']
|
139
139
|
}
|
140
140
|
cfg[:region] = opts[:region] if opts[:region]
|
141
|
-
|
141
|
+
with_metrics('CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN') do
|
142
|
+
creds = AssumeRoleWebIdentityCredentials.new(cfg)
|
143
|
+
creds.metrics << 'CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN'
|
144
|
+
creds
|
145
|
+
end
|
142
146
|
end
|
143
147
|
end
|
144
148
|
end
|
@@ -199,6 +203,7 @@ module Aws
|
|
199
203
|
config_reader(
|
200
204
|
:region,
|
201
205
|
:account_id_endpoint_mode,
|
206
|
+
:auth_scheme_preference,
|
202
207
|
:sigv4a_signing_region_set,
|
203
208
|
:ca_bundle,
|
204
209
|
:credential_process,
|
@@ -208,10 +213,13 @@ module Aws
|
|
208
213
|
:ec2_metadata_service_endpoint,
|
209
214
|
:ec2_metadata_service_endpoint_mode,
|
210
215
|
:ec2_metadata_v1_disabled,
|
216
|
+
:disable_host_prefix_injection,
|
211
217
|
:max_attempts,
|
212
218
|
:retry_mode,
|
213
219
|
:adaptive_retry_wait_to_fill,
|
214
220
|
:correct_clock_skew,
|
221
|
+
:request_checksum_calculation,
|
222
|
+
:response_checksum_validation,
|
215
223
|
:csm_client_id,
|
216
224
|
:csm_enabled,
|
217
225
|
:csm_host,
|
@@ -253,8 +261,8 @@ module Aws
|
|
253
261
|
'provide only source_profile or credential_source, not both.'
|
254
262
|
elsif opts[:source_profile]
|
255
263
|
opts[:visited_profiles] ||= Set.new
|
256
|
-
|
257
|
-
if opts[:credentials]
|
264
|
+
provider = resolve_source_profile(opts[:source_profile], opts)
|
265
|
+
if provider && (opts[:credentials] = provider.credentials)
|
258
266
|
opts[:role_session_name] ||= prof_cfg['role_session_name']
|
259
267
|
opts[:role_session_name] ||= 'default_session'
|
260
268
|
opts[:role_arn] ||= prof_cfg['role_arn']
|
@@ -263,17 +271,28 @@ module Aws
|
|
263
271
|
opts[:serial_number] ||= prof_cfg['mfa_serial']
|
264
272
|
opts[:profile] = opts.delete(:source_profile)
|
265
273
|
opts.delete(:visited_profiles)
|
266
|
-
|
274
|
+
|
275
|
+
metrics = provider.metrics
|
276
|
+
if provider.is_a?(AssumeRoleCredentials)
|
277
|
+
opts[:credentials] = provider
|
278
|
+
metrics.delete('CREDENTIALS_STS_ASSUME_ROLE')
|
279
|
+
else
|
280
|
+
metrics << 'CREDENTIALS_PROFILE_SOURCE_PROFILE'
|
281
|
+
end
|
282
|
+
# Set the original credentials metrics to [] to prevent duplicate metrics during sign plugin
|
283
|
+
opts[:credentials].metrics = []
|
284
|
+
with_metrics(metrics) do
|
285
|
+
creds = AssumeRoleCredentials.new(opts)
|
286
|
+
creds.metrics.push(*metrics)
|
287
|
+
creds
|
288
|
+
end
|
267
289
|
else
|
268
290
|
raise Errors::NoSourceProfileError,
|
269
291
|
"Profile #{profile} has a role_arn, and source_profile, but the"\
|
270
292
|
' source_profile does not have credentials.'
|
271
293
|
end
|
272
294
|
elsif credential_source
|
273
|
-
opts[:credentials] = credentials_from_source(
|
274
|
-
credential_source,
|
275
|
-
chain_config
|
276
|
-
)
|
295
|
+
opts[:credentials] = credentials_from_source(credential_source, chain_config)
|
277
296
|
if opts[:credentials]
|
278
297
|
opts[:role_session_name] ||= prof_cfg['role_session_name']
|
279
298
|
opts[:role_session_name] ||= 'default_session'
|
@@ -282,7 +301,16 @@ module Aws
|
|
282
301
|
opts[:external_id] ||= prof_cfg['external_id']
|
283
302
|
opts[:serial_number] ||= prof_cfg['mfa_serial']
|
284
303
|
opts.delete(:source_profile) # Cleanup
|
285
|
-
|
304
|
+
|
305
|
+
metrics = opts[:credentials].metrics
|
306
|
+
metrics << 'CREDENTIALS_PROFILE_NAMED_PROVIDER'
|
307
|
+
# Set the original credentials metrics to [] to prevent duplicate metrics during sign plugin
|
308
|
+
opts[:credentials].metrics = []
|
309
|
+
with_metrics(metrics) do
|
310
|
+
creds = AssumeRoleCredentials.new(opts)
|
311
|
+
creds.metrics.push(*metrics)
|
312
|
+
creds
|
313
|
+
end
|
286
314
|
else
|
287
315
|
raise Errors::NoSourceCredentials,
|
288
316
|
"Profile #{profile} could not get source credentials from"\
|
@@ -310,12 +338,24 @@ module Aws
|
|
310
338
|
elsif profile_config && profile_config['source_profile']
|
311
339
|
opts.delete(:source_profile)
|
312
340
|
assume_role_credentials_from_config(opts.merge(profile: profile))
|
313
|
-
elsif (provider =
|
314
|
-
provider
|
341
|
+
elsif (provider = assume_role_web_identity_credentials_from_config_with_metrics(opts.merge(profile: profile)))
|
342
|
+
provider if provider.credentials.set?
|
315
343
|
elsif (provider = assume_role_process_credentials_from_config(profile))
|
316
|
-
provider
|
317
|
-
elsif (provider =
|
318
|
-
provider
|
344
|
+
provider if provider.credentials.set?
|
345
|
+
elsif (provider = sso_credentials_from_config_with_metrics(profile))
|
346
|
+
provider if provider.credentials.set?
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def assume_role_web_identity_credentials_from_config_with_metrics(opts)
|
351
|
+
with_metrics('CREDENTIALS_PROFILE_SOURCE_PROFILE') do
|
352
|
+
assume_role_web_identity_credentials_from_config(opts)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
def sso_credentials_from_config_with_metrics(profile)
|
357
|
+
with_metrics('CREDENTIALS_PROFILE_SOURCE_PROFILE') do
|
358
|
+
sso_credentials_from_config(profile: profile)
|
319
359
|
end
|
320
360
|
end
|
321
361
|
|
@@ -340,7 +380,11 @@ module Aws
|
|
340
380
|
if @parsed_config
|
341
381
|
credential_process ||= @parsed_config.fetch(profile, {})['credential_process']
|
342
382
|
end
|
343
|
-
|
383
|
+
if credential_process
|
384
|
+
creds = ProcessCredentials.new([credential_process])
|
385
|
+
creds.metrics << 'CREDENTIALS_PROFILE_PROCESS'
|
386
|
+
creds
|
387
|
+
end
|
344
388
|
end
|
345
389
|
|
346
390
|
def credentials_from_shared(profile, _opts)
|
@@ -384,13 +428,18 @@ module Aws
|
|
384
428
|
sso_start_url = prof_config['sso_start_url']
|
385
429
|
end
|
386
430
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
431
|
+
metric = prof_config['sso_session'] ? 'CREDENTIALS_PROFILE_SSO' : 'CREDENTIALS_PROFILE_SSO_LEGACY'
|
432
|
+
with_metrics(metric) do
|
433
|
+
creds = SSOCredentials.new(
|
434
|
+
sso_account_id: prof_config['sso_account_id'],
|
435
|
+
sso_role_name: prof_config['sso_role_name'],
|
436
|
+
sso_session: prof_config['sso_session'],
|
437
|
+
sso_region: sso_region,
|
438
|
+
sso_start_url: sso_start_url
|
393
439
|
)
|
440
|
+
creds.metrics << metric
|
441
|
+
creds
|
442
|
+
end
|
394
443
|
end
|
395
444
|
end
|
396
445
|
|
@@ -418,6 +467,7 @@ module Aws
|
|
418
467
|
prof_config['aws_session_token'],
|
419
468
|
account_id: prof_config['aws_account_id']
|
420
469
|
)
|
470
|
+
creds.metrics = ['CREDENTIALS_PROFILE']
|
421
471
|
creds if creds.set?
|
422
472
|
end
|
423
473
|
|
@@ -478,5 +528,9 @@ module Aws
|
|
478
528
|
|
479
529
|
sso_session
|
480
530
|
end
|
531
|
+
|
532
|
+
def with_metrics(metrics, &block)
|
533
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
534
|
+
end
|
481
535
|
end
|
482
536
|
end
|
@@ -91,6 +91,7 @@ module Aws
|
|
91
91
|
client_opts[:credentials] = nil
|
92
92
|
@client = Aws::SSO::Client.new(client_opts)
|
93
93
|
end
|
94
|
+
@metrics = ['CREDENTIALS_SSO']
|
94
95
|
else # legacy behavior
|
95
96
|
missing_keys = LEGACY_REQUIRED_OPTS.select { |k| options[k].nil? }
|
96
97
|
unless missing_keys.empty?
|
@@ -111,6 +112,7 @@ module Aws
|
|
111
112
|
client_opts[:credentials] = nil
|
112
113
|
|
113
114
|
@client = options[:client] || Aws::SSO::Client.new(client_opts)
|
115
|
+
@metrics = ['CREDENTIALS_SSO_LEGACY']
|
114
116
|
end
|
115
117
|
|
116
118
|
@async_refresh = true
|
@@ -2,12 +2,11 @@
|
|
2
2
|
|
3
3
|
module Aws
|
4
4
|
class StaticTokenProvider
|
5
|
-
|
6
5
|
include TokenProvider
|
7
6
|
|
8
7
|
# @param [String] token
|
9
8
|
# @param [Time] expiration
|
10
|
-
def initialize(token, expiration=nil)
|
9
|
+
def initialize(token, expiration = nil)
|
11
10
|
@token = Token.new(token, expiration)
|
12
11
|
end
|
13
12
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<ErrorResponse>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
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(
|
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[
|
12
|
-
resp.headers[
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
{
|
22
|
-
|
23
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
28
|
+
builder.node("#{operation.name}Response", xmlns: xmlns(api)) do
|
28
29
|
if (rules = operation.output)
|
29
|
-
rules.location_name = operation.name
|
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[
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
{
|
21
|
-
|
22
|
-
|
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
|
-
|
26
|
+
resp
|
26
27
|
end
|
27
28
|
|
28
29
|
end
|