aws-sdk-core 3.31.0 → 3.168.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1573 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -1
  5. data/lib/aws-defaults/default_configuration.rb +153 -0
  6. data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
  7. data/lib/aws-defaults.rb +3 -0
  8. data/lib/aws-sdk-core/arn.rb +105 -0
  9. data/lib/aws-sdk-core/arn_parser.rb +40 -0
  10. data/lib/aws-sdk-core/assume_role_credentials.rb +23 -7
  11. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +108 -0
  12. data/lib/aws-sdk-core/async_client_stubs.rb +82 -0
  13. data/lib/aws-sdk-core/binary/decode_handler.rb +11 -1
  14. data/lib/aws-sdk-core/binary/encode_handler.rb +45 -0
  15. data/lib/aws-sdk-core/binary/event_builder.rb +124 -0
  16. data/lib/aws-sdk-core/binary/event_parser.rb +50 -18
  17. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +7 -2
  18. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +55 -0
  19. data/lib/aws-sdk-core/binary.rb +5 -0
  20. data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +11 -1
  21. data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +71 -9
  22. data/lib/aws-sdk-core/client_stubs.rb +21 -14
  23. data/lib/aws-sdk-core/credential_provider.rb +1 -30
  24. data/lib/aws-sdk-core/credential_provider_chain.rb +107 -43
  25. data/lib/aws-sdk-core/credentials.rb +2 -0
  26. data/lib/aws-sdk-core/deprecations.rb +17 -11
  27. data/lib/aws-sdk-core/eager_loader.rb +2 -0
  28. data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
  29. data/lib/aws-sdk-core/ecs_credentials.rb +24 -9
  30. data/lib/aws-sdk-core/endpoint_cache.rb +193 -0
  31. data/lib/aws-sdk-core/endpoints/condition.rb +36 -0
  32. data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
  33. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +71 -0
  34. data/lib/aws-sdk-core/endpoints/error_rule.rb +37 -0
  35. data/lib/aws-sdk-core/endpoints/function.rb +75 -0
  36. data/lib/aws-sdk-core/endpoints/matchers.rb +127 -0
  37. data/lib/aws-sdk-core/endpoints/reference.rb +26 -0
  38. data/lib/aws-sdk-core/endpoints/rule.rb +20 -0
  39. data/lib/aws-sdk-core/endpoints/rule_set.rb +47 -0
  40. data/lib/aws-sdk-core/endpoints/rules_provider.rb +32 -0
  41. data/lib/aws-sdk-core/endpoints/templater.rb +52 -0
  42. data/lib/aws-sdk-core/endpoints/tree_rule.rb +40 -0
  43. data/lib/aws-sdk-core/endpoints/url.rb +59 -0
  44. data/lib/aws-sdk-core/endpoints.rb +74 -0
  45. data/lib/aws-sdk-core/errors.rb +172 -12
  46. data/lib/aws-sdk-core/event_emitter.rb +44 -0
  47. data/lib/aws-sdk-core/ini_parser.rb +2 -0
  48. data/lib/aws-sdk-core/instance_profile_credentials.rb +231 -42
  49. data/lib/aws-sdk-core/json/builder.rb +2 -0
  50. data/lib/aws-sdk-core/json/error_handler.rb +31 -3
  51. data/lib/aws-sdk-core/json/handler.rb +21 -1
  52. data/lib/aws-sdk-core/json/json_engine.rb +12 -8
  53. data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
  54. data/lib/aws-sdk-core/json/parser.rb +10 -0
  55. data/lib/aws-sdk-core/json.rb +11 -28
  56. data/lib/aws-sdk-core/log/formatter.rb +16 -4
  57. data/lib/aws-sdk-core/log/handler.rb +2 -0
  58. data/lib/aws-sdk-core/log/param_filter.rb +38 -13
  59. data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
  60. data/lib/aws-sdk-core/pageable_response.rb +118 -47
  61. data/lib/aws-sdk-core/pager.rb +5 -0
  62. data/lib/aws-sdk-core/param_converter.rb +2 -0
  63. data/lib/aws-sdk-core/param_validator.rb +63 -7
  64. data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
  65. data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
  66. data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
  67. data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
  69. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +340 -0
  70. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +65 -6
  71. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +10 -4
  72. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +50 -7
  73. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  74. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +172 -0
  75. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +65 -0
  76. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +16 -0
  77. data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
  78. data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
  79. data/lib/aws-sdk-core/plugins/http_checksum.rb +64 -0
  80. data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
  81. data/lib/aws-sdk-core/plugins/invocation_id.rb +35 -0
  82. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
  83. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  84. data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
  85. data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
  86. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
  87. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
  88. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
  89. data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
  90. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
  91. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
  92. data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
  93. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +81 -16
  94. data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
  95. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +139 -0
  96. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +100 -0
  97. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +147 -0
  98. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +59 -0
  99. data/lib/aws-sdk-core/plugins/retry_errors.rb +312 -92
  100. data/lib/aws-sdk-core/plugins/sign.rb +200 -0
  101. data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
  102. data/lib/aws-sdk-core/plugins/signature_v4.rb +42 -32
  103. data/lib/aws-sdk-core/plugins/stub_responses.rb +28 -7
  104. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +53 -0
  105. data/lib/aws-sdk-core/plugins/user_agent.rb +9 -5
  106. data/lib/aws-sdk-core/process_credentials.rb +20 -15
  107. data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
  108. data/lib/aws-sdk-core/query/handler.rb +8 -1
  109. data/lib/aws-sdk-core/query/param.rb +2 -0
  110. data/lib/aws-sdk-core/query/param_builder.rb +2 -0
  111. data/lib/aws-sdk-core/query/param_list.rb +2 -0
  112. data/lib/aws-sdk-core/query.rb +2 -0
  113. data/lib/aws-sdk-core/refreshing_credentials.rb +45 -12
  114. data/lib/aws-sdk-core/refreshing_token.rb +71 -0
  115. data/lib/aws-sdk-core/resources/collection.rb +3 -1
  116. data/lib/aws-sdk-core/rest/handler.rb +3 -1
  117. data/lib/aws-sdk-core/rest/request/body.rb +21 -1
  118. data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
  119. data/lib/aws-sdk-core/rest/request/endpoint.rb +10 -3
  120. data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
  121. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +4 -2
  122. data/lib/aws-sdk-core/rest/response/body.rb +2 -0
  123. data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
  124. data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
  125. data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
  126. data/lib/aws-sdk-core/rest.rb +2 -0
  127. data/lib/aws-sdk-core/shared_config.rb +222 -118
  128. data/lib/aws-sdk-core/shared_credentials.rb +9 -1
  129. data/lib/aws-sdk-core/sso_credentials.rb +172 -0
  130. data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
  131. data/lib/aws-sdk-core/static_token_provider.rb +14 -0
  132. data/lib/aws-sdk-core/structure.rb +24 -7
  133. data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
  134. data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
  135. data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
  136. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
  137. data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
  138. data/lib/aws-sdk-core/stubbing/protocols/query.rb +4 -2
  139. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +52 -7
  140. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
  141. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
  142. data/lib/aws-sdk-core/stubbing/stub_data.rb +15 -4
  143. data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
  144. data/lib/aws-sdk-core/token.rb +31 -0
  145. data/lib/aws-sdk-core/token_provider.rb +15 -0
  146. data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
  147. data/lib/aws-sdk-core/type_builder.rb +2 -0
  148. data/lib/aws-sdk-core/util.rb +24 -0
  149. data/lib/aws-sdk-core/waiters/errors.rb +2 -0
  150. data/lib/aws-sdk-core/waiters/poller.rb +2 -0
  151. data/lib/aws-sdk-core/waiters/waiter.rb +4 -2
  152. data/lib/aws-sdk-core/waiters.rb +2 -0
  153. data/lib/aws-sdk-core/xml/builder.rb +5 -3
  154. data/lib/aws-sdk-core/xml/default_list.rb +2 -0
  155. data/lib/aws-sdk-core/xml/default_map.rb +2 -0
  156. data/lib/aws-sdk-core/xml/doc_builder.rb +15 -4
  157. data/lib/aws-sdk-core/xml/error_handler.rb +36 -4
  158. data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
  159. data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
  160. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  161. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
  162. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +4 -1
  163. data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
  164. data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
  165. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  166. data/lib/aws-sdk-core/xml/parser.rb +7 -0
  167. data/lib/aws-sdk-core/xml.rb +2 -0
  168. data/lib/aws-sdk-core.rb +42 -4
  169. data/lib/aws-sdk-sso/client.rb +610 -0
  170. data/lib/aws-sdk-sso/client_api.rb +190 -0
  171. data/lib/aws-sdk-sso/customizations.rb +1 -0
  172. data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
  173. data/lib/aws-sdk-sso/endpoint_provider.rb +112 -0
  174. data/lib/aws-sdk-sso/endpoints.rb +71 -0
  175. data/lib/aws-sdk-sso/errors.rb +102 -0
  176. data/lib/aws-sdk-sso/plugins/endpoints.rb +76 -0
  177. data/lib/aws-sdk-sso/resource.rb +26 -0
  178. data/lib/aws-sdk-sso/types.rb +317 -0
  179. data/lib/aws-sdk-sso.rb +59 -0
  180. data/lib/aws-sdk-ssooidc/client.rb +606 -0
  181. data/lib/aws-sdk-ssooidc/client_api.rb +216 -0
  182. data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
  183. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
  184. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +111 -0
  185. data/lib/aws-sdk-ssooidc/endpoints.rb +57 -0
  186. data/lib/aws-sdk-ssooidc/errors.rb +290 -0
  187. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +74 -0
  188. data/lib/aws-sdk-ssooidc/resource.rb +26 -0
  189. data/lib/aws-sdk-ssooidc/types.rb +502 -0
  190. data/lib/aws-sdk-ssooidc.rb +59 -0
  191. data/lib/aws-sdk-sts/client.rb +1426 -616
  192. data/lib/aws-sdk-sts/client_api.rb +76 -1
  193. data/lib/aws-sdk-sts/customizations.rb +4 -0
  194. data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
  195. data/lib/aws-sdk-sts/endpoint_provider.rb +229 -0
  196. data/lib/aws-sdk-sts/endpoints.rb +135 -0
  197. data/lib/aws-sdk-sts/errors.rb +153 -1
  198. data/lib/aws-sdk-sts/plugins/endpoints.rb +84 -0
  199. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +38 -0
  200. data/lib/aws-sdk-sts/presigner.rb +73 -0
  201. data/lib/aws-sdk-sts/resource.rb +4 -1
  202. data/lib/aws-sdk-sts/types.rb +918 -296
  203. data/lib/aws-sdk-sts.rb +20 -6
  204. data/lib/seahorse/client/async_base.rb +51 -0
  205. data/lib/seahorse/client/async_response.rb +64 -0
  206. data/lib/seahorse/client/base.rb +7 -2
  207. data/lib/seahorse/client/block_io.rb +6 -2
  208. data/lib/seahorse/client/configuration.rb +17 -3
  209. data/lib/seahorse/client/events.rb +3 -1
  210. data/lib/seahorse/client/h2/connection.rb +247 -0
  211. data/lib/seahorse/client/h2/handler.rb +152 -0
  212. data/lib/seahorse/client/handler.rb +2 -0
  213. data/lib/seahorse/client/handler_builder.rb +2 -0
  214. data/lib/seahorse/client/handler_list.rb +2 -0
  215. data/lib/seahorse/client/handler_list_entry.rb +6 -4
  216. data/lib/seahorse/client/http/async_response.rb +44 -0
  217. data/lib/seahorse/client/http/headers.rb +2 -0
  218. data/lib/seahorse/client/http/request.rb +5 -3
  219. data/lib/seahorse/client/http/response.rb +18 -11
  220. data/lib/seahorse/client/logging/formatter.rb +6 -2
  221. data/lib/seahorse/client/logging/handler.rb +2 -0
  222. data/lib/seahorse/client/managed_file.rb +2 -0
  223. data/lib/seahorse/client/net_http/connection_pool.rb +30 -23
  224. data/lib/seahorse/client/net_http/handler.rb +24 -7
  225. data/lib/seahorse/client/net_http/patches.rb +16 -79
  226. data/lib/seahorse/client/networking_error.rb +30 -0
  227. data/lib/seahorse/client/plugin.rb +10 -7
  228. data/lib/seahorse/client/plugin_list.rb +2 -0
  229. data/lib/seahorse/client/plugins/content_length.rb +14 -3
  230. data/lib/seahorse/client/plugins/endpoint.rb +4 -2
  231. data/lib/seahorse/client/plugins/h2.rb +69 -0
  232. data/lib/seahorse/client/plugins/logging.rb +2 -0
  233. data/lib/seahorse/client/plugins/net_http.rb +39 -3
  234. data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
  235. data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
  236. data/lib/seahorse/client/plugins/request_callback.rb +110 -0
  237. data/lib/seahorse/client/plugins/response_target.rb +23 -14
  238. data/lib/seahorse/client/request.rb +2 -0
  239. data/lib/seahorse/client/request_context.rb +2 -0
  240. data/lib/seahorse/client/response.rb +5 -5
  241. data/lib/seahorse/model/api.rb +14 -0
  242. data/lib/seahorse/model/authorizer.rb +2 -0
  243. data/lib/seahorse/model/operation.rb +21 -0
  244. data/lib/seahorse/model/shapes.rb +29 -2
  245. data/lib/seahorse/util.rb +12 -1
  246. data/lib/seahorse/version.rb +2 -0
  247. data/lib/seahorse.rb +12 -0
  248. metadata +117 -16
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
  require 'thread'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Plugins
@@ -5,13 +7,22 @@ module Seahorse
5
7
 
6
8
  # @api private
7
9
  class Handler < Client::Handler
10
+ # https://github.com/ruby/net-http/blob/master/lib/net/http/requests.rb
11
+ # Methods without body are forwards compatible, because content-length
12
+ # may be set for requests without body but is technically incorrect.
13
+ METHODS_WITHOUT_BODY = Set.new(
14
+ %w[GET HEAD DELETE OPTIONS TRACE COPY MOVE]
15
+ )
8
16
 
9
17
  def call(context)
10
- length = context.http_request.body.size
11
- context.http_request.headers['Content-Length'] = length
18
+ body = context.http_request.body
19
+ method = context.http_request.http_method
20
+ # We use Net::HTTP with body_stream which doesn't do this by default
21
+ if body.respond_to?(:size) && !METHODS_WITHOUT_BODY.include?(method)
22
+ context.http_request.headers['Content-Length'] = body.size
23
+ end
12
24
  @handler.call(context)
13
25
  end
14
-
15
26
  end
16
27
 
17
28
  handler(Handler, step: :sign, priority: 0)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Plugins
@@ -9,8 +11,8 @@ module Seahorse
9
11
  Normally you should not configure the `:endpoint` option
10
12
  directly. This is normally constructed from the `:region`
11
13
  option. Configuring `:endpoint` is normally reserved for
12
- connecting to test endpoints. The endpoint should be a URI
13
- formatted like:
14
+ connecting to test or custom endpoints. The endpoint should
15
+ be a URI formatted like:
14
16
 
15
17
  'http://example.com'
16
18
  'https://example.com'
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'seahorse/client/h2/handler'
4
+
5
+ module Seahorse
6
+ module Client
7
+ module Plugins
8
+ class H2 < Plugin
9
+
10
+ # H2 Client
11
+ option(:max_concurrent_streams, default: 100, doc_type: Integer, docstring: <<-DOCS)
12
+ Maximum concurrent streams used in HTTP2 connection, defaults to 100. Note that server may send back
13
+ :settings_max_concurrent_streams value which will take priority when initializing new streams.
14
+ DOCS
15
+
16
+ option(:connection_timeout, default: 60, doc_type: Integer, docstring: <<-DOCS)
17
+ Connection timeout in seconds, defaults to 60 sec.
18
+ DOCS
19
+
20
+ option(:connection_read_timeout, default: 60, doc_type: Integer, docstring: <<-DOCS)
21
+ Connection read timeout in seconds, defaults to 60 sec.
22
+ DOCS
23
+
24
+ option(:read_chunk_size, default: 1024, doc_type: Integer, docstring: '')
25
+
26
+ option(:raise_response_errors, default: true, doc_type: 'Boolean', docstring: <<-DOCS)
27
+ Defaults to `true`, raises errors if exist when #wait or #join! is called upon async response.
28
+ DOCS
29
+
30
+ # SSL Context
31
+ option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: <<-DOCS) do |cfg|
32
+ Full path to the SSL certificate authority bundle file that should be used when
33
+ verifying peer certificates. If you do not pass `:ssl_ca_directory` or `:ssl_ca_bundle`
34
+ the system default will be used if available.
35
+ DOCS
36
+ ENV['AWS_CA_BUNDLE'] ||
37
+ Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
38
+ end
39
+
40
+ option(:ssl_ca_directory, default: nil, doc_type: String, docstring: <<-DOCS)
41
+ Full path of the directory that contains the unbundled SSL certificate authority
42
+ files for verifying peer certificates. If you do not pass `:ssl_ca_bundle` or
43
+ `:ssl_ca_directory` the system default will be used if available.
44
+ DOCS
45
+
46
+ option(:ssl_ca_store, default: nil, doc_type: String, docstring: '')
47
+
48
+ option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: <<-DOCS)
49
+ When `true`, SSL peer certificates are verified when establishing a connection.
50
+ DOCS
51
+
52
+ option(:http_wire_trace, default: false, doc_type: 'Boolean', docstring: <<-DOCS)
53
+ When `true`, HTTP2 debug output will be sent to the `:logger`.
54
+ DOCS
55
+
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.
60
+ DOCS
61
+
62
+ option(:logger)
63
+
64
+ handler(Client::H2::Handler, step: :send)
65
+
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Plugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'seahorse/client/net_http/handler'
2
4
 
3
5
  module Seahorse
@@ -7,9 +9,13 @@ module Seahorse
7
9
 
8
10
  option(:http_proxy, default: nil, doc_type: String, docstring: '')
9
11
 
10
- option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '')
12
+ option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '') do |cfg|
13
+ resolve_http_open_timeout(cfg)
14
+ end
11
15
 
12
- option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '')
16
+ option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '') do |cfg|
17
+ resolve_http_read_timeout(cfg)
18
+ end
13
19
 
14
20
  option(:http_idle_timeout, default: 5, doc_type: Integer, docstring: '')
15
21
 
@@ -19,16 +25,46 @@ module Seahorse
19
25
 
20
26
  option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: '')
21
27
 
22
- option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: '')
28
+ option(:ssl_ca_bundle, doc_type: String, docstring: '') do |cfg|
29
+ ENV['AWS_CA_BUNDLE'] ||
30
+ Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
31
+ end
23
32
 
24
33
  option(:ssl_ca_directory, default: nil, doc_type: String, docstring: '')
25
34
 
26
35
  option(:ssl_ca_store, default: nil, doc_type: String, docstring: '')
27
36
 
37
+ option(:ssl_timeout, default: nil, doc_type: Float, docstring: '') do |cfg|
38
+ resolve_ssl_timeout(cfg)
39
+ end
40
+
28
41
  option(:logger) # for backwards compat
29
42
 
30
43
  handler(Client::NetHttp::Handler, step: :send)
31
44
 
45
+ def self.resolve_http_open_timeout(cfg)
46
+ default_mode_value =
47
+ if cfg.respond_to?(:defaults_mode_config_resolver)
48
+ cfg.defaults_mode_config_resolver.resolve(:http_open_timeout)
49
+ end
50
+ default_mode_value || 15
51
+ end
52
+
53
+ def self.resolve_http_read_timeout(cfg)
54
+ default_mode_value =
55
+ if cfg.respond_to?(:defaults_mode_config_resolver)
56
+ cfg.defaults_mode_config_resolver.resolve(:http_read_timeout)
57
+ end
58
+ default_mode_value || 60
59
+ end
60
+
61
+ def self.resolve_ssl_timeout(cfg)
62
+ default_mode_value =
63
+ if cfg.respond_to?(:defaults_mode_config_resolver)
64
+ cfg.defaults_mode_config_resolver.resolve(:ssl_timeout)
65
+ end
66
+ default_mode_value || nil
67
+ end
32
68
  end
33
69
  end
34
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Plugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Plugins
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ require 'forwardable'
5
+
6
+ module Seahorse
7
+ module Client
8
+ module Plugins
9
+
10
+ # @api private
11
+ class ReadCallbackIO
12
+ extend Forwardable
13
+ def_delegators :@io, :size
14
+
15
+ def initialize(io, on_read = nil)
16
+ @io = io
17
+ @on_read = on_read if on_read.is_a? Proc
18
+ @bytes_read = 0
19
+
20
+ # Some IO objects support readpartial - IO.copy_stream used by the
21
+ # request will call readpartial if available, so define a wrapper
22
+ # for it if the underlying IO supports it.
23
+ if @io.respond_to?(:readpartial)
24
+ def self.readpartial(*args)
25
+ @io.readpartial(*args).tap do |chunk|
26
+ handle_chunk(chunk)
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ attr_reader :io
33
+
34
+ def read(*args)
35
+ @io.read(*args).tap do |chunk|
36
+ handle_chunk(chunk)
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def handle_chunk(chunk)
43
+ @bytes_read += chunk.bytesize if chunk && chunk.respond_to?(:bytesize)
44
+ total_size = @io.respond_to?(:size) ? @io.size : nil
45
+ @on_read.call(chunk, @bytes_read, total_size) if @on_read
46
+ end
47
+ end
48
+
49
+ # @api private
50
+ class RequestCallback < Plugin
51
+
52
+ option(
53
+ :on_chunk_sent,
54
+ default: nil,
55
+ doc_type: 'Proc',
56
+ docstring: <<-DOCS)
57
+ When a Proc object is provided, it will be used as callback when each chunk
58
+ of the request body is sent. It provides three arguments: the chunk,
59
+ the number of bytes read from the body, and the total number of
60
+ bytes in the body.
61
+ DOCS
62
+
63
+ # @api private
64
+ class OptionHandler < Client::Handler
65
+ def call(context)
66
+ if context.params.is_a?(Hash) && context.params[:on_chunk_sent]
67
+ on_chunk_sent = context.params.delete(:on_chunk_sent)
68
+ end
69
+ on_chunk_sent = context.config.on_chunk_sent if on_chunk_sent.nil?
70
+ context[:on_chunk_sent] = on_chunk_sent if on_chunk_sent
71
+ @handler.call(context)
72
+ end
73
+ end
74
+
75
+ # @api private
76
+ class ReadCallbackHandler < Client::Handler
77
+ def call(context)
78
+ if (callback = context[:on_chunk_sent])
79
+ context.http_request.body = ReadCallbackIO.new(
80
+ context.http_request.body,
81
+ callback
82
+ )
83
+ @handler.call(context).tap do
84
+ unwrap_callback_body(context)
85
+ end
86
+ else
87
+ @handler.call(context)
88
+ end
89
+ end
90
+
91
+ def unwrap_callback_body(context)
92
+ body = context.http_request.body
93
+ if body.is_a? ReadCallbackIO
94
+ context.http_request.body = body.io
95
+ end
96
+ end
97
+ end
98
+
99
+ # OptionHandler is needed to remove :on_chunk_sent
100
+ # from the params before build
101
+ handler(OptionHandler, step: :initialize)
102
+
103
+ # ReadCallbackHandlerneeds to go late in the call stack
104
+ # other plugins including Sigv4 and content_md5 read the request body
105
+ # and rewind it
106
+ handler(ReadCallbackHandler, step: :sign, priority: 0)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Seahorse
@@ -15,10 +17,9 @@ module Seahorse
15
17
 
16
18
  def call(context)
17
19
  if context.params.is_a?(Hash) && context.params[:response_target]
18
- target = context.params.delete(:response_target)
19
- else
20
- target = context[:response_target]
20
+ context[:response_target] = context.params.delete(:response_target)
21
21
  end
22
+ target = context[:response_target]
22
23
  add_event_listeners(context, target) if target
23
24
  @handler.call(context)
24
25
  end
@@ -26,35 +27,43 @@ module Seahorse
26
27
  private
27
28
 
28
29
  def add_event_listeners(context, target)
29
- handler = self
30
30
  context.http_response.on_headers(200..299) do
31
- context.http_response.body = handler.send(:io, target)
31
+ # In a fresh response body will be a StringIO
32
+ # However, when a request is retried we may have
33
+ # an existing ManagedFile or BlockIO and those
34
+ # should be reused.
35
+ if context.http_response.body.is_a? StringIO
36
+ context.http_response.body = io(target, context.http_response.headers)
37
+ end
32
38
  end
33
39
 
34
40
  context.http_response.on_success(200..299) do
35
41
  body = context.http_response.body
36
- if ManagedFile === body && body.open?
42
+ if body.is_a?(ManagedFile) && body.open?
37
43
  body.close
38
44
  end
39
45
  end
40
46
 
41
47
  context.http_response.on_error do
42
48
  body = context.http_response.body
43
- File.unlink(body) if ManagedFile === body
49
+
50
+ # When using response_target of file we do not want to write
51
+ # error messages to the file. So set the body to a new StringIO
52
+ if body.is_a? ManagedFile
53
+ File.unlink(body)
54
+ context.http_response.body = StringIO.new
55
+ end
56
+
44
57
  # Aws::S3::Encryption::DecryptHandler (with lower priority)
45
58
  # has callbacks registered after ResponseTarget::Handler,
46
59
  # where http_response.body is an IODecrypter
47
- # and has error callbacks handling for it.
48
- # Thus avoid early remove of IODecrypter at ResponseTarget::Handler
49
- unless context.http_response.body.respond_to?(:io)
50
- context.http_response.body = StringIO.new
51
- end
60
+ # and has error callbacks handling for it so no action is required here
52
61
  end
53
62
  end
54
63
 
55
- def io(target)
64
+ def io(target, headers)
56
65
  case target
57
- when Proc then BlockIO.new(&target)
66
+ when Proc then BlockIO.new(headers, &target)
58
67
  when String, Pathname then ManagedFile.new(target, 'w+b')
59
68
  else target
60
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class Request
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
 
3
5
  module Seahorse
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'delegate'
2
4
 
3
5
  module Seahorse
4
6
  module Client
5
7
  class Response < Delegator
6
-
7
8
  # @option options [RequestContext] :context (nil)
8
9
  # @option options [Integer] :status_code (nil)
9
10
  # @option options [Http::Headers] :headers (Http::Headers.new)
@@ -39,10 +40,10 @@ module Seahorse
39
40
  # witin the given range.
40
41
  #
41
42
  # @return [self]
42
- def on(range, &block)
43
+ def on(range, &_block)
43
44
  response = self
44
45
  @context.http_response.on_success(range) do
45
- block.call(response)
46
+ yield response
46
47
  end
47
48
  self
48
49
  end
@@ -56,7 +57,7 @@ module Seahorse
56
57
  # @return [Boolean] Returns `true` if the response is complete with
57
58
  # a ~ 200 level http status code.
58
59
  def successful?
59
- (200..299).include?(@context.http_response.status_code) && @error.nil?
60
+ (200..299).cover?(@context.http_response.status_code) && @error.nil?
60
61
  end
61
62
 
62
63
  # @api private
@@ -76,7 +77,6 @@ module Seahorse
76
77
  def __setobj__(obj)
77
78
  @data = obj
78
79
  end
79
-
80
80
  end
81
81
  end
82
82
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Model
3
5
  class Api
@@ -6,6 +8,8 @@ module Seahorse
6
8
  @metadata = {}
7
9
  @operations = {}
8
10
  @authorizers = {}
11
+ @endpoint_operation = nil
12
+ @require_endpoint_discovery = false
9
13
  end
10
14
 
11
15
  # @return [String, nil]
@@ -14,6 +18,12 @@ module Seahorse
14
18
  # @return [Hash]
15
19
  attr_accessor :metadata
16
20
 
21
+ # @return [Symbol|nil]
22
+ attr_accessor :endpoint_operation
23
+
24
+ # @return [Boolean|nil]
25
+ attr_accessor :require_endpoint_discovery
26
+
17
27
  def operations(&block)
18
28
  if block_given?
19
29
  @operations.each(&block)
@@ -34,6 +44,10 @@ module Seahorse
34
44
  @operations.keys
35
45
  end
36
46
 
47
+ def async_operation_names
48
+ @operations.select {|_, op| op.async }.keys
49
+ end
50
+
37
51
  def add_operation(name, operation)
38
52
  @operations[name.to_sym] = operation
39
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Model
3
5
  class Authorizer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Model
3
5
  class Operation
@@ -8,6 +10,7 @@ module Seahorse
8
10
  @deprecated = false
9
11
  @errors = []
10
12
  @metadata = {}
13
+ @async = false
11
14
  end
12
15
 
13
16
  # @return [String, nil]
@@ -19,12 +22,27 @@ module Seahorse
19
22
  # @return [String]
20
23
  attr_accessor :http_request_uri
21
24
 
25
+ # @return [Boolean]
26
+ attr_accessor :http_checksum_required
27
+
28
+ # @return [Hash]
29
+ attr_accessor :http_checksum
30
+
22
31
  # @return [Boolean]
23
32
  attr_accessor :deprecated
24
33
 
34
+ # @return [Boolean]
35
+ attr_accessor :endpoint_operation
36
+
37
+ # @return [Hash]
38
+ attr_accessor :endpoint_discovery
39
+
25
40
  # @return [String, nil]
26
41
  attr_accessor :documentation
27
42
 
43
+ # @return [Hash, nil]
44
+ attr_accessor :endpoint_pattern
45
+
28
46
  # @return [String, nil]
29
47
  attr_accessor :authorizer
30
48
 
@@ -41,6 +59,9 @@ module Seahorse
41
59
  # @return [Boolean]
42
60
  attr_accessor :require_apikey
43
61
 
62
+ # @return [Boolean]
63
+ attr_accessor :async
64
+
44
65
  def [](key)
45
66
  @metadata[key.to_s]
46
67
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Seahorse
@@ -15,9 +17,9 @@ module Seahorse
15
17
  @event = false
16
18
  @eventstream = false
17
19
  @eventpayload = false
18
- @eventpayload_type = ''
20
+ @eventpayload_type = ''.freeze
19
21
  @eventheader = false
20
- @eventheader_type = ''
22
+ @eventheader_type = ''.freeze
21
23
  options.each do |key, value|
22
24
  if key == :metadata
23
25
  value.each do |k,v|
@@ -59,6 +61,9 @@ module Seahorse
59
61
  # @return [Boolean]
60
62
  attr_accessor :eventheader_type
61
63
 
64
+ # @return [Boolean]
65
+ attr_accessor :document
66
+
62
67
  # @return [String, nil]
63
68
  def location
64
69
  @location || (shape && shape[:location])
@@ -112,6 +117,9 @@ module Seahorse
112
117
  # @return [String, nil]
113
118
  attr_accessor :documentation
114
119
 
120
+ # @return [Boolean]
121
+ attr_accessor :union
122
+
115
123
  # Gets metadata for the given `key`.
116
124
  def [](key)
117
125
  @metadata[key.to_s]
@@ -262,8 +270,27 @@ module Seahorse
262
270
 
263
271
  end
264
272
 
273
+ class UnionShape < StructureShape
274
+ def initialize(options = {})
275
+ @member_subclasses = {}
276
+ super options.merge(union: true)
277
+ end
278
+
279
+ # @api private
280
+ def member_subclass(member)
281
+ @member_subclasses[member]
282
+ end
283
+
284
+ # @api private
285
+ def add_member_subclass(member, subclass)
286
+ @member_subclasses[member] = subclass
287
+ end
288
+ end
289
+
265
290
  class TimestampShape < Shape; end
266
291
 
292
+ class DocumentShape < Shape; end
293
+
267
294
  end
268
295
  end
269
296
  end
data/lib/seahorse/util.rb CHANGED
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cgi'
2
4
 
3
5
  module Seahorse
4
6
  # @api private
5
7
  module Util
6
8
  class << self
7
-
8
9
  def uri_escape(string)
9
10
  CGI.escape(string.to_s.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
10
11
  end
@@ -13,6 +14,16 @@ module Seahorse
13
14
  path.gsub(/[^\/]+/) { |part| uri_escape(part) }
14
15
  end
15
16
 
17
+ def escape_header_list_string(s)
18
+ s.include?('"') || s.include?(',') ? "\"#{s.gsub('"', '\"')}\"" : s
19
+ end
20
+
21
+ # Checks for a valid host label
22
+ # @see https://tools.ietf.org/html/rfc3986#section-3.2.2
23
+ # @see https://tools.ietf.org/html/rfc1123#page-13
24
+ def host_label?(str)
25
+ str =~ /^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)$/
26
+ end
16
27
  end
17
28
  end
18
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  VERSION = '0.1.0'
3
5
  end