aws-sdk-core 3.152.0 → 3.234.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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +942 -1
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +5 -6
  5. data/lib/aws-defaults.rb +4 -1
  6. data/lib/aws-sdk-core/arn.rb +14 -3
  7. data/lib/aws-sdk-core/assume_role_credentials.rb +21 -13
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -9
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +13 -2
  11. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  12. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  13. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  14. data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
  15. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  16. data/lib/aws-sdk-core/cbor.rb +53 -0
  17. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  18. data/lib/aws-sdk-core/client_stubs.rb +33 -55
  19. data/lib/aws-sdk-core/credential_provider.rb +8 -1
  20. data/lib/aws-sdk-core/credential_provider_chain.rb +81 -29
  21. data/lib/aws-sdk-core/credentials.rb +19 -6
  22. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  23. data/lib/aws-sdk-core/ecs_credentials.rb +186 -60
  24. data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
  25. data/lib/aws-sdk-core/endpoints/endpoint.rb +19 -0
  26. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
  27. data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
  28. data/lib/aws-sdk-core/endpoints/function.rb +80 -0
  29. data/lib/aws-sdk-core/endpoints/matchers.rb +129 -0
  30. data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
  31. data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
  32. data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
  33. data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
  34. data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
  35. data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
  36. data/lib/aws-sdk-core/endpoints/url.rb +60 -0
  37. data/lib/aws-sdk-core/endpoints.rb +158 -0
  38. data/lib/aws-sdk-core/error_handler.rb +46 -0
  39. data/lib/aws-sdk-core/errors.rb +14 -5
  40. data/lib/aws-sdk-core/event_emitter.rb +1 -17
  41. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  42. data/lib/aws-sdk-core/instance_profile_credentials.rb +168 -155
  43. data/lib/aws-sdk-core/json/builder.rb +8 -1
  44. data/lib/aws-sdk-core/json/error_handler.rb +46 -11
  45. data/lib/aws-sdk-core/json/handler.rb +13 -6
  46. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  47. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  48. data/lib/aws-sdk-core/json/parser.rb +33 -3
  49. data/lib/aws-sdk-core/json.rb +43 -14
  50. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  51. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  52. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  53. data/lib/aws-sdk-core/log.rb +10 -0
  54. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  55. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  56. data/lib/aws-sdk-core/param_validator.rb +9 -4
  57. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  58. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +348 -169
  59. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -1
  60. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  61. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +84 -38
  62. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
  63. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
  64. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  65. data/lib/aws-sdk-core/plugins/http_checksum.rb +3 -8
  66. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  67. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  69. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  70. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  71. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  72. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  73. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  74. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  75. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +164 -34
  76. data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
  77. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  78. data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
  79. data/lib/aws-sdk-core/plugins/sign.rb +222 -0
  80. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -0
  81. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -0
  82. data/lib/aws-sdk-core/plugins/stub_responses.rb +59 -9
  83. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  84. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  85. data/lib/aws-sdk-core/plugins/user_agent.rb +192 -14
  86. data/lib/aws-sdk-core/plugins.rb +39 -0
  87. data/lib/aws-sdk-core/process_credentials.rb +48 -29
  88. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  89. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  90. data/lib/aws-sdk-core/query/handler.rb +4 -4
  91. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  92. data/lib/aws-sdk-core/query.rb +2 -1
  93. data/lib/aws-sdk-core/refreshing_credentials.rb +20 -23
  94. data/lib/aws-sdk-core/resources.rb +8 -0
  95. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  96. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  97. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  98. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  99. data/lib/aws-sdk-core/rest/request/headers.rb +14 -10
  100. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
  101. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  102. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  103. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  104. data/lib/aws-sdk-core/rest.rb +1 -0
  105. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  106. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  107. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  108. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +95 -0
  109. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  110. data/lib/aws-sdk-core/rpc_v2/parser.rb +98 -0
  111. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  112. data/lib/aws-sdk-core/shared_config.rb +160 -36
  113. data/lib/aws-sdk-core/shared_credentials.rb +1 -7
  114. data/lib/aws-sdk-core/sso_credentials.rb +84 -46
  115. data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
  116. data/lib/aws-sdk-core/static_token_provider.rb +1 -2
  117. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  118. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  119. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  120. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  121. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  122. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  123. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  124. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  125. data/lib/aws-sdk-core/stubbing.rb +22 -0
  126. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  127. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  128. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  129. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  130. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  131. data/lib/aws-sdk-core/telemetry.rb +78 -0
  132. data/lib/aws-sdk-core/token.rb +3 -3
  133. data/lib/aws-sdk-core/token_provider.rb +4 -0
  134. data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
  135. data/lib/aws-sdk-core/util.rb +41 -1
  136. data/lib/aws-sdk-core/waiters/poller.rb +12 -5
  137. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  138. data/lib/aws-sdk-core/xml/error_handler.rb +35 -43
  139. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  140. data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +2 -0
  141. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  142. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  143. data/lib/aws-sdk-core.rb +82 -103
  144. data/lib/aws-sdk-sso/client.rb +219 -89
  145. data/lib/aws-sdk-sso/client_api.rb +7 -0
  146. data/lib/aws-sdk-sso/endpoint_parameters.rb +69 -0
  147. data/lib/aws-sdk-sso/endpoint_provider.rb +53 -0
  148. data/lib/aws-sdk-sso/endpoints.rb +20 -0
  149. data/lib/aws-sdk-sso/plugins/endpoints.rb +77 -0
  150. data/lib/aws-sdk-sso/types.rb +1 -35
  151. data/lib/aws-sdk-sso.rb +15 -7
  152. data/lib/aws-sdk-ssooidc/client.rb +650 -118
  153. data/lib/aws-sdk-ssooidc/client_api.rb +94 -1
  154. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +69 -0
  155. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +53 -0
  156. data/lib/aws-sdk-ssooidc/endpoints.rb +20 -0
  157. data/lib/aws-sdk-ssooidc/errors.rb +62 -0
  158. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +77 -0
  159. data/lib/aws-sdk-ssooidc/types.rb +437 -67
  160. data/lib/aws-sdk-ssooidc.rb +15 -7
  161. data/lib/aws-sdk-sts/client.rb +670 -368
  162. data/lib/aws-sdk-sts/client_api.rb +48 -9
  163. data/lib/aws-sdk-sts/customizations.rb +5 -2
  164. data/lib/aws-sdk-sts/endpoint_parameters.rb +79 -0
  165. data/lib/aws-sdk-sts/endpoint_provider.rb +107 -0
  166. data/lib/aws-sdk-sts/endpoints.rb +20 -0
  167. data/lib/aws-sdk-sts/errors.rb +15 -0
  168. data/lib/aws-sdk-sts/plugins/endpoints.rb +77 -0
  169. data/lib/aws-sdk-sts/presigner.rb +12 -18
  170. data/lib/aws-sdk-sts/types.rb +296 -222
  171. data/lib/aws-sdk-sts.rb +15 -7
  172. data/lib/seahorse/client/async_base.rb +4 -6
  173. data/lib/seahorse/client/async_response.rb +19 -0
  174. data/lib/seahorse/client/base.rb +18 -21
  175. data/lib/seahorse/client/configuration.rb +1 -5
  176. data/lib/seahorse/client/h2/connection.rb +27 -36
  177. data/lib/seahorse/client/h2/handler.rb +14 -3
  178. data/lib/seahorse/client/handler.rb +1 -1
  179. data/lib/seahorse/client/http/response.rb +1 -1
  180. data/lib/seahorse/client/net_http/connection_pool.rb +15 -12
  181. data/lib/seahorse/client/net_http/handler.rb +21 -9
  182. data/lib/seahorse/client/net_http/patches.rb +1 -4
  183. data/lib/seahorse/client/networking_error.rb +1 -1
  184. data/lib/seahorse/client/plugin.rb +9 -0
  185. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  186. data/lib/seahorse/client/plugins/h2.rb +4 -4
  187. data/lib/seahorse/client/plugins/net_http.rb +57 -16
  188. data/lib/seahorse/client/plugins/request_callback.rb +40 -9
  189. data/lib/seahorse/client/request_context.rb +9 -2
  190. data/lib/seahorse/client/response.rb +8 -0
  191. data/lib/seahorse/model/operation.rb +3 -0
  192. data/lib/seahorse/model/shapes.rb +2 -2
  193. data/lib/seahorse/util.rb +6 -1
  194. data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
  195. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  196. data/sig/aws-sdk-core/errors.rbs +22 -0
  197. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  198. data/sig/aws-sdk-core/structure.rbs +4 -0
  199. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  200. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  201. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  202. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  203. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  204. data/sig/aws-sdk-core.rbs +7 -0
  205. data/sig/seahorse/client/async_base.rbs +18 -0
  206. data/sig/seahorse/client/base.rbs +25 -0
  207. data/sig/seahorse/client/handler_builder.rbs +16 -0
  208. data/sig/seahorse/client/response.rbs +61 -0
  209. metadata +133 -23
  210. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  211. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  212. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  213. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -7,37 +7,78 @@ 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
 
73
+ option(:ssl_cert, default: nil, doc_type: OpenSSL::X509::Certificate, docstring: <<-DOCS)
74
+ Sets a client certificate when creating http connections.
75
+ DOCS
76
+
77
+
78
+ option(:ssl_key, default: nil, doc_type: OpenSSL::PKey, docstring: <<-DOCS)
79
+ Sets a client key when creating http connections.
80
+ DOCS
81
+
41
82
  option(:logger) # for backwards compat
42
83
 
43
84
  handler(Client::NetHttp::Handler, step: :send)
@@ -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
@@ -80,18 +111,18 @@ bytes in the body.
80
111
  context.http_request.body,
81
112
  callback
82
113
  )
83
- add_event_listeners(context)
114
+ @handler.call(context).tap do
115
+ unwrap_callback_body(context)
116
+ end
117
+ else
118
+ @handler.call(context)
84
119
  end
85
- @handler.call(context)
86
120
  end
87
121
 
88
- def add_event_listeners(context)
89
- # unwrap the request body as soon as we start receiving a response
90
- context.http_response.on_headers do
91
- body = context.http_request.body
92
- if body.is_a? ReadCallbackIO
93
- context.http_request.body = body.io
94
- end
122
+ def unwrap_callback_body(context)
123
+ body = context.http_request.body
124
+ if body.is_a? ReadCallbackIO
125
+ context.http_request.body = body.io
95
126
  end
96
127
  end
97
128
  end
@@ -5,15 +5,18 @@ require 'stringio'
5
5
  module Seahorse
6
6
  module Client
7
7
  class RequestContext
8
-
8
+ # @param [Hash] options
9
9
  # @option options [required,Symbol] :operation_name (nil)
10
10
  # @option options [required,Model::Operation] :operation (nil)
11
11
  # @option options [Model::Authorizer] :authorizer (nil)
12
+ # @option options [Client] :client (nil)
12
13
  # @option options [Hash] :params ({})
13
14
  # @option options [Configuration] :config (nil)
14
15
  # @option options [Http::Request] :http_request (Http::Request.new)
15
16
  # @option options [Http::Response] :http_response (Http::Response.new)
16
- # and #rewind.
17
+ # @option options [Integer] :retries (0)
18
+ # @option options [Aws::Telemetry::TracerBase] :tracer (Aws::Telemetry::NoOpTracer.new)
19
+ # @option options [Hash] :metadata ({})
17
20
  def initialize(options = {})
18
21
  @operation_name = options[:operation_name]
19
22
  @operation = options[:operation]
@@ -24,6 +27,7 @@ module Seahorse
24
27
  @http_request = options[:http_request] || Http::Request.new
25
28
  @http_response = options[:http_response] || Http::Response.new
26
29
  @retries = 0
30
+ @tracer = options[:tracer] || Aws::Telemetry::NoOpTracer.new
27
31
  @metadata = {}
28
32
  end
29
33
 
@@ -54,6 +58,9 @@ module Seahorse
54
58
  # @return [Integer]
55
59
  attr_accessor :retries
56
60
 
61
+ # @return [Tracer]
62
+ attr_accessor :tracer
63
+
57
64
  # @return [Hash]
58
65
  attr_reader :metadata
59
66
 
@@ -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.
@@ -69,6 +75,8 @@ module Seahorse
69
75
  # Necessary to define as a subclass of Delegator
70
76
  # @api private
71
77
  def __getobj__
78
+ return yield if block_given? && !defined?(@data)
79
+
72
80
  @data
73
81
  end
74
82
 
@@ -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
data/lib/seahorse/util.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cgi'
3
+ require "cgi/escape"
4
+ require "cgi/util" if RUBY_VERSION < "3.5"
4
5
 
5
6
  module Seahorse
6
7
  # @api private
@@ -14,6 +15,10 @@ module Seahorse
14
15
  path.gsub(/[^\/]+/) { |part| uri_escape(part) }
15
16
  end
16
17
 
18
+ def escape_header_list_string(s)
19
+ s.include?('"') || s.include?(',') ? "\"#{s.gsub('"', '\"')}\"" : s
20
+ end
21
+
17
22
  # Checks for a valid host label
18
23
  # @see https://tools.ietf.org/html/rfc3986#section-3.2.2
19
24
  # @see https://tools.ietf.org/html/rfc1123#page-13
@@ -0,0 +1,21 @@
1
+ module Aws
2
+ module AsyncClientStubs
3
+ include ClientStubs
4
+
5
+ def send_events: () -> untyped
6
+
7
+ class StubsStream
8
+ def initialize: () -> void
9
+
10
+ attr_accessor send_events: untyped
11
+
12
+ attr_reader state: Symbol
13
+
14
+ def data: (untyped bytes, ?::Hash[untyped, untyped] options) -> untyped
15
+
16
+ def closed?: () -> bool
17
+
18
+ def close: () -> void
19
+ end
20
+ end
21
+ 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,46 @@
1
+ module Aws
2
+ module Telemetry
3
+ class TelemetryProviderBase
4
+ def initialize: (?tracer_provider: TracerProviderBase, ?context_manager: ContextManagerBase) -> void
5
+ attr_reader tracer_provider: TracerProviderBase
6
+
7
+ attr_reader context_manager: ContextManagerBase
8
+ end
9
+
10
+ class TracerProviderBase
11
+ def tracer: (?String name) -> TracerBase
12
+ end
13
+
14
+ class TracerBase
15
+ def start_span: (String name, ?untyped with_parent, ?Hash[String, untyped] attributes, ?SpanKind kind) -> SpanBase
16
+
17
+ def in_span: (String name, ?Hash[String, untyped] attributes, ?SpanKind kind) -> SpanBase
18
+
19
+ def current_span: () -> SpanBase
20
+ end
21
+
22
+ class SpanBase
23
+ def set_attribute: (String key, untyped value) -> self
24
+ alias []= set_attribute
25
+
26
+ def add_attributes: (Hash[String, untyped] attributes) -> self
27
+
28
+ def add_event: (String name, ?Hash[String, untyped] attributes) -> self
29
+
30
+ def status=: (SpanStatus status) -> void
31
+
32
+ def finish: (?Time end_timestamp) -> self
33
+
34
+ def record_exception: (untyped exception, ?Hash[String, untyped] attributes) -> void
35
+ end
36
+
37
+ class ContextManagerBase
38
+ def current: () -> untyped
39
+
40
+ def attach: (untyped context) -> untyped
41
+
42
+ def detach: (untyped token) -> bool
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,22 @@
1
+ module Aws
2
+ module Telemetry
3
+ class OTelProvider < TelemetryProviderBase
4
+ def initialize: () -> void
5
+ end
6
+
7
+ class OTelTracerProvider < TracerProviderBase
8
+ def initialize: () -> void
9
+ end
10
+
11
+ class OTelTracer < TracerBase
12
+ def initialize: (untyped tracer) -> void
13
+ end
14
+
15
+ class OTelSpan < SpanBase
16
+ def initialize: (untyped span) -> void
17
+ end
18
+
19
+ class OTelContextManager < ContextManagerBase
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ module Aws
2
+ module Telemetry
3
+ module SpanKind
4
+ INTERNAL: :internal
5
+
6
+ SERVER: :server
7
+
8
+ CLIENT: :client
9
+
10
+ CONSUMER: :consumer
11
+
12
+ PRODUCER: :producer
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module Aws
2
+ module Telemetry
3
+ class SpanStatus
4
+
5
+ def self.unset: (?::String description) -> SpanStatus
6
+
7
+ def self.ok: (?::String description) -> SpanStatus
8
+
9
+ def self.error: (?::String description) -> SpanStatus
10
+
11
+ def initialize: (Integer code, ?description: ::String) -> void
12
+
13
+ attr_reader code: Integer
14
+
15
+ attr_reader description: String
16
+
17
+ OK: 0
18
+
19
+ UNSET: 1
20
+
21
+ ERROR: 2
22
+ end
23
+ end
24
+ 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,18 @@
1
+ module Seahorse
2
+ module Client
3
+ class AsyncBase < Base
4
+
5
+ def self.new: (?untyped options) -> instance
6
+
7
+ attr_reader connection: untyped
8
+
9
+ def operation_names: () -> Array[Symbol]
10
+
11
+ def close_connection: () -> Symbol
12
+
13
+ def new_connection: () -> untyped
14
+
15
+ def connection_errors: () -> Array[untyped]
16
+ end
17
+ end
18
+ 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