aws-sdk-core 3.131.1 → 3.170.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +275 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/arn.rb +13 -0
  5. data/lib/aws-sdk-core/binary/encode_handler.rb +12 -1
  6. data/lib/aws-sdk-core/credential_provider_chain.rb +6 -4
  7. data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
  8. data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
  9. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
  10. data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
  11. data/lib/aws-sdk-core/endpoints/function.rb +80 -0
  12. data/lib/aws-sdk-core/endpoints/matchers.rb +127 -0
  13. data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
  14. data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
  15. data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
  16. data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
  17. data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
  18. data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
  19. data/lib/aws-sdk-core/endpoints/url.rb +60 -0
  20. data/lib/aws-sdk-core/endpoints.rb +74 -0
  21. data/lib/aws-sdk-core/errors.rb +13 -0
  22. data/lib/aws-sdk-core/json/error_handler.rb +10 -1
  23. data/lib/aws-sdk-core/pageable_response.rb +7 -0
  24. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
  25. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +24 -0
  26. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
  27. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +34 -6
  28. data/lib/aws-sdk-core/plugins/recursion_detection.rb +14 -3
  29. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +5 -0
  30. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  31. data/lib/aws-sdk-core/plugins/sign.rb +200 -0
  32. data/lib/aws-sdk-core/plugins/signature_v2.rb +1 -0
  33. data/lib/aws-sdk-core/plugins/signature_v4.rb +13 -7
  34. data/lib/aws-sdk-core/refreshing_token.rb +71 -0
  35. data/lib/aws-sdk-core/rest/handler.rb +1 -1
  36. data/lib/aws-sdk-core/rest/request/headers.rb +2 -6
  37. data/lib/aws-sdk-core/shared_config.rb +76 -5
  38. data/lib/aws-sdk-core/sso_credentials.rb +79 -44
  39. data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
  40. data/lib/aws-sdk-core/static_token_provider.rb +14 -0
  41. data/lib/aws-sdk-core/structure.rb +6 -4
  42. data/lib/aws-sdk-core/token.rb +31 -0
  43. data/lib/aws-sdk-core/token_provider.rb +15 -0
  44. data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
  45. data/lib/aws-sdk-core/xml/error_handler.rb +7 -0
  46. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  47. data/lib/aws-sdk-core.rb +14 -0
  48. data/lib/aws-sdk-sso/client.rb +51 -11
  49. data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
  50. data/lib/aws-sdk-sso/endpoint_provider.rb +51 -0
  51. data/lib/aws-sdk-sso/endpoints.rb +71 -0
  52. data/lib/aws-sdk-sso/plugins/endpoints.rb +76 -0
  53. data/lib/aws-sdk-sso/types.rb +8 -43
  54. data/lib/aws-sdk-sso.rb +5 -1
  55. data/lib/aws-sdk-ssooidc/client.rb +606 -0
  56. data/lib/aws-sdk-ssooidc/client_api.rb +216 -0
  57. data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
  58. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
  59. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +51 -0
  60. data/lib/aws-sdk-ssooidc/endpoints.rb +57 -0
  61. data/lib/aws-sdk-ssooidc/errors.rb +290 -0
  62. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +74 -0
  63. data/lib/aws-sdk-ssooidc/resource.rb +26 -0
  64. data/lib/aws-sdk-ssooidc/types.rb +502 -0
  65. data/lib/aws-sdk-ssooidc.rb +59 -0
  66. data/lib/aws-sdk-sts/client.rb +153 -134
  67. data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
  68. data/lib/aws-sdk-sts/endpoint_provider.rb +109 -0
  69. data/lib/aws-sdk-sts/endpoints.rb +135 -0
  70. data/lib/aws-sdk-sts/plugins/endpoints.rb +84 -0
  71. data/lib/aws-sdk-sts/presigner.rb +13 -15
  72. data/lib/aws-sdk-sts/types.rb +79 -186
  73. data/lib/aws-sdk-sts.rb +5 -1
  74. data/lib/seahorse/client/async_base.rb +0 -1
  75. data/lib/seahorse/client/configuration.rb +2 -2
  76. data/lib/seahorse/client/h2/connection.rb +2 -5
  77. data/lib/seahorse/client/plugins/request_callback.rb +9 -9
  78. data/lib/seahorse/util.rb +4 -0
  79. metadata +47 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d25aed21a4d1a4e440f095565b04567939d9f1762346a1402373e19c402ca8f0
4
- data.tar.gz: 237863ff6fbc7e36e5787721ae68c50f04e4453265f14465c7c51ba168d59a05
3
+ metadata.gz: 621db310544612392db658a6d7ef590b805f1de5e445fce164af947327bccf66
4
+ data.tar.gz: 87484fd54203a9bac01f64aa23f09f4fa042b4f3a0a263bc3c4b0669a9086d21
5
5
  SHA512:
6
- metadata.gz: 5864566f11163702d6a0d3e187ee827f47ebfd1c24030d8da65d4b4e234532338c532669e6fea385ef94b433e49a29ed84be5aa85740504cf86d2f764e779313
7
- data.tar.gz: 1afd6c9611c06bda29cadf6fc0ffa29a1f3baec7d31a8365a0de91e6cf273bbd403a44f075da83dd22c61fc3f0f62ceb1ad59b78cc6df2f18ebd82774face1c7
6
+ metadata.gz: 213e9846a695ffa86ead83972d6d2d98e94ef06b0f3449cb8602e188cf55e65b4eb3c5045548dc51c144d855fb02c8758bfd34b721b65ca1b8afaebb959750bf
7
+ data.tar.gz: e3b5347c678c996eae43e13007e61272e8711d522b84842397e2773fb65c0fc469921761ffd01377383d25ad7309ba0b3da886d592f990ee3efcfa39f2e9f687
data/CHANGELOG.md CHANGED
@@ -1,6 +1,281 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.170.0 (2023-01-25)
5
+ ------------------
6
+
7
+ * Feature - Updated Aws::STS::Client with the latest API changes.
8
+
9
+ 3.169.0 (2023-01-18)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
15
+
16
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
17
+
18
+ * Issue - Replace runtime endpoint resolution approach with generated ruby code for STS, SSO, and SSOOIDC.
19
+
20
+ 3.168.4 (2022-12-08)
21
+ ------------------
22
+
23
+ * Issue - Fix Sign to not sign Sigv2 requests to S3.
24
+
25
+ 3.168.3 (2022-12-02)
26
+ ------------------
27
+
28
+ * Issue - Retry S3's `BadDigest` error
29
+
30
+ 3.168.2 (2022-11-29)
31
+ ------------------
32
+
33
+ * Issue - Allow region resolution in `AssumeRoleCredentials` from `CredentialProviderChain`.
34
+
35
+ 3.168.1 (2022-11-18)
36
+ ------------------
37
+
38
+ * Issue - Fix initialization of SSOTokenProvider when `AWS_PROFILE` is specified.
39
+
40
+ 3.168.0 (2022-11-17)
41
+ ------------------
42
+
43
+ * Feature - Updated Aws::STS::Client with the latest API changes.
44
+
45
+ 3.167.0 (2022-11-09)
46
+ ------------------
47
+
48
+ * Issue - Ensure the stream_thread is not killed before H2 connection status is updated (#2779).
49
+
50
+ * Feature - Add token refresh support to `SSOCredentialProvider`.
51
+
52
+ 3.166.0 (2022-10-26)
53
+ ------------------
54
+
55
+ * Feature - Updated Aws::STS::Client with the latest API changes.
56
+
57
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
58
+
59
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
60
+
61
+ 3.165.1 (2022-10-25)
62
+ ------------------
63
+
64
+ * Issue - Require the SignatureV4 plugin to fix compatability with older `aws-sdk-s3` versions (#2774).
65
+
66
+ 3.165.0 (2022-10-25)
67
+ ------------------
68
+
69
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
70
+
71
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
72
+
73
+ * Feature - Add support for service gems to dynamically determine their own endpoints via modeling. Service gems now generate a plugin called "Endpoints" that defines configuration for EndpointProvider, a new public type, and any client config related to endpoints. Endpoint providers will resolve values using another new public type, Endpoint Parameters, generated for each service. The plugin will use the endpoint provider to resolve an endpoint and then apply it to the request prior to serialization. Endpoint providers can be composed to change endpoint resolution logic, i.e. for testing. In addition to endpoints, the endpoint provider may also override the authentication scheme (auth scheme) which details how the request should be signed for the endpoint. A new "Sign" plugin in core replaces the SignatureV4 plugin that will generically sign any type of auth scheme that a service might have.
74
+
75
+ 3.164.0 (2022-10-21)
76
+ ------------------
77
+
78
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
79
+
80
+ 3.163.0 (2022-10-20)
81
+ ------------------
82
+
83
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
84
+
85
+ 3.162.0 (2022-10-19)
86
+ ------------------
87
+
88
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
89
+
90
+ 3.161.0 (2022-10-18)
91
+ ------------------
92
+
93
+ * Feature - Support AwsQueryCompatible trait to read error code from x-amzn-query-error header.
94
+
95
+ 3.160.0 (2022-10-13)
96
+ ------------------
97
+
98
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
99
+
100
+ 3.159.0 (2022-10-07)
101
+ ------------------
102
+
103
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
104
+
105
+ 3.158.1 (2022-10-06)
106
+ ------------------
107
+
108
+ * Issue - Ensure that the ReadCallbackIO is always unwrapped (#2761).
109
+
110
+ 3.158.0 (2022-09-30)
111
+ ------------------
112
+
113
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
114
+
115
+ 3.157.0 (2022-09-29)
116
+ ------------------
117
+
118
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
119
+
120
+ 3.156.0 (2022-09-27)
121
+ ------------------
122
+
123
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
124
+
125
+ 3.155.0 (2022-09-26)
126
+ ------------------
127
+
128
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
129
+
130
+ 3.154.0 (2022-09-23)
131
+ ------------------
132
+
133
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
134
+
135
+ 3.153.0 (2022-09-22)
136
+ ------------------
137
+
138
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
139
+
140
+ 3.152.0 (2022-09-21)
141
+ ------------------
142
+
143
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
144
+
145
+ 3.151.0 (2022-09-20)
146
+ ------------------
147
+
148
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
149
+
150
+ 3.150.0 (2022-09-19)
151
+ ------------------
152
+
153
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
154
+
155
+ 3.149.0 (2022-09-16)
156
+ ------------------
157
+
158
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
159
+
160
+ 3.148.0 (2022-09-15)
161
+ ------------------
162
+
163
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
164
+
165
+ 3.147.0 (2022-09-14)
166
+ ------------------
167
+
168
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
169
+
170
+ 3.146.0 (2022-09-13)
171
+ ------------------
172
+
173
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
174
+
175
+ 3.145.0 (2022-09-12)
176
+ ------------------
177
+
178
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
179
+
180
+ 3.144.0 (2022-09-09)
181
+ ------------------
182
+
183
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
184
+
185
+ 3.143.0 (2022-09-08)
186
+ ------------------
187
+
188
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
189
+
190
+ 3.142.0 (2022-09-07)
191
+ ------------------
192
+
193
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
194
+
195
+ 3.141.0 (2022-09-06)
196
+ ------------------
197
+
198
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
199
+
200
+ 3.140.0 (2022-09-02)
201
+ ------------------
202
+
203
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
204
+
205
+ 3.139.0 (2022-09-01)
206
+ ------------------
207
+
208
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
209
+
210
+ 3.138.0 (2022-08-31)
211
+ ------------------
212
+
213
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
214
+
215
+ 3.137.0 (2022-08-30)
216
+ ------------------
217
+
218
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
219
+
220
+ * Issue - Fix errors in recursion detection when `_X_AMZN_TRACE_ID` is unset (#2748).
221
+
222
+ 3.136.0 (2022-08-25)
223
+ ------------------
224
+
225
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
226
+
227
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
228
+
229
+ 3.135.0 (2022-08-24)
230
+ ------------------
231
+
232
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
233
+
234
+ 3.134.0 (2022-08-23)
235
+ ------------------
236
+
237
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
238
+
239
+ * Feature - Add support for Bearer Token Authentication and TokenProviders.
240
+
241
+ * Issue - Validate that `_X_AMZN_TRACE_ID` ENV value contains only valid, non-control characters.
242
+
243
+ 3.133.0 (2022-08-22)
244
+ ------------------
245
+
246
+ * Feature - Moved functionality from `aws-sdk-ssooidc` into core.
247
+
248
+ 3.132.0 (2022-08-08)
249
+ ------------------
250
+
251
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
252
+
253
+ 3.131.6 (2022-08-03)
254
+ ------------------
255
+
256
+ * Issue - Fix typo in `RecursionDetection`, change amz to amzn in header and env name.
257
+
258
+ 3.131.5 (2022-07-28)
259
+ ------------------
260
+
261
+ * Issue - Fix `to_json` usage in nested hashes by defining `as_json` (#2733).
262
+
263
+ 3.131.4 (2022-07-27)
264
+ ------------------
265
+
266
+ * Issue - Fix `to_json` usage on pageable responses when using Rails (#2733).
267
+ * Issue - Use `expand_path` on credential/config paths in SharedConfig (#2735).
268
+
269
+ 3.131.3 (2022-07-18)
270
+ ------------------
271
+
272
+ * Issue - Add support for serializing shapes on the body with `jsonvalue` members.
273
+
274
+ 3.131.2 (2022-06-20)
275
+ ------------------
276
+
277
+ * Issue - Populate context :request_id for XML error responses.
278
+
4
279
  3.131.1 (2022-05-20)
5
280
  ------------------
6
281
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.131.1
1
+ 3.170.0
@@ -88,5 +88,18 @@ module Aws
88
88
  resource: @resource
89
89
  }
90
90
  end
91
+
92
+ # Return the ARN as JSON
93
+ #
94
+ # @return [Hash]
95
+ def as_json(_options = nil)
96
+ {
97
+ 'partition' => @partition,
98
+ 'service' => @service,
99
+ 'region' => @region,
100
+ 'accountId' => @account_id,
101
+ 'resource' => @resource
102
+ }
103
+ end
91
104
  end
92
105
  end
@@ -13,7 +13,7 @@ module Aws
13
13
  context.config.api.metadata['protocol'],
14
14
  eventstream_member,
15
15
  context.operation.input,
16
- context.config.sigv4_signer
16
+ signer_for(context)
17
17
  )
18
18
  context[:input_event_emitter] = input_es_handler.event_emitter
19
19
  end
@@ -22,6 +22,17 @@ module Aws
22
22
 
23
23
  private
24
24
 
25
+ def signer_for(context)
26
+ # New endpoint/signing logic, use the auth scheme to make a signer
27
+ if context[:auth_scheme]
28
+ Aws::Plugins::Sign.signer_for(context[:auth_scheme], context.config)
29
+ else
30
+ # Previous implementation always assumed sigv4_signer from config.
31
+ # Relies only on sigv4 signing (and plugin) for event stream services
32
+ context.config.sigv4_signer
33
+ end
34
+ end
35
+
25
36
  def eventstream_input?(ctx)
26
37
  ctx.operation.input.shape.members.each do |_, ref|
27
38
  return ref if ref.eventstream
@@ -169,12 +169,14 @@ module Aws
169
169
  end
170
170
 
171
171
  def assume_role_with_profile(options, profile_name)
172
- region = (options[:config] && options[:config].region)
173
- Aws.shared_config.assume_role_credentials_from_config(
172
+ assume_opts = {
174
173
  profile: profile_name,
175
- region: region,
176
174
  chain_config: @config
177
- )
175
+ }
176
+ if options[:config] && options[:config].region
177
+ assume_opts[:region] = options[:config].region
178
+ end
179
+ Aws.shared_config.assume_role_credentials_from_config(assume_opts)
178
180
  end
179
181
  end
180
182
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
10
+ # @api private
11
+ class Condition
12
+ def initialize(fn:, argv:, assign: nil)
13
+ @fn = Function.new(fn: fn, argv: argv)
14
+ @assign = assign
15
+ @assigned = {}
16
+ end
17
+
18
+ attr_reader :fn
19
+ attr_reader :argv
20
+ attr_reader :assign
21
+
22
+ attr_reader :assigned
23
+
24
+ def match?(parameters, assigns)
25
+ output = @fn.call(parameters, assigns)
26
+ @assigned = @assigned.merge({ @assign => output }) if @assign
27
+ output
28
+ end
29
+
30
+ def self.from_json(conditions_json)
31
+ conditions_json.each.with_object([]) do |condition, conditions|
32
+ conditions << new(
33
+ fn: condition['fn'],
34
+ argv: condition['argv'],
35
+ assign: condition['assign']
36
+ )
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Endpoints
5
+ class Endpoint
6
+ def initialize(url:, properties: {}, headers: {})
7
+ @url = url
8
+ @properties = properties
9
+ @headers = headers
10
+ end
11
+
12
+ attr_reader :url
13
+ attr_reader :properties
14
+ attr_reader :headers
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version. # @api private
10
+ class EndpointRule < Rule
11
+ def initialize(type: 'endpoint', conditions:, endpoint:,
12
+ documentation: nil)
13
+ @type = type
14
+ @conditions = Condition.from_json(conditions)
15
+ @endpoint = endpoint
16
+ @documentation = documentation
17
+ end
18
+
19
+ attr_reader :type
20
+ attr_reader :conditions
21
+ attr_reader :endpoint
22
+ attr_reader :documentation
23
+
24
+ def match(parameters, assigned = {})
25
+ assigns = assigned.dup
26
+ matched = conditions.all? do |condition|
27
+ output = condition.match?(parameters, assigns)
28
+ assigns = assigns.merge(condition.assigned) if condition.assign
29
+ output
30
+ end
31
+ resolved_endpoint(parameters, assigns) if matched
32
+ end
33
+
34
+ def resolved_endpoint(parameters, assigns)
35
+ Endpoint.new(
36
+ url: resolve_value(@endpoint['url'], parameters, assigns),
37
+ properties: resolve_properties(
38
+ @endpoint['properties'] || {},
39
+ parameters,
40
+ assigns
41
+ ),
42
+ headers: resolve_headers(parameters, assigns)
43
+ )
44
+ end
45
+
46
+ private
47
+
48
+ def resolve_headers(parameters, assigns)
49
+ (@endpoint['headers'] || {}).each.with_object({}) do |(key, arr), headers|
50
+ headers[key] = []
51
+ arr.each do |value|
52
+ headers[key] << resolve_value(value, parameters, assigns)
53
+ end
54
+ end
55
+ end
56
+
57
+ def resolve_properties(obj, parameters, assigns)
58
+ case obj
59
+ when Hash
60
+ obj.each.with_object({}) do |(key, value), hash|
61
+ hash[key] = resolve_properties(value, parameters, assigns)
62
+ end
63
+ when Array
64
+ obj.collect { |value| resolve_properties(value, parameters, assigns) }
65
+ else
66
+ if obj.is_a?(String)
67
+ Templater.resolve(obj, parameters, assigns)
68
+ else
69
+ obj
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
10
+ # @api private
11
+ class ErrorRule < Rule
12
+ def initialize(type: 'error', conditions:, error: nil, documentation: nil)
13
+ @type = type
14
+ @conditions = Condition.from_json(conditions)
15
+ @error = error
16
+ @documentation = documentation
17
+ end
18
+
19
+ attr_reader :type
20
+ attr_reader :conditions
21
+ attr_reader :error
22
+ attr_reader :documentation
23
+
24
+ def match(parameters, assigned = {})
25
+ assigns = assigned.dup
26
+ matched = conditions.all? do |condition|
27
+ output = condition.match?(parameters, assigns)
28
+ assigns = assigns.merge(condition.assigned) if condition.assign
29
+ output
30
+ end
31
+ resolved_error(parameters, assigns) if matched
32
+ end
33
+
34
+ private
35
+
36
+ def resolved_error(parameters, assigns)
37
+ error = resolve_value(@error, parameters, assigns)
38
+ ArgumentError.new(error)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Endpoints
5
+ # This class is deprecated. It is used by the Runtime endpoint
6
+ # resolution approach. It has been replaced by a code generated
7
+ # approach in each service gem. It can be removed in a new
8
+ # major version. It has to exist because
9
+ # old service gems can use a new core version.
10
+ # @api private
11
+ class Function
12
+ def initialize(fn:, argv:)
13
+ @fn = fn
14
+ @argv = build_argv(argv)
15
+ end
16
+
17
+ attr_reader :fn
18
+ attr_reader :argv
19
+
20
+ def call(parameters, assigns)
21
+ args = []
22
+ @argv.each do |arg|
23
+ if arg.is_a?(Reference)
24
+ args << arg.resolve(parameters, assigns)
25
+ elsif arg.is_a?(Function)
26
+ args << arg.call(parameters, assigns)
27
+ else
28
+ if arg.is_a?(String)
29
+ arg = Templater.resolve(arg, parameters, assigns)
30
+ end
31
+ args << arg
32
+ end
33
+ end
34
+
35
+ case @fn
36
+ when 'isSet'
37
+ Matchers.set?(*args)
38
+ when 'not'
39
+ Matchers.not(*args)
40
+ when 'getAttr'
41
+ Matchers.attr(*args)
42
+ when 'substring'
43
+ Matchers.substring(*args)
44
+ when 'stringEquals'
45
+ Matchers.string_equals?(*args)
46
+ when 'booleanEquals'
47
+ Matchers.boolean_equals?(*args)
48
+ when 'uriEncode'
49
+ Matchers.uri_encode(*args)
50
+ when 'parseURL'
51
+ Matchers.parse_url(*args)
52
+ when 'isValidHostLabel'
53
+ Matchers.valid_host_label?(*args)
54
+ when 'aws.partition'
55
+ Matchers.aws_partition(*args)
56
+ when 'aws.parseArn'
57
+ Matchers.aws_parse_arn(*args)
58
+ when 'aws.isVirtualHostableS3Bucket'
59
+ Matchers.aws_virtual_hostable_s3_bucket?(*args)
60
+ else
61
+ raise "Function not found: #{@fn}"
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ def build_argv(argv_json)
68
+ argv_json.each.with_object([]) do |arg, argv|
69
+ argv << if arg.is_a?(Hash) && arg['ref']
70
+ Reference.new(ref: arg['ref'])
71
+ elsif arg.is_a?(Hash) && arg['fn']
72
+ Function.new(fn: arg['fn'], argv: arg['argv'])
73
+ else
74
+ arg
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end