aws-sdk-core 3.100.0 → 3.191.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1815 -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 +28 -0
  9. data/lib/aws-sdk-core/arn_parser.rb +2 -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 +16 -10
  12. data/lib/aws-sdk-core/async_client_stubs.rb +2 -0
  13. data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
  14. data/lib/aws-sdk-core/binary/encode_handler.rb +14 -1
  15. data/lib/aws-sdk-core/binary/event_builder.rb +2 -0
  16. data/lib/aws-sdk-core/binary/event_parser.rb +2 -0
  17. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +2 -0
  18. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +2 -0
  19. data/lib/aws-sdk-core/binary.rb +2 -0
  20. data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +2 -0
  21. data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
  22. data/lib/aws-sdk-core/client_stubs.rb +22 -13
  23. data/lib/aws-sdk-core/credential_provider.rb +5 -0
  24. data/lib/aws-sdk-core/credential_provider_chain.rb +31 -6
  25. data/lib/aws-sdk-core/credentials.rb +2 -0
  26. data/lib/aws-sdk-core/deprecations.rb +2 -0
  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 +188 -53
  30. data/lib/aws-sdk-core/endpoint_cache.rb +2 -0
  31. data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
  32. data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
  33. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
  34. data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
  35. data/lib/aws-sdk-core/endpoints/function.rb +80 -0
  36. data/lib/aws-sdk-core/endpoints/matchers.rb +131 -0
  37. data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
  38. data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
  39. data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
  40. data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
  41. data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
  42. data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
  43. data/lib/aws-sdk-core/endpoints/url.rb +60 -0
  44. data/lib/aws-sdk-core/endpoints.rb +78 -0
  45. data/lib/aws-sdk-core/errors.rb +27 -5
  46. data/lib/aws-sdk-core/event_emitter.rb +2 -0
  47. data/lib/aws-sdk-core/ini_parser.rb +9 -0
  48. data/lib/aws-sdk-core/instance_profile_credentials.rb +167 -38
  49. data/lib/aws-sdk-core/json/builder.rb +2 -0
  50. data/lib/aws-sdk-core/json/error_handler.rb +22 -1
  51. data/lib/aws-sdk-core/json/handler.rb +10 -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 +36 -1
  55. data/lib/aws-sdk-core/json.rb +10 -26
  56. data/lib/aws-sdk-core/log/formatter.rb +15 -3
  57. data/lib/aws-sdk-core/log/handler.rb +2 -0
  58. data/lib/aws-sdk-core/log/param_filter.rb +37 -12
  59. data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
  60. data/lib/aws-sdk-core/pageable_response.rb +91 -32
  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 +56 -6
  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 +342 -0
  70. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +3 -0
  71. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
  72. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +52 -7
  73. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  74. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +8 -2
  75. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
  76. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -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 +11 -1
  80. data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
  81. data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
  82. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
  83. data/lib/aws-sdk-core/plugins/logging.rb +4 -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 +146 -17
  94. data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
  95. data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
  96. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +2 -0
  97. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +2 -0
  98. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +9 -4
  99. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +2 -0
  100. data/lib/aws-sdk-core/plugins/retry_errors.rb +29 -8
  101. data/lib/aws-sdk-core/plugins/sign.rb +206 -0
  102. data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
  103. data/lib/aws-sdk-core/plugins/signature_v4.rb +30 -31
  104. data/lib/aws-sdk-core/plugins/stub_responses.rb +10 -1
  105. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +2 -0
  106. data/lib/aws-sdk-core/plugins/user_agent.rb +119 -14
  107. data/lib/aws-sdk-core/process_credentials.rb +14 -15
  108. data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
  109. data/lib/aws-sdk-core/query/handler.rb +2 -0
  110. data/lib/aws-sdk-core/query/param.rb +2 -0
  111. data/lib/aws-sdk-core/query/param_builder.rb +2 -0
  112. data/lib/aws-sdk-core/query/param_list.rb +2 -0
  113. data/lib/aws-sdk-core/query.rb +2 -0
  114. data/lib/aws-sdk-core/refreshing_credentials.rb +50 -17
  115. data/lib/aws-sdk-core/refreshing_token.rb +71 -0
  116. data/lib/aws-sdk-core/resources/collection.rb +2 -0
  117. data/lib/aws-sdk-core/rest/handler.rb +3 -1
  118. data/lib/aws-sdk-core/rest/request/body.rb +21 -1
  119. data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
  120. data/lib/aws-sdk-core/rest/request/endpoint.rb +2 -0
  121. data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
  122. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +45 -29
  123. data/lib/aws-sdk-core/rest/response/body.rb +2 -0
  124. data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
  125. data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
  126. data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
  127. data/lib/aws-sdk-core/rest.rb +2 -0
  128. data/lib/aws-sdk-core/shared_config.rb +163 -8
  129. data/lib/aws-sdk-core/shared_credentials.rb +9 -1
  130. data/lib/aws-sdk-core/sso_credentials.rb +172 -0
  131. data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
  132. data/lib/aws-sdk-core/static_token_provider.rb +14 -0
  133. data/lib/aws-sdk-core/structure.rb +19 -6
  134. data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
  135. data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
  136. data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
  137. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
  138. data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
  139. data/lib/aws-sdk-core/stubbing/protocols/query.rb +2 -0
  140. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +3 -1
  141. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
  142. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
  143. data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -0
  144. data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
  145. data/lib/aws-sdk-core/token.rb +31 -0
  146. data/lib/aws-sdk-core/token_provider.rb +15 -0
  147. data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
  148. data/lib/aws-sdk-core/type_builder.rb +2 -0
  149. data/lib/aws-sdk-core/util.rb +2 -0
  150. data/lib/aws-sdk-core/waiters/errors.rb +2 -0
  151. data/lib/aws-sdk-core/waiters/poller.rb +6 -2
  152. data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
  153. data/lib/aws-sdk-core/waiters.rb +2 -0
  154. data/lib/aws-sdk-core/xml/builder.rb +4 -2
  155. data/lib/aws-sdk-core/xml/default_list.rb +2 -0
  156. data/lib/aws-sdk-core/xml/default_map.rb +2 -0
  157. data/lib/aws-sdk-core/xml/doc_builder.rb +8 -1
  158. data/lib/aws-sdk-core/xml/error_handler.rb +9 -0
  159. data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
  160. data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
  161. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +4 -0
  162. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
  163. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +2 -0
  164. data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
  165. data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
  166. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  167. data/lib/aws-sdk-core/xml/parser.rb +7 -0
  168. data/lib/aws-sdk-core/xml.rb +2 -0
  169. data/lib/aws-sdk-core.rb +29 -3
  170. data/lib/aws-sdk-sso/client.rb +630 -0
  171. data/lib/aws-sdk-sso/client_api.rb +190 -0
  172. data/lib/aws-sdk-sso/customizations.rb +1 -0
  173. data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
  174. data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
  175. data/lib/aws-sdk-sso/endpoints.rb +72 -0
  176. data/lib/aws-sdk-sso/errors.rb +102 -0
  177. data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
  178. data/lib/aws-sdk-sso/resource.rb +26 -0
  179. data/lib/aws-sdk-sso/types.rb +317 -0
  180. data/lib/aws-sdk-sso.rb +59 -0
  181. data/lib/aws-sdk-ssooidc/client.rb +935 -0
  182. data/lib/aws-sdk-ssooidc/client_api.rb +271 -0
  183. data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
  184. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
  185. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
  186. data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
  187. data/lib/aws-sdk-ssooidc/errors.rb +321 -0
  188. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
  189. data/lib/aws-sdk-ssooidc/resource.rb +26 -0
  190. data/lib/aws-sdk-ssooidc/types.rb +755 -0
  191. data/lib/aws-sdk-ssooidc.rb +59 -0
  192. data/lib/aws-sdk-sts/client.rb +655 -490
  193. data/lib/aws-sdk-sts/client_api.rb +21 -2
  194. data/lib/aws-sdk-sts/customizations.rb +2 -0
  195. data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
  196. data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
  197. data/lib/aws-sdk-sts/endpoints.rb +136 -0
  198. data/lib/aws-sdk-sts/errors.rb +3 -1
  199. data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
  200. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +7 -1
  201. data/lib/aws-sdk-sts/presigner.rb +16 -10
  202. data/lib/aws-sdk-sts/resource.rb +3 -1
  203. data/lib/aws-sdk-sts/types.rb +416 -316
  204. data/lib/aws-sdk-sts.rb +14 -3
  205. data/lib/seahorse/client/async_base.rb +2 -1
  206. data/lib/seahorse/client/async_response.rb +2 -0
  207. data/lib/seahorse/client/base.rb +3 -0
  208. data/lib/seahorse/client/block_io.rb +5 -2
  209. data/lib/seahorse/client/configuration.rb +7 -5
  210. data/lib/seahorse/client/events.rb +2 -0
  211. data/lib/seahorse/client/h2/connection.rb +29 -24
  212. data/lib/seahorse/client/h2/handler.rb +6 -5
  213. data/lib/seahorse/client/handler.rb +2 -0
  214. data/lib/seahorse/client/handler_builder.rb +2 -0
  215. data/lib/seahorse/client/handler_list.rb +2 -0
  216. data/lib/seahorse/client/handler_list_entry.rb +2 -0
  217. data/lib/seahorse/client/http/async_response.rb +2 -0
  218. data/lib/seahorse/client/http/headers.rb +2 -0
  219. data/lib/seahorse/client/http/request.rb +2 -0
  220. data/lib/seahorse/client/http/response.rb +3 -1
  221. data/lib/seahorse/client/logging/formatter.rb +2 -0
  222. data/lib/seahorse/client/logging/handler.rb +2 -0
  223. data/lib/seahorse/client/managed_file.rb +2 -0
  224. data/lib/seahorse/client/net_http/connection_pool.rb +12 -4
  225. data/lib/seahorse/client/net_http/handler.rb +19 -8
  226. data/lib/seahorse/client/net_http/patches.rb +14 -86
  227. data/lib/seahorse/client/networking_error.rb +2 -0
  228. data/lib/seahorse/client/plugin.rb +3 -0
  229. data/lib/seahorse/client/plugin_list.rb +2 -0
  230. data/lib/seahorse/client/plugins/content_length.rb +13 -5
  231. data/lib/seahorse/client/plugins/endpoint.rb +2 -0
  232. data/lib/seahorse/client/plugins/h2.rb +9 -4
  233. data/lib/seahorse/client/plugins/logging.rb +2 -0
  234. data/lib/seahorse/client/plugins/net_http.rb +39 -3
  235. data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
  236. data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
  237. data/lib/seahorse/client/plugins/request_callback.rb +141 -0
  238. data/lib/seahorse/client/plugins/response_target.rb +8 -8
  239. data/lib/seahorse/client/request.rb +2 -0
  240. data/lib/seahorse/client/request_context.rb +2 -0
  241. data/lib/seahorse/client/response.rb +8 -0
  242. data/lib/seahorse/model/api.rb +2 -0
  243. data/lib/seahorse/model/authorizer.rb +2 -0
  244. data/lib/seahorse/model/operation.rb +8 -0
  245. data/lib/seahorse/model/shapes.rb +27 -0
  246. data/lib/seahorse/util.rb +12 -1
  247. data/lib/seahorse/version.rb +2 -0
  248. data/lib/seahorse.rb +3 -0
  249. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  250. data/sig/aws-sdk-core/errors.rbs +22 -0
  251. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  252. data/sig/aws-sdk-core/structure.rbs +4 -0
  253. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  254. data/sig/aws-sdk-core.rbs +7 -0
  255. data/sig/seahorse/client/base.rbs +25 -0
  256. data/sig/seahorse/client/handler_builder.rbs +16 -0
  257. data/sig/seahorse/client/response.rbs +61 -0
  258. metadata +93 -19
data/lib/aws-sdk-sts.rb CHANGED
@@ -1,16 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # WARNING ABOUT GENERATED CODE
2
4
  #
3
5
  # This file is generated. See the contributing guide for more information:
4
- # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
5
7
  #
6
8
  # WARNING ABOUT GENERATED CODE
7
9
 
8
10
 
11
+ unless Module.const_defined?(:Aws)
12
+ require 'aws-sdk-core'
13
+ require 'aws-sigv4'
14
+ end
15
+
9
16
  require_relative 'aws-sdk-sts/types'
10
17
  require_relative 'aws-sdk-sts/client_api'
18
+ require_relative 'aws-sdk-sts/plugins/endpoints.rb'
11
19
  require_relative 'aws-sdk-sts/client'
12
20
  require_relative 'aws-sdk-sts/errors'
13
21
  require_relative 'aws-sdk-sts/resource'
22
+ require_relative 'aws-sdk-sts/endpoint_parameters'
23
+ require_relative 'aws-sdk-sts/endpoint_provider'
24
+ require_relative 'aws-sdk-sts/endpoints'
14
25
  require_relative 'aws-sdk-sts/customizations'
15
26
 
16
27
  # This module provides support for AWS Security Token Service. This module is available in the
@@ -40,9 +51,9 @@ require_relative 'aws-sdk-sts/customizations'
40
51
  #
41
52
  # See {Errors} for more information.
42
53
  #
43
- # @service
54
+ # @!group service
44
55
  module Aws::STS
45
56
 
46
- GEM_VERSION = '3.100.0'
57
+ GEM_VERSION = '3.191.0'
47
58
 
48
59
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class AsyncBase < Seahorse::Client::Base
@@ -47,4 +49,3 @@ module Seahorse
47
49
  end
48
50
  end
49
51
  end
50
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class AsyncResponse
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thread'
2
4
 
3
5
  module Seahorse
@@ -12,6 +14,7 @@ module Seahorse
12
14
  Plugins::NetHttp,
13
15
  Plugins::RaiseResponseErrors,
14
16
  Plugins::ResponseTarget,
17
+ Plugins::RequestCallback
15
18
  ])
16
19
 
17
20
  # @api private
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class BlockIO
4
6
 
5
- def initialize(&block)
7
+ def initialize(headers = nil, &block)
8
+ @headers = headers
6
9
  @block = block
7
10
  @size = 0
8
11
  end
@@ -10,7 +13,7 @@ module Seahorse
10
13
  # @param [String] chunk
11
14
  # @return [Integer]
12
15
  def write(chunk)
13
- @block.call(chunk)
16
+ @block.call(chunk, @headers)
14
17
  ensure
15
18
  chunk.bytesize.tap { |chunk_size| @size += chunk_size }
16
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Seahorse
@@ -66,7 +68,7 @@ module Seahorse
66
68
  @block = block
67
69
  end
68
70
 
69
- def call(*args)
71
+ def call(*args)
70
72
  @block.call(*args)
71
73
  end
72
74
  end
@@ -193,15 +195,15 @@ module Seahorse
193
195
  @members.include?(method_name) or super
194
196
  end
195
197
 
198
+ def override_config(k, v)
199
+ @struct[k] = v
200
+ end
201
+
196
202
  private
197
203
 
198
204
  def value_at(opt_name)
199
205
  value = @struct[opt_name]
200
206
  if value.is_a?(Defaults)
201
- # this config value is used by endpoint discovery
202
- if opt_name == :endpoint && @struct.members.include?(:regional_endpoint)
203
- @struct[:regional_endpoint] = true
204
- end
205
207
  resolve_defaults(opt_name, value)
206
208
  else
207
209
  value
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module EventEmitter
@@ -1,8 +1,8 @@
1
- if RUBY_VERSION >= '2.1'
2
- begin
3
- require 'http/2'
4
- rescue LoadError; end
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'http/2'
5
+ rescue LoadError; end
6
6
  require 'openssl'
7
7
  require 'socket'
8
8
 
@@ -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
@@ -73,18 +75,23 @@ module Seahorse
73
75
  def connect(endpoint)
74
76
  @mutex.synchronize {
75
77
  if @status == :ready
76
- tcp, addr = _tcp_socket(endpoint)
78
+ tcp, addr = _tcp_socket(endpoint)
77
79
  debug_output("opening connection to #{endpoint.host}:#{endpoint.port} ...")
78
80
  _nonblocking_connect(tcp, addr)
79
81
  debug_output('opened')
80
82
 
81
- @socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
82
- @socket.sync_close = true
83
- @socket.hostname = endpoint.host
83
+ if endpoint.scheme == 'https'
84
+ @socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
85
+ @socket.sync_close = true
86
+ @socket.hostname = endpoint.host
87
+
88
+ debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
89
+ @socket.connect
90
+ debug_output('TLS established')
91
+ else
92
+ @socket = tcp
93
+ end
84
94
 
85
- debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
86
- @socket.connect
87
- debug_output('TLS established')
88
95
  _register_h2_callbacks
89
96
  @status = :active
90
97
  elsif @status == :closed
@@ -99,7 +106,7 @@ module Seahorse
99
106
  @mutex.synchronize {
100
107
  return if @socket_thread
101
108
  @socket_thread = Thread.new do
102
- while !@socket.closed?
109
+ while @socket && !@socket.closed?
103
110
  begin
104
111
  data = @socket.read_nonblock(@chunk_size)
105
112
  @h2_client << data
@@ -125,6 +132,7 @@ module Seahorse
125
132
  self.close!
126
133
  end
127
134
  end
135
+ @socket_thread = nil
128
136
  end
129
137
  @socket_thread.abort_on_exception = true
130
138
  }
@@ -137,10 +145,6 @@ module Seahorse
137
145
  @socket.close
138
146
  @socket = nil
139
147
  end
140
- if @socket_thread
141
- Thread.kill(@socket_thread)
142
- @socket_thread = nil
143
- end
144
148
  @status = :closed
145
149
  }
146
150
  end
@@ -178,11 +182,13 @@ module Seahorse
178
182
  @socket.flush
179
183
  end
180
184
  end
181
- @h2_client.on(:frame_sent) do |frame|
182
- debug_output("frame: #{frame.inspect}", :send)
183
- end
184
- @h2_client.on(:frame_received) do |frame|
185
- 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
186
192
  end
187
193
  end
188
194
 
@@ -243,4 +249,3 @@ module Seahorse
243
249
  end
244
250
  end
245
251
  end
246
-
@@ -1,8 +1,9 @@
1
- if RUBY_VERSION >= '2.1'
2
- begin
3
- require 'http/2'
4
- rescue LoadError; end
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'http/2'
5
+ rescue LoadError; end
6
+
6
7
  require 'securerandom'
7
8
 
8
9
  module Seahorse
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class Handler
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thread'
2
4
  require 'set'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Http
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Http
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
  require 'uri'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Http
@@ -71,7 +73,7 @@ module Seahorse
71
73
 
72
74
  # Completes the http response.
73
75
  #
74
- # @example Completing the response in a singal call
76
+ # @example Completing the response in a single call
75
77
  #
76
78
  # http_response.signal_done(
77
79
  # status_code: 200,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Seahorse
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  # @deprecated Use Aws::Logging instead.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  # This utility class is used to track files opened by Seahorse.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cgi'
2
4
  require 'net/http'
3
5
  require 'net/https'
@@ -32,6 +34,7 @@ module Seahorse
32
34
  ssl_ca_bundle: nil,
33
35
  ssl_ca_directory: nil,
34
36
  ssl_ca_store: nil,
37
+ ssl_timeout: nil
35
38
  }
36
39
 
37
40
  # @api private
@@ -169,10 +172,9 @@ module Seahorse
169
172
  # seconds to wait when opening an HTTP session before raising a
170
173
  # `Timeout::Error`.
171
174
  #
172
- # @option options [Integer] :http_read_timeout (60) The default
173
- # number of seconds to wait for response data. This value can
174
- # safely be set
175
- # per-request on the session yielded by {#session_for}.
175
+ # @option options [Float] :http_read_timeout (60) The default
176
+ # number of seconds to wait for response data. This value can be
177
+ # safely set per-request on the session yielded by {#session_for}.
176
178
  #
177
179
  # @option options [Float] :http_idle_timeout (5) The number of
178
180
  # seconds a connection is allowed to sit idle before it is
@@ -186,6 +188,9 @@ module Seahorse
186
188
  # disables this behaviour. This value can safely be set per
187
189
  # request on the session yielded by {#session_for}.
188
190
  #
191
+ # @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
192
+ # in seconds.
193
+ #
189
194
  # @option options [Boolean] :http_wire_trace (false) When `true`,
190
195
  # HTTP debug output will be sent to the `:logger`.
191
196
  #
@@ -247,6 +252,7 @@ module Seahorse
247
252
  :ssl_ca_bundle => options[:ssl_ca_bundle],
248
253
  :ssl_ca_directory => options[:ssl_ca_directory],
249
254
  :ssl_ca_store => options[:ssl_ca_store],
255
+ :ssl_timeout => options[:ssl_timeout]
250
256
  }
251
257
  end
252
258
 
@@ -284,6 +290,8 @@ module Seahorse
284
290
 
285
291
  if endpoint.scheme == 'https'
286
292
  http.use_ssl = true
293
+ http.ssl_timeout = ssl_timeout
294
+
287
295
  if ssl_verify_peer?
288
296
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
289
297
  http.ca_file = ssl_ca_bundle if ssl_ca_bundle
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/https'
2
4
  require 'openssl'
3
5
 
@@ -23,7 +25,8 @@ module Seahorse
23
25
  SocketError, EOFError, IOError, Timeout::Error,
24
26
  Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE,
25
27
  Errno::EINVAL, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError,
26
- Errno::EHOSTUNREACH, Errno::ECONNREFUSED
28
+ Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
29
+ Net::HTTPFatalError # for proxy connection failures
27
30
  ]
28
31
 
29
32
  # does not exist in Ruby 1.9.3
@@ -71,8 +74,9 @@ module Seahorse
71
74
  # @return [void]
72
75
  def transmit(config, req, resp)
73
76
  session(config, req) do |http|
77
+ # Monkey patch default content-type set by Net::HTTP
78
+ Thread.current[:net_http_skip_default_content_type] = true
74
79
  http.request(build_net_request(req)) do |net_resp|
75
-
76
80
  status_code = net_resp.code.to_i
77
81
  headers = extract_headers(net_resp)
78
82
 
@@ -93,6 +97,9 @@ module Seahorse
93
97
  rescue => error
94
98
  # not retryable
95
99
  resp.signal_error(error)
100
+ ensure
101
+ # ensure we turn off monkey patch in case of error
102
+ Thread.current[:net_http_skip_default_content_type] = nil
96
103
  end
97
104
 
98
105
  def complete_response(req, resp, bytes_received)
@@ -144,7 +151,12 @@ module Seahorse
144
151
  def build_net_request(request)
145
152
  request_class = net_http_request_class(request)
146
153
  req = request_class.new(request.endpoint.request_uri, headers(request))
147
- req.body_stream = request.body
154
+ # Net::HTTP adds a default Content-Type when a body is present.
155
+ # Set the body stream when it has an unknown size or when it is > 0.
156
+ if !request.body.respond_to?(:size) ||
157
+ (request.body.respond_to?(:size) && request.body.size > 0)
158
+ req.body_stream = request.body
159
+ end
148
160
  req
149
161
  end
150
162
 
@@ -163,14 +175,13 @@ module Seahorse
163
175
  # @return [Hash] Returns a vanilla hash of headers to send with the
164
176
  # HTTP request.
165
177
  def headers(request)
166
- # Net::HTTP adds default headers for content-type to POSTs (1.8.7+)
167
- # and accept-encoding (2.0.0+). Setting a default empty value defeats
168
- # this.
178
+ # Net::HTTP adds a default header for accept-encoding (2.0.0+).
179
+ # Setting a default empty value defeats this.
169
180
  #
170
- # Removing these are necessary for most services to not break request
181
+ # Removing this is necessary for most services to not break request
171
182
  # signatures as well as dynamodb crc32 checks (these fail if the
172
183
  # response is gzipped).
173
- headers = { 'content-type' => '', 'accept-encoding' => '' }
184
+ headers = { 'accept-encoding' => '' }
174
185
  request.headers.each_pair do |key, value|
175
186
  headers[key] = value
176
187
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
2
4
 
3
5
  module Seahorse
@@ -9,97 +11,23 @@ module Seahorse
9
11
  module Patches
10
12
 
11
13
  def self.apply!
12
- return unless RUBY_VERSION < '2.5'
13
- if RUBY_VERSION >= '2.3'
14
- Net::HTTP::IDEMPOTENT_METHODS_.clear
15
- return
16
- end
17
- # no further patches needed for above versions
18
-
19
- if RUBY_VERSION >= '2.0'
20
- Net::HTTP.send(:include, Ruby_2)
21
- Net::HTTP::IDEMPOTENT_METHODS_.clear
22
- elsif RUBY_VERSION >= '1.9.3'
23
- Net::HTTP.send(:include, Ruby_1_9_3)
24
- end
25
- Net::HTTP.send(:alias_method, :old_transport_request, :transport_request)
26
- Net::HTTP.send(:alias_method, :transport_request, :new_transport_request)
14
+ Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
27
15
  end
28
16
 
29
- module Ruby_2
30
- def new_transport_request(req)
31
- count = 0
32
- begin
33
- begin_transport req
34
- res = catch(:response) {
35
- req.exec @socket, @curr_http_version, edit_path(req.path)
36
- begin
37
- res = Net::HTTPResponse.read_new(@socket)
38
- res.decode_content = req.decode_content
39
- end while res.kind_of?(Net::HTTPInformation)
40
-
41
- res.uri = req.uri
42
-
43
- res
44
- }
45
- res.reading_body(@socket, req.response_body_permitted?) {
46
- yield res if block_given?
47
- }
48
- rescue Net::OpenTimeout
49
- raise
50
- rescue Net::ReadTimeout, IOError, EOFError,
51
- Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
52
- # avoid a dependency on OpenSSL
53
- defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
54
- Timeout::Error => exception
55
- if count == 0 && Net::HTTP::IDEMPOTENT_METHODS_.include?(req.method)
56
- count += 1
57
- @socket.close if @socket and not @socket.closed?
58
- D "Conn close because of error #{exception}, and retry"
59
- if req.body_stream
60
- if req.body_stream.respond_to?(:rewind)
61
- req.body_stream.rewind
62
- else
63
- raise
64
- end
65
- end
66
- retry
67
- end
68
- D "Conn close because of error #{exception}"
69
- @socket.close if @socket and not @socket.closed?
70
- raise
71
- end
72
-
73
- end_transport req, res
74
- res
75
- rescue => exception
76
- D "Conn close because of error #{exception}"
77
- @socket.close if @socket and not @socket.closed?
78
- raise exception
17
+ # For requests with bodies, Net::HTTP sets a default content type of:
18
+ # 'application/x-www-form-urlencoded'
19
+ # There are cases where we should not send content type at all.
20
+ # Even when no body is supplied, Net::HTTP uses a default empty body
21
+ # and sets it anyway. This patch disables the behavior when a Thread
22
+ # local variable is set.
23
+ module PatchDefaultContentType
24
+ def supply_default_content_type
25
+ return if Thread.current[:net_http_skip_default_content_type]
26
+
27
+ super
79
28
  end
80
29
  end
81
30
 
82
- module Ruby_1_9_3
83
- def new_transport_request(req)
84
- begin_transport req
85
- res = catch(:response) {
86
- req.exec @socket, @curr_http_version, edit_path(req.path)
87
- begin
88
- res = Net::HTTPResponse.read_new(@socket)
89
- end while res.kind_of?(Net::HTTPContinue)
90
- res
91
- }
92
- res.reading_body(@socket, req.response_body_permitted?) {
93
- yield res if block_given?
94
- }
95
- end_transport req, res
96
- res
97
- rescue => exception
98
- D "Conn close because of error #{exception}"
99
- @socket.close if @socket and not @socket.closed?
100
- raise exception
101
- end
102
- end
103
31
  end
104
32
  end
105
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class NetworkingError < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  class Plugin
@@ -122,6 +124,7 @@ module Seahorse
122
124
  attr_accessor :doc_type
123
125
  attr_writer :doc_default
124
126
  attr_accessor :docstring
127
+ attr_accessor :rbs_type
125
128
 
126
129
  def doc_default(options)
127
130
  if @doc_default.nil? && !default.is_a?(Proc)
@@ -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,16 +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
- # If it's an IO object and not a File / String / String IO
11
- if context.http_request.body.respond_to?(:size)
12
- length = context.http_request.body.size
13
- 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
14
23
  end
15
24
  @handler.call(context)
16
25
  end
17
-
18
26
  end
19
27
 
20
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