aws-sdk-core 3.165.0 → 3.201.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 +462 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +4 -4
- 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/cbor_engine.rb +19 -0
- 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 +106 -0
- data/lib/aws-sdk-core/client_stubs.rb +18 -14
- data/lib/aws-sdk-core/credential_provider.rb +4 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +178 -53
- data/lib/aws-sdk-core/endpoints/condition.rb +5 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +5 -1
- data/lib/aws-sdk-core/endpoints/error_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/function.rb +5 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +18 -10
- data/lib/aws-sdk-core/endpoints/reference.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +5 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +6 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/url.rb +1 -0
- data/lib/aws-sdk-core/endpoints.rb +69 -19
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +12 -3
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- 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 +29 -14
- data/lib/aws-sdk-core/json/handler.rb +12 -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 +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +7 -4
- 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 +2 -0
- 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 +140 -35
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +43 -19
- 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 +1 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
- data/lib/aws-sdk-core/process_credentials.rb +45 -27
- 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 -12
- 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 +15 -7
- 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/content_type_handler.rb +45 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +6 -0
- data/lib/aws-sdk-core/shared_config.rb +77 -18
- data/lib/aws-sdk-core/sso_credentials.rb +80 -45
- data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +4 -2
- 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/{engines/oga.rb → oga_engine.rb} +2 -0
- 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 +8 -2
- data/lib/aws-sdk-sso/client.rb +103 -46
- data/lib/aws-sdk-sso/client_api.rb +6 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +41 -96
- data/lib/aws-sdk-sso/endpoints.rb +1 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sso/types.rb +0 -35
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +488 -74
- data/lib/aws-sdk-ssooidc/client_api.rb +82 -1
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +41 -95
- data/lib/aws-sdk-ssooidc/endpoints.rb +15 -0
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +6 -2
- data/lib/aws-sdk-ssooidc/types.rb +372 -83
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +361 -288
- data/lib/aws-sdk-sts/client_api.rb +24 -11
- data/lib/aws-sdk-sts/endpoint_provider.rb +96 -213
- data/lib/aws-sdk-sts/endpoints.rb +1 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +128 -197
- data/lib/aws-sdk-sts.rb +1 -1
- 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/configuration.rb +0 -4
- data/lib/seahorse/client/h2/connection.rb +12 -11
- data/lib/seahorse/client/h2/handler.rb +1 -0
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +3 -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 +48 -16
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +3 -0
- 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/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 +44 -17
- /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/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -43,7 +43,9 @@ module Seahorse
|
|
43
43
|
@h2_client = HTTP2::Client.new(
|
44
44
|
settings_max_concurrent_streams: max_concurrent_streams
|
45
45
|
)
|
46
|
-
@logger =
|
46
|
+
@logger = if @http_wire_trace
|
47
|
+
options[:logger] || Logger.new($stdout)
|
48
|
+
end
|
47
49
|
@chunk_size = options[:read_chunk_size] || CHUNKSIZE
|
48
50
|
@errors = []
|
49
51
|
@status = :ready
|
@@ -104,7 +106,7 @@ module Seahorse
|
|
104
106
|
@mutex.synchronize {
|
105
107
|
return if @socket_thread
|
106
108
|
@socket_thread = Thread.new do
|
107
|
-
while !@socket.closed?
|
109
|
+
while @socket && !@socket.closed?
|
108
110
|
begin
|
109
111
|
data = @socket.read_nonblock(@chunk_size)
|
110
112
|
@h2_client << data
|
@@ -130,6 +132,7 @@ module Seahorse
|
|
130
132
|
self.close!
|
131
133
|
end
|
132
134
|
end
|
135
|
+
@socket_thread = nil
|
133
136
|
end
|
134
137
|
@socket_thread.abort_on_exception = true
|
135
138
|
}
|
@@ -142,10 +145,6 @@ module Seahorse
|
|
142
145
|
@socket.close
|
143
146
|
@socket = nil
|
144
147
|
end
|
145
|
-
if @socket_thread
|
146
|
-
Thread.kill(@socket_thread)
|
147
|
-
@socket_thread = nil
|
148
|
-
end
|
149
148
|
@status = :closed
|
150
149
|
}
|
151
150
|
end
|
@@ -183,11 +182,13 @@ module Seahorse
|
|
183
182
|
@socket.flush
|
184
183
|
end
|
185
184
|
end
|
186
|
-
@
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
185
|
+
if @http_wire_trace
|
186
|
+
@h2_client.on(:frame_sent) do |frame|
|
187
|
+
debug_output("frame: #{frame.inspect}", :send)
|
188
|
+
end
|
189
|
+
@h2_client.on(:frame_received) do |frame|
|
190
|
+
debug_output("frame: #{frame.inspect}", :receive)
|
191
|
+
end
|
191
192
|
end
|
192
193
|
end
|
193
194
|
|
@@ -126,6 +126,7 @@ module Seahorse
|
|
126
126
|
# https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
|
127
127
|
def _h2_headers(req)
|
128
128
|
headers = {}
|
129
|
+
headers[':authority'] = req.endpoint.host
|
129
130
|
headers[':method'] = req.http_method.upcase
|
130
131
|
headers[':scheme'] = req.endpoint.scheme
|
131
132
|
headers[':path'] = req.endpoint.path.empty? ? '/' : req.endpoint.path
|
@@ -119,11 +119,7 @@ module Seahorse
|
|
119
119
|
# pool, not counting those currently in use.
|
120
120
|
def size
|
121
121
|
@pool_mutex.synchronize do
|
122
|
-
size
|
123
|
-
@pool.each_pair do |endpoint,sessions|
|
124
|
-
size += sessions.size
|
125
|
-
end
|
126
|
-
size
|
122
|
+
@pool.values.flatten.size
|
127
123
|
end
|
128
124
|
end
|
129
125
|
|
@@ -142,9 +138,7 @@ module Seahorse
|
|
142
138
|
# @return [nil]
|
143
139
|
def empty!
|
144
140
|
@pool_mutex.synchronize do
|
145
|
-
@pool.
|
146
|
-
sessions.each(&:finish)
|
147
|
-
end
|
141
|
+
@pool.values.flatten.map(&:finish)
|
148
142
|
@pool.clear
|
149
143
|
end
|
150
144
|
nil
|
@@ -312,7 +306,7 @@ module Seahorse
|
|
312
306
|
# @note **Must** be called behind a `@pool_mutex` synchronize block.
|
313
307
|
def _clean
|
314
308
|
now = Aws::Util.monotonic_milliseconds
|
315
|
-
@pool.
|
309
|
+
@pool.values.each do |sessions|
|
316
310
|
sessions.delete_if do |session|
|
317
311
|
if session.last_used.nil? or now - session.last_used > http_idle_timeout * 1000
|
318
312
|
session.finish
|
@@ -12,12 +12,9 @@ module Seahorse
|
|
12
12
|
|
13
13
|
def self.apply!
|
14
14
|
Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
|
15
|
-
return unless RUBY_VERSION < '2.5'
|
16
|
-
|
17
|
-
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
18
15
|
end
|
19
16
|
|
20
|
-
# For requests with
|
17
|
+
# For requests with bodies, Net::HTTP sets a default content type of:
|
21
18
|
# 'application/x-www-form-urlencoded'
|
22
19
|
# There are cases where we should not send content type at all.
|
23
20
|
# Even when no body is supplied, Net::HTTP uses a default empty body
|
@@ -111,7 +111,15 @@ module Seahorse
|
|
111
111
|
|
112
112
|
def initialize(name, options = {})
|
113
113
|
@name = name
|
114
|
+
# prevent unstable object shapes by ensuring
|
115
|
+
# order and presence of instance variables
|
116
|
+
@default = nil
|
117
|
+
@default_block = nil
|
118
|
+
@required = nil
|
119
|
+
@doc_type = nil
|
114
120
|
@doc_default = nil
|
121
|
+
@docstring = nil
|
122
|
+
@rbs_type = nil
|
115
123
|
options.each_pair do |opt_name, opt_value|
|
116
124
|
self.send("#{opt_name}=", opt_value)
|
117
125
|
end
|
@@ -124,6 +132,7 @@ module Seahorse
|
|
124
132
|
attr_accessor :doc_type
|
125
133
|
attr_writer :doc_default
|
126
134
|
attr_accessor :docstring
|
135
|
+
attr_accessor :rbs_type
|
127
136
|
|
128
137
|
def doc_default(options)
|
129
138
|
if @doc_default.nil? && !default.is_a?(Proc)
|
@@ -54,9 +54,9 @@ When `true`, HTTP2 debug output will be sent to the `:logger`.
|
|
54
54
|
DOCS
|
55
55
|
|
56
56
|
option(:enable_alpn, default: false, doc_type: 'Boolean', docstring: <<-DOCS)
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
Set to `true` to enable ALPN in HTTP2 over TLS. Requires Openssl version >= 1.0.2.
|
58
|
+
Defaults to false. Note: not all service HTTP2 operations supports ALPN on server
|
59
|
+
side, please refer to service documentation.
|
60
60
|
DOCS
|
61
61
|
|
62
62
|
option(:logger)
|
@@ -7,34 +7,66 @@ module Seahorse
|
|
7
7
|
module Plugins
|
8
8
|
class NetHttp < Plugin
|
9
9
|
|
10
|
-
option(:http_proxy, default: nil, doc_type: String, docstring:
|
11
|
-
|
12
|
-
|
10
|
+
option(:http_proxy, default: nil, doc_type: "URI::HTTP,String", docstring: <<-DOCS)
|
11
|
+
A proxy to send requests through. Formatted like 'http://proxy.com:123'.
|
12
|
+
DOCS
|
13
|
+
|
14
|
+
option(:http_open_timeout, default: 15, doc_type: Float, docstring: <<-DOCS) do |cfg|
|
15
|
+
The default number of seconds to wait for response data.
|
16
|
+
This value can safely be set per-request on the session.
|
17
|
+
DOCS
|
13
18
|
resolve_http_open_timeout(cfg)
|
14
19
|
end
|
15
20
|
|
16
|
-
option(:http_read_timeout, default: 60, doc_type:
|
21
|
+
option(:http_read_timeout, default: 60, doc_type: Float, docstring: <<-DOCS) do |cfg|
|
22
|
+
The default number of seconds to wait for response data.
|
23
|
+
This value can safely be set per-request on the session.
|
24
|
+
DOCS
|
17
25
|
resolve_http_read_timeout(cfg)
|
18
26
|
end
|
19
27
|
|
20
|
-
option(:http_idle_timeout, default: 5, doc_type:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
option(:
|
27
|
-
|
28
|
-
|
28
|
+
option(:http_idle_timeout, default: 5, doc_type: Float, docstring: <<-DOCS)
|
29
|
+
The number of seconds a connection is allowed to sit idle before it
|
30
|
+
is considered stale. Stale connections are closed and removed from the
|
31
|
+
pool before making a request.
|
32
|
+
DOCS
|
33
|
+
|
34
|
+
option(:http_continue_timeout, default: 1, doc_type: Float, docstring: <<-DOCS)
|
35
|
+
The number of seconds to wait for a 100-continue response before sending the
|
36
|
+
request body. This option has no effect unless the request has "Expect"
|
37
|
+
header set to "100-continue". Defaults to `nil` which disables this
|
38
|
+
behaviour. This value can safely be set per request on the session.
|
39
|
+
DOCS
|
40
|
+
|
41
|
+
option(:http_wire_trace, default: false, doc_type: 'Boolean', docstring: <<-DOCS)
|
42
|
+
When `true`, HTTP debug output will be sent to the `:logger`.
|
43
|
+
DOCS
|
44
|
+
|
45
|
+
option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: <<-DOCS)
|
46
|
+
When `true`, SSL peer certificates are verified when establishing a connection.
|
47
|
+
DOCS
|
48
|
+
|
49
|
+
option(:ssl_ca_bundle, doc_type: String, docstring: <<-DOCS) do |cfg|
|
50
|
+
Full path to the SSL certificate authority bundle file that should be used when
|
51
|
+
verifying peer certificates. If you do not pass `:ssl_ca_bundle` or
|
52
|
+
`:ssl_ca_directory` the the system default will be used if available.
|
53
|
+
DOCS
|
29
54
|
ENV['AWS_CA_BUNDLE'] ||
|
30
55
|
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
31
56
|
end
|
32
57
|
|
33
|
-
option(:ssl_ca_directory, default: nil, doc_type: String, docstring:
|
58
|
+
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: <<-DOCS)
|
59
|
+
Full path of the directory that contains the unbundled SSL certificate
|
60
|
+
authority files for verifying peer certificates. If you do
|
61
|
+
not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the system
|
62
|
+
default will be used if available.
|
63
|
+
DOCS
|
34
64
|
|
35
|
-
option(:ssl_ca_store, default: nil, doc_type: String, docstring:
|
65
|
+
option(:ssl_ca_store, default: nil, doc_type: String, docstring: <<-DOCS)
|
66
|
+
Sets the X509::Store to verify peer certificate.
|
67
|
+
DOCS
|
36
68
|
|
37
|
-
option(:ssl_timeout, default: nil, doc_type: Float, docstring: '') do |cfg|
|
69
|
+
option(:ssl_timeout, default: nil, doc_type: Float, docstring: 'Sets the SSL timeout in seconds') do |cfg|
|
38
70
|
resolve_ssl_timeout(cfg)
|
39
71
|
end
|
40
72
|
|
@@ -60,6 +60,16 @@ the number of bytes read from the body, and the total number of
|
|
60
60
|
bytes in the body.
|
61
61
|
DOCS
|
62
62
|
|
63
|
+
option(:on_chunk_received,
|
64
|
+
default: nil,
|
65
|
+
doc_type: 'Proc',
|
66
|
+
docstring: <<-DOCS)
|
67
|
+
When a Proc object is provided, it will be used as callback when each chunk
|
68
|
+
of the response body is received. It provides three arguments: the chunk,
|
69
|
+
the number of bytes received, and the total number of
|
70
|
+
bytes in the response (or nil if the server did not send a `content-length`).
|
71
|
+
DOCS
|
72
|
+
|
63
73
|
# @api private
|
64
74
|
class OptionHandler < Client::Handler
|
65
75
|
def call(context)
|
@@ -68,8 +78,29 @@ bytes in the body.
|
|
68
78
|
end
|
69
79
|
on_chunk_sent = context.config.on_chunk_sent if on_chunk_sent.nil?
|
70
80
|
context[:on_chunk_sent] = on_chunk_sent if on_chunk_sent
|
81
|
+
|
82
|
+
if context.params.is_a?(Hash) && context.params[:on_chunk_received]
|
83
|
+
on_chunk_received = context.params.delete(:on_chunk_received)
|
84
|
+
end
|
85
|
+
on_chunk_received = context.config.on_chunk_received if on_chunk_received.nil?
|
86
|
+
|
87
|
+
add_response_events(on_chunk_received, context) if on_chunk_received
|
88
|
+
|
71
89
|
@handler.call(context)
|
72
90
|
end
|
91
|
+
|
92
|
+
def add_response_events(on_chunk_received, context)
|
93
|
+
shared_data = {bytes_received: 0}
|
94
|
+
|
95
|
+
context.http_response.on_headers do |_status, headers|
|
96
|
+
shared_data[:content_length] = headers['content-length']&.to_i
|
97
|
+
end
|
98
|
+
|
99
|
+
context.http_response.on_data do |chunk|
|
100
|
+
shared_data[:bytes_received] += chunk.bytesize if chunk && chunk.respond_to?(:bytesize)
|
101
|
+
on_chunk_received.call(chunk, shared_data[:bytes_received], shared_data[:content_length])
|
102
|
+
end
|
103
|
+
end
|
73
104
|
end
|
74
105
|
|
75
106
|
# @api private
|
@@ -30,6 +30,12 @@ module Seahorse
|
|
30
30
|
# @return [StandardError, nil]
|
31
31
|
attr_accessor :error
|
32
32
|
|
33
|
+
# @return [String, nil] returns the algorithm used to validate
|
34
|
+
# the response checksum. Returns nil if no verification was done.
|
35
|
+
def checksum_validated
|
36
|
+
context[:http_checksum][:validated] if context[:http_checksum]
|
37
|
+
end
|
38
|
+
|
33
39
|
# @overload on(status_code, &block)
|
34
40
|
# @param [Integer] status_code The block will be
|
35
41
|
# triggered only for responses with the given status code.
|
@@ -75,7 +75,7 @@ module Seahorse
|
|
75
75
|
|
76
76
|
# @return [String, nil]
|
77
77
|
def location_name
|
78
|
-
@location_name || (shape && shape[
|
78
|
+
@location_name || (shape && shape['locationName'])
|
79
79
|
end
|
80
80
|
|
81
81
|
def location_name= location_name
|
@@ -86,7 +86,7 @@ module Seahorse
|
|
86
86
|
def [](key)
|
87
87
|
if @metadata.key?(key.to_s)
|
88
88
|
@metadata[key.to_s]
|
89
|
-
|
89
|
+
elsif @shape
|
90
90
|
@shape[key.to_s]
|
91
91
|
end
|
92
92
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Aws
|
2
|
+
module ClientStubs
|
3
|
+
def stub_responses: (Symbol operation_name, *untyped stubs) -> void
|
4
|
+
|
5
|
+
def api_requests: (?exclude_presign: bool) -> Array[{ operation_name: Symbol, params: untyped, context: untyped }]
|
6
|
+
| (?Hash[:exclude_presign, bool] options) -> Array[{ operation_name: Symbol, params: untyped, context: untyped }]
|
7
|
+
|
8
|
+
def stub_data: (Symbol operation_name, ?untyped data) -> untyped
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Aws
|
2
|
+
module Errors
|
3
|
+
class NonSupportedRubyVersionError < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
# The base class for all errors returned by an Amazon Web Service.
|
7
|
+
# All ~400 level client errors and ~500 level server errors are raised
|
8
|
+
# as service errors. This indicates it was an error returned from the
|
9
|
+
# service and not one generated by the client.
|
10
|
+
class ServiceError < RuntimeError
|
11
|
+
def initialize: (untyped context, String? message, ?untyped data) -> void
|
12
|
+
|
13
|
+
attr_reader code: String
|
14
|
+
|
15
|
+
attr_reader context: untyped
|
16
|
+
|
17
|
+
attr_reader data: untyped
|
18
|
+
|
19
|
+
attr_accessor self.code: String?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Aws
|
2
|
+
module Resources
|
3
|
+
class Collection[T]
|
4
|
+
include Enumerable[T]
|
5
|
+
|
6
|
+
def initialize: (Enumerable[Enumerable[T]] batches, ?size: Integer, ?limit: Integer) -> void
|
7
|
+
|
8
|
+
def each: () -> Enumerator[T, untyped]
|
9
|
+
| () { (T) -> untyped } -> Enumerator[T, untyped]
|
10
|
+
|
11
|
+
def size: () -> Integer?
|
12
|
+
|
13
|
+
alias length size
|
14
|
+
|
15
|
+
def first: () -> T?
|
16
|
+
| (Integer) -> self
|
17
|
+
|
18
|
+
def limit: (Integer) -> self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Aws
|
2
|
+
module Waiters
|
3
|
+
module Errors
|
4
|
+
class WaiterFailed < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class FailureStateError < WaiterFailed
|
8
|
+
end
|
9
|
+
|
10
|
+
class TooManyAttemptsError < WaiterFailed
|
11
|
+
end
|
12
|
+
|
13
|
+
class UnexpectedError < WaiterFailed
|
14
|
+
end
|
15
|
+
|
16
|
+
class NoSuchWaiterError < ArgumentError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
class Base
|
4
|
+
include HandlerBuilder
|
5
|
+
|
6
|
+
def self.new: (?untyped options) -> instance
|
7
|
+
def self.add_plugin: (untyped plugin) -> untyped
|
8
|
+
def self.remove_plugin: (untyped plugin) -> untyped
|
9
|
+
def self.clear_plugins: () -> untyped
|
10
|
+
def self.set_plugins: (Array[untyped] plugins) -> untyped
|
11
|
+
def self.plugins: () -> Array[untyped]
|
12
|
+
def self.api: () -> untyped
|
13
|
+
def self.set_api: (untyped api) -> untyped
|
14
|
+
def self.define: (?untyped options) -> untyped
|
15
|
+
|
16
|
+
attr_reader config: untyped
|
17
|
+
|
18
|
+
attr_reader handlers: untyped
|
19
|
+
|
20
|
+
def build_request: (_ToS operation_name, ?untyped params) -> untyped
|
21
|
+
|
22
|
+
def operation_names: () -> Array[Symbol]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
# This module provides the ability to add handlers to a class or
|
4
|
+
# module. The including class or extending module must respond to
|
5
|
+
# `#handlers`, returning a {HandlerList}.
|
6
|
+
module HandlerBuilder
|
7
|
+
def handle_request: (*untyped) { (untyped context) -> void } -> untyped
|
8
|
+
|
9
|
+
def handle_response: (*untyped) { (untyped resp) -> void } -> untyped
|
10
|
+
|
11
|
+
def handle: (*untyped) ?{ (untyped context) -> void } -> untyped
|
12
|
+
|
13
|
+
alias handler handle
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
# RBS does not support Delegator.
|
4
|
+
# the behavior is mimicked `Seahorse::Client::Response` as much as possible.
|
5
|
+
interface _ResponseCommon
|
6
|
+
def context: () -> untyped
|
7
|
+
|
8
|
+
def checksum_validated: () -> ::String?
|
9
|
+
|
10
|
+
def on: (Integer) { (self) -> void } -> self
|
11
|
+
| (Range[Integer]) { (self) -> void } -> self
|
12
|
+
|
13
|
+
def on_success: () { (self) -> void } -> self
|
14
|
+
|
15
|
+
def successful?: () -> bool
|
16
|
+
end
|
17
|
+
|
18
|
+
# The interface for response success
|
19
|
+
# An interface representing response is provided for each operation,
|
20
|
+
# and _ResponseSuccess is embedded in this interface.
|
21
|
+
# @example client.rbs
|
22
|
+
#
|
23
|
+
# interface _OperationResponseSuccess
|
24
|
+
# include ::Seahorse::Client::_ResponseSuccess[Types::OperationOutput]
|
25
|
+
# def foo: () -> ::String
|
26
|
+
# def bar: () -> ::Integer
|
27
|
+
# end
|
28
|
+
# @client.operation: () -> _OperationResponseSuccess
|
29
|
+
interface _ResponseSuccess[DATA]
|
30
|
+
include _ResponseCommon
|
31
|
+
|
32
|
+
def data: () -> DATA
|
33
|
+
|
34
|
+
def data=: (DATA) -> DATA
|
35
|
+
|
36
|
+
def error: () -> nil
|
37
|
+
|
38
|
+
def error=: (nil) -> nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# The interface for response error
|
42
|
+
# It is useful to use annotation on ruby code
|
43
|
+
# @example foo.rb
|
44
|
+
#
|
45
|
+
# client = Client.new(raise_response_errors: false)
|
46
|
+
# # @type var response: ::Seahorse::Client::_ResponseError
|
47
|
+
# response = client.operation()
|
48
|
+
# response.error.message
|
49
|
+
interface _ResponseError
|
50
|
+
include _ResponseCommon
|
51
|
+
|
52
|
+
def data: () -> nil
|
53
|
+
|
54
|
+
def data=: (nil) -> nil
|
55
|
+
|
56
|
+
def error: () -> StandardError
|
57
|
+
|
58
|
+
def error=: (StandardError) -> StandardError
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|