aws-sdk-sustainability 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.
@@ -0,0 +1,187 @@
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::Sustainability
12
+ # @api private
13
+ module ClientApi
14
+
15
+ include Seahorse::Model
16
+
17
+ AccessDeniedException = Shapes::StructureShape.new(name: 'AccessDeniedException')
18
+ Dimension = Shapes::StringShape.new(name: 'Dimension')
19
+ DimensionEntry = Shapes::StructureShape.new(name: 'DimensionEntry')
20
+ DimensionEntryList = Shapes::ListShape.new(name: 'DimensionEntryList')
21
+ DimensionList = Shapes::ListShape.new(name: 'DimensionList')
22
+ DimensionListMap = Shapes::MapShape.new(name: 'DimensionListMap')
23
+ DimensionValueList = Shapes::ListShape.new(name: 'DimensionValueList')
24
+ DimensionsMap = Shapes::MapShape.new(name: 'DimensionsMap')
25
+ Double = Shapes::FloatShape.new(name: 'Double')
26
+ Emissions = Shapes::StructureShape.new(name: 'Emissions')
27
+ EmissionsMap = Shapes::MapShape.new(name: 'EmissionsMap')
28
+ EmissionsType = Shapes::StringShape.new(name: 'EmissionsType')
29
+ EmissionsTypeList = Shapes::ListShape.new(name: 'EmissionsTypeList')
30
+ EmissionsUnit = Shapes::StringShape.new(name: 'EmissionsUnit')
31
+ EstimatedCarbonEmissions = Shapes::StructureShape.new(name: 'EstimatedCarbonEmissions')
32
+ EstimatedCarbonEmissionsList = Shapes::ListShape.new(name: 'EstimatedCarbonEmissionsList')
33
+ FilterExpression = Shapes::StructureShape.new(name: 'FilterExpression')
34
+ GetEstimatedCarbonEmissionsDimensionValuesRequest = Shapes::StructureShape.new(name: 'GetEstimatedCarbonEmissionsDimensionValuesRequest')
35
+ GetEstimatedCarbonEmissionsDimensionValuesResponse = Shapes::StructureShape.new(name: 'GetEstimatedCarbonEmissionsDimensionValuesResponse')
36
+ GetEstimatedCarbonEmissionsRequest = Shapes::StructureShape.new(name: 'GetEstimatedCarbonEmissionsRequest')
37
+ GetEstimatedCarbonEmissionsResponse = Shapes::StructureShape.new(name: 'GetEstimatedCarbonEmissionsResponse')
38
+ GranularityConfiguration = Shapes::StructureShape.new(name: 'GranularityConfiguration')
39
+ InternalServerException = Shapes::StructureShape.new(name: 'InternalServerException')
40
+ MaxResults = Shapes::IntegerShape.new(name: 'MaxResults')
41
+ ModelVersion = Shapes::StringShape.new(name: 'ModelVersion')
42
+ Month = Shapes::IntegerShape.new(name: 'Month')
43
+ NextToken = Shapes::StringShape.new(name: 'NextToken')
44
+ String = Shapes::StringShape.new(name: 'String')
45
+ ThrottlingException = Shapes::StructureShape.new(name: 'ThrottlingException')
46
+ TimeGranularity = Shapes::StringShape.new(name: 'TimeGranularity')
47
+ TimePeriod = Shapes::StructureShape.new(name: 'TimePeriod')
48
+ Timestamp = Shapes::TimestampShape.new(name: 'Timestamp', timestampFormat: "iso8601")
49
+ ValidationException = Shapes::StructureShape.new(name: 'ValidationException')
50
+
51
+ AccessDeniedException.add_member(:message, Shapes::ShapeRef.new(shape: String, required: true, location_name: "message"))
52
+ AccessDeniedException.struct_class = Types::AccessDeniedException
53
+
54
+ DimensionEntry.add_member(:dimension, Shapes::ShapeRef.new(shape: Dimension, required: true, location_name: "Dimension"))
55
+ DimensionEntry.add_member(:value, Shapes::ShapeRef.new(shape: String, required: true, location_name: "Value"))
56
+ DimensionEntry.struct_class = Types::DimensionEntry
57
+
58
+ DimensionEntryList.member = Shapes::ShapeRef.new(shape: DimensionEntry)
59
+
60
+ DimensionList.member = Shapes::ShapeRef.new(shape: Dimension)
61
+
62
+ DimensionListMap.key = Shapes::ShapeRef.new(shape: Dimension)
63
+ DimensionListMap.value = Shapes::ShapeRef.new(shape: DimensionValueList)
64
+
65
+ DimensionValueList.member = Shapes::ShapeRef.new(shape: String)
66
+
67
+ DimensionsMap.key = Shapes::ShapeRef.new(shape: Dimension)
68
+ DimensionsMap.value = Shapes::ShapeRef.new(shape: String)
69
+
70
+ Emissions.add_member(:value, Shapes::ShapeRef.new(shape: Double, required: true, location_name: "Value"))
71
+ Emissions.add_member(:unit, Shapes::ShapeRef.new(shape: EmissionsUnit, required: true, location_name: "Unit"))
72
+ Emissions.struct_class = Types::Emissions
73
+
74
+ EmissionsMap.key = Shapes::ShapeRef.new(shape: EmissionsType)
75
+ EmissionsMap.value = Shapes::ShapeRef.new(shape: Emissions)
76
+
77
+ EmissionsTypeList.member = Shapes::ShapeRef.new(shape: EmissionsType)
78
+
79
+ EstimatedCarbonEmissions.add_member(:time_period, Shapes::ShapeRef.new(shape: TimePeriod, required: true, location_name: "TimePeriod"))
80
+ EstimatedCarbonEmissions.add_member(:dimensions_values, Shapes::ShapeRef.new(shape: DimensionsMap, required: true, location_name: "DimensionsValues"))
81
+ EstimatedCarbonEmissions.add_member(:model_version, Shapes::ShapeRef.new(shape: ModelVersion, required: true, location_name: "ModelVersion"))
82
+ EstimatedCarbonEmissions.add_member(:emissions_values, Shapes::ShapeRef.new(shape: EmissionsMap, required: true, location_name: "EmissionsValues"))
83
+ EstimatedCarbonEmissions.struct_class = Types::EstimatedCarbonEmissions
84
+
85
+ EstimatedCarbonEmissionsList.member = Shapes::ShapeRef.new(shape: EstimatedCarbonEmissions)
86
+
87
+ FilterExpression.add_member(:dimensions, Shapes::ShapeRef.new(shape: DimensionListMap, location_name: "Dimensions"))
88
+ FilterExpression.struct_class = Types::FilterExpression
89
+
90
+ GetEstimatedCarbonEmissionsDimensionValuesRequest.add_member(:time_period, Shapes::ShapeRef.new(shape: TimePeriod, required: true, location_name: "TimePeriod"))
91
+ GetEstimatedCarbonEmissionsDimensionValuesRequest.add_member(:dimensions, Shapes::ShapeRef.new(shape: DimensionList, required: true, location_name: "Dimensions"))
92
+ GetEstimatedCarbonEmissionsDimensionValuesRequest.add_member(:max_results, Shapes::ShapeRef.new(shape: MaxResults, location_name: "MaxResults"))
93
+ GetEstimatedCarbonEmissionsDimensionValuesRequest.add_member(:next_token, Shapes::ShapeRef.new(shape: NextToken, location_name: "NextToken"))
94
+ GetEstimatedCarbonEmissionsDimensionValuesRequest.struct_class = Types::GetEstimatedCarbonEmissionsDimensionValuesRequest
95
+
96
+ GetEstimatedCarbonEmissionsDimensionValuesResponse.add_member(:results, Shapes::ShapeRef.new(shape: DimensionEntryList, location_name: "Results"))
97
+ GetEstimatedCarbonEmissionsDimensionValuesResponse.add_member(:next_token, Shapes::ShapeRef.new(shape: NextToken, location_name: "NextToken"))
98
+ GetEstimatedCarbonEmissionsDimensionValuesResponse.struct_class = Types::GetEstimatedCarbonEmissionsDimensionValuesResponse
99
+
100
+ GetEstimatedCarbonEmissionsRequest.add_member(:time_period, Shapes::ShapeRef.new(shape: TimePeriod, required: true, location_name: "TimePeriod"))
101
+ GetEstimatedCarbonEmissionsRequest.add_member(:group_by, Shapes::ShapeRef.new(shape: DimensionList, location_name: "GroupBy"))
102
+ GetEstimatedCarbonEmissionsRequest.add_member(:filter_by, Shapes::ShapeRef.new(shape: FilterExpression, location_name: "FilterBy"))
103
+ GetEstimatedCarbonEmissionsRequest.add_member(:emissions_types, Shapes::ShapeRef.new(shape: EmissionsTypeList, location_name: "EmissionsTypes"))
104
+ GetEstimatedCarbonEmissionsRequest.add_member(:granularity, Shapes::ShapeRef.new(shape: TimeGranularity, location_name: "Granularity"))
105
+ GetEstimatedCarbonEmissionsRequest.add_member(:granularity_configuration, Shapes::ShapeRef.new(shape: GranularityConfiguration, location_name: "GranularityConfiguration"))
106
+ GetEstimatedCarbonEmissionsRequest.add_member(:max_results, Shapes::ShapeRef.new(shape: MaxResults, location_name: "MaxResults"))
107
+ GetEstimatedCarbonEmissionsRequest.add_member(:next_token, Shapes::ShapeRef.new(shape: NextToken, location_name: "NextToken"))
108
+ GetEstimatedCarbonEmissionsRequest.struct_class = Types::GetEstimatedCarbonEmissionsRequest
109
+
110
+ GetEstimatedCarbonEmissionsResponse.add_member(:results, Shapes::ShapeRef.new(shape: EstimatedCarbonEmissionsList, required: true, location_name: "Results"))
111
+ GetEstimatedCarbonEmissionsResponse.add_member(:next_token, Shapes::ShapeRef.new(shape: NextToken, location_name: "NextToken"))
112
+ GetEstimatedCarbonEmissionsResponse.struct_class = Types::GetEstimatedCarbonEmissionsResponse
113
+
114
+ GranularityConfiguration.add_member(:fiscal_year_start_month, Shapes::ShapeRef.new(shape: Month, location_name: "FiscalYearStartMonth"))
115
+ GranularityConfiguration.struct_class = Types::GranularityConfiguration
116
+
117
+ InternalServerException.add_member(:message, Shapes::ShapeRef.new(shape: String, required: true, location_name: "message"))
118
+ InternalServerException.struct_class = Types::InternalServerException
119
+
120
+ ThrottlingException.add_member(:message, Shapes::ShapeRef.new(shape: String, required: true, location_name: "message"))
121
+ ThrottlingException.struct_class = Types::ThrottlingException
122
+
123
+ TimePeriod.add_member(:start, Shapes::ShapeRef.new(shape: Timestamp, required: true, location_name: "Start"))
124
+ TimePeriod.add_member(:end, Shapes::ShapeRef.new(shape: Timestamp, required: true, location_name: "End"))
125
+ TimePeriod.struct_class = Types::TimePeriod
126
+
127
+ ValidationException.add_member(:message, Shapes::ShapeRef.new(shape: String, required: true, location_name: "message"))
128
+ ValidationException.struct_class = Types::ValidationException
129
+
130
+
131
+ # @api private
132
+ API = Seahorse::Model::Api.new.tap do |api|
133
+
134
+ api.version = "2018-05-10"
135
+
136
+ api.metadata = {
137
+ "apiVersion" => "2018-05-10",
138
+ "auth" => ["aws.auth#sigv4a", "aws.auth#sigv4"],
139
+ "endpointPrefix" => "sustainability",
140
+ "protocol" => "rest-json",
141
+ "protocols" => ["rest-json"],
142
+ "serviceFullName" => "AWS Sustainability",
143
+ "serviceId" => "Sustainability",
144
+ "signatureVersion" => "v4",
145
+ "signingName" => "sustainability",
146
+ "uid" => "sustainability-2018-05-10",
147
+ }
148
+
149
+ api.add_operation(:get_estimated_carbon_emissions, Seahorse::Model::Operation.new.tap do |o|
150
+ o.name = "GetEstimatedCarbonEmissions"
151
+ o.http_method = "POST"
152
+ o.http_request_uri = "/v1/estimated-carbon-emissions"
153
+ o.input = Shapes::ShapeRef.new(shape: GetEstimatedCarbonEmissionsRequest)
154
+ o.output = Shapes::ShapeRef.new(shape: GetEstimatedCarbonEmissionsResponse)
155
+ o.errors << Shapes::ShapeRef.new(shape: ValidationException)
156
+ o.errors << Shapes::ShapeRef.new(shape: InternalServerException)
157
+ o.errors << Shapes::ShapeRef.new(shape: AccessDeniedException)
158
+ o.errors << Shapes::ShapeRef.new(shape: ThrottlingException)
159
+ o[:pager] = Aws::Pager.new(
160
+ limit_key: "max_results",
161
+ tokens: {
162
+ "next_token" => "next_token"
163
+ }
164
+ )
165
+ end)
166
+
167
+ api.add_operation(:get_estimated_carbon_emissions_dimension_values, Seahorse::Model::Operation.new.tap do |o|
168
+ o.name = "GetEstimatedCarbonEmissionsDimensionValues"
169
+ o.http_method = "POST"
170
+ o.http_request_uri = "/v1/estimated-carbon-emissions-dimension-values"
171
+ o.input = Shapes::ShapeRef.new(shape: GetEstimatedCarbonEmissionsDimensionValuesRequest)
172
+ o.output = Shapes::ShapeRef.new(shape: GetEstimatedCarbonEmissionsDimensionValuesResponse)
173
+ o.errors << Shapes::ShapeRef.new(shape: ValidationException)
174
+ o.errors << Shapes::ShapeRef.new(shape: InternalServerException)
175
+ o.errors << Shapes::ShapeRef.new(shape: AccessDeniedException)
176
+ o.errors << Shapes::ShapeRef.new(shape: ThrottlingException)
177
+ o[:pager] = Aws::Pager.new(
178
+ limit_key: "max_results",
179
+ tokens: {
180
+ "next_token" => "next_token"
181
+ }
182
+ )
183
+ end)
184
+ end
185
+
186
+ end
187
+ end
File without changes
@@ -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::Sustainability
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,41 @@
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::Sustainability
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
+ return Aws::Endpoints::Endpoint.new(url: parameters.endpoint, headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4"}]})
18
+ end
19
+ if Aws::Endpoints::Matchers.set?(parameters.region)
20
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
21
+ if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws") && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, false)
22
+ return Aws::Endpoints::Endpoint.new(url: "https://api.sustainability.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4", "signingRegion" => "us-east-1"}]})
23
+ end
24
+ if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-us-gov") && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, false)
25
+ return Aws::Endpoints::Endpoint.new(url: "https://sustainability.us-gov.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4", "signingRegion" => "us-gov-west-1"}]})
26
+ end
27
+ if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-us-gov") && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
28
+ return Aws::Endpoints::Endpoint.new(url: "https://sustainability-fips.us-gov.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4", "signingRegion" => "us-gov-west-1"}]})
29
+ end
30
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
31
+ return Aws::Endpoints::Endpoint.new(url: "https://sustainability-fips.global.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4", "signingRegion" => "#{partition_result['implicitGlobalRegion']}"}]})
32
+ end
33
+ return Aws::Endpoints::Endpoint.new(url: "https://sustainability.global.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4a", "signingRegionSet" => ["*"]}, {"name" => "sigv4", "signingRegion" => "#{partition_result['implicitGlobalRegion']}"}]})
34
+ end
35
+ end
36
+ raise ArgumentError, "Invalid Configuration: Missing Region"
37
+ raise ArgumentError, 'No endpoint could be resolved'
38
+
39
+ end
40
+ end
41
+ 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::Sustainability
12
+ # @api private
13
+ module Endpoints
14
+
15
+
16
+ def self.parameters_for_operation(context)
17
+ Aws::Sustainability::EndpointParameters.create(context.config)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,110 @@
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::Sustainability
11
+
12
+ # When Sustainability returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::Sustainability::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all Sustainability errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::Sustainability::Errors::ServiceError
20
+ # # rescues all Sustainability 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
+ # * {ThrottlingException}
33
+ # * {ValidationException}
34
+ #
35
+ # Additionally, error classes are dynamically generated for service errors based on the error code
36
+ # if they are not defined above.
37
+ module Errors
38
+
39
+ extend Aws::Errors::DynamicErrors
40
+
41
+ class AccessDeniedException < ServiceError
42
+
43
+ # @param [Seahorse::Client::RequestContext] context
44
+ # @param [String] message
45
+ # @param [Aws::Sustainability::Types::AccessDeniedException] data
46
+ def initialize(context, message, data = Aws::EmptyStructure.new)
47
+ super(context, message, data)
48
+ end
49
+
50
+ # @return [String]
51
+ def message
52
+ @message || @data[:message]
53
+ end
54
+ end
55
+
56
+ class InternalServerException < ServiceError
57
+
58
+ # @param [Seahorse::Client::RequestContext] context
59
+ # @param [String] message
60
+ # @param [Aws::Sustainability::Types::InternalServerException] data
61
+ def initialize(context, message, data = Aws::EmptyStructure.new)
62
+ super(context, message, data)
63
+ end
64
+
65
+ # @return [String]
66
+ def message
67
+ @message || @data[:message]
68
+ end
69
+
70
+ def retryable?
71
+ true
72
+ end
73
+ end
74
+
75
+ class ThrottlingException < ServiceError
76
+
77
+ # @param [Seahorse::Client::RequestContext] context
78
+ # @param [String] message
79
+ # @param [Aws::Sustainability::Types::ThrottlingException] data
80
+ def initialize(context, message, data = Aws::EmptyStructure.new)
81
+ super(context, message, data)
82
+ end
83
+
84
+ # @return [String]
85
+ def message
86
+ @message || @data[:message]
87
+ end
88
+
89
+ def retryable?
90
+ true
91
+ end
92
+ end
93
+
94
+ class ValidationException < ServiceError
95
+
96
+ # @param [Seahorse::Client::RequestContext] context
97
+ # @param [String] message
98
+ # @param [Aws::Sustainability::Types::ValidationException] data
99
+ def initialize(context, message, data = Aws::EmptyStructure.new)
100
+ super(context, message, data)
101
+ end
102
+
103
+ # @return [String]
104
+ def message
105
+ @message || @data[:message]
106
+ end
107
+ end
108
+
109
+ end
110
+ 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::Sustainability
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::Sustainability::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::Sustainability::EndpointParameters`.
22
+ DOCS
23
+ Aws::Sustainability::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::Sustainability::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::Sustainability
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