aws-sdk-lambdamicrovms 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::LambdaMicrovms
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute region
14
+ # The AWS region used to dispatch the request.
15
+ #
16
+ # @return [string]
17
+ #
18
+ # @!attribute use_dual_stack
19
+ # When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
20
+ #
21
+ # @return [boolean]
22
+ #
23
+ # @!attribute use_fips
24
+ # When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
25
+ #
26
+ # @return [boolean]
27
+ #
28
+ # @!attribute endpoint
29
+ # Override the endpoint used to send this request
30
+ #
31
+ # @return [string]
32
+ #
33
+ EndpointParameters = Struct.new(
34
+ :region,
35
+ :use_dual_stack,
36
+ :use_fips,
37
+ :endpoint,
38
+ ) do
39
+ include Aws::Structure
40
+
41
+ # @api private
42
+ class << self
43
+ PARAM_MAP = {
44
+ 'Region' => :region,
45
+ 'UseDualStack' => :use_dual_stack,
46
+ 'UseFIPS' => :use_fips,
47
+ 'Endpoint' => :endpoint,
48
+ }.freeze
49
+ end
50
+
51
+ def initialize(options = {})
52
+ self[:region] = options[:region]
53
+ self[:use_dual_stack] = options[:use_dual_stack]
54
+ self[:use_dual_stack] = false if self[:use_dual_stack].nil?
55
+ self[:use_fips] = options[:use_fips]
56
+ self[:use_fips] = false if self[:use_fips].nil?
57
+ self[:endpoint] = options[:endpoint]
58
+ end
59
+
60
+ def self.create(config, options={})
61
+ new({
62
+ region: config.region,
63
+ use_dual_stack: config.use_dualstack_endpoint,
64
+ use_fips: config.use_fips_endpoint,
65
+ endpoint: (config.endpoint.to_s unless config.regional_endpoint),
66
+ }.merge(options))
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::LambdaMicrovms
11
+ class EndpointProvider
12
+ def resolve_endpoint(parameters)
13
+ if Aws::Endpoints::Matchers.set?(parameters.endpoint)
14
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
15
+ raise ArgumentError, "Invalid Configuration: FIPS and custom endpoint are not supported"
16
+ end
17
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
18
+ raise ArgumentError, "Invalid Configuration: Dualstack and custom endpoint are not supported"
19
+ end
20
+ return Aws::Endpoints::Endpoint.new(url: parameters.endpoint, headers: {}, properties: {})
21
+ end
22
+ if Aws::Endpoints::Matchers.set?(parameters.region)
23
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
24
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
25
+ if Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsFIPS")) && Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsDualStack"))
26
+ return Aws::Endpoints::Endpoint.new(url: "https://lambda-fips.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
27
+ end
28
+ raise ArgumentError, "FIPS and DualStack are enabled, but this partition does not support one or both"
29
+ end
30
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
31
+ if Aws::Endpoints::Matchers.boolean_equals?(Aws::Endpoints::Matchers.attr(partition_result, "supportsFIPS"), true)
32
+ return Aws::Endpoints::Endpoint.new(url: "https://lambda-fips.#{parameters.region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
33
+ end
34
+ raise ArgumentError, "FIPS is enabled but this partition does not support FIPS"
35
+ end
36
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
37
+ if Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsDualStack"))
38
+ return Aws::Endpoints::Endpoint.new(url: "https://lambda.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
39
+ end
40
+ raise ArgumentError, "DualStack is enabled but this partition does not support DualStack"
41
+ end
42
+ return Aws::Endpoints::Endpoint.new(url: "https://lambda.#{parameters.region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
43
+ end
44
+ end
45
+ raise ArgumentError, "Invalid Configuration: Missing Region"
46
+ raise ArgumentError, 'No endpoint could be resolved'
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::LambdaMicrovms
12
+ # @api private
13
+ module Endpoints
14
+
15
+
16
+ def self.parameters_for_operation(context)
17
+ Aws::LambdaMicrovms::EndpointParameters.create(context.config)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,306 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::LambdaMicrovms
11
+
12
+ # When LambdaMicrovms returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::LambdaMicrovms::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all LambdaMicrovms errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::LambdaMicrovms::Errors::ServiceError
20
+ # # rescues all LambdaMicrovms API errors
21
+ # end
22
+ #
23
+ #
24
+ # ## Request Context
25
+ # ServiceError objects have a {Aws::Errors::ServiceError#context #context} method that returns
26
+ # information about the request that generated the error.
27
+ # See {Seahorse::Client::RequestContext} for more information.
28
+ #
29
+ # ## Error Classes
30
+ # * {AccessDeniedException}
31
+ # * {ConflictException}
32
+ # * {InternalServerException}
33
+ # * {InvalidParameterValueException}
34
+ # * {ResourceConflictException}
35
+ # * {ResourceNotFoundException}
36
+ # * {ServiceException}
37
+ # * {ServiceQuotaExceededException}
38
+ # * {ThrottlingException}
39
+ # * {TooManyRequestsException}
40
+ # * {ValidationException}
41
+ #
42
+ # Additionally, error classes are dynamically generated for service errors based on the error code
43
+ # if they are not defined above.
44
+ module Errors
45
+
46
+ extend Aws::Errors::DynamicErrors
47
+
48
+ class AccessDeniedException < ServiceError
49
+
50
+ # @param [Seahorse::Client::RequestContext] context
51
+ # @param [String] message
52
+ # @param [Aws::LambdaMicrovms::Types::AccessDeniedException] data
53
+ def initialize(context, message, data = Aws::EmptyStructure.new)
54
+ super(context, message, data)
55
+ end
56
+
57
+ # @return [String]
58
+ def message
59
+ @message || @data[:message]
60
+ end
61
+ end
62
+
63
+ class ConflictException < ServiceError
64
+
65
+ # @param [Seahorse::Client::RequestContext] context
66
+ # @param [String] message
67
+ # @param [Aws::LambdaMicrovms::Types::ConflictException] data
68
+ def initialize(context, message, data = Aws::EmptyStructure.new)
69
+ super(context, message, data)
70
+ end
71
+
72
+ # @return [String]
73
+ def message
74
+ @message || @data[:message]
75
+ end
76
+
77
+ # @return [String]
78
+ def resource_id
79
+ @data[:resource_id]
80
+ end
81
+
82
+ # @return [String]
83
+ def resource_type
84
+ @data[:resource_type]
85
+ end
86
+ end
87
+
88
+ class InternalServerException < ServiceError
89
+
90
+ # @param [Seahorse::Client::RequestContext] context
91
+ # @param [String] message
92
+ # @param [Aws::LambdaMicrovms::Types::InternalServerException] data
93
+ def initialize(context, message, data = Aws::EmptyStructure.new)
94
+ super(context, message, data)
95
+ end
96
+
97
+ # @return [String]
98
+ def message
99
+ @message || @data[:message]
100
+ end
101
+
102
+ # @return [String]
103
+ def retry_after_seconds
104
+ @data[:retry_after_seconds]
105
+ end
106
+
107
+ def retryable?
108
+ true
109
+ end
110
+ end
111
+
112
+ class InvalidParameterValueException < ServiceError
113
+
114
+ # @param [Seahorse::Client::RequestContext] context
115
+ # @param [String] message
116
+ # @param [Aws::LambdaMicrovms::Types::InvalidParameterValueException] data
117
+ def initialize(context, message, data = Aws::EmptyStructure.new)
118
+ super(context, message, data)
119
+ end
120
+
121
+ # @return [String]
122
+ def type
123
+ @data[:type]
124
+ end
125
+
126
+ # @return [String]
127
+ def message
128
+ @message || @data[:message]
129
+ end
130
+ end
131
+
132
+ class ResourceConflictException < ServiceError
133
+
134
+ # @param [Seahorse::Client::RequestContext] context
135
+ # @param [String] message
136
+ # @param [Aws::LambdaMicrovms::Types::ResourceConflictException] data
137
+ def initialize(context, message, data = Aws::EmptyStructure.new)
138
+ super(context, message, data)
139
+ end
140
+
141
+ # @return [String]
142
+ def type
143
+ @data[:type]
144
+ end
145
+
146
+ # @return [String]
147
+ def message
148
+ @message || @data[:message]
149
+ end
150
+ end
151
+
152
+ class ResourceNotFoundException < ServiceError
153
+
154
+ # @param [Seahorse::Client::RequestContext] context
155
+ # @param [String] message
156
+ # @param [Aws::LambdaMicrovms::Types::ResourceNotFoundException] data
157
+ def initialize(context, message, data = Aws::EmptyStructure.new)
158
+ super(context, message, data)
159
+ end
160
+
161
+ # @return [String]
162
+ def message
163
+ @message || @data[:message]
164
+ end
165
+
166
+ # @return [String]
167
+ def resource_type
168
+ @data[:resource_type]
169
+ end
170
+
171
+ # @return [String]
172
+ def resource_id
173
+ @data[:resource_id]
174
+ end
175
+ end
176
+
177
+ class ServiceException < ServiceError
178
+
179
+ # @param [Seahorse::Client::RequestContext] context
180
+ # @param [String] message
181
+ # @param [Aws::LambdaMicrovms::Types::ServiceException] data
182
+ def initialize(context, message, data = Aws::EmptyStructure.new)
183
+ super(context, message, data)
184
+ end
185
+
186
+ # @return [String]
187
+ def type
188
+ @data[:type]
189
+ end
190
+
191
+ # @return [String]
192
+ def message
193
+ @message || @data[:message]
194
+ end
195
+ end
196
+
197
+ class ServiceQuotaExceededException < ServiceError
198
+
199
+ # @param [Seahorse::Client::RequestContext] context
200
+ # @param [String] message
201
+ # @param [Aws::LambdaMicrovms::Types::ServiceQuotaExceededException] data
202
+ def initialize(context, message, data = Aws::EmptyStructure.new)
203
+ super(context, message, data)
204
+ end
205
+
206
+ # @return [String]
207
+ def message
208
+ @message || @data[:message]
209
+ end
210
+
211
+ # @return [String]
212
+ def resource_id
213
+ @data[:resource_id]
214
+ end
215
+
216
+ # @return [String]
217
+ def resource_type
218
+ @data[:resource_type]
219
+ end
220
+
221
+ # @return [String]
222
+ def service_code
223
+ @data[:service_code]
224
+ end
225
+
226
+ # @return [String]
227
+ def quota_code
228
+ @data[:quota_code]
229
+ end
230
+ end
231
+
232
+ class ThrottlingException < ServiceError
233
+
234
+ # @param [Seahorse::Client::RequestContext] context
235
+ # @param [String] message
236
+ # @param [Aws::LambdaMicrovms::Types::ThrottlingException] data
237
+ def initialize(context, message, data = Aws::EmptyStructure.new)
238
+ super(context, message, data)
239
+ end
240
+
241
+ # @return [String]
242
+ def message
243
+ @message || @data[:message]
244
+ end
245
+
246
+ # @return [String]
247
+ def service_code
248
+ @data[:service_code]
249
+ end
250
+
251
+ # @return [String]
252
+ def quota_code
253
+ @data[:quota_code]
254
+ end
255
+
256
+ # @return [String]
257
+ def retry_after_seconds
258
+ @data[:retry_after_seconds]
259
+ end
260
+
261
+ def retryable?
262
+ true
263
+ end
264
+
265
+ def throttling?
266
+ true
267
+ end
268
+ end
269
+
270
+ class TooManyRequestsException < ServiceError
271
+
272
+ # @param [Seahorse::Client::RequestContext] context
273
+ # @param [String] message
274
+ # @param [Aws::LambdaMicrovms::Types::TooManyRequestsException] data
275
+ def initialize(context, message, data = Aws::EmptyStructure.new)
276
+ super(context, message, data)
277
+ end
278
+
279
+ # @return [String]
280
+ def type
281
+ @data[:type]
282
+ end
283
+
284
+ # @return [String]
285
+ def message
286
+ @message || @data[:message]
287
+ end
288
+ end
289
+
290
+ class ValidationException < ServiceError
291
+
292
+ # @param [Seahorse::Client::RequestContext] context
293
+ # @param [String] message
294
+ # @param [Aws::LambdaMicrovms::Types::ValidationException] data
295
+ def initialize(context, message, data = Aws::EmptyStructure.new)
296
+ super(context, message, data)
297
+ end
298
+
299
+ # @return [String]
300
+ def message
301
+ @message || @data[:message]
302
+ end
303
+ end
304
+
305
+ end
306
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::LambdaMicrovms
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::LambdaMicrovms::EndpointProvider',
17
+ rbs_type: 'untyped',
18
+ docstring: <<~DOCS) do |_cfg|
19
+ The endpoint provider used to resolve endpoints. Any object that responds to
20
+ `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
21
+ `Aws::LambdaMicrovms::EndpointParameters`.
22
+ DOCS
23
+ Aws::LambdaMicrovms::EndpointProvider.new
24
+ end
25
+
26
+ # @api private
27
+ class Handler < Seahorse::Client::Handler
28
+ def call(context)
29
+ unless context[:discovered_endpoint]
30
+ params = Aws::LambdaMicrovms::Endpoints.parameters_for_operation(context)
31
+ endpoint = context.config.endpoint_provider.resolve_endpoint(params)
32
+
33
+ context.http_request.endpoint = endpoint.url
34
+ apply_endpoint_headers(context, endpoint.headers)
35
+
36
+ context[:endpoint_params] = params
37
+ context[:endpoint_properties] = endpoint.properties
38
+ end
39
+
40
+ context[:auth_scheme] =
41
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
42
+
43
+ with_metrics(context) { @handler.call(context) }
44
+ end
45
+
46
+ private
47
+
48
+ def with_metrics(context, &block)
49
+ metrics = []
50
+ metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
51
+ if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
52
+ metrics << 'SIGV4A_SIGNING'
53
+ end
54
+ if context.config.credentials&.credentials&.account_id
55
+ metrics << 'RESOLVED_ACCOUNT_ID'
56
+ end
57
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
58
+ end
59
+
60
+ def apply_endpoint_headers(context, headers)
61
+ headers.each do |key, values|
62
+ value = values
63
+ .compact
64
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
65
+ .join(',')
66
+
67
+ context.http_request.headers[key] = value
68
+ end
69
+ end
70
+ end
71
+
72
+ def add_handlers(handlers, _config)
73
+ handlers.add(Handler, step: :build, priority: 75)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::LambdaMicrovms
11
+
12
+ class Resource
13
+
14
+ # @param options ({})
15
+ # @option options [Client] :client
16
+ def initialize(options = {})
17
+ @client = options[:client] || Client.new(options)
18
+ end
19
+
20
+ # @return [Client]
21
+ def client
22
+ @client
23
+ end
24
+
25
+ end
26
+ end