aws-sdk-costoptimizationhub 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,66 @@
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::CostOptimizationHub
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
+ if self[:use_dual_stack].nil?
56
+ raise ArgumentError, "Missing required EndpointParameter: :use_dual_stack"
57
+ end
58
+ self[:use_fips] = options[:use_fips]
59
+ self[:use_fips] = false if self[:use_fips].nil?
60
+ if self[:use_fips].nil?
61
+ raise ArgumentError, "Missing required EndpointParameter: :use_fips"
62
+ end
63
+ self[:endpoint] = options[:endpoint]
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,54 @@
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::CostOptimizationHub
11
+ class EndpointProvider
12
+ def resolve_endpoint(parameters)
13
+ region = parameters.region
14
+ use_dual_stack = parameters.use_dual_stack
15
+ use_fips = parameters.use_fips
16
+ endpoint = parameters.endpoint
17
+ if Aws::Endpoints::Matchers.set?(endpoint)
18
+ if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
19
+ raise ArgumentError, "Invalid Configuration: FIPS and custom endpoint are not supported"
20
+ end
21
+ if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
22
+ raise ArgumentError, "Invalid Configuration: Dualstack and custom endpoint are not supported"
23
+ end
24
+ return Aws::Endpoints::Endpoint.new(url: endpoint, headers: {}, properties: {})
25
+ end
26
+ if Aws::Endpoints::Matchers.set?(region)
27
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
28
+ if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
29
+ 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"))
30
+ return Aws::Endpoints::Endpoint.new(url: "https://cost-optimization-hub-fips.#{region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
31
+ end
32
+ raise ArgumentError, "FIPS and DualStack are enabled, but this partition does not support one or both"
33
+ end
34
+ if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
35
+ if Aws::Endpoints::Matchers.boolean_equals?(Aws::Endpoints::Matchers.attr(partition_result, "supportsFIPS"), true)
36
+ return Aws::Endpoints::Endpoint.new(url: "https://cost-optimization-hub-fips.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
37
+ end
38
+ raise ArgumentError, "FIPS is enabled but this partition does not support FIPS"
39
+ end
40
+ if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
41
+ if Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsDualStack"))
42
+ return Aws::Endpoints::Endpoint.new(url: "https://cost-optimization-hub.#{region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
43
+ end
44
+ raise ArgumentError, "DualStack is enabled but this partition does not support DualStack"
45
+ end
46
+ return Aws::Endpoints::Endpoint.new(url: "https://cost-optimization-hub.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
47
+ end
48
+ end
49
+ raise ArgumentError, "Invalid Configuration: Missing Region"
50
+ raise ArgumentError, 'No endpoint could be resolved'
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,114 @@
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::CostOptimizationHub
12
+ # @api private
13
+ module Endpoints
14
+
15
+ class GetPreferences
16
+ def self.build(context)
17
+ unless context.config.regional_endpoint
18
+ endpoint = context.config.endpoint.to_s
19
+ end
20
+ Aws::CostOptimizationHub::EndpointParameters.new(
21
+ region: context.config.region,
22
+ use_dual_stack: context.config.use_dualstack_endpoint,
23
+ use_fips: context.config.use_fips_endpoint,
24
+ endpoint: endpoint,
25
+ )
26
+ end
27
+ end
28
+
29
+ class GetRecommendation
30
+ def self.build(context)
31
+ unless context.config.regional_endpoint
32
+ endpoint = context.config.endpoint.to_s
33
+ end
34
+ Aws::CostOptimizationHub::EndpointParameters.new(
35
+ region: context.config.region,
36
+ use_dual_stack: context.config.use_dualstack_endpoint,
37
+ use_fips: context.config.use_fips_endpoint,
38
+ endpoint: endpoint,
39
+ )
40
+ end
41
+ end
42
+
43
+ class ListEnrollmentStatuses
44
+ def self.build(context)
45
+ unless context.config.regional_endpoint
46
+ endpoint = context.config.endpoint.to_s
47
+ end
48
+ Aws::CostOptimizationHub::EndpointParameters.new(
49
+ region: context.config.region,
50
+ use_dual_stack: context.config.use_dualstack_endpoint,
51
+ use_fips: context.config.use_fips_endpoint,
52
+ endpoint: endpoint,
53
+ )
54
+ end
55
+ end
56
+
57
+ class ListRecommendationSummaries
58
+ def self.build(context)
59
+ unless context.config.regional_endpoint
60
+ endpoint = context.config.endpoint.to_s
61
+ end
62
+ Aws::CostOptimizationHub::EndpointParameters.new(
63
+ region: context.config.region,
64
+ use_dual_stack: context.config.use_dualstack_endpoint,
65
+ use_fips: context.config.use_fips_endpoint,
66
+ endpoint: endpoint,
67
+ )
68
+ end
69
+ end
70
+
71
+ class ListRecommendations
72
+ def self.build(context)
73
+ unless context.config.regional_endpoint
74
+ endpoint = context.config.endpoint.to_s
75
+ end
76
+ Aws::CostOptimizationHub::EndpointParameters.new(
77
+ region: context.config.region,
78
+ use_dual_stack: context.config.use_dualstack_endpoint,
79
+ use_fips: context.config.use_fips_endpoint,
80
+ endpoint: endpoint,
81
+ )
82
+ end
83
+ end
84
+
85
+ class UpdateEnrollmentStatus
86
+ def self.build(context)
87
+ unless context.config.regional_endpoint
88
+ endpoint = context.config.endpoint.to_s
89
+ end
90
+ Aws::CostOptimizationHub::EndpointParameters.new(
91
+ region: context.config.region,
92
+ use_dual_stack: context.config.use_dualstack_endpoint,
93
+ use_fips: context.config.use_fips_endpoint,
94
+ endpoint: endpoint,
95
+ )
96
+ end
97
+ end
98
+
99
+ class UpdatePreferences
100
+ def self.build(context)
101
+ unless context.config.regional_endpoint
102
+ endpoint = context.config.endpoint.to_s
103
+ end
104
+ Aws::CostOptimizationHub::EndpointParameters.new(
105
+ region: context.config.region,
106
+ use_dual_stack: context.config.use_dualstack_endpoint,
107
+ use_fips: context.config.use_fips_endpoint,
108
+ endpoint: endpoint,
109
+ )
110
+ end
111
+ end
112
+
113
+ end
114
+ end
@@ -0,0 +1,133 @@
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::CostOptimizationHub
11
+
12
+ # When CostOptimizationHub returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::CostOptimizationHub::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all CostOptimizationHub errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::CostOptimizationHub::Errors::ServiceError
20
+ # # rescues all CostOptimizationHub 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
+ # * {InternalServerException}
32
+ # * {ResourceNotFoundException}
33
+ # * {ThrottlingException}
34
+ # * {ValidationException}
35
+ #
36
+ # Additionally, error classes are dynamically generated for service errors based on the error code
37
+ # if they are not defined above.
38
+ module Errors
39
+
40
+ extend Aws::Errors::DynamicErrors
41
+
42
+ class AccessDeniedException < ServiceError
43
+
44
+ # @param [Seahorse::Client::RequestContext] context
45
+ # @param [String] message
46
+ # @param [Aws::CostOptimizationHub::Types::AccessDeniedException] data
47
+ def initialize(context, message, data = Aws::EmptyStructure.new)
48
+ super(context, message, data)
49
+ end
50
+
51
+ # @return [String]
52
+ def message
53
+ @message || @data[:message]
54
+ end
55
+ end
56
+
57
+ class InternalServerException < ServiceError
58
+
59
+ # @param [Seahorse::Client::RequestContext] context
60
+ # @param [String] message
61
+ # @param [Aws::CostOptimizationHub::Types::InternalServerException] data
62
+ def initialize(context, message, data = Aws::EmptyStructure.new)
63
+ super(context, message, data)
64
+ end
65
+
66
+ # @return [String]
67
+ def message
68
+ @message || @data[:message]
69
+ end
70
+ end
71
+
72
+ class ResourceNotFoundException < ServiceError
73
+
74
+ # @param [Seahorse::Client::RequestContext] context
75
+ # @param [String] message
76
+ # @param [Aws::CostOptimizationHub::Types::ResourceNotFoundException] data
77
+ def initialize(context, message, data = Aws::EmptyStructure.new)
78
+ super(context, message, data)
79
+ end
80
+
81
+ # @return [String]
82
+ def message
83
+ @message || @data[:message]
84
+ end
85
+
86
+ # @return [String]
87
+ def resource_id
88
+ @data[:resource_id]
89
+ end
90
+ end
91
+
92
+ class ThrottlingException < ServiceError
93
+
94
+ # @param [Seahorse::Client::RequestContext] context
95
+ # @param [String] message
96
+ # @param [Aws::CostOptimizationHub::Types::ThrottlingException] data
97
+ def initialize(context, message, data = Aws::EmptyStructure.new)
98
+ super(context, message, data)
99
+ end
100
+
101
+ # @return [String]
102
+ def message
103
+ @message || @data[:message]
104
+ end
105
+ end
106
+
107
+ class ValidationException < ServiceError
108
+
109
+ # @param [Seahorse::Client::RequestContext] context
110
+ # @param [String] message
111
+ # @param [Aws::CostOptimizationHub::Types::ValidationException] data
112
+ def initialize(context, message, data = Aws::EmptyStructure.new)
113
+ super(context, message, data)
114
+ end
115
+
116
+ # @return [String]
117
+ def fields
118
+ @data[:fields]
119
+ end
120
+
121
+ # @return [String]
122
+ def message
123
+ @message || @data[:message]
124
+ end
125
+
126
+ # @return [String]
127
+ def reason
128
+ @data[:reason]
129
+ end
130
+ end
131
+
132
+ end
133
+ end
@@ -0,0 +1,82 @@
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::CostOptimizationHub
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::CostOptimizationHub::EndpointProvider',
17
+ docstring: 'The endpoint provider used to resolve endpoints. Any '\
18
+ 'object that responds to `#resolve_endpoint(parameters)` '\
19
+ 'where `parameters` is a Struct similar to '\
20
+ '`Aws::CostOptimizationHub::EndpointParameters`'
21
+ ) do |cfg|
22
+ Aws::CostOptimizationHub::EndpointProvider.new
23
+ end
24
+
25
+ # @api private
26
+ class Handler < Seahorse::Client::Handler
27
+ def call(context)
28
+ # If endpoint was discovered, do not resolve or apply the endpoint.
29
+ unless context[:discovered_endpoint]
30
+ params = 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
+ end
36
+
37
+ context[:endpoint_params] = params
38
+ context[:auth_scheme] =
39
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
40
+
41
+ @handler.call(context)
42
+ end
43
+
44
+ private
45
+
46
+ def apply_endpoint_headers(context, headers)
47
+ headers.each do |key, values|
48
+ value = values
49
+ .compact
50
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
51
+ .join(',')
52
+
53
+ context.http_request.headers[key] = value
54
+ end
55
+ end
56
+
57
+ def parameters_for_operation(context)
58
+ case context.operation_name
59
+ when :get_preferences
60
+ Aws::CostOptimizationHub::Endpoints::GetPreferences.build(context)
61
+ when :get_recommendation
62
+ Aws::CostOptimizationHub::Endpoints::GetRecommendation.build(context)
63
+ when :list_enrollment_statuses
64
+ Aws::CostOptimizationHub::Endpoints::ListEnrollmentStatuses.build(context)
65
+ when :list_recommendation_summaries
66
+ Aws::CostOptimizationHub::Endpoints::ListRecommendationSummaries.build(context)
67
+ when :list_recommendations
68
+ Aws::CostOptimizationHub::Endpoints::ListRecommendations.build(context)
69
+ when :update_enrollment_status
70
+ Aws::CostOptimizationHub::Endpoints::UpdateEnrollmentStatus.build(context)
71
+ when :update_preferences
72
+ Aws::CostOptimizationHub::Endpoints::UpdatePreferences.build(context)
73
+ end
74
+ end
75
+ end
76
+
77
+ def add_handlers(handlers, _config)
78
+ handlers.add(Handler, step: :build, priority: 75)
79
+ end
80
+ end
81
+ end
82
+ 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::CostOptimizationHub
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