aws-sdk-bcmpricingcalculator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
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::BCMPricingCalculator
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute use_fips
14
+ # 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.
15
+ #
16
+ # @return [Boolean]
17
+ #
18
+ # @!attribute endpoint
19
+ # Override the endpoint used to send this request
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @!attribute region
24
+ # The AWS region used to dispatch the request.
25
+ #
26
+ # @return [String]
27
+ #
28
+ EndpointParameters = Struct.new(
29
+ :use_fips,
30
+ :endpoint,
31
+ :region,
32
+ ) do
33
+ include Aws::Structure
34
+
35
+ # @api private
36
+ class << self
37
+ PARAM_MAP = {
38
+ 'UseFIPS' => :use_fips,
39
+ 'Endpoint' => :endpoint,
40
+ 'Region' => :region,
41
+ }.freeze
42
+ end
43
+
44
+ def initialize(options = {})
45
+ self[:use_fips] = options[:use_fips]
46
+ self[:use_fips] = false if self[:use_fips].nil?
47
+ self[:endpoint] = options[:endpoint]
48
+ self[:region] = options[:region]
49
+ end
50
+
51
+ def self.create(config, options={})
52
+ new({
53
+ use_fips: config.use_fips_endpoint,
54
+ endpoint: (config.endpoint.to_s unless config.regional_endpoint),
55
+ region: config.region,
56
+ }.merge(options))
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,35 @@
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::BCMPricingCalculator
11
+ class EndpointProvider
12
+ def resolve_endpoint(parameters)
13
+ use_fips = parameters.use_fips
14
+ endpoint = parameters.endpoint
15
+ region = parameters.region
16
+ if Aws::Endpoints::Matchers.set?(endpoint)
17
+ if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
18
+ raise ArgumentError, "Invalid Configuration: FIPS and custom endpoint are not supported"
19
+ end
20
+ return Aws::Endpoints::Endpoint.new(url: endpoint, headers: {}, properties: {})
21
+ end
22
+ if Aws::Endpoints::Matchers.set?(region)
23
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
24
+ if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
25
+ return Aws::Endpoints::Endpoint.new(url: "https://bcm-pricing-calculator-fips.#{partition_result['implicitGlobalRegion']}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingRegion"=>"#{partition_result['implicitGlobalRegion']}"}]})
26
+ end
27
+ return Aws::Endpoints::Endpoint.new(url: "https://bcm-pricing-calculator.#{partition_result['implicitGlobalRegion']}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingRegion"=>"#{partition_result['implicitGlobalRegion']}"}]})
28
+ end
29
+ end
30
+ raise ArgumentError, "Invalid Configuration: Missing Region"
31
+ raise ArgumentError, 'No endpoint could be resolved'
32
+
33
+ end
34
+ end
35
+ 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::BCMPricingCalculator
12
+ # @api private
13
+ module Endpoints
14
+
15
+
16
+ def self.parameters_for_operation(context)
17
+ Aws::BCMPricingCalculator::EndpointParameters.create(context.config)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,236 @@
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::BCMPricingCalculator
11
+
12
+ # When BCMPricingCalculator returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::BCMPricingCalculator::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all BCMPricingCalculator errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::BCMPricingCalculator::Errors::ServiceError
20
+ # # rescues all BCMPricingCalculator 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
+ # * {DataUnavailableException}
33
+ # * {InternalServerException}
34
+ # * {ResourceNotFoundException}
35
+ # * {ServiceQuotaExceededException}
36
+ # * {ThrottlingException}
37
+ # * {ValidationException}
38
+ #
39
+ # Additionally, error classes are dynamically generated for service errors based on the error code
40
+ # if they are not defined above.
41
+ module Errors
42
+
43
+ extend Aws::Errors::DynamicErrors
44
+
45
+ class AccessDeniedException < ServiceError
46
+
47
+ # @param [Seahorse::Client::RequestContext] context
48
+ # @param [String] message
49
+ # @param [Aws::BCMPricingCalculator::Types::AccessDeniedException] data
50
+ def initialize(context, message, data = Aws::EmptyStructure.new)
51
+ super(context, message, data)
52
+ end
53
+
54
+ # @return [String]
55
+ def message
56
+ @message || @data[:message]
57
+ end
58
+ end
59
+
60
+ class ConflictException < ServiceError
61
+
62
+ # @param [Seahorse::Client::RequestContext] context
63
+ # @param [String] message
64
+ # @param [Aws::BCMPricingCalculator::Types::ConflictException] data
65
+ def initialize(context, message, data = Aws::EmptyStructure.new)
66
+ super(context, message, data)
67
+ end
68
+
69
+ # @return [String]
70
+ def message
71
+ @message || @data[:message]
72
+ end
73
+
74
+ # @return [String]
75
+ def resource_id
76
+ @data[:resource_id]
77
+ end
78
+
79
+ # @return [String]
80
+ def resource_type
81
+ @data[:resource_type]
82
+ end
83
+ end
84
+
85
+ class DataUnavailableException < ServiceError
86
+
87
+ # @param [Seahorse::Client::RequestContext] context
88
+ # @param [String] message
89
+ # @param [Aws::BCMPricingCalculator::Types::DataUnavailableException] data
90
+ def initialize(context, message, data = Aws::EmptyStructure.new)
91
+ super(context, message, data)
92
+ end
93
+
94
+ # @return [String]
95
+ def message
96
+ @message || @data[:message]
97
+ end
98
+ end
99
+
100
+ class InternalServerException < ServiceError
101
+
102
+ # @param [Seahorse::Client::RequestContext] context
103
+ # @param [String] message
104
+ # @param [Aws::BCMPricingCalculator::Types::InternalServerException] data
105
+ def initialize(context, message, data = Aws::EmptyStructure.new)
106
+ super(context, message, data)
107
+ end
108
+
109
+ # @return [String]
110
+ def message
111
+ @message || @data[:message]
112
+ end
113
+
114
+ # @return [String]
115
+ def retry_after_seconds
116
+ @data[:retry_after_seconds]
117
+ end
118
+ end
119
+
120
+ class ResourceNotFoundException < ServiceError
121
+
122
+ # @param [Seahorse::Client::RequestContext] context
123
+ # @param [String] message
124
+ # @param [Aws::BCMPricingCalculator::Types::ResourceNotFoundException] data
125
+ def initialize(context, message, data = Aws::EmptyStructure.new)
126
+ super(context, message, data)
127
+ end
128
+
129
+ # @return [String]
130
+ def message
131
+ @message || @data[:message]
132
+ end
133
+
134
+ # @return [String]
135
+ def resource_id
136
+ @data[:resource_id]
137
+ end
138
+
139
+ # @return [String]
140
+ def resource_type
141
+ @data[:resource_type]
142
+ end
143
+ end
144
+
145
+ class ServiceQuotaExceededException < ServiceError
146
+
147
+ # @param [Seahorse::Client::RequestContext] context
148
+ # @param [String] message
149
+ # @param [Aws::BCMPricingCalculator::Types::ServiceQuotaExceededException] data
150
+ def initialize(context, message, data = Aws::EmptyStructure.new)
151
+ super(context, message, data)
152
+ end
153
+
154
+ # @return [String]
155
+ def message
156
+ @message || @data[:message]
157
+ end
158
+
159
+ # @return [String]
160
+ def resource_id
161
+ @data[:resource_id]
162
+ end
163
+
164
+ # @return [String]
165
+ def resource_type
166
+ @data[:resource_type]
167
+ end
168
+
169
+ # @return [String]
170
+ def service_code
171
+ @data[:service_code]
172
+ end
173
+
174
+ # @return [String]
175
+ def quota_code
176
+ @data[:quota_code]
177
+ end
178
+ end
179
+
180
+ class ThrottlingException < ServiceError
181
+
182
+ # @param [Seahorse::Client::RequestContext] context
183
+ # @param [String] message
184
+ # @param [Aws::BCMPricingCalculator::Types::ThrottlingException] data
185
+ def initialize(context, message, data = Aws::EmptyStructure.new)
186
+ super(context, message, data)
187
+ end
188
+
189
+ # @return [String]
190
+ def message
191
+ @message || @data[:message]
192
+ end
193
+
194
+ # @return [String]
195
+ def service_code
196
+ @data[:service_code]
197
+ end
198
+
199
+ # @return [String]
200
+ def quota_code
201
+ @data[:quota_code]
202
+ end
203
+
204
+ # @return [String]
205
+ def retry_after_seconds
206
+ @data[:retry_after_seconds]
207
+ end
208
+ end
209
+
210
+ class ValidationException < ServiceError
211
+
212
+ # @param [Seahorse::Client::RequestContext] context
213
+ # @param [String] message
214
+ # @param [Aws::BCMPricingCalculator::Types::ValidationException] data
215
+ def initialize(context, message, data = Aws::EmptyStructure.new)
216
+ super(context, message, data)
217
+ end
218
+
219
+ # @return [String]
220
+ def message
221
+ @message || @data[:message]
222
+ end
223
+
224
+ # @return [String]
225
+ def reason
226
+ @data[:reason]
227
+ end
228
+
229
+ # @return [String]
230
+ def field_list
231
+ @data[:field_list]
232
+ end
233
+ end
234
+
235
+ end
236
+ 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::BCMPricingCalculator
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::BCMPricingCalculator::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::BCMPricingCalculator::EndpointParameters`.
22
+ DOCS
23
+ Aws::BCMPricingCalculator::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::BCMPricingCalculator::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::BCMPricingCalculator
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