aws-sdk-core 3.103.0 → 3.130.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1304 -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 +13 -0
  9. data/lib/aws-sdk-core/assume_role_credentials.rb +20 -1
  10. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +9 -4
  11. data/lib/aws-sdk-core/client_stubs.rb +5 -1
  12. data/lib/aws-sdk-core/credential_provider_chain.rb +21 -1
  13. data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
  14. data/lib/aws-sdk-core/ecs_credentials.rb +8 -4
  15. data/lib/aws-sdk-core/errors.rb +9 -2
  16. data/lib/aws-sdk-core/instance_profile_credentials.rb +122 -22
  17. data/lib/aws-sdk-core/json/json_engine.rb +10 -8
  18. data/lib/aws-sdk-core/json/oj_engine.rb +33 -6
  19. data/lib/aws-sdk-core/json/parser.rb +8 -0
  20. data/lib/aws-sdk-core/json.rb +8 -26
  21. data/lib/aws-sdk-core/log/formatter.rb +1 -1
  22. data/lib/aws-sdk-core/log/param_filter.rb +11 -3
  23. data/lib/aws-sdk-core/pageable_response.rb +80 -32
  24. data/lib/aws-sdk-core/pager.rb +3 -0
  25. data/lib/aws-sdk-core/param_validator.rb +52 -4
  26. data/lib/aws-sdk-core/plugins/api_key.rb +3 -1
  27. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +340 -0
  28. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +24 -7
  29. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  30. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +6 -6
  31. data/lib/aws-sdk-core/plugins/http_checksum.rb +8 -1
  32. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +17 -0
  33. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +16 -1
  34. data/lib/aws-sdk-core/plugins/recursion_detection.rb +27 -0
  35. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +48 -2
  36. data/lib/aws-sdk-core/plugins/response_paging.rb +1 -1
  37. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +5 -3
  38. data/lib/aws-sdk-core/plugins/retry_errors.rb +25 -8
  39. data/lib/aws-sdk-core/plugins/signature_v4.rb +15 -24
  40. data/lib/aws-sdk-core/plugins/stub_responses.rb +7 -1
  41. data/lib/aws-sdk-core/process_credentials.rb +5 -4
  42. data/lib/aws-sdk-core/refreshing_credentials.rb +42 -11
  43. data/lib/aws-sdk-core/rest/request/body.rb +19 -1
  44. data/lib/aws-sdk-core/rest/request/headers.rb +18 -6
  45. data/lib/aws-sdk-core/rest/response/headers.rb +4 -3
  46. data/lib/aws-sdk-core/shared_config.rb +60 -8
  47. data/lib/aws-sdk-core/shared_credentials.rb +7 -1
  48. data/lib/aws-sdk-core/sso_credentials.rb +141 -0
  49. data/lib/aws-sdk-core/structure.rb +10 -1
  50. data/lib/aws-sdk-core/stubbing/protocols/json.rb +1 -1
  51. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +1 -1
  52. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +1 -1
  53. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +0 -2
  54. data/lib/aws-sdk-core/xml/builder.rb +2 -2
  55. data/lib/aws-sdk-core/xml/doc_builder.rb +6 -1
  56. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +1 -1
  57. data/lib/aws-sdk-core/xml/parser/frame.rb +23 -0
  58. data/lib/aws-sdk-core/xml/parser.rb +5 -0
  59. data/lib/aws-sdk-core.rb +13 -3
  60. data/lib/aws-sdk-sso/client.rb +570 -0
  61. data/lib/aws-sdk-sso/client_api.rb +190 -0
  62. data/lib/aws-sdk-sso/customizations.rb +1 -0
  63. data/lib/aws-sdk-sso/errors.rb +102 -0
  64. data/lib/aws-sdk-sso/resource.rb +26 -0
  65. data/lib/aws-sdk-sso/types.rb +352 -0
  66. data/lib/aws-sdk-sso.rb +55 -0
  67. data/lib/aws-sdk-sts/client.rb +536 -435
  68. data/lib/aws-sdk-sts/client_api.rb +7 -1
  69. data/lib/aws-sdk-sts/errors.rb +1 -1
  70. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +5 -1
  71. data/lib/aws-sdk-sts/presigner.rb +7 -1
  72. data/lib/aws-sdk-sts/resource.rb +1 -1
  73. data/lib/aws-sdk-sts/types.rb +332 -193
  74. data/lib/aws-sdk-sts.rb +8 -3
  75. data/lib/seahorse/client/base.rb +1 -0
  76. data/lib/seahorse/client/block_io.rb +3 -2
  77. data/lib/seahorse/client/configuration.rb +4 -0
  78. data/lib/seahorse/client/h2/connection.rb +15 -13
  79. data/lib/seahorse/client/h2/handler.rb +4 -5
  80. data/lib/seahorse/client/http/response.rb +1 -1
  81. data/lib/seahorse/client/net_http/connection_pool.rb +10 -4
  82. data/lib/seahorse/client/net_http/handler.rb +17 -8
  83. data/lib/seahorse/client/net_http/patches.rb +13 -84
  84. data/lib/seahorse/client/plugins/content_length.rb +11 -5
  85. data/lib/seahorse/client/plugins/h2.rb +4 -1
  86. data/lib/seahorse/client/plugins/net_http.rb +37 -3
  87. data/lib/seahorse/client/plugins/request_callback.rb +110 -0
  88. data/lib/seahorse/client/plugins/response_target.rb +3 -4
  89. data/lib/seahorse/model/operation.rb +3 -0
  90. data/lib/seahorse/model/shapes.rb +25 -0
  91. data/lib/seahorse/util.rb +6 -1
  92. data/lib/seahorse.rb +1 -0
  93. metadata +26 -9
@@ -5,6 +5,8 @@ require_relative 'json/builder'
5
5
  require_relative 'json/error_handler'
6
6
  require_relative 'json/handler'
7
7
  require_relative 'json/parser'
8
+ require_relative 'json/json_engine'
9
+ require_relative 'json/oj_engine'
8
10
 
9
11
  module Aws
10
12
  # @api private
@@ -20,9 +22,7 @@ module Aws
20
22
 
21
23
  class << self
22
24
  def load(json)
23
- ENGINE.load(json, *ENGINE_LOAD_OPTIONS)
24
- rescue *ENGINE_ERRORS => e
25
- raise ParseError, e
25
+ ENGINE.load(json)
26
26
  end
27
27
 
28
28
  def load_file(path)
@@ -30,38 +30,20 @@ module Aws
30
30
  end
31
31
 
32
32
  def dump(value)
33
- ENGINE.dump(value, *ENGINE_DUMP_OPTIONS)
33
+ ENGINE.dump(value)
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- def oj_engine
38
+ def select_engine
39
39
  require 'oj'
40
- [
41
- Oj,
42
- [{ mode: :compat, symbol_keys: false }],
43
- [{ mode: :compat }],
44
- oj_parse_error
45
- ]
40
+ OjEngine
46
41
  rescue LoadError
47
- false
48
- end
49
-
50
- def json_engine
51
- [JSON, [], [], [JSON::ParserError]]
52
- end
53
-
54
- def oj_parse_error
55
- if Oj.const_defined?('ParseError')
56
- [Oj::ParseError, EncodingError, JSON::ParserError]
57
- else
58
- [SyntaxError]
59
- end
42
+ JSONEngine
60
43
  end
61
44
  end
62
45
 
63
46
  # @api private
64
- ENGINE, ENGINE_LOAD_OPTIONS, ENGINE_DUMP_OPTIONS, ENGINE_ERRORS =
65
- oj_engine || json_engine
47
+ ENGINE = select_engine
66
48
  end
67
49
  end
@@ -97,7 +97,7 @@ module Aws
97
97
  # @return [String]
98
98
  attr_reader :pattern
99
99
 
100
- # Given a resopnse, this will format a log message and return it as a
100
+ # Given a response, this will format a log message and return it as a
101
101
  # string according to {#pattern}.
102
102
  # @param [Seahorse::Client::Response] response
103
103
  # @return [String]
@@ -6,9 +6,9 @@ require 'set'
6
6
  module Aws
7
7
  module Log
8
8
  class ParamFilter
9
- # DEPRECATED - this must exist for backwards compatibility. Sensitive
9
+ # DEPRECATED - This must exist for backwards compatibility. Sensitive
10
10
  # members are now computed for each request/response type. This can be
11
- # removed in a new major version.
11
+ # removed in a new major version. This list is no longer updated.
12
12
  #
13
13
  # A managed list of sensitive parameters that should be filtered from
14
14
  # logs. This is updated automatically as part of each release. See the
@@ -26,7 +26,8 @@ module Aws
26
26
 
27
27
  def filter(values, type)
28
28
  case values
29
- when Struct, Hash then filter_hash(values, type)
29
+ when Struct then filter_struct(values, type)
30
+ when Hash then filter_hash(values, type)
30
31
  when Array then filter_array(values, type)
31
32
  else values
32
33
  end
@@ -34,6 +35,13 @@ module Aws
34
35
 
35
36
  private
36
37
 
38
+ def filter_struct(values, type)
39
+ if values.class.include? Aws::Structure::Union
40
+ values = { values.member => values.value }
41
+ end
42
+ filter_hash(values, type)
43
+ end
44
+
37
45
  def filter_hash(values, type)
38
46
  if type.const_defined?('SENSITIVE')
39
47
  filters = type::SENSITIVE + @additional_filters
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aws
4
-
5
4
  # Decorates a {Seahorse::Client::Response} with paging convenience methods.
6
5
  # Some AWS calls provide paged responses to limit the amount of data returned
7
- # with each response. To optimize for latency, some APIs may return an
8
- # inconsistent number of responses per page. You should rely on the values of
9
- # the `next_page?` method or using enumerable methods such as `each`
10
- # rather than the number of items returned to iterate through results.
11
- # See below for examples.
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.
11
+ #
12
+ # @note Methods such as `to_json` will enumerate all of the responses before
13
+ # returning the full response as JSON.
12
14
  #
13
15
  # # Paged Responses Are Enumerable
14
16
  # The simplest way to handle paged response data is to use the built-in
@@ -46,11 +48,11 @@ module Aws
46
48
  #
47
49
  module PageableResponse
48
50
 
49
- def self.extended(base)
50
- base.send(:extend, Enumerable)
51
- base.send(:extend, UnsafeEnumerableMethods)
52
- base.instance_variable_set("@last_page", nil)
53
- base.instance_variable_set("@more_results", nil)
51
+ def self.apply(base)
52
+ base.extend Extension
53
+ base.instance_variable_set(:@last_page, nil)
54
+ base.instance_variable_set(:@more_results, nil)
55
+ base
54
56
  end
55
57
 
56
58
  # @return [Paging::Pager]
@@ -60,39 +62,26 @@ module Aws
60
62
  # when this method returns `false` will raise an error.
61
63
  # @return [Boolean]
62
64
  def last_page?
63
- if @last_page.nil?
64
- @last_page = !@pager.truncated?(self)
65
- end
66
- @last_page
65
+ # Actual implementation is in PageableResponse::Extension
67
66
  end
68
67
 
69
68
  # Returns `true` if there are more results. Calling {#next_page} will
70
69
  # return the next response.
71
70
  # @return [Boolean]
72
71
  def next_page?
73
- !last_page?
72
+ # Actual implementation is in PageableResponse::Extension
74
73
  end
75
74
 
76
75
  # @return [Seahorse::Client::Response]
77
76
  def next_page(params = {})
78
- if last_page?
79
- raise LastPageError.new(self)
80
- else
81
- next_response(params)
82
- end
77
+ # Actual implementation is in PageableResponse::Extension
83
78
  end
84
79
 
85
80
  # Yields the current and each following response to the given block.
86
81
  # @yieldparam [Response] response
87
82
  # @return [Enumerable,nil] Returns a new Enumerable if no block is given.
88
83
  def each(&block)
89
- return enum_for(:each_page) unless block_given?
90
- response = self
91
- yield(response)
92
- until response.last_page?
93
- response = response.next_page
94
- yield(response)
95
- end
84
+ # Actual implementation is in PageableResponse::Extension
96
85
  end
97
86
  alias each_page each
98
87
 
@@ -103,9 +92,7 @@ module Aws
103
92
  # @return [Seahorse::Client::Response] Returns the next page of
104
93
  # results.
105
94
  def next_response(params)
106
- params = next_page_params(params)
107
- request = context.client.build_request(context.operation_name, params)
108
- request.send_request
95
+ # Actual implementation is in PageableResponse::Extension
109
96
  end
110
97
 
111
98
  # @param [Hash] params A hash of additional request params to
@@ -113,7 +100,7 @@ module Aws
113
100
  # @return [Hash] Returns the hash of request parameters for the
114
101
  # next page, merging any given params.
115
102
  def next_page_params(params)
116
- context[:original_params].merge(@pager.next_tokens(self).merge(params))
103
+ # Actual implementation is in PageableResponse::Extension
117
104
  end
118
105
 
119
106
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -160,5 +147,66 @@ module Aws
160
147
  end
161
148
 
162
149
  end
150
+
151
+ # The actual decorator module implementation. It is in a distinct module
152
+ # so that it can be used to extend objects without busting Ruby's constant cache.
153
+ # object.extend(mod) bust the constant cache only if `mod` contains constants of its own.
154
+ # @api private
155
+ module Extension
156
+
157
+ include Enumerable
158
+ include UnsafeEnumerableMethods
159
+
160
+ attr_accessor :pager
161
+
162
+ def last_page?
163
+ if @last_page.nil?
164
+ @last_page = !@pager.truncated?(self)
165
+ end
166
+ @last_page
167
+ end
168
+
169
+ def next_page?
170
+ !last_page?
171
+ end
172
+
173
+ def next_page(params = {})
174
+ if last_page?
175
+ raise LastPageError.new(self)
176
+ else
177
+ next_response(params)
178
+ end
179
+ end
180
+
181
+ def each(&block)
182
+ return enum_for(:each_page) unless block_given?
183
+ response = self
184
+ yield(response)
185
+ until response.last_page?
186
+ response = response.next_page
187
+ yield(response)
188
+ end
189
+ end
190
+ alias each_page each
191
+
192
+ private
193
+
194
+ def next_response(params)
195
+ params = next_page_params(params)
196
+ request = context.client.build_request(context.operation_name, params)
197
+ request.send_request
198
+ end
199
+
200
+ def next_page_params(params)
201
+ # Remove all previous tokens from original params
202
+ # Sometimes a token can be nil and merge would not include it.
203
+ tokens = @pager.tokens.values.map(&:to_sym)
204
+
205
+ params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
206
+ params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
207
+ params_without_tokens
208
+ end
209
+
210
+ end
163
211
  end
164
212
  end
@@ -18,6 +18,9 @@ module Aws
18
18
  # @return [Symbol, nil]
19
19
  attr_reader :limit_key
20
20
 
21
+ # @return [Hash, nil]
22
+ attr_reader :tokens
23
+
21
24
  # @param [Seahorse::Client::Response] response
22
25
  # @return [Hash]
23
26
  def next_tokens(response)
@@ -70,6 +70,14 @@ module Aws
70
70
  end
71
71
  end
72
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
+
73
81
  # validate non-nil members
74
82
  values.each_pair do |name, value|
75
83
  unless value.nil?
@@ -117,11 +125,32 @@ module Aws
117
125
  end
118
126
  end
119
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
+
120
148
  def shape(ref, value, errors, context)
121
149
  case ref.shape
122
150
  when StructureShape then structure(ref, value, errors, context)
123
151
  when ListShape then list(ref, value, errors, context)
124
152
  when MapShape then map(ref, value, errors, context)
153
+ when DocumentShape then document(ref, value, errors, context)
125
154
  when StringShape
126
155
  unless value.is_a?(String)
127
156
  errors << expected_got(context, "a String", value)
@@ -143,8 +172,22 @@ module Aws
143
172
  errors << expected_got(context, "true or false", value)
144
173
  end
145
174
  when BlobShape
146
- unless value.is_a?(String) || io_like?(value)
147
- 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
148
191
  end
149
192
  else
150
193
  raise "unhandled shape type: #{ref.shape.class.name}"
@@ -167,8 +210,13 @@ module Aws
167
210
  end
168
211
  end
169
212
 
170
- def io_like?(value)
171
- value.respond_to?(:read) && value.respond_to?(:rewind)
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)
@@ -23,7 +23,9 @@ When provided, `x-api-key` header will be injected with the value provided.
23
23
  class OptionHandler < Seahorse::Client::Handler
24
24
  def call(context)
25
25
  if context.operation.require_apikey
26
- 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
27
29
  api_key = context.config.api_key if api_key.nil?
28
30
  context[:api_key] = api_key
29
31
  end