aws-sdk-core 3.54.2 → 3.126.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1247 -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 +92 -0
  9. data/lib/aws-sdk-core/arn_parser.rb +40 -0
  10. data/lib/aws-sdk-core/assume_role_credentials.rb +2 -0
  11. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +104 -0
  12. data/lib/aws-sdk-core/async_client_stubs.rb +4 -2
  13. data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
  14. data/lib/aws-sdk-core/binary/encode_handler.rb +2 -0
  15. data/lib/aws-sdk-core/binary/event_builder.rb +8 -6
  16. data/lib/aws-sdk-core/binary/event_parser.rb +5 -3
  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 +11 -1
  21. data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
  22. data/lib/aws-sdk-core/client_stubs.rb +15 -12
  23. data/lib/aws-sdk-core/credential_provider.rb +1 -30
  24. data/lib/aws-sdk-core/credential_provider_chain.rb +102 -40
  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 +237 -0
  29. data/lib/aws-sdk-core/ecs_credentials.rb +5 -4
  30. data/lib/aws-sdk-core/endpoint_cache.rb +16 -11
  31. data/lib/aws-sdk-core/errors.rb +102 -15
  32. data/lib/aws-sdk-core/event_emitter.rb +2 -0
  33. data/lib/aws-sdk-core/ini_parser.rb +2 -0
  34. data/lib/aws-sdk-core/instance_profile_credentials.rb +153 -39
  35. data/lib/aws-sdk-core/json/builder.rb +2 -0
  36. data/lib/aws-sdk-core/json/error_handler.rb +2 -0
  37. data/lib/aws-sdk-core/json/handler.rb +2 -0
  38. data/lib/aws-sdk-core/json/json_engine.rb +12 -8
  39. data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
  40. data/lib/aws-sdk-core/json/parser.rb +10 -0
  41. data/lib/aws-sdk-core/json.rb +11 -28
  42. data/lib/aws-sdk-core/log/formatter.rb +16 -4
  43. data/lib/aws-sdk-core/log/handler.rb +2 -0
  44. data/lib/aws-sdk-core/log/param_filter.rb +38 -13
  45. data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
  46. data/lib/aws-sdk-core/pageable_response.rb +48 -24
  47. data/lib/aws-sdk-core/pager.rb +5 -0
  48. data/lib/aws-sdk-core/param_converter.rb +2 -0
  49. data/lib/aws-sdk-core/param_validator.rb +55 -7
  50. data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
  51. data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
  52. data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
  53. data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
  54. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +28 -1
  55. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
  56. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +26 -7
  57. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  58. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +12 -4
  59. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
  60. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -0
  61. data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
  62. data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
  63. data/lib/aws-sdk-core/plugins/http_checksum.rb +57 -0
  64. data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
  65. data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
  66. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +2 -0
  67. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
  69. data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
  70. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
  71. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
  72. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
  73. data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
  74. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
  75. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
  76. data/lib/aws-sdk-core/plugins/recursion_detection.rb +27 -0
  77. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -16
  78. data/lib/aws-sdk-core/plugins/response_paging.rb +2 -0
  79. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +139 -0
  80. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +100 -0
  81. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +146 -0
  82. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +59 -0
  83. data/lib/aws-sdk-core/plugins/retry_errors.rb +295 -108
  84. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -0
  85. data/lib/aws-sdk-core/plugins/signature_v4.rb +28 -25
  86. data/lib/aws-sdk-core/plugins/stub_responses.rb +5 -0
  87. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +4 -4
  88. data/lib/aws-sdk-core/plugins/user_agent.rb +6 -8
  89. data/lib/aws-sdk-core/process_credentials.rb +8 -7
  90. data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
  91. data/lib/aws-sdk-core/query/handler.rb +2 -0
  92. data/lib/aws-sdk-core/query/param.rb +2 -0
  93. data/lib/aws-sdk-core/query/param_builder.rb +2 -0
  94. data/lib/aws-sdk-core/query/param_list.rb +2 -0
  95. data/lib/aws-sdk-core/query.rb +2 -0
  96. data/lib/aws-sdk-core/refreshing_credentials.rb +2 -0
  97. data/lib/aws-sdk-core/resources/collection.rb +2 -0
  98. data/lib/aws-sdk-core/rest/handler.rb +2 -0
  99. data/lib/aws-sdk-core/rest/request/body.rb +21 -1
  100. data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
  101. data/lib/aws-sdk-core/rest/request/endpoint.rb +10 -3
  102. data/lib/aws-sdk-core/rest/request/headers.rb +20 -6
  103. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +4 -2
  104. data/lib/aws-sdk-core/rest/response/body.rb +2 -0
  105. data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
  106. data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
  107. data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
  108. data/lib/aws-sdk-core/rest.rb +2 -0
  109. data/lib/aws-sdk-core/shared_config.rb +153 -122
  110. data/lib/aws-sdk-core/shared_credentials.rb +9 -1
  111. data/lib/aws-sdk-core/sso_credentials.rb +131 -0
  112. data/lib/aws-sdk-core/structure.rb +13 -2
  113. data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
  114. data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
  115. data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
  116. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
  117. data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
  118. data/lib/aws-sdk-core/stubbing/protocols/query.rb +4 -2
  119. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +33 -7
  120. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
  121. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
  122. data/lib/aws-sdk-core/stubbing/stub_data.rb +2 -0
  123. data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
  124. data/lib/aws-sdk-core/type_builder.rb +2 -0
  125. data/lib/aws-sdk-core/util.rb +6 -0
  126. data/lib/aws-sdk-core/waiters/errors.rb +2 -0
  127. data/lib/aws-sdk-core/waiters/poller.rb +2 -0
  128. data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
  129. data/lib/aws-sdk-core/waiters.rb +2 -0
  130. data/lib/aws-sdk-core/xml/builder.rb +5 -3
  131. data/lib/aws-sdk-core/xml/default_list.rb +2 -0
  132. data/lib/aws-sdk-core/xml/default_map.rb +2 -0
  133. data/lib/aws-sdk-core/xml/doc_builder.rb +15 -4
  134. data/lib/aws-sdk-core/xml/error_handler.rb +3 -1
  135. data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
  136. data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
  137. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  138. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
  139. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +4 -1
  140. data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
  141. data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
  142. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  143. data/lib/aws-sdk-core/xml/parser.rb +7 -0
  144. data/lib/aws-sdk-core/xml.rb +2 -0
  145. data/lib/aws-sdk-core.rb +22 -4
  146. data/lib/aws-sdk-sso/client.rb +568 -0
  147. data/lib/aws-sdk-sso/client_api.rb +190 -0
  148. data/lib/aws-sdk-sso/customizations.rb +1 -0
  149. data/lib/aws-sdk-sso/errors.rb +102 -0
  150. data/lib/aws-sdk-sso/resource.rb +26 -0
  151. data/lib/aws-sdk-sso/types.rb +352 -0
  152. data/lib/aws-sdk-sso.rb +55 -0
  153. data/lib/aws-sdk-sts/client.rb +970 -414
  154. data/lib/aws-sdk-sts/client_api.rb +41 -1
  155. data/lib/aws-sdk-sts/customizations.rb +4 -0
  156. data/lib/aws-sdk-sts/errors.rb +33 -9
  157. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +38 -0
  158. data/lib/aws-sdk-sts/presigner.rb +75 -0
  159. data/lib/aws-sdk-sts/resource.rb +4 -1
  160. data/lib/aws-sdk-sts/types.rb +632 -236
  161. data/lib/aws-sdk-sts.rb +16 -6
  162. data/lib/seahorse/client/async_base.rb +2 -0
  163. data/lib/seahorse/client/async_response.rb +2 -0
  164. data/lib/seahorse/client/base.rb +6 -1
  165. data/lib/seahorse/client/block_io.rb +6 -2
  166. data/lib/seahorse/client/configuration.rb +6 -0
  167. data/lib/seahorse/client/events.rb +2 -0
  168. data/lib/seahorse/client/h2/connection.rb +31 -25
  169. data/lib/seahorse/client/h2/handler.rb +6 -5
  170. data/lib/seahorse/client/handler.rb +2 -0
  171. data/lib/seahorse/client/handler_builder.rb +2 -0
  172. data/lib/seahorse/client/handler_list.rb +2 -0
  173. data/lib/seahorse/client/handler_list_entry.rb +6 -4
  174. data/lib/seahorse/client/http/async_response.rb +2 -0
  175. data/lib/seahorse/client/http/headers.rb +2 -0
  176. data/lib/seahorse/client/http/request.rb +5 -3
  177. data/lib/seahorse/client/http/response.rb +5 -3
  178. data/lib/seahorse/client/logging/formatter.rb +6 -2
  179. data/lib/seahorse/client/logging/handler.rb +2 -0
  180. data/lib/seahorse/client/managed_file.rb +2 -0
  181. data/lib/seahorse/client/net_http/connection_pool.rb +30 -23
  182. data/lib/seahorse/client/net_http/handler.rb +24 -7
  183. data/lib/seahorse/client/net_http/patches.rb +15 -84
  184. data/lib/seahorse/client/networking_error.rb +2 -0
  185. data/lib/seahorse/client/plugin.rb +9 -6
  186. data/lib/seahorse/client/plugin_list.rb +2 -0
  187. data/lib/seahorse/client/plugins/content_length.rb +13 -7
  188. data/lib/seahorse/client/plugins/endpoint.rb +4 -2
  189. data/lib/seahorse/client/plugins/h2.rb +6 -1
  190. data/lib/seahorse/client/plugins/logging.rb +2 -0
  191. data/lib/seahorse/client/plugins/net_http.rb +39 -3
  192. data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
  193. data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
  194. data/lib/seahorse/client/plugins/request_callback.rb +110 -0
  195. data/lib/seahorse/client/plugins/response_target.rb +23 -14
  196. data/lib/seahorse/client/request.rb +2 -0
  197. data/lib/seahorse/client/request_context.rb +2 -0
  198. data/lib/seahorse/client/response.rb +5 -5
  199. data/lib/seahorse/model/api.rb +6 -0
  200. data/lib/seahorse/model/authorizer.rb +2 -0
  201. data/lib/seahorse/model/operation.rb +5 -0
  202. data/lib/seahorse/model/shapes.rb +27 -0
  203. data/lib/seahorse/util.rb +8 -1
  204. data/lib/seahorse/version.rb +2 -0
  205. data/lib/seahorse.rb +3 -0
  206. metadata +43 -11
data/lib/aws-sdk-sts.rb CHANGED
@@ -1,11 +1,18 @@
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'
11
18
  require_relative 'aws-sdk-sts/client'
@@ -22,24 +29,27 @@ require_relative 'aws-sdk-sts/customizations'
22
29
  # methods each accept a hash of request parameters and return a response
23
30
  # structure.
24
31
  #
32
+ # sts = Aws::STS::Client.new
33
+ # resp = sts.assume_role(params)
34
+ #
25
35
  # See {Client} for more information.
26
36
  #
27
37
  # # Errors
28
38
  #
29
- # Errors returned from AWS Security Token Service all
30
- # extend {Errors::ServiceError}.
39
+ # Errors returned from AWS Security Token Service are defined in the
40
+ # {Errors} module and all extend {Errors::ServiceError}.
31
41
  #
32
42
  # begin
33
43
  # # do stuff
34
44
  # rescue Aws::STS::Errors::ServiceError
35
- # # rescues all service API errors
45
+ # # rescues all AWS Security Token Service API errors
36
46
  # end
37
47
  #
38
48
  # See {Errors} for more information.
39
49
  #
40
- # @service
50
+ # @!group service
41
51
  module Aws::STS
42
52
 
43
- GEM_VERSION = '3.54.2'
53
+ GEM_VERSION = '3.126.0'
44
54
 
45
55
  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
@@ -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
@@ -194,13 +197,15 @@ module Seahorse
194
197
  private
195
198
 
196
199
  def define_operation_methods
200
+ operations_module = Module.new
197
201
  @api.operation_names.each do |method_name|
198
- define_method(method_name) do |*args, &block|
202
+ operations_module.send(:define_method, method_name) do |*args, &block|
199
203
  params = args[0] || {}
200
204
  options = args[1] || {}
201
205
  build_request(method_name, params).send_request(options, &block)
202
206
  end
203
207
  end
208
+ include(operations_module)
204
209
  end
205
210
 
206
211
  def build_plugins
@@ -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,8 @@ 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)
17
+ ensure
14
18
  chunk.bytesize.tap { |chunk_size| @size += chunk_size }
15
19
  end
16
20
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Seahorse
@@ -193,6 +195,10 @@ 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)
@@ -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
 
@@ -48,6 +48,8 @@ module Seahorse
48
48
  @errors = []
49
49
  @status = :ready
50
50
  @mutex = Mutex.new # connection can be shared across requests
51
+ @socket = nil
52
+ @socket_thread = nil
51
53
  end
52
54
 
53
55
  OPTIONS.keys.each do |attr_name|
@@ -71,23 +73,28 @@ module Seahorse
71
73
  def connect(endpoint)
72
74
  @mutex.synchronize {
73
75
  if @status == :ready
74
- tcp, addr = _tcp_socket(endpoint)
76
+ tcp, addr = _tcp_socket(endpoint)
75
77
  debug_output("opening connection to #{endpoint.host}:#{endpoint.port} ...")
76
78
  _nonblocking_connect(tcp, addr)
77
- debug_output("opened")
78
-
79
- @socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
80
- @socket.sync_close = true
81
- @socket.hostname = endpoint.host
79
+ debug_output('opened')
80
+
81
+ if endpoint.scheme == 'https'
82
+ @socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
83
+ @socket.sync_close = true
84
+ @socket.hostname = endpoint.host
85
+
86
+ debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
87
+ @socket.connect
88
+ debug_output('TLS established')
89
+ else
90
+ @socket = tcp
91
+ end
82
92
 
83
- debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
84
- @socket.connect
85
- debug_output("TLS established")
86
93
  _register_h2_callbacks
87
94
  @status = :active
88
95
  elsif @status == :closed
89
- msg = "Async Client HTTP2 Connection is closed, you may"\
90
- " use #new_connection to create a new HTTP2 Connection for this client"
96
+ msg = 'Async Client HTTP2 Connection is closed, you may'\
97
+ ' use #new_connection to create a new HTTP2 Connection for this client'
91
98
  raise Http2ConnectionClosedError.new(msg)
92
99
  end
93
100
  }
@@ -104,7 +111,7 @@ module Seahorse
104
111
  rescue IO::WaitReadable
105
112
  begin
106
113
  unless IO.select([@socket], nil, nil, connection_read_timeout)
107
- self.debug_output("socket connection read time out")
114
+ self.debug_output('socket connection read time out')
108
115
  self.close!
109
116
  else
110
117
  # available, retry to start reading
@@ -130,7 +137,7 @@ module Seahorse
130
137
 
131
138
  def close!
132
139
  @mutex.synchronize {
133
- self.debug_output("closing connection ...")
140
+ self.debug_output('closing connection ...')
134
141
  if @socket
135
142
  @socket.close
136
143
  @socket = nil
@@ -149,10 +156,10 @@ module Seahorse
149
156
 
150
157
  def debug_output(msg, type = nil)
151
158
  prefix = case type
152
- when :send then "-> "
153
- when :receive then "<- "
159
+ when :send then '-> '
160
+ when :receive then '<- '
154
161
  else
155
- ""
162
+ ''
156
163
  end
157
164
  return unless @logger
158
165
  _debug_entry(prefix + msg)
@@ -168,8 +175,8 @@ module Seahorse
168
175
  def _register_h2_callbacks
169
176
  @h2_client.on(:frame) do |bytes|
170
177
  if @socket.nil?
171
- msg = "Connection is closed due to errors, "\
172
- "you can find errors at async_client.connection.errors"
178
+ msg = 'Connection is closed due to errors, '\
179
+ 'you can find errors at async_client.connection.errors'
173
180
  raise Http2ConnectionClosedError.new(msg)
174
181
  else
175
182
  @socket.print(bytes)
@@ -221,7 +228,7 @@ module Seahorse
221
228
  ssl_ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
222
229
  end
223
230
  if enable_alpn
224
- debug_output("enabling ALPN for TLS ...")
231
+ debug_output('enabling ALPN for TLS ...')
225
232
  ssl_ctx.alpn_protocols = ['h2']
226
233
  end
227
234
  ssl_ctx
@@ -241,4 +248,3 @@ module Seahorse
241
248
  end
242
249
  end
243
250
  end
244
-
@@ -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
 
@@ -77,8 +79,8 @@ module Seahorse
77
79
  if options.key?(name)
78
80
  options[name]
79
81
  else
80
- msg = "invalid :priority `%s', must be between 0 and 99"
81
- raise ArgumentError, msg % priority.inspect
82
+ msg = "missing option: `%s'"
83
+ raise ArgumentError, msg % name.inspect
82
84
  end
83
85
  end
84
86
 
@@ -86,8 +88,8 @@ module Seahorse
86
88
  if STEPS.key?(step)
87
89
  @step = step
88
90
  else
89
- msg = "invalid :step `%s', must be one of :initialize, :validate, "
90
- msg << ":build, :sign or :send"
91
+ msg = "invalid :step `%s', must be one of :initialize, :validate, "\
92
+ ':build, :sign or :send'
91
93
  raise ArgumentError, msg % step.inspect
92
94
  end
93
95
  end
@@ -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
 
@@ -34,8 +36,8 @@ module Seahorse
34
36
  if endpoint.nil? or URI::HTTP === endpoint or URI::HTTPS === endpoint
35
37
  @endpoint = endpoint
36
38
  else
37
- msg = "invalid endpoint, expected URI::HTTP, URI::HTTPS, or nil, "
38
- msg << "got #{endpoint.inspect}"
39
+ msg = 'invalid endpoint, expected URI::HTTP, URI::HTTPS, or nil, '\
40
+ "got #{endpoint.inspect}"
39
41
  raise ArgumentError, msg
40
42
  end
41
43
  end
@@ -55,7 +57,7 @@ module Seahorse
55
57
 
56
58
  # @param [#read, #size, #rewind] io
57
59
  def body=(io)
58
- @body =case io
60
+ @body = case io
59
61
  when nil then StringIO.new('')
60
62
  when String then StringIO.new(io)
61
63
  else io
@@ -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,
@@ -109,8 +111,8 @@ module Seahorse
109
111
  @done = true
110
112
  emit(:done)
111
113
  else
112
- msg = "options must be empty or must contain :status_code, :headers, "
113
- msg << "and :body"
114
+ msg = 'options must be empty or must contain :status_code, :headers, '\
115
+ 'and :body'
114
116
  raise ArgumentError, msg
115
117
  end
116
118
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Seahorse
@@ -173,9 +175,11 @@ module Seahorse
173
175
  end
174
176
 
175
177
  def _http_response_body(response)
176
- response.context.http_response.body.respond_to?(:rewind) ?
177
- summarize_value(response.context.http_response.body_contents) :
178
+ if response.context.http_response.body.respond_to?(:rewind)
179
+ summarize_value(response.context.http_response.body_contents)
180
+ else
178
181
  ''
182
+ end
179
183
  end
180
184
 
181
185
  def _error_class(response)
@@ -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'
@@ -18,6 +20,7 @@ module Seahorse
18
20
 
19
21
  @pools_mutex = Mutex.new
20
22
  @pools = {}
23
+ @default_logger = Logger.new($stdout)
21
24
 
22
25
  OPTIONS = {
23
26
  http_proxy: nil,
@@ -31,6 +34,7 @@ module Seahorse
31
34
  ssl_ca_bundle: nil,
32
35
  ssl_ca_directory: nil,
33
36
  ssl_ca_store: nil,
37
+ ssl_timeout: nil
34
38
  }
35
39
 
36
40
  # @api private
@@ -52,14 +56,14 @@ module Seahorse
52
56
 
53
57
  # Makes an HTTP request, yielding a Net::HTTPResponse object.
54
58
  #
55
- # pool.request('http://domain', Net::HTTP::Get.new('/')) do |resp|
59
+ # pool.request(URI.parse('http://domain'), Net::HTTP::Get.new('/')) do |resp|
56
60
  # puts resp.code # status code
57
61
  # puts resp.to_h.inspect # dump the headers
58
62
  # puts resp.body
59
63
  # end
60
64
  #
61
- # @param [String] endpoint The HTTP(S) endpoint to
62
- # connect to (e.g. 'https://domain.com').
65
+ # @param [URI::HTTP, URI::HTTPS] endpoint The HTTP(S) endpoint
66
+ # to connect to (e.g. 'https://domain.com').
63
67
  #
64
68
  # @param [Net::HTTPRequest] request The request to make. This can be
65
69
  # any request object from Net::HTTP (e.g. Net::HTTP::Get,
@@ -131,7 +135,7 @@ module Seahorse
131
135
  nil
132
136
  end
133
137
 
134
- # Closes and removes removes all sessions from the pool.
138
+ # Closes and removes all sessions from the pool.
135
139
  # If empty! is called while there are outstanding requests they may
136
140
  # get checked back into the pool, leaving the pool in a non-empty
137
141
  # state.
@@ -165,16 +169,15 @@ module Seahorse
165
169
  # requests through. Formatted like 'http://proxy.com:123'.
166
170
  #
167
171
  # @option options [Float] :http_open_timeout (15) The number of
168
- # seconds to wait when opening a HTTP session before rasing a
172
+ # seconds to wait when opening an HTTP session before raising a
169
173
  # `Timeout::Error`.
170
174
  #
171
- # @option options [Integer] :http_read_timeout (60) The default
172
- # number of seconds to wait for response data. This value can
173
- # safely be set
174
- # per-request on the session yeidled 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}.
175
178
  #
176
179
  # @option options [Float] :http_idle_timeout (5) The number of
177
- # seconds a connection is allowed to sit idble before it is
180
+ # seconds a connection is allowed to sit idle before it is
178
181
  # considered stale. Stale connections are closed and removed
179
182
  # from the pool before making a request.
180
183
  #
@@ -183,7 +186,10 @@ module Seahorse
183
186
  # request body. This option has no effect unless the request has
184
187
  # "Expect" header set to "100-continue". Defaults to `nil` which
185
188
  # disables this behaviour. This value can safely be set per
186
- # request on the session yeidled by {#session_for}.
189
+ # request on the session yielded by {#session_for}.
190
+ #
191
+ # @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
192
+ # in seconds.
187
193
  #
188
194
  # @option options [Boolean] :http_wire_trace (false) When `true`,
189
195
  # HTTP debug output will be sent to the `:logger`.
@@ -200,13 +206,13 @@ module Seahorse
200
206
  # @option options [String] :ssl_ca_bundle Full path to the SSL
201
207
  # certificate authority bundle file that should be used when
202
208
  # verifying peer certificates. If you do not pass
203
- # `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default
209
+ # `:ssl_ca_bundle` or `:ssl_ca_directory` the system default
204
210
  # will be used if available.
205
211
  #
206
212
  # @option options [String] :ssl_ca_directory Full path of the
207
213
  # directory that contains the unbundled SSL certificate
208
214
  # authority files for verifying peer certificates. If you do
209
- # not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the
215
+ # not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the
210
216
  # system default will be used if available.
211
217
  #
212
218
  # @return [ConnectionPool]
@@ -217,7 +223,7 @@ module Seahorse
217
223
  end
218
224
  end
219
225
 
220
- # @return [Array<ConnectionPool>] Returns a list of of the
226
+ # @return [Array<ConnectionPool>] Returns a list of the
221
227
  # constructed connection pools.
222
228
  def pools
223
229
  @pools_mutex.synchronize do
@@ -231,7 +237,7 @@ module Seahorse
231
237
  # @return [Hash]
232
238
  def pool_options options
233
239
  wire_trace = !!options[:http_wire_trace]
234
- logger = options[:logger] || Logger.new($stdout) if wire_trace
240
+ logger = options[:logger] || @default_logger if wire_trace
235
241
  verify_peer = options.key?(:ssl_verify_peer) ?
236
242
  !!options[:ssl_verify_peer] : true
237
243
  {
@@ -246,6 +252,7 @@ module Seahorse
246
252
  :ssl_ca_bundle => options[:ssl_ca_bundle],
247
253
  :ssl_ca_directory => options[:ssl_ca_directory],
248
254
  :ssl_ca_store => options[:ssl_ca_store],
255
+ :ssl_timeout => options[:ssl_timeout]
249
256
  }
250
257
  end
251
258
 
@@ -279,9 +286,12 @@ module Seahorse
279
286
  http = ExtendedSession.new(Net::HTTP.new(*args.compact))
280
287
  http.set_debug_output(logger) if http_wire_trace?
281
288
  http.open_timeout = http_open_timeout
289
+ http.keep_alive_timeout = http_idle_timeout if http.respond_to?(:keep_alive_timeout=)
282
290
 
283
291
  if endpoint.scheme == 'https'
284
292
  http.use_ssl = true
293
+ http.ssl_timeout = ssl_timeout
294
+
285
295
  if ssl_verify_peer?
286
296
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
287
297
  http.ca_file = ssl_ca_bundle if ssl_ca_bundle
@@ -301,13 +311,10 @@ module Seahorse
301
311
  # Removes stale sessions from the pool. This method *must* be called
302
312
  # @note **Must** be called behind a `@pool_mutex` synchronize block.
303
313
  def _clean
304
- now = Time.now
314
+ now = Aws::Util.monotonic_milliseconds
305
315
  @pool.each_pair do |endpoint,sessions|
306
316
  sessions.delete_if do |session|
307
- if
308
- session.last_used.nil? or
309
- now - session.last_used > http_idle_timeout
310
- then
317
+ if session.last_used.nil? or now - session.last_used > http_idle_timeout * 1000
311
318
  session.finish
312
319
  true
313
320
  end
@@ -315,7 +322,7 @@ module Seahorse
315
322
  end
316
323
  end
317
324
 
318
- # Helper methods extended onto Net::HTTPSession objects opend by the
325
+ # Helper methods extended onto Net::HTTPSession objects opened by the
319
326
  # connection pool.
320
327
  # @api private
321
328
  class ExtendedSession < Delegator
@@ -325,7 +332,7 @@ module Seahorse
325
332
  @http = http
326
333
  end
327
334
 
328
- # @return [Time,nil]
335
+ # @return [Integer,nil]
329
336
  attr_reader :last_used
330
337
 
331
338
  def __getobj__
@@ -338,8 +345,8 @@ module Seahorse
338
345
 
339
346
  # Sends the request and tracks that this session has been used.
340
347
  def request(*args, &block)
341
- @last_used = Time.now
342
348
  @http.request(*args, &block)
349
+ @last_used = Aws::Util.monotonic_milliseconds
343
350
  end
344
351
 
345
352
  # Attempts to close/finish the session without raising an error.