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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +462 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +4 -4
  5. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  6. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  7. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  8. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  9. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  10. data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
  11. data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
  12. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  13. data/lib/aws-sdk-core/cbor.rb +106 -0
  14. data/lib/aws-sdk-core/client_stubs.rb +18 -14
  15. data/lib/aws-sdk-core/credential_provider.rb +4 -1
  16. data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
  17. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  18. data/lib/aws-sdk-core/ecs_credentials.rb +178 -53
  19. data/lib/aws-sdk-core/endpoints/condition.rb +5 -0
  20. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +5 -1
  21. data/lib/aws-sdk-core/endpoints/error_rule.rb +5 -0
  22. data/lib/aws-sdk-core/endpoints/function.rb +5 -0
  23. data/lib/aws-sdk-core/endpoints/matchers.rb +18 -10
  24. data/lib/aws-sdk-core/endpoints/reference.rb +5 -0
  25. data/lib/aws-sdk-core/endpoints/rule.rb +5 -0
  26. data/lib/aws-sdk-core/endpoints/rule_set.rb +5 -0
  27. data/lib/aws-sdk-core/endpoints/rules_provider.rb +5 -0
  28. data/lib/aws-sdk-core/endpoints/templater.rb +6 -0
  29. data/lib/aws-sdk-core/endpoints/tree_rule.rb +5 -0
  30. data/lib/aws-sdk-core/endpoints/url.rb +1 -0
  31. data/lib/aws-sdk-core/endpoints.rb +69 -19
  32. data/lib/aws-sdk-core/error_handler.rb +41 -0
  33. data/lib/aws-sdk-core/errors.rb +12 -3
  34. data/lib/aws-sdk-core/event_emitter.rb +0 -16
  35. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  36. data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
  37. data/lib/aws-sdk-core/json/builder.rb +8 -1
  38. data/lib/aws-sdk-core/json/error_handler.rb +29 -14
  39. data/lib/aws-sdk-core/json/handler.rb +12 -6
  40. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  41. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  42. data/lib/aws-sdk-core/json/parser.rb +33 -3
  43. data/lib/aws-sdk-core/json.rb +43 -14
  44. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  45. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  46. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  47. data/lib/aws-sdk-core/param_validator.rb +9 -4
  48. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  49. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +7 -4
  50. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
  51. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  52. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +2 -0
  53. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  54. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
  55. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  56. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  57. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  58. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  59. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  60. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  61. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  62. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  63. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  64. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +140 -35
  65. data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
  66. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  67. data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
  68. data/lib/aws-sdk-core/plugins/sign.rb +43 -19
  69. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  70. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  71. data/lib/aws-sdk-core/plugins/stub_responses.rb +1 -0
  72. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  73. data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
  74. data/lib/aws-sdk-core/process_credentials.rb +45 -27
  75. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  76. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  77. data/lib/aws-sdk-core/query/handler.rb +4 -4
  78. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  79. data/lib/aws-sdk-core/query.rb +2 -1
  80. data/lib/aws-sdk-core/refreshing_credentials.rb +12 -12
  81. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  82. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  83. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  84. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  85. data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
  86. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
  87. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  88. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  89. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  90. data/lib/aws-sdk-core/rest.rb +1 -0
  91. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  92. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
  93. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
  94. data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
  95. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  96. data/lib/aws-sdk-core/rpc_v2.rb +6 -0
  97. data/lib/aws-sdk-core/shared_config.rb +77 -18
  98. data/lib/aws-sdk-core/sso_credentials.rb +80 -45
  99. data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
  100. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
  101. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  102. data/lib/aws-sdk-core/util.rb +39 -0
  103. data/lib/aws-sdk-core/waiters/poller.rb +4 -2
  104. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  105. data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
  106. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  107. data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +2 -0
  108. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  109. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  110. data/lib/aws-sdk-core.rb +8 -2
  111. data/lib/aws-sdk-sso/client.rb +103 -46
  112. data/lib/aws-sdk-sso/client_api.rb +6 -0
  113. data/lib/aws-sdk-sso/endpoint_provider.rb +41 -96
  114. data/lib/aws-sdk-sso/endpoints.rb +1 -0
  115. data/lib/aws-sdk-sso/plugins/endpoints.rb +4 -2
  116. data/lib/aws-sdk-sso/types.rb +0 -35
  117. data/lib/aws-sdk-sso.rb +1 -1
  118. data/lib/aws-sdk-ssooidc/client.rb +488 -74
  119. data/lib/aws-sdk-ssooidc/client_api.rb +82 -1
  120. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +41 -95
  121. data/lib/aws-sdk-ssooidc/endpoints.rb +15 -0
  122. data/lib/aws-sdk-ssooidc/errors.rb +52 -0
  123. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +6 -2
  124. data/lib/aws-sdk-ssooidc/types.rb +372 -83
  125. data/lib/aws-sdk-ssooidc.rb +1 -1
  126. data/lib/aws-sdk-sts/client.rb +361 -288
  127. data/lib/aws-sdk-sts/client_api.rb +24 -11
  128. data/lib/aws-sdk-sts/endpoint_provider.rb +96 -213
  129. data/lib/aws-sdk-sts/endpoints.rb +1 -0
  130. data/lib/aws-sdk-sts/plugins/endpoints.rb +4 -2
  131. data/lib/aws-sdk-sts/presigner.rb +1 -1
  132. data/lib/aws-sdk-sts/types.rb +128 -197
  133. data/lib/aws-sdk-sts.rb +1 -1
  134. data/lib/seahorse/client/async_base.rb +1 -1
  135. data/lib/seahorse/client/async_response.rb +19 -0
  136. data/lib/seahorse/client/base.rb +18 -7
  137. data/lib/seahorse/client/configuration.rb +0 -4
  138. data/lib/seahorse/client/h2/connection.rb +12 -11
  139. data/lib/seahorse/client/h2/handler.rb +1 -0
  140. data/lib/seahorse/client/handler.rb +1 -1
  141. data/lib/seahorse/client/net_http/connection_pool.rb +3 -9
  142. data/lib/seahorse/client/net_http/patches.rb +1 -4
  143. data/lib/seahorse/client/plugin.rb +9 -0
  144. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  145. data/lib/seahorse/client/plugins/h2.rb +3 -3
  146. data/lib/seahorse/client/plugins/net_http.rb +48 -16
  147. data/lib/seahorse/client/plugins/request_callback.rb +31 -0
  148. data/lib/seahorse/client/response.rb +6 -0
  149. data/lib/seahorse/model/operation.rb +3 -0
  150. data/lib/seahorse/model/shapes.rb +2 -2
  151. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  152. data/sig/aws-sdk-core/errors.rbs +22 -0
  153. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  154. data/sig/aws-sdk-core/structure.rbs +4 -0
  155. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  156. data/sig/aws-sdk-core.rbs +7 -0
  157. data/sig/seahorse/client/base.rbs +25 -0
  158. data/sig/seahorse/client/handler_builder.rbs +16 -0
  159. data/sig/seahorse/client/response.rbs +61 -0
  160. metadata +44 -17
  161. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  162. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  163. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  164. /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 = options[:logger] || Logger.new($stdout) if @http_wire_trace
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
- @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)
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
@@ -15,7 +15,7 @@ module Seahorse
15
15
  attr_accessor :handler
16
16
 
17
17
  # @param [RequestContext] context
18
- # @return [Response]
18
+ # @return [Seahorse::Response]
19
19
  def call(context)
20
20
  @handler.call(context)
21
21
  end
@@ -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 = 0
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.each_pair do |endpoint,sessions|
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.each_pair do |endpoint,sessions|
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 bodys, Net::HTTP sets a default content type of:
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)
@@ -17,7 +17,6 @@ be a URI formatted like:
17
17
  'http://example.com'
18
18
  'https://example.com'
19
19
  'http://example.com:123'
20
-
21
20
  DOCS
22
21
 
23
22
  def add_handlers(handlers, config)
@@ -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
- Setting to `true` to enable ALPN in HTTP2 over TLS, requires Ruby version >= 2.3 and
58
- Openssl version >= 1.0.2. Defaults to false. Note: not all service HTTP2 operations
59
- supports ALPN on server side, please refer to service documentation.
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
- option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '') do |cfg|
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: Integer, docstring: '') do |cfg|
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: Integer, docstring: '')
21
-
22
- option(:http_continue_timeout, default: 1, doc_type: Integer, docstring: '')
23
-
24
- option(:http_wire_trace, default: false, doc_type: 'Boolean', docstring: '')
25
-
26
- option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: '')
27
-
28
- option(:ssl_ca_bundle, doc_type: String, docstring: '') do |cfg|
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.
@@ -28,6 +28,9 @@ module Seahorse
28
28
  # @return [Hash]
29
29
  attr_accessor :http_checksum
30
30
 
31
+ # @return [Hash]
32
+ attr_accessor :request_compression
33
+
31
34
  # @return [Boolean]
32
35
  attr_accessor :deprecated
33
36
 
@@ -75,7 +75,7 @@ module Seahorse
75
75
 
76
76
  # @return [String, nil]
77
77
  def location_name
78
- @location_name || (shape && shape[:location_name])
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
- else
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,4 @@
1
+ module Aws
2
+ class EmptyStructure
3
+ end
4
+ 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,7 @@
1
+ module Aws
2
+ attr_reader self.config: Hash[Symbol, untyped]
3
+
4
+ def self.config=: (Hash[Symbol, untyped] config) -> Hash[Symbol, untyped]
5
+
6
+ def self.use_bundled_cert!: () -> String
7
+ 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