aws-sdk-core 3.185.1 → 3.214.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +409 -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/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 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- 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 +310 -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 +23 -19
- data/lib/aws-sdk-core/credential_provider.rb +1 -1
- 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/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +78 -11
- 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 +11 -2
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +17 -11
- data/lib/aws-sdk-core/json/handler.rb +13 -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 +32 -2
- 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.rb +10 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +1 -1
- data/lib/aws-sdk-core/param_validator.rb +7 -2
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +6 -3
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +9 -3
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- 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 +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- 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/request_compression.rb +11 -2
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +27 -15
- 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 +30 -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 +70 -26
- 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/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +12 -6
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +14 -6
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- 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/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +10 -5
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +82 -107
- data/lib/aws-sdk-sso/client.rb +119 -55
- 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/endpoints.rb +2 -54
- data/lib/aws-sdk-sso/plugins/endpoints.rb +23 -22
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +504 -83
- data/lib/aws-sdk-ssooidc/client_api.rb +83 -1
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +2 -2
- data/lib/aws-sdk-ssooidc/endpoints.rb +2 -40
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +23 -20
- data/lib/aws-sdk-ssooidc/types.rb +373 -51
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +334 -105
- data/lib/aws-sdk-sts/client_api.rb +36 -10
- 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 +2 -2
- data/lib/aws-sdk-sts/endpoints.rb +2 -118
- data/lib/aws-sdk-sts/plugins/endpoints.rb +23 -30
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +188 -30
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/async_base.rb +1 -1
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -7
- data/lib/seahorse/client/h2/handler.rb +14 -3
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +11 -11
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/net_http/patches.rb +1 -4
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +57 -16
- data/lib/seahorse/client/request_context.rb +8 -1
- data/lib/seahorse/model/shapes.rb +2 -2
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -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
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +61 -19
- /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
@@ -27,13 +27,13 @@ module Aws
|
|
27
27
|
# @return [Seahorse::Client::Response]
|
28
28
|
def call(context)
|
29
29
|
build_request(context)
|
30
|
-
@handler.call(context).on_success do |
|
31
|
-
|
30
|
+
@handler.call(context).on_success do |resp|
|
31
|
+
resp.error = nil
|
32
32
|
parsed = parse_xml(context)
|
33
33
|
if parsed.nil? || parsed == EmptyStructure
|
34
|
-
|
34
|
+
resp.data = EmptyStructure.new
|
35
35
|
else
|
36
|
-
|
36
|
+
resp.data = parsed
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -36,7 +36,7 @@ module Aws
|
|
36
36
|
return
|
37
37
|
end
|
38
38
|
if flat?(ref)
|
39
|
-
if name = query_name(
|
39
|
+
if (name = query_name(ref))
|
40
40
|
parts = prefix.split('.')
|
41
41
|
parts.pop
|
42
42
|
parts.push(name)
|
@@ -82,7 +82,7 @@ module Aws
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def flat?(ref)
|
85
|
-
ref.shape.flattened
|
85
|
+
ref[:flattened] || ref.shape.flattened
|
86
86
|
end
|
87
87
|
|
88
88
|
def timestamp(ref, value)
|
data/lib/aws-sdk-core/query.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'query/ec2_param_builder'
|
4
3
|
require_relative 'query/handler'
|
4
|
+
require_relative 'query/ec2_handler'
|
5
5
|
require_relative 'query/param'
|
6
6
|
require_relative 'query/param_builder'
|
7
|
+
require_relative 'query/ec2_param_builder'
|
7
8
|
require_relative 'query/param_list'
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'thread'
|
4
|
-
|
5
3
|
module Aws
|
6
4
|
|
7
5
|
# Base class used credential classes that can be refreshed. This
|
@@ -48,6 +46,14 @@ module Aws
|
|
48
46
|
|
49
47
|
private
|
50
48
|
|
49
|
+
def sync_expiration_length
|
50
|
+
self.class::SYNC_EXPIRATION_LENGTH
|
51
|
+
end
|
52
|
+
|
53
|
+
def async_expiration_length
|
54
|
+
self.class::ASYNC_EXPIRATION_LENGTH
|
55
|
+
end
|
56
|
+
|
51
57
|
# Refreshes credentials asynchronously and synchronously.
|
52
58
|
# If we are near to expiration, block while getting new credentials.
|
53
59
|
# Otherwise, if we're approaching expiration, use the existing credentials
|
@@ -56,18 +62,18 @@ module Aws
|
|
56
62
|
# Note: This check is an optimization. Rather than acquire the mutex on every #refresh_if_near_expiration
|
57
63
|
# call, we check before doing so, and then we check within the mutex to avoid a race condition.
|
58
64
|
# See issue: https://github.com/aws/aws-sdk-ruby/issues/2641 for more info.
|
59
|
-
if near_expiration?(
|
65
|
+
if near_expiration?(sync_expiration_length)
|
60
66
|
@mutex.synchronize do
|
61
|
-
if near_expiration?(
|
67
|
+
if near_expiration?(sync_expiration_length)
|
62
68
|
@before_refresh.call(self) if @before_refresh
|
63
69
|
refresh
|
64
70
|
end
|
65
71
|
end
|
66
|
-
elsif @async_refresh && near_expiration?(
|
72
|
+
elsif @async_refresh && near_expiration?(async_expiration_length)
|
67
73
|
unless @mutex.locked?
|
68
74
|
Thread.new do
|
69
75
|
@mutex.synchronize do
|
70
|
-
if near_expiration?(
|
76
|
+
if near_expiration?(async_expiration_length)
|
71
77
|
@before_refresh.call(self) if @before_refresh
|
72
78
|
refresh
|
73
79
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Rest
|
5
|
+
# NOTE: headers could be already populated if specified on input shape
|
6
|
+
class ContentTypeHandler < Seahorse::Client::Handler
|
7
|
+
def call(context)
|
8
|
+
if eventstream?(context)
|
9
|
+
context.http_request.headers['Content-Type'] ||=
|
10
|
+
'application/vnd.amazon.eventstream'
|
11
|
+
elsif (payload = context.operation.input[:payload_member])
|
12
|
+
case payload.shape
|
13
|
+
when Seahorse::Model::Shapes::BlobShape
|
14
|
+
context.http_request.headers['Content-Type'] ||=
|
15
|
+
'application/octet-stream'
|
16
|
+
when Seahorse::Model::Shapes::StringShape
|
17
|
+
context.http_request.headers['Content-Type'] ||=
|
18
|
+
'text/plain'
|
19
|
+
else
|
20
|
+
apply_default_content_type(context)
|
21
|
+
end
|
22
|
+
elsif (body = context.http_request.body) &&
|
23
|
+
(!body.respond_to?(:size) || non_empty_body?(body))
|
24
|
+
apply_default_content_type(context)
|
25
|
+
end
|
26
|
+
|
27
|
+
@handler.call(context)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def non_empty_body?(body)
|
33
|
+
body.respond_to?(:size) && body.size.positive?
|
34
|
+
end
|
35
|
+
|
36
|
+
def eventstream?(context)
|
37
|
+
context.operation.input.shape.members.each do |_, ref|
|
38
|
+
return true if ref.eventstream
|
39
|
+
end
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
# content-type defaults as noted here:
|
44
|
+
# rest-json: https://smithy.io/2.0/aws/protocols/aws-restxml-protocol.html#content-type
|
45
|
+
# rest-xml: https://smithy.io/2.0/aws/protocols/aws-restxml-protocol.html#content-type
|
46
|
+
def apply_default_content_type(context)
|
47
|
+
protocol = context.config.api.metadata['protocol']
|
48
|
+
case protocol
|
49
|
+
when 'rest-json'
|
50
|
+
context.http_request.headers['Content-Type'] ||=
|
51
|
+
'application/json'
|
52
|
+
when 'rest-xml'
|
53
|
+
context.http_request.headers['Content-Type'] ||=
|
54
|
+
'application/xml'
|
55
|
+
else raise "Unsupported protocol #{protocol}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -7,10 +7,9 @@ module Aws
|
|
7
7
|
|
8
8
|
def call(context)
|
9
9
|
Rest::Request::Builder.new.apply(context)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
resp
|
10
|
+
response = @handler.call(context)
|
11
|
+
response.on(200..299) { |resp| Response::Parser.new.apply(resp) }
|
12
|
+
response.on(200..599) { |_resp| apply_request_id(context) }
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
@@ -18,10 +18,13 @@ module Aws
|
|
18
18
|
# @param [Hash] params
|
19
19
|
def apply(http_req, params)
|
20
20
|
body = build_body(params)
|
21
|
+
|
21
22
|
# for rest-json, ensure we send at least an empty object
|
22
23
|
# don't send an empty object for streaming? case.
|
23
|
-
if body.nil? &&
|
24
|
-
|
24
|
+
if body.nil? &&
|
25
|
+
json_builder? &&
|
26
|
+
modeled_body? &&
|
27
|
+
!streaming?
|
25
28
|
body = '{}'
|
26
29
|
end
|
27
30
|
http_req.body = body
|
@@ -45,13 +48,29 @@ module Aws
|
|
45
48
|
params[@rules[:payload]]
|
46
49
|
elsif @rules[:payload]
|
47
50
|
params = params[@rules[:payload]]
|
48
|
-
|
51
|
+
if params
|
52
|
+
if xml_builder? &&
|
53
|
+
@rules.shape.member?(@rules[:payload_member].location_name)
|
54
|
+
# serializing payload member name for rest-xml is as follows:
|
55
|
+
# 1. Use the member locationName if the member value doesn't match the member's name (default)
|
56
|
+
# 2. Use the value of the locationName on the member's target if present
|
57
|
+
# 3. Use the shape name of the member's target
|
58
|
+
serialize(@rules[:payload_member], params, location_name: payload_location_name)
|
59
|
+
else
|
60
|
+
serialize(@rules[:payload_member], params)
|
61
|
+
end
|
62
|
+
end
|
49
63
|
else
|
50
64
|
params = body_params(params)
|
51
65
|
serialize(@rules, params) unless params.empty?
|
52
66
|
end
|
53
67
|
end
|
54
68
|
|
69
|
+
def payload_location_name
|
70
|
+
@rules[:payload_member].shape['locationName'] ||
|
71
|
+
@rules[:payload_member].shape.name
|
72
|
+
end
|
73
|
+
|
55
74
|
def streaming?
|
56
75
|
@rules[:payload] && (
|
57
76
|
BlobShape === @rules[:payload_member].shape ||
|
@@ -59,8 +78,16 @@ module Aws
|
|
59
78
|
)
|
60
79
|
end
|
61
80
|
|
62
|
-
def
|
63
|
-
@serializer_class
|
81
|
+
def xml_builder?
|
82
|
+
@serializer_class == Xml::Builder
|
83
|
+
end
|
84
|
+
|
85
|
+
def json_builder?
|
86
|
+
@serializer_class == Json::Builder
|
87
|
+
end
|
88
|
+
|
89
|
+
def serialize(rules, params, location_name: nil)
|
90
|
+
@serializer_class.new(rules, location_name: location_name).serialize(params)
|
64
91
|
end
|
65
92
|
|
66
93
|
def body_params(params)
|
@@ -30,7 +30,9 @@ module Aws
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def apply_path_params(uri, params)
|
33
|
-
path = uri.path.sub(
|
33
|
+
path = uri.path.sub(%r{/$}, '')
|
34
|
+
# handle trailing slash
|
35
|
+
path += @path_pattern.split('?')[0] if path.empty? || @path_pattern != '/'
|
34
36
|
uri.path = path.gsub(/{.+?}/) do |placeholder|
|
35
37
|
param_value_for_placeholder(placeholder, params)
|
36
38
|
end
|
@@ -38,22 +40,40 @@ module Aws
|
|
38
40
|
|
39
41
|
def param_value_for_placeholder(placeholder, params)
|
40
42
|
name = param_name(placeholder)
|
41
|
-
|
43
|
+
param_shape = @rules.shape.member(name).shape
|
44
|
+
value =
|
45
|
+
case param_shape
|
46
|
+
when Seahorse::Model::Shapes::TimestampShape
|
47
|
+
timestamp(param_shape, params[name]).to_s
|
48
|
+
else
|
49
|
+
params[name].to_s
|
50
|
+
end
|
51
|
+
|
42
52
|
raise ArgumentError, ":#{name} must not be blank" if value.empty?
|
43
53
|
|
44
54
|
if placeholder.include?('+')
|
45
|
-
value.gsub(
|
55
|
+
value.gsub(%r{[^/]+}) { |v| escape(v) }
|
46
56
|
else
|
47
57
|
escape(value)
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
51
61
|
def param_name(placeholder)
|
52
|
-
location_name = placeholder.gsub(/[{}+]/,'')
|
62
|
+
location_name = placeholder.gsub(/[{}+]/, '')
|
53
63
|
param_name, _ = @rules.shape.member_by_location_name(location_name)
|
54
64
|
param_name
|
55
65
|
end
|
56
66
|
|
67
|
+
def timestamp(ref, value)
|
68
|
+
case ref['timestampFormat']
|
69
|
+
when 'unixTimestamp' then value.to_i
|
70
|
+
when 'rfc822' then value.utc.httpdate
|
71
|
+
else
|
72
|
+
# serializing as RFC 3399 date-time is the default
|
73
|
+
value.utc.iso8601
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
57
77
|
def apply_querystring_params(uri, params)
|
58
78
|
# collect params that are supposed to be part of the query string
|
59
79
|
parts = @rules.shape.members.inject([]) do |prts, (member_name, member_ref)|
|
@@ -21,6 +21,7 @@ module Aws
|
|
21
21
|
@rules.shape.members.each do |name, ref|
|
22
22
|
value = params[name]
|
23
23
|
next if value.nil?
|
24
|
+
|
24
25
|
case ref.location
|
25
26
|
when 'header' then apply_header_value(http_req.headers, ref, value)
|
26
27
|
when 'headers' then apply_header_map(http_req.headers, ref, value)
|
@@ -49,12 +50,19 @@ module Aws
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
def list(headers, ref,
|
53
|
-
return if
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
.
|
53
|
+
def list(headers, ref, values)
|
54
|
+
return if values.nil?
|
55
|
+
|
56
|
+
member_ref = ref.shape.member
|
57
|
+
values = values.collect do |value|
|
58
|
+
case member_ref.shape
|
59
|
+
when TimestampShape
|
60
|
+
timestamp(member_ref, value).to_s
|
61
|
+
else
|
62
|
+
Seahorse::Util.escape_header_list_string(value.to_s)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
headers[ref.location_name] = values.compact.join(', ')
|
58
66
|
end
|
59
67
|
|
60
68
|
def apply_header_map(headers, ref, values)
|
@@ -4,9 +4,16 @@ module Aws
|
|
4
4
|
module Rest
|
5
5
|
module Request
|
6
6
|
class QuerystringBuilder
|
7
|
-
|
8
7
|
include Seahorse::Model::Shapes
|
9
8
|
|
9
|
+
SUPPORTED_TYPES = [
|
10
|
+
BooleanShape,
|
11
|
+
FloatShape,
|
12
|
+
IntegerShape,
|
13
|
+
StringShape,
|
14
|
+
TimestampShape
|
15
|
+
].freeze
|
16
|
+
|
10
17
|
# Provide shape references and param values:
|
11
18
|
#
|
12
19
|
# [
|
@@ -23,39 +30,32 @@ module Aws
|
|
23
30
|
#
|
24
31
|
# @return [String] Returns a built querystring
|
25
32
|
def build(params)
|
33
|
+
# keys in query maps must NOT override other keys
|
34
|
+
query_keys = query_keys(params)
|
26
35
|
params.map do |(shape_ref, param_value)|
|
27
|
-
build_part(shape_ref, param_value)
|
28
|
-
end.join('&')
|
36
|
+
build_part(shape_ref, param_value, query_keys)
|
37
|
+
end.reject { |p| p.nil? || p.empty? }.join('&')
|
29
38
|
end
|
30
39
|
|
31
40
|
private
|
32
41
|
|
33
|
-
def
|
42
|
+
def query_keys(params)
|
43
|
+
keys = Set.new
|
44
|
+
params.each do |(shape_ref, _)|
|
45
|
+
keys << shape_ref.location_name unless shape_ref.shape.is_a?(MapShape)
|
46
|
+
end
|
47
|
+
keys
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_part(shape_ref, param_value, query_keys)
|
34
51
|
case shape_ref.shape
|
35
52
|
# supported scalar types
|
36
|
-
when
|
37
|
-
|
38
|
-
"#{param_name}=#{escape(param_value.to_s)}"
|
39
|
-
when TimestampShape
|
40
|
-
param_name = shape_ref.location_name
|
41
|
-
"#{param_name}=#{escape(timestamp(shape_ref, param_value))}"
|
53
|
+
when *SUPPORTED_TYPES
|
54
|
+
"#{shape_ref.location_name}=#{query_value(shape_ref, param_value)}"
|
42
55
|
when MapShape
|
43
|
-
|
44
|
-
query_map_of_string(param_value)
|
45
|
-
elsif ListShape === shape_ref.shape.value.shape
|
46
|
-
query_map_of_string_list(param_value)
|
47
|
-
else
|
48
|
-
msg = "only map of string and string list supported"
|
49
|
-
raise NotImplementedError, msg
|
50
|
-
end
|
56
|
+
generate_query_map(shape_ref, param_value, query_keys)
|
51
57
|
when ListShape
|
52
|
-
|
53
|
-
list_of_strings(shape_ref.location_name, param_value)
|
54
|
-
else
|
55
|
-
msg = "Only list of strings supported, got "\
|
56
|
-
"#{shape_ref.shape.member.shape.class.name}"
|
57
|
-
raise NotImplementedError, msg
|
58
|
-
end
|
58
|
+
generate_query_list(shape_ref, param_value)
|
59
59
|
else
|
60
60
|
raise NotImplementedError
|
61
61
|
end
|
@@ -71,34 +71,60 @@ module Aws
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def query_value(ref, value)
|
75
|
+
case ref.shape
|
76
|
+
when TimestampShape
|
77
|
+
escape(timestamp(ref, value))
|
78
|
+
when *SUPPORTED_TYPES
|
79
|
+
escape(value.to_s)
|
80
|
+
else
|
81
|
+
raise NotImplementedError
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def generate_query_list(ref, values)
|
86
|
+
member_ref = ref.shape.member
|
87
|
+
values.map do |value|
|
88
|
+
value = query_value(member_ref, value)
|
89
|
+
"#{ref.location_name}=#{value}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def generate_query_map(ref, value, query_keys)
|
94
|
+
case ref.shape.value.shape
|
95
|
+
when StringShape
|
96
|
+
query_map_of_string(value, query_keys)
|
97
|
+
when ListShape
|
98
|
+
query_map_of_string_list(value, query_keys)
|
99
|
+
else
|
100
|
+
msg = 'Only map of string and string list supported'
|
101
|
+
raise NotImplementedError, msg
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def query_map_of_string(hash, query_keys)
|
75
106
|
list = []
|
76
107
|
hash.each_pair do |key, value|
|
77
|
-
|
108
|
+
key = escape(key)
|
109
|
+
list << "#{key}=#{escape(value)}" unless query_keys.include?(key)
|
78
110
|
end
|
79
111
|
list
|
80
112
|
end
|
81
113
|
|
82
|
-
def query_map_of_string_list(hash)
|
114
|
+
def query_map_of_string_list(hash, query_keys)
|
83
115
|
list = []
|
84
116
|
hash.each_pair do |key, values|
|
117
|
+
key = escape(key)
|
85
118
|
values.each do |value|
|
86
|
-
list << "#{
|
119
|
+
list << "#{key}=#{escape(value)}" unless query_keys.include?(key)
|
87
120
|
end
|
88
121
|
end
|
89
122
|
list
|
90
123
|
end
|
91
124
|
|
92
|
-
def list_of_strings(name, values)
|
93
|
-
values.map do |value|
|
94
|
-
"#{name}=#{escape(value)}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
125
|
def escape(string)
|
99
126
|
Seahorse::Util.uri_escape(string)
|
100
127
|
end
|
101
|
-
|
102
128
|
end
|
103
129
|
end
|
104
130
|
end
|
@@ -20,7 +20,8 @@ module Aws
|
|
20
20
|
if event_stream?
|
21
21
|
data[@rules[:payload]] = parse_eventstream(body)
|
22
22
|
elsif streaming?
|
23
|
-
|
23
|
+
# empty blob payloads are omitted
|
24
|
+
data[@rules[:payload]] = body unless empty_blob_payload?(body)
|
24
25
|
elsif @rules[:payload]
|
25
26
|
data[@rules[:payload]] = parse(body.read, @rules[:payload_member])
|
26
27
|
elsif !@rules.shape.member_names.empty?
|
@@ -30,6 +31,19 @@ module Aws
|
|
30
31
|
|
31
32
|
private
|
32
33
|
|
34
|
+
def empty_blob_payload?(body)
|
35
|
+
true if non_streaming_blob_payload? && empty_body?(body)
|
36
|
+
end
|
37
|
+
|
38
|
+
def non_streaming_blob_payload?
|
39
|
+
@rules[:payload_member].shape.is_a?(BlobShape) &&
|
40
|
+
!@rules[:payload_member]['streaming']
|
41
|
+
end
|
42
|
+
|
43
|
+
def empty_body?(body)
|
44
|
+
body.respond_to?(:size) && body.size.zero?
|
45
|
+
end
|
46
|
+
|
33
47
|
def event_stream?
|
34
48
|
@rules[:payload] && @rules[:payload_member].eventstream
|
35
49
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'strscan'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module Rest
|
7
|
+
module Response
|
8
|
+
# @api private
|
9
|
+
module HeaderListParser
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# parse a list of possibly quoted and escaped string values
|
13
|
+
# Follows:
|
14
|
+
# # [RFC-7230's specification of header values](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6).
|
15
|
+
def parse_string_list(value)
|
16
|
+
buffer = StringScanner.new(value)
|
17
|
+
parsed = []
|
18
|
+
|
19
|
+
parsed << read_value(buffer) until buffer.eos?
|
20
|
+
|
21
|
+
parsed
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_timestamp_list(value, ref)
|
25
|
+
# timestamp lists use an http-date by default and are unescaped
|
26
|
+
# eg: Mon, 16 Dec 2019 23:48:18 GMT, Mon, 16 Dec 2019 23:48:18 GMT
|
27
|
+
case ref['timestampFormat'] || ref.shape['timestampFormat']
|
28
|
+
when 'unixTimestamp'
|
29
|
+
value.split(', ').map { |v| Time.at(v.to_f) }
|
30
|
+
when 'iso8601' then value.split(', ').map { |v| Time.parse(v) }
|
31
|
+
else
|
32
|
+
# header default to rfc822/http-date, which has a comma after day
|
33
|
+
value.split(',').each_slice(2).map { |v| Time.parse(v[0] + v[1])}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def read_value(buffer)
|
40
|
+
until buffer.eos?
|
41
|
+
case buffer.peek(1)
|
42
|
+
when ' ', "\t"
|
43
|
+
# drop leading whitespace
|
44
|
+
buffer.getch
|
45
|
+
next
|
46
|
+
when '"'
|
47
|
+
buffer.getch # drop the quote and advance
|
48
|
+
return read_quoted_value(buffer)
|
49
|
+
else
|
50
|
+
return read_unquoted_value(buffer)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# buffer is only whitespace
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def read_unquoted_value(buffer)
|
58
|
+
# there cannot be any escaped values
|
59
|
+
value = buffer.scan_until(/,|$/)
|
60
|
+
# drop the comma if we matched it
|
61
|
+
buffer.matched == ',' ? value.chop : value
|
62
|
+
end
|
63
|
+
|
64
|
+
def read_quoted_value(buffer)
|
65
|
+
# scan until we have an unescaped double quote
|
66
|
+
value = buffer.scan_until(/[^\\]"/)
|
67
|
+
raise ArgumentError, 'Invalid String list: No closing quote found' unless value
|
68
|
+
|
69
|
+
# drop any remaining whitespace/commas
|
70
|
+
buffer.scan_until(/[\s,]*/)
|
71
|
+
# the last character will always be the closing quote.
|
72
|
+
# Add a starting quote and then unescape (undump)
|
73
|
+
"\"#{value}".undump
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'time'
|
4
4
|
require 'base64'
|
5
|
+
require_relative 'header_list_parser'
|
5
6
|
|
6
7
|
module Aws
|
7
8
|
module Rest
|
@@ -36,12 +37,16 @@ module Aws
|
|
36
37
|
def cast_value(ref, value)
|
37
38
|
value = extract_json_trait(value) if ref['jsonvalue']
|
38
39
|
case ref.shape
|
39
|
-
when StringShape then value
|
40
|
+
when StringShape then value.to_s
|
40
41
|
when IntegerShape then value.to_i
|
41
|
-
when FloatShape then value
|
42
|
+
when FloatShape then Util.deserialize_number(value)
|
42
43
|
when BooleanShape then value == 'true'
|
43
44
|
when ListShape then
|
44
|
-
|
45
|
+
case ref.shape.member.shape
|
46
|
+
when StringShape then HeaderListParser.parse_string_list(value)
|
47
|
+
when TimestampShape then HeaderListParser.parse_timestamp_list(value, ref.shape.member)
|
48
|
+
else value.split(', ').map { |v| cast_value(ref.shape.member, v) }
|
49
|
+
end
|
45
50
|
when TimestampShape
|
46
51
|
if value =~ /^\d+(\.\d*)/
|
47
52
|
Time.at(value.to_f)
|
data/lib/aws-sdk-core/rest.rb
CHANGED