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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +297 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +1 -2
- data/lib/aws-defaults.rb +4 -1
- data/lib/aws-sdk-core/arn.rb +1 -3
- data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -4
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +53 -0
- data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
- data/lib/aws-sdk-core/client_stubs.rb +8 -7
- data/lib/aws-sdk-core/credential_provider_chain.rb +13 -6
- data/lib/aws-sdk-core/credentials.rb +13 -6
- data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
- data/lib/aws-sdk-core/endpoints/matchers.rb +6 -9
- data/lib/aws-sdk-core/endpoints.rb +74 -18
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +9 -0
- data/lib/aws-sdk-core/json/error_handler.rb +8 -9
- data/lib/aws-sdk-core/json/handler.rb +6 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +2 -0
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/param_filter.rb +2 -2
- data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
- data/lib/aws-sdk-core/log.rb +10 -0
- data/lib/aws-sdk-core/param_validator.rb +1 -1
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -169
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -3
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +5 -1
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -25
- data/lib/aws-sdk-core/plugins/retry_errors.rb +0 -1
- data/lib/aws-sdk-core/plugins/sign.rb +13 -11
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
- data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +26 -8
- data/lib/aws-sdk-core/plugins.rb +39 -0
- data/lib/aws-sdk-core/process_credentials.rb +47 -28
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/{request/content_type.rb → content_type_handler.rb} +1 -1
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/endpoint.rb +3 -1
- data/lib/aws-sdk-core/rest/request/headers.rb +2 -2
- data/lib/aws-sdk-core/rest.rb +1 -1
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +69 -0
- data/lib/aws-sdk-core/shared_config.rb +7 -2
- data/lib/aws-sdk-core/shared_credentials.rb +0 -7
- data/lib/aws-sdk-core/sso_credentials.rb +2 -1
- 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 +39 -0
- data/lib/aws-sdk-core/stubbing.rb +22 -0
- data/lib/aws-sdk-core/telemetry/base.rb +177 -0
- data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
- data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
- data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
- data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
- data/lib/aws-sdk-core/telemetry.rb +78 -0
- data/lib/aws-sdk-core/waiters/poller.rb +9 -4
- data/lib/aws-sdk-core/xml/error_handler.rb +11 -37
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +82 -108
- data/lib/aws-sdk-sso/client.rb +99 -37
- data/lib/aws-sdk-sso/client_api.rb +7 -0
- 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 -54
- data/lib/aws-sdk-sso/plugins/endpoints.rb +19 -20
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +123 -55
- data/lib/aws-sdk-ssooidc/client_api.rb +5 -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 -54
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +19 -20
- data/lib/aws-sdk-ssooidc/types.rb +21 -15
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +307 -89
- data/lib/aws-sdk-sts/client_api.rb +28 -2
- data/lib/aws-sdk-sts/customizations.rb +5 -1
- data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
- data/lib/aws-sdk-sts/endpoint_provider.rb +33 -38
- data/lib/aws-sdk-sts/endpoints.rb +2 -118
- data/lib/aws-sdk-sts/errors.rb +16 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +19 -28
- data/lib/aws-sdk-sts/types.rb +171 -28
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/base.rb +17 -7
- data/lib/seahorse/client/h2/handler.rb +13 -3
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +10 -2
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/net_http.rb +9 -0
- data/lib/seahorse/client/request_context.rb +8 -1
- data/lib/seahorse/client/response.rb +2 -0
- data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
- data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
- data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
- data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
- metadata +62 -18
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module RpcV2
|
7
|
+
class Parser
|
8
|
+
include Seahorse::Model::Shapes
|
9
|
+
|
10
|
+
# @param [Seahorse::Model::ShapeRef] rules
|
11
|
+
def initialize(rules, query_compatible: false)
|
12
|
+
@rules = rules
|
13
|
+
@query_compatible = query_compatible
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(cbor, target = nil)
|
17
|
+
return {} if cbor.empty?
|
18
|
+
|
19
|
+
parse_ref(@rules, RpcV2.decode(cbor), target)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def structure(ref, values, target = nil)
|
25
|
+
shape = ref.shape
|
26
|
+
target = ref.shape.struct_class.new if target.nil?
|
27
|
+
values.each do |key, value|
|
28
|
+
member_name, member_ref = shape.member_by_location_name(key)
|
29
|
+
if member_ref
|
30
|
+
target[member_name] = parse_ref(member_ref, value)
|
31
|
+
elsif shape.union && key != '__type'
|
32
|
+
target[:unknown] = { 'name' => key, 'value' => value }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# In services that were previously Query/XML, members that were
|
36
|
+
# "flattened" defaulted to empty lists. In JSON, these values are nil,
|
37
|
+
# which is backwards incompatible. To preserve backwards compatibility,
|
38
|
+
# we set a default value of [] for these members.
|
39
|
+
if @query_compatible
|
40
|
+
ref.shape.members.each do |member_name, member_target|
|
41
|
+
next unless target[member_name].nil?
|
42
|
+
|
43
|
+
if flattened_list?(member_target.shape)
|
44
|
+
target[member_name] = []
|
45
|
+
elsif flattened_map?(member_target.shape)
|
46
|
+
target[member_name] = {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if shape.union
|
52
|
+
# convert to subclass
|
53
|
+
member_subclass = shape.member_subclass(target.member).new
|
54
|
+
member_subclass[target.member] = target.value
|
55
|
+
target = member_subclass
|
56
|
+
end
|
57
|
+
target
|
58
|
+
end
|
59
|
+
|
60
|
+
def list(ref, values, target = nil)
|
61
|
+
target = [] if target.nil?
|
62
|
+
values.each do |value|
|
63
|
+
target << parse_ref(ref.shape.member, value)
|
64
|
+
end
|
65
|
+
target
|
66
|
+
end
|
67
|
+
|
68
|
+
def map(ref, values, target = nil)
|
69
|
+
target = {} if target.nil?
|
70
|
+
values.each do |key, value|
|
71
|
+
target[key] = parse_ref(ref.shape.value, value) unless value.nil?
|
72
|
+
end
|
73
|
+
target
|
74
|
+
end
|
75
|
+
|
76
|
+
def parse_ref(ref, value, target = nil)
|
77
|
+
if value.nil?
|
78
|
+
nil
|
79
|
+
else
|
80
|
+
case ref.shape
|
81
|
+
when StructureShape then structure(ref, value, target)
|
82
|
+
when ListShape then list(ref, value, target)
|
83
|
+
when MapShape then map(ref, value, target)
|
84
|
+
else value
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cbor'
|
4
|
+
require_relative 'rpc_v2/builder'
|
5
|
+
require_relative 'rpc_v2/content_type_handler'
|
6
|
+
require_relative 'rpc_v2/error_handler'
|
7
|
+
require_relative 'rpc_v2/handler'
|
8
|
+
require_relative 'rpc_v2/parser'
|
9
|
+
|
10
|
+
module Aws
|
11
|
+
# @api private
|
12
|
+
module RpcV2
|
13
|
+
class << self
|
14
|
+
# @param [Symbol,Class] engine
|
15
|
+
# Must be one of the following values:
|
16
|
+
#
|
17
|
+
# * :cbor
|
18
|
+
#
|
19
|
+
def engine=(engine)
|
20
|
+
@engine = Class === engine ? engine : load_engine(engine)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Class] Returns the default engine.
|
24
|
+
# One of:
|
25
|
+
#
|
26
|
+
# * {CborEngine}
|
27
|
+
#
|
28
|
+
def engine
|
29
|
+
set_default_engine unless @engine
|
30
|
+
@engine
|
31
|
+
end
|
32
|
+
|
33
|
+
def encode(data)
|
34
|
+
@engine.encode(data)
|
35
|
+
end
|
36
|
+
|
37
|
+
def decode(bytes)
|
38
|
+
bytes.force_encoding(Encoding::BINARY)
|
39
|
+
@engine.decode(bytes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_default_engine
|
43
|
+
[:cbor].each do |name|
|
44
|
+
@engine ||= try_load_engine(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless @engine
|
48
|
+
raise 'Unable to find a compatible cbor library.'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def load_engine(name)
|
55
|
+
require "aws-sdk-core/rpc_v2/#{name}_engine"
|
56
|
+
const_name = name[0].upcase + name[1..-1] + 'Engine'
|
57
|
+
const_get(const_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def try_load_engine(name)
|
61
|
+
load_engine(name)
|
62
|
+
rescue LoadError
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
set_default_engine
|
68
|
+
end
|
69
|
+
end
|
@@ -198,6 +198,8 @@ module Aws
|
|
198
198
|
|
199
199
|
config_reader(
|
200
200
|
:region,
|
201
|
+
:account_id_endpoint_mode,
|
202
|
+
:sigv4a_signing_region_set,
|
201
203
|
:ca_bundle,
|
202
204
|
:credential_process,
|
203
205
|
:endpoint_discovery_enabled,
|
@@ -210,6 +212,8 @@ module Aws
|
|
210
212
|
:retry_mode,
|
211
213
|
:adaptive_retry_wait_to_fill,
|
212
214
|
:correct_clock_skew,
|
215
|
+
:request_checksum_calculation,
|
216
|
+
:response_checksum_validation,
|
213
217
|
:csm_client_id,
|
214
218
|
:csm_enabled,
|
215
219
|
:csm_host,
|
@@ -338,7 +342,7 @@ module Aws
|
|
338
342
|
if @parsed_config
|
339
343
|
credential_process ||= @parsed_config.fetch(profile, {})['credential_process']
|
340
344
|
end
|
341
|
-
ProcessCredentials.new(credential_process) if credential_process
|
345
|
+
ProcessCredentials.new([credential_process]) if credential_process
|
342
346
|
end
|
343
347
|
|
344
348
|
def credentials_from_shared(profile, _opts)
|
@@ -413,7 +417,8 @@ module Aws
|
|
413
417
|
creds = Credentials.new(
|
414
418
|
prof_config['aws_access_key_id'],
|
415
419
|
prof_config['aws_secret_access_key'],
|
416
|
-
prof_config['aws_session_token']
|
420
|
+
prof_config['aws_session_token'],
|
421
|
+
account_id: prof_config['aws_account_id']
|
417
422
|
)
|
418
423
|
creds if creds.set?
|
419
424
|
end
|
@@ -7,13 +7,6 @@ module Aws
|
|
7
7
|
|
8
8
|
include CredentialProvider
|
9
9
|
|
10
|
-
# @api private
|
11
|
-
KEY_MAP = {
|
12
|
-
'aws_access_key_id' => 'access_key_id',
|
13
|
-
'aws_secret_access_key' => 'secret_access_key',
|
14
|
-
'aws_session_token' => 'session_token',
|
15
|
-
}
|
16
|
-
|
17
10
|
# Constructs a new SharedCredentials object. This will load static
|
18
11
|
# (access_key_id, secret_access_key and session_token) AWS access
|
19
12
|
# credentials from an ini file, which supports profiles. The default
|
@@ -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
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Aws
|
4
4
|
module Stubbing
|
5
5
|
module Protocols
|
6
|
+
# @api private
|
6
7
|
class RestXml < Rest
|
7
8
|
|
8
9
|
def body_for(api, operation, rules, data)
|
@@ -10,7 +11,7 @@ module Aws
|
|
10
11
|
encode_eventstream_response(rules, data, Xml::Builder)
|
11
12
|
else
|
12
13
|
xml = []
|
13
|
-
rules.location_name = operation.name
|
14
|
+
rules.location_name = "#{operation.name}Result"
|
14
15
|
rules['xmlNamespace'] = { 'uri' => api.metadata['xmlNamespace'] }
|
15
16
|
Xml::Builder.new(rules, target:xml).to_xml(data)
|
16
17
|
xml.join
|
@@ -18,10 +19,10 @@ module Aws
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def stub_error(error_code)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
resp = Seahorse::Client::Http::Response.new
|
23
|
+
resp.status_code = 400
|
24
|
+
resp.body = XmlError.new(error_code).to_xml
|
25
|
+
resp
|
25
26
|
end
|
26
27
|
|
27
28
|
def xmlns(api)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Stubbing
|
5
|
+
module Protocols
|
6
|
+
# @api private
|
7
|
+
class RpcV2
|
8
|
+
|
9
|
+
def stub_data(_api, operation, data)
|
10
|
+
resp = Seahorse::Client::Http::Response.new
|
11
|
+
resp.status_code = 200
|
12
|
+
resp.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
|
13
|
+
resp.headers['Content-Type'] = 'application/cbor'
|
14
|
+
resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
|
15
|
+
resp.body = build_body(operation, data)
|
16
|
+
resp
|
17
|
+
end
|
18
|
+
|
19
|
+
def stub_error(error_code)
|
20
|
+
resp = Seahorse::Client::Http::Response.new
|
21
|
+
resp.status_code = 400
|
22
|
+
resp.body = Aws::RpcV2.encode(
|
23
|
+
{
|
24
|
+
'code' => error_code,
|
25
|
+
'message' => 'stubbed-response-error-message'
|
26
|
+
}
|
27
|
+
)
|
28
|
+
resp
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def build_body(operation, data)
|
34
|
+
Aws::RpcV2::Builder.new(operation.output).serialize(data)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
# @api private
|
5
|
+
module Stubbing
|
6
|
+
autoload :EmptyStub, 'aws-sdk-core/stubbing/empty_stub'
|
7
|
+
autoload :DataApplicator, 'aws-sdk-core/stubbing/data_applicator'
|
8
|
+
autoload :StubData, 'aws-sdk-core/stubbing/stub_data'
|
9
|
+
autoload :XmlError, 'aws-sdk-core/stubbing/xml_error'
|
10
|
+
|
11
|
+
module Protocols
|
12
|
+
autoload :Json, 'aws-sdk-core/stubbing/protocols/json'
|
13
|
+
autoload :Rest, 'aws-sdk-core/stubbing/protocols/rest'
|
14
|
+
autoload :RestJson, 'aws-sdk-core/stubbing/protocols/rest_json'
|
15
|
+
autoload :RestXml, 'aws-sdk-core/stubbing/protocols/rest_xml'
|
16
|
+
autoload :Query, 'aws-sdk-core/stubbing/protocols/query'
|
17
|
+
autoload :EC2, 'aws-sdk-core/stubbing/protocols/ec2'
|
18
|
+
autoload :RpcV2, 'aws-sdk-core/stubbing/protocols/rpc_v2'
|
19
|
+
autoload :ApiGateway, 'aws-sdk-core/stubbing/protocols/api_gateway'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Telemetry
|
5
|
+
# Base for `TelemetryProvider` classes.
|
6
|
+
# They are used to emit telemetry data. It needs the
|
7
|
+
# following class implementations to function:
|
8
|
+
# * {TracerProviderBase} - A provider that returns a tracer
|
9
|
+
# instance. Then, a tracer will create spans and those
|
10
|
+
# spans will contain information in that given moment.
|
11
|
+
# * {ContextManagerBase} - Manages context and used to
|
12
|
+
# return the current context within a trace.
|
13
|
+
class TelemetryProviderBase
|
14
|
+
# @param [Aws::Telemetry::TracerBase] tracer_provider A provider
|
15
|
+
# that returns a tracer instance.
|
16
|
+
# @param [Aws::Telemetry::ContextManagerBase] context_manager Manages
|
17
|
+
# context and used to return the current context.
|
18
|
+
def initialize(tracer_provider: nil, context_manager: nil)
|
19
|
+
@tracer_provider = tracer_provider
|
20
|
+
@context_manager = context_manager
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Aws::Telemetry::TracerProviderBase]
|
24
|
+
attr_reader :tracer_provider
|
25
|
+
|
26
|
+
# @return [Aws::Telemetry::ContextManagerBase]
|
27
|
+
attr_reader :context_manager
|
28
|
+
end
|
29
|
+
|
30
|
+
# Base for `TracerProvider` classes.
|
31
|
+
class TracerProviderBase
|
32
|
+
# Returns a Tracer instance.
|
33
|
+
#
|
34
|
+
# @param [String] name Tracer name
|
35
|
+
# @return [Aws::Telemetry::TracerBase]
|
36
|
+
def tracer(name = nil)
|
37
|
+
raise NotImplementedError
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Base for `Tracer` classes.
|
42
|
+
class TracerBase
|
43
|
+
# Used when a caller wants to manage the activation/deactivation and
|
44
|
+
# lifecycle of the Span and its parent manually.
|
45
|
+
#
|
46
|
+
# @param [String] name Span name
|
47
|
+
# @param [Object] with_parent Parent Context
|
48
|
+
# @param [Hash] attributes Attributes to attach to the span
|
49
|
+
# @param [Aws::Telemetry::SpanKind] kind Type of Span
|
50
|
+
# @return [Aws::Telemetry::SpanBase]
|
51
|
+
def start_span(name, with_parent: nil, attributes: nil, kind: nil)
|
52
|
+
raise NotImplementedError
|
53
|
+
end
|
54
|
+
|
55
|
+
# A helper for the default use-case of extending the current trace
|
56
|
+
# with a span.
|
57
|
+
# On exit, the Span that was active before calling this method will
|
58
|
+
# be reactivated. If an exception occurs during the execution of the
|
59
|
+
# provided block, it will be recorded on the span and re-raised.
|
60
|
+
#
|
61
|
+
# @param [String] name Span name
|
62
|
+
# @param [Hash] attributes Attributes to attach to the span
|
63
|
+
# @param [Aws::Telemetry::SpanKind] kind Type of Span
|
64
|
+
# @return [Aws::Telemetry::SpanBase]
|
65
|
+
def in_span(name, attributes: nil, kind: nil)
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the current active span.
|
70
|
+
#
|
71
|
+
# @return [Aws::Telemetry::SpanBase]
|
72
|
+
def current_span
|
73
|
+
raise NotImplementedError
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Base for `Span` classes.
|
78
|
+
class SpanBase
|
79
|
+
# Set attribute.
|
80
|
+
#
|
81
|
+
# @param [String] key
|
82
|
+
# @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
|
83
|
+
# Value must be non-nil and (array of) string, boolean or numeric type.
|
84
|
+
# Array values must not contain nil elements and all elements must be of
|
85
|
+
# the same basic type (string, numeric, boolean)
|
86
|
+
# @return [self] returns itself
|
87
|
+
def set_attribute(key, value)
|
88
|
+
raise NotImplementedError
|
89
|
+
end
|
90
|
+
alias []= set_attribute
|
91
|
+
|
92
|
+
# Add attributes.
|
93
|
+
#
|
94
|
+
# @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric,
|
95
|
+
# Boolean>}] attributes Values must be non-nil and (array of) string,
|
96
|
+
# boolean or numeric type. Array values must not contain nil elements
|
97
|
+
# and all elements must be of the same basic type (string, numeric,
|
98
|
+
# boolean)
|
99
|
+
# @return [self] returns itself
|
100
|
+
def add_attributes(attributes)
|
101
|
+
raise NotImplementedError
|
102
|
+
end
|
103
|
+
|
104
|
+
# Add event to a Span.
|
105
|
+
#
|
106
|
+
# @param [String] name Name of the event
|
107
|
+
# @param [Hash{String => String, Numeric, Boolean, Array<String,
|
108
|
+
# Numeric, Boolean>}] attributes Values must be non-nil and (array of)
|
109
|
+
# string, boolean or numeric type. Array values must not contain nil
|
110
|
+
# elements and all elements must be of the same basic type (string,
|
111
|
+
# numeric, boolean)
|
112
|
+
# @return [self] returns itself
|
113
|
+
def add_event(name, attributes: nil)
|
114
|
+
raise NotImplementedError
|
115
|
+
end
|
116
|
+
|
117
|
+
# Sets the Span status.
|
118
|
+
#
|
119
|
+
# @param [Aws::Telemetry::SpanStatus] status The new status, which
|
120
|
+
# overrides the default Span status, which is `OK`
|
121
|
+
# @return [void]
|
122
|
+
def status=(status)
|
123
|
+
raise NotImplementedError
|
124
|
+
end
|
125
|
+
|
126
|
+
# Finishes the Span.
|
127
|
+
#
|
128
|
+
# @param [Time] end_timestamp End timestamp for the span.
|
129
|
+
# @return [self] returns itself
|
130
|
+
def finish(end_timestamp: nil)
|
131
|
+
raise NotImplementedError
|
132
|
+
end
|
133
|
+
|
134
|
+
# Record an exception during the execution of this span. Multiple
|
135
|
+
# exceptions can be recorded on a span.
|
136
|
+
#
|
137
|
+
# @param [Exception] exception The exception to be recorded
|
138
|
+
# @param [Hash{String => String, Numeric, Boolean, Array<String,
|
139
|
+
# Numeric, Boolean>}] attributes One or more key:value pairs, where the
|
140
|
+
# keys must be strings and the values may be (array of) string, boolean
|
141
|
+
# or numeric type.
|
142
|
+
# @return [void]
|
143
|
+
def record_exception(exception, attributes: nil)
|
144
|
+
raise NotImplementedError
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Base for all `ContextManager` classes.
|
149
|
+
class ContextManagerBase
|
150
|
+
# Returns current context.
|
151
|
+
#
|
152
|
+
# @return [Context]
|
153
|
+
def current
|
154
|
+
raise NotImplementedError
|
155
|
+
end
|
156
|
+
|
157
|
+
# Associates a Context with the caller’s current execution unit.
|
158
|
+
# Returns a token to be used with the matching call to detach.
|
159
|
+
#
|
160
|
+
# @param [Object] context The new context
|
161
|
+
# @return [Object] token A token to be used when detaching
|
162
|
+
def attach(context)
|
163
|
+
raise NotImplementedError
|
164
|
+
end
|
165
|
+
|
166
|
+
# Restore the previous Context associated with the current
|
167
|
+
# execution unit to the value it had before attaching a
|
168
|
+
# specified Context.
|
169
|
+
#
|
170
|
+
# @param [Object] token The token provided by matching the call to attach
|
171
|
+
# @return [Boolean] `True` if the calls matched, `False` otherwise
|
172
|
+
def detach(token)
|
173
|
+
raise NotImplementedError
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|