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
@@ -1,38 +1,56 @@
1
- module Aws
1
+ # frozen_string_literal: true
2
2
 
3
- # Decorates a {Seahorse::Client::Response} with paging methods:
4
- #
5
- # resp = s3.list_objects(params)
6
- # resp.last_page?
7
- # #=> false
3
+ module Aws
4
+ # Decorates a {Seahorse::Client::Response} with paging convenience methods.
5
+ # Some AWS calls provide paged responses to limit the amount of data returned
6
+ # with each response. To optimize for latency, some APIs may return an
7
+ # inconsistent number of responses per page. You should rely on the values of
8
+ # the `next_page?` method or using enumerable methods such as `each` rather
9
+ # than the number of items returned to iterate through results. See below for
10
+ # examples.
8
11
  #
9
- # # sends a request to receive the next response page
10
- # resp = resp.next_page
11
- # resp.last_page?
12
- # #=> true
12
+ # @note Methods such as `to_json` will enumerate all of the responses before
13
+ # returning the full response as JSON.
13
14
  #
14
- # resp.next_page
15
- # #=> raises PageableResponse::LastPageError
15
+ # # Paged Responses Are Enumerable
16
+ # The simplest way to handle paged response data is to use the built-in
17
+ # enumerator in the response object, as shown in the following example.
16
18
  #
17
- # You can enumerate all response pages with a block
19
+ # s3 = Aws::S3::Client.new
18
20
  #
19
- # ec2.describe_instances(params).each do |page|
20
- # # yields once per page
21
- # page.reservations.each do |r|
22
- # # ...
23
- # end
21
+ # s3.list_objects(bucket:'aws-sdk').each do |response|
22
+ # puts response.contents.map(&:key)
24
23
  # end
25
24
  #
26
- # Or using {#next_page} and {#last_page?}:
25
+ # This yields one response object per API call made, and enumerates objects
26
+ # in the named bucket. The SDK retrieves additional pages of data to
27
+ # complete the request.
28
+ #
29
+ # # Handling Paged Responses Manually
30
+ # To handle paging yourself, use the response’s `next_page?` method to verify
31
+ # there are more pages to retrieve, or use the last_page? method to verify
32
+ # there are no more pages to retrieve.
33
+ #
34
+ # If there are more pages, use the `next_page` method to retrieve the
35
+ # next page of results, as shown in the following example.
27
36
  #
28
- # resp.last_page?
29
- # resp = resp.next_page until resp.last_page?
37
+ # s3 = Aws::S3::Client.new
38
+ #
39
+ # # Get the first page of data
40
+ # response = s3.list_objects(bucket:'aws-sdk')
41
+ #
42
+ # # Get additional pages
43
+ # while response.next_page? do
44
+ # response = response.next_page
45
+ # # Use the response data here...
46
+ # puts response.contents.map(&:key)
47
+ # end
30
48
  #
31
49
  module PageableResponse
32
50
 
33
51
  def self.extended(base)
34
- base.send(:extend, Enumerable)
35
- base.send(:extend, UnsafeEnumerableMethods)
52
+ base.extend Enumerable
53
+ base.extend UnsafeEnumerableMethods
36
54
  base.instance_variable_set("@last_page", nil)
37
55
  base.instance_variable_set("@more_results", nil)
38
56
  end
@@ -97,7 +115,13 @@ module Aws
97
115
  # @return [Hash] Returns the hash of request parameters for the
98
116
  # next page, merging any given params.
99
117
  def next_page_params(params)
100
- context[:original_params].merge(@pager.next_tokens(self).merge(params))
118
+ # Remove all previous tokens from original params
119
+ # Sometimes a token can be nil and merge would not include it.
120
+ tokens = @pager.tokens.values.map(&:to_sym)
121
+
122
+ params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
123
+ params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
124
+ params_without_tokens
101
125
  end
102
126
 
103
127
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jmespath'
2
4
 
3
5
  module Aws
@@ -16,6 +18,9 @@ module Aws
16
18
  # @return [Symbol, nil]
17
19
  attr_reader :limit_key
18
20
 
21
+ # @return [Hash, nil]
22
+ attr_reader :tokens
23
+
19
24
  # @param [Seahorse::Client::Response] response
20
25
  # @return [Hash]
21
26
  def next_tokens(response)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
  require 'date'
3
5
  require 'time'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  class ParamValidator
@@ -68,6 +70,14 @@ module Aws
68
70
  end
69
71
  end
70
72
 
73
+ if @validate_required && shape.union
74
+ if values.length > 1
75
+ errors << "multiple values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
76
+ elsif values.length == 0
77
+ errors << "No values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
78
+ end
79
+ end
80
+
71
81
  # validate non-nil members
72
82
  values.each_pair do |name, value|
73
83
  unless value.nil?
@@ -115,11 +125,32 @@ module Aws
115
125
  end
116
126
  end
117
127
 
128
+ def document(ref, value, errors, context)
129
+ document_types = [Hash, Array, Numeric, String, TrueClass, FalseClass, NilClass]
130
+ unless document_types.any? { |t| value.is_a?(t) }
131
+ errors << expected_got(context, "one of #{document_types.join(', ')}", value)
132
+ end
133
+
134
+ # recursively validate types for aggregated types
135
+ case value
136
+ when Hash
137
+ value.each do |k, v|
138
+ document(ref, v, errors, context + "[#{k}]")
139
+ end
140
+ when Array
141
+ value.each do |v|
142
+ document(ref, v, errors, context)
143
+ end
144
+ end
145
+
146
+ end
147
+
118
148
  def shape(ref, value, errors, context)
119
149
  case ref.shape
120
150
  when StructureShape then structure(ref, value, errors, context)
121
151
  when ListShape then list(ref, value, errors, context)
122
152
  when MapShape then map(ref, value, errors, context)
153
+ when DocumentShape then document(ref, value, errors, context)
123
154
  when StringShape
124
155
  unless value.is_a?(String)
125
156
  errors << expected_got(context, "a String", value)
@@ -141,8 +172,22 @@ module Aws
141
172
  errors << expected_got(context, "true or false", value)
142
173
  end
143
174
  when BlobShape
144
- unless io_like?(value) or value.is_a?(String)
145
- errors << expected_got(context, "a String or IO object", value)
175
+ unless value.is_a?(String)
176
+ if streaming_input?(ref)
177
+ unless io_like?(value, _require_size = false)
178
+ errors << expected_got(
179
+ context,
180
+ "a String or IO like object that supports read and rewind",
181
+ value
182
+ )
183
+ end
184
+ elsif !io_like?(value, _require_size = true)
185
+ errors << expected_got(
186
+ context,
187
+ "a String or IO like object that supports read, rewind, and size",
188
+ value
189
+ )
190
+ end
146
191
  end
147
192
  else
148
193
  raise "unhandled shape type: #{ref.shape.class.name}"
@@ -152,7 +197,7 @@ module Aws
152
197
  def correct_type?(ref, value, errors, context)
153
198
  if ref.eventstream && @input
154
199
  errors << "instead of providing value directly for eventstreams at input,"\
155
- " expected to use #signal events per stream"
200
+ " expected to use #signal events per stream"
156
201
  return false
157
202
  end
158
203
  case value
@@ -165,10 +210,13 @@ module Aws
165
210
  end
166
211
  end
167
212
 
168
- def io_like?(value)
169
- value.respond_to?(:read) &&
170
- value.respond_to?(:rewind) &&
171
- value.respond_to?(:size)
213
+ def io_like?(value, require_size = true)
214
+ value.respond_to?(:read) && value.respond_to?(:rewind) &&
215
+ (!require_size || value.respond_to?(:size))
216
+ end
217
+
218
+ def streaming_input?(ref)
219
+ (ref["streaming"] || ref.shape["streaming"])
172
220
  end
173
221
 
174
222
  def error_messages(errors)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -21,7 +23,9 @@ When provided, `x-api-key` header will be injected with the value provided.
21
23
  class OptionHandler < Seahorse::Client::Handler
22
24
  def call(context)
23
25
  if context.operation.require_apikey
24
- api_key = context.params.delete(:api_key)
26
+ if context.params.is_a?(Hash) && context.params[:api_key]
27
+ api_key = context.params.delete(:api_key)
28
+ end
25
29
  api_key = context.config.api_key if api_key.nil?
26
30
  context[:api_key] = api_key
27
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  module Plugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
4
+ require_relative 'retries/error_inspector'
2
5
 
3
6
  module Aws
4
7
  module Plugins
@@ -24,6 +27,16 @@ agent is running on, where client metrics will be published via UDP.
24
27
  resolve_client_side_monitoring_port(cfg)
25
28
  end
26
29
 
30
+ option(:client_side_monitoring_host,
31
+ default: "127.0.0.1",
32
+ doc_type: String,
33
+ docstring: <<-DOCS) do |cfg|
34
+ Allows you to specify the DNS hostname or IPv4 or IPv6 address that the client
35
+ side monitoring agent is running on, where client metrics will be published via UDP.
36
+ DOCS
37
+ resolve_client_side_monitoring_host(cfg)
38
+ end
39
+
27
40
  option(:client_side_monitoring_publisher,
28
41
  default: ClientSideMonitoring::Publisher,
29
42
  doc_type: Aws::ClientSideMonitoring::Publisher,
@@ -49,6 +62,7 @@ all generated client side metrics. Defaults to an empty string.
49
62
  handlers.add(Handler, step: :initialize)
50
63
  publisher = config.client_side_monitoring_publisher
51
64
  publisher.agent_port = config.client_side_monitoring_port
65
+ publisher.agent_host = config.client_side_monitoring_host
52
66
  end
53
67
  end
54
68
 
@@ -70,6 +84,19 @@ all generated client side metrics. Defaults to an empty string.
70
84
  end
71
85
  end
72
86
 
87
+ def self.resolve_client_side_monitoring_host(cfg)
88
+ env_source = ENV["AWS_CSM_HOST"]
89
+ env_source = nil if env_source == ""
90
+ cfg_source = Aws.shared_config.csm_host(profile: cfg.profile)
91
+ if env_source
92
+ env_source
93
+ elsif cfg_source
94
+ cfg_source
95
+ else
96
+ "127.0.0.1"
97
+ end
98
+ end
99
+
73
100
  def self.resolve_client_side_monitoring(cfg)
74
101
  env_source = ENV["AWS_CSM_ENABLED"]
75
102
  env_source = nil if env_source == ""
@@ -117,7 +144,7 @@ all generated client side metrics. Defaults to an empty string.
117
144
  @handler.call(context)
118
145
  rescue StandardError => e
119
146
  # Handle SDK Exceptions
120
- inspector = Aws::Plugins::RetryErrors::ErrorInspector.new(
147
+ inspector = Retries::ErrorInspector.new(
121
148
  e,
122
149
  context.http_response.status_code
123
150
  )
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  module Plugins
@@ -28,13 +30,28 @@ following classes:
28
30
  * `Aws::Credentials` - Used for configuring static, non-refreshing
29
31
  credentials.
30
32
 
33
+ * `Aws::SharedCredentials` - Used for loading static credentials from a
34
+ shared file, such as `~/.aws/config`.
35
+
36
+ * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
37
+
38
+ * `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
39
+ assume a role after providing credentials via the web.
40
+
41
+ * `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
42
+ access token generated from `aws login`.
43
+
44
+ * `Aws::ProcessCredentials` - Used for loading credentials from a
45
+ process that outputs to stdout.
46
+
31
47
  * `Aws::InstanceProfileCredentials` - Used for loading credentials
32
48
  from an EC2 IMDS on an EC2 instance.
33
49
 
34
- * `Aws::SharedCredentials` - Used for loading credentials from a
35
- shared file, such as `~/.aws/config`.
50
+ * `Aws::ECSCredentials` - Used for loading credentials from
51
+ instances running in ECS.
36
52
 
37
- * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
53
+ * `Aws::CognitoIdentityCredentials` - Used for loading credentials
54
+ from the Cognito Identity service.
38
55
 
39
56
  When `:credentials` are not configured directly, the following
40
57
  locations will be searched for credentials:
@@ -44,10 +61,12 @@ locations will be searched for credentials:
44
61
  * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
45
62
  * `~/.aws/credentials`
46
63
  * `~/.aws/config`
47
- * EC2 IMDS instance profile - When used by default, the timeouts are
48
- very aggressive. Construct and pass an instance of
49
- `Aws::InstanceProfileCredentails` to enable retries and extended
50
- timeouts.
64
+ * EC2/ECS IMDS instance profile - When used by default, the timeouts
65
+ are very aggressive. Construct and pass an instance of
66
+ `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
67
+ enable retries and extended timeouts. Instance profile credential
68
+ fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
69
+ to true.
51
70
  DOCS
52
71
  ) do |config|
53
72
  CredentialProviderChain.new(config).resolve
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # @api private
5
+ module Plugins
6
+ # @api private
7
+ class DefaultsMode < Seahorse::Client::Plugin
8
+
9
+ option(:defaults_mode,
10
+ default: 'legacy',
11
+ doc_type: String,
12
+ docstring: <<-DOCS
13
+ See {Aws::DefaultsModeConfiguration} for a list of the
14
+ accepted modes and the configuration defaults that are included.
15
+ DOCS
16
+ ) do |cfg|
17
+ resolve_defaults_mode(cfg)
18
+ end
19
+
20
+ option(:defaults_mode_config_resolver,
21
+ doc_type: 'Aws::DefaultsModeConfigResolver') do |cfg|
22
+ Aws::DefaultsModeConfigResolver.new(
23
+ Aws::DefaultsModeConfiguration::SDK_DEFAULT_CONFIGURATION, cfg)
24
+ end
25
+
26
+ class << self
27
+ private
28
+
29
+ def resolve_defaults_mode(cfg)
30
+ value = ENV['AWS_DEFAULTS_MODE']
31
+ value ||= Aws.shared_config.defaults_mode(
32
+ profile: cfg.profile
33
+ )
34
+ value&.downcase || "legacy"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
4
6
  class EndpointDiscovery < Seahorse::Client::Plugin
5
7
 
6
8
  option(:endpoint_discovery,
7
- default: false,
9
+ doc_default: Proc.new { |options| options[:require_endpoint_discovery] },
8
10
  doc_type: 'Boolean',
9
11
  docstring: <<-DOCS) do |cfg|
10
- When set to `true`, endpoint discovery will be enabled for operations when available. Defaults to `false`.
12
+ When set to `true`, endpoint discovery will be enabled for operations when available.
11
13
  DOCS
12
14
  resolve_endpoint_discovery(cfg)
13
15
  end
@@ -102,6 +104,10 @@ the background every 60 secs (default). Defaults to `false`.
102
104
  key = cache.extract_key(ctx)
103
105
 
104
106
  if required
107
+ unless ctx.config.endpoint_discovery
108
+ raise ArgumentError, "Operation #{ctx.operation.name} requires "\
109
+ 'endpoint_discovery to be enabled.'
110
+ end
105
111
  # required for the operation
106
112
  unless cache.key?(key)
107
113
  cache.update(key, ctx)
@@ -151,8 +157,10 @@ the background every 60 secs (default). Defaults to `false`.
151
157
 
152
158
  def self.resolve_endpoint_discovery(cfg)
153
159
  env = ENV['AWS_ENABLE_ENDPOINT_DISCOVERY']
154
- shared_cfg = Aws.shared_config.endpoint_discovery(profile: cfg.profile)
155
- Aws::Util.str_2_bool(env) || Aws::Util.str_2_bool(shared_cfg)
160
+ default = cfg.api.require_endpoint_discovery
161
+ shared_cfg = Aws.shared_config.endpoint_discovery_enabled(profile: cfg.profile)
162
+ resolved = Aws::Util.str_2_bool(env) || Aws::Util.str_2_bool(shared_cfg)
163
+ env.nil? && shared_cfg.nil? ? default : !!resolved
156
164
  end
157
165
 
158
166
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -13,17 +15,17 @@ to default service endpoint when available.
13
15
  )
14
16
 
15
17
  def add_handlers(handlers, config)
16
- if config.regional_endpoint && !config.disable_host_prefix_injection
17
- handlers.add(Handler, priority: 90)
18
- end
18
+ handlers.add(Handler, priority: 10)
19
19
  end
20
20
 
21
21
  class Handler < Seahorse::Client::Handler
22
22
 
23
23
  def call(context)
24
- endpoint_trait = context.operation.endpoint_pattern
25
- if endpoint_trait && !endpoint_trait.empty?
26
- _apply_endpoint_trait(context, endpoint_trait)
24
+ if !context.config.disable_host_prefix_injection
25
+ endpoint_trait = context.operation.endpoint_pattern
26
+ if endpoint_trait && !endpoint_trait.empty?
27
+ _apply_endpoint_trait(context, endpoint_trait)
28
+ end
27
29
  end
28
30
  @handler.call(context)
29
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+
5
+ module Aws
6
+ module Plugins
7
+ # @api private
8
+ class HttpChecksum < Seahorse::Client::Plugin
9
+ # @api private
10
+ class Handler < Seahorse::Client::Handler
11
+ CHUNK_SIZE = 1 * 1024 * 1024 # one MB
12
+
13
+ def call(context)
14
+ if context.operation.http_checksum_required
15
+ body = context.http_request.body
16
+ context.http_request.headers['Content-Md5'] ||= md5(body)
17
+ end
18
+ @handler.call(context)
19
+ end
20
+
21
+ private
22
+
23
+ # @param [File, Tempfile, IO#read, String] value
24
+ # @return [String<MD5>]
25
+ def md5(value)
26
+ if (value.is_a?(File) || value.is_a?(Tempfile)) &&
27
+ !value.path.nil? && File.exist?(value.path)
28
+ OpenSSL::Digest::MD5.file(value).base64digest
29
+ elsif value.respond_to?(:read)
30
+ md5 = OpenSSL::Digest::MD5.new
31
+ update_in_chunks(md5, value)
32
+ md5.base64digest
33
+ else
34
+ OpenSSL::Digest::MD5.digest(value).base64digest
35
+ end
36
+ end
37
+
38
+ def update_in_chunks(digest, io)
39
+ loop do
40
+ chunk = io.read(CHUNK_SIZE)
41
+ break unless chunk
42
+ digest.update(chunk)
43
+ end
44
+ io.rewind
45
+ end
46
+
47
+ end
48
+
49
+ def add_handlers(handlers, _config)
50
+ # priority set low to ensure checksum is computed AFTER the request is
51
+ # built but before it is signed
52
+ handlers.add(Handler, priority: 10, step: :build)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @see Log::Formatter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -1,10 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  module Protocols
4
6
  class ApiGateway < Seahorse::Client::Plugin
7
+
8
+ class ContentTypeHandler < Seahorse::Client::Handler
9
+ def call(context)
10
+ body = context.http_request.body
11
+ # Rest::Handler will set a default JSON body, so size can be checked
12
+ # if this handler is run after serialization.
13
+ if !body.respond_to?(:size) ||
14
+ (body.respond_to?(:size) && body.size > 0)
15
+ context.http_request.headers['Content-Type'] ||=
16
+ 'application/json'
17
+ end
18
+ @handler.call(context)
19
+ end
20
+ end
21
+
5
22
  handler(Rest::Handler)
23
+ handler(ContentTypeHandler, priority: 30)
6
24
  handler(Json::ErrorHandler, step: :sign)
7
25
  end
26
+
8
27
  end
9
28
  end
10
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../query'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  module Protocols
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../query'
2
4
 
3
5
  module Aws