fix(region): vendor update (#24609)

This commit is contained in:
屈轩
2026-04-02 10:34:51 +08:00
committed by GitHub
parent f73e975920
commit 54a98594be
105 changed files with 46479 additions and 343 deletions
+4
View File
@@ -118,6 +118,10 @@ const (
CredentialSourceHTTP
// CredentialSourceIMDS credentials resolved from the instance metadata service (IMDS)
CredentialSourceIMDS
// CredentialSourceProfileLogin credentials resolved from an `aws login` session sourced from a profile
CredentialSourceProfileLogin
// CredentialSourceLogin credentials resolved from an `aws login` session
CredentialSourceLogin
)
// A Credentials is the AWS credentials value for individual credential fields.
+1 -1
View File
@@ -3,4 +3,4 @@
package aws
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.39.2"
const goModuleVersion = "1.41.4"
+5
View File
@@ -137,6 +137,9 @@ const (
UserAgentFeatureCredentialsIMDS = "0"
UserAgentFeatureBearerServiceEnvVars = "3"
UserAgentFeatureCredentialsProfileLogin = "AC"
UserAgentFeatureCredentialsLogin = "AD"
)
var credentialSourceToFeature = map[aws.CredentialSource]UserAgentFeature{
@@ -160,6 +163,8 @@ var credentialSourceToFeature = map[aws.CredentialSource]UserAgentFeature{
aws.CredentialSourceProcess: UserAgentFeatureCredentialsProcess,
aws.CredentialSourceHTTP: UserAgentFeatureCredentialsHTTP,
aws.CredentialSourceIMDS: UserAgentFeatureCredentialsIMDS,
aws.CredentialSourceProfileLogin: UserAgentFeatureCredentialsProfileLogin,
aws.CredentialSourceLogin: UserAgentFeatureCredentialsLogin,
}
// RequestUserAgent is a build middleware that set the User-Agent for the request.
+2 -2
View File
@@ -3,7 +3,7 @@ package query
import (
"context"
"fmt"
"io/ioutil"
"io"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
@@ -52,7 +52,7 @@ func (m *asGetRequest) HandleSerialize(
delim = "&"
}
b, err := ioutil.ReadAll(stream)
b, err := io.ReadAll(stream)
if err != nil {
return out, metadata, fmt.Errorf("unable to get request body %w", err)
}
+13
View File
@@ -18,6 +18,7 @@ var (
// Default connection pool options
DefaultHTTPTransportMaxIdleConns = 100
DefaultHTTPTransportMaxIdleConnsPerHost = 10
DefaultHTTPTransportMaxConnsPerHost = 2048
// Default connection timeouts
DefaultHTTPTransportIdleConnTimeout = 90 * time.Second
@@ -186,6 +187,7 @@ func defaultHTTPTransport() *http.Transport {
TLSHandshakeTimeout: DefaultHTTPTransportTLSHandleshakeTimeout,
MaxIdleConns: DefaultHTTPTransportMaxIdleConns,
MaxIdleConnsPerHost: DefaultHTTPTransportMaxIdleConnsPerHost,
MaxConnsPerHost: DefaultHTTPTransportMaxConnsPerHost,
IdleConnTimeout: DefaultHTTPTransportIdleConnTimeout,
ExpectContinueTimeout: DefaultHTTPTransportExpectContinueTimeout,
ForceAttemptHTTP2: true,
@@ -298,6 +300,17 @@ func limitedRedirect(r *http.Request, via []*http.Request) error {
switch resp.StatusCode {
case 307, 308:
// Only allow 307 and 308 redirects as they preserve the method.
// If redirecting to a different host, remove X-Amz-Security-Token header
// to prevent credentials from being sent to a different host, similar to
// how Authorization header is handled by the HTTP client.
if len(via) > 0 {
lastRequest := via[len(via)-1]
if lastRequest.URL.Host != r.URL.Host {
r.Header.Del("X-Amz-Security-Token")
}
}
return nil
}
@@ -64,6 +64,11 @@ func (r *timeoutReadCloser) Close() error {
// AddResponseReadTimeoutMiddleware adds a middleware to the stack that wraps the
// response body so that a read that takes too long will return an error.
//
// Deprecated: This API was previously exposed to customize behavior of the
// Kinesis service. That customization has been removed and this middleware's
// implementation can cause panics within the standard library networking loop.
// See #2752.
func AddResponseReadTimeoutMiddleware(stack *middleware.Stack, duration time.Duration) error {
return stack.Deserialize.Add(&readTimeout{duration: duration}, middleware.After)
}
@@ -1,3 +1,52 @@
# v1.4.20 (2026-03-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.19 (2026-03-03)
* **Bug Fix**: Modernize non codegen files with go fix
* **Dependency Update**: Bump minimum Go version to 1.24
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.18 (2026-02-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.17 (2026-01-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.16 (2025-12-08)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.15 (2025-12-02)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.24.0. Notably this version of the library reduces the allocation footprint of the middleware system. We observe a ~10% reduction in allocations per SDK call with this change.
# v1.4.14 (2025-11-19.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.13 (2025-11-04)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.23.2 which should convey some passive reduction of overall allocations, especially when not using the metrics system.
# v1.4.12 (2025-10-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.11 (2025-10-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.10 (2025-10-16)
* **Dependency Update**: Bump minimum Go version to 1.23.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.4.9 (2025-09-26)
* **Dependency Update**: Updated to the latest SDK module versions
+3 -3
View File
@@ -14,7 +14,7 @@ type EnableEndpointDiscoveryProvider interface {
// ResolveEnableEndpointDiscovery extracts the first instance of a EnableEndpointDiscoveryProvider from the config slice.
// Additionally returns a aws.EndpointDiscoveryEnableState to indicate if the value was found in provided configs,
// and error if one is encountered.
func ResolveEnableEndpointDiscovery(ctx context.Context, configs []interface{}) (value aws.EndpointDiscoveryEnableState, found bool, err error) {
func ResolveEnableEndpointDiscovery(ctx context.Context, configs []any) (value aws.EndpointDiscoveryEnableState, found bool, err error) {
for _, cfg := range configs {
if p, ok := cfg.(EnableEndpointDiscoveryProvider); ok {
value, found, err = p.GetEnableEndpointDiscovery(ctx)
@@ -33,7 +33,7 @@ type UseDualStackEndpointProvider interface {
// ResolveUseDualStackEndpoint extracts the first instance of a UseDualStackEndpoint from the config slice.
// Additionally returns a boolean to indicate if the value was found in provided configs, and error if one is encountered.
func ResolveUseDualStackEndpoint(ctx context.Context, configs []interface{}) (value aws.DualStackEndpointState, found bool, err error) {
func ResolveUseDualStackEndpoint(ctx context.Context, configs []any) (value aws.DualStackEndpointState, found bool, err error) {
for _, cfg := range configs {
if p, ok := cfg.(UseDualStackEndpointProvider); ok {
value, found, err = p.GetUseDualStackEndpoint(ctx)
@@ -52,7 +52,7 @@ type UseFIPSEndpointProvider interface {
// ResolveUseFIPSEndpoint extracts the first instance of a UseFIPSEndpointProvider from the config slice.
// Additionally, returns a boolean to indicate if the value was found in provided configs, and error if one is encountered.
func ResolveUseFIPSEndpoint(ctx context.Context, configs []interface{}) (value aws.FIPSEndpointState, found bool, err error) {
func ResolveUseFIPSEndpoint(ctx context.Context, configs []any) (value aws.FIPSEndpointState, found bool, err error) {
for _, cfg := range configs {
if p, ok := cfg.(UseFIPSEndpointProvider); ok {
value, found, err = p.GetUseFIPSEndpoint(ctx)
+2 -2
View File
@@ -26,7 +26,7 @@ type IgnoreConfiguredEndpointsProvider interface {
// Currently duplicated from github.com/aws/aws-sdk-go-v2/config because
// service packages cannot import github.com/aws/aws-sdk-go-v2/config
// due to result import cycle error.
func GetIgnoreConfiguredEndpoints(ctx context.Context, configs []interface{}) (value bool, found bool, err error) {
func GetIgnoreConfiguredEndpoints(ctx context.Context, configs []any) (value bool, found bool, err error) {
for _, cfg := range configs {
if p, ok := cfg.(IgnoreConfiguredEndpointsProvider); ok {
value, found, err = p.GetIgnoreConfiguredEndpoints(ctx)
@@ -40,7 +40,7 @@ func GetIgnoreConfiguredEndpoints(ctx context.Context, configs []interface{}) (v
// ResolveServiceBaseEndpoint is used to retrieve service endpoints from configured sources
// while allowing for configured endpoints to be disabled
func ResolveServiceBaseEndpoint(ctx context.Context, sdkID string, configs []interface{}) (value string, found bool, err error) {
func ResolveServiceBaseEndpoint(ctx context.Context, sdkID string, configs []any) (value string, found bool, err error) {
if val, found, _ := GetIgnoreConfiguredEndpoints(ctx, configs); found && val {
return "", false, nil
}
@@ -3,4 +3,4 @@
package configsources
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.4.9"
const goModuleVersion = "1.4.20"
@@ -386,6 +386,13 @@ var partitions = []Partition{
SupportsFIPS: nil,
SupportsDualStack: nil,
},
"us-isob-west-1": {
Name: nil,
DnsSuffix: nil,
DualStackDnsSuffix: nil,
SupportsFIPS: nil,
SupportsDualStack: nil,
},
},
},
{
@@ -152,7 +152,7 @@
"regionRegex" : "^eusc\\-(de)\\-\\w+\\-\\d+$",
"regions" : {
"eusc-de-east-1" : {
"description" : "EU (Germany)"
"description" : "AWS European Sovereign Cloud (Germany)"
}
}
}, {
@@ -194,6 +194,9 @@
},
"us-isob-east-1" : {
"description" : "US ISOB East (Ohio)"
},
"us-isob-west-1" : {
"description" : "US ISOB West"
}
}
}, {
+49
View File
@@ -1,3 +1,52 @@
# v2.7.20 (2026-03-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.19 (2026-03-03)
* **Bug Fix**: Modernize non codegen files with go fix
* **Dependency Update**: Bump minimum Go version to 1.24
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.18 (2026-02-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.17 (2026-01-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.16 (2025-12-08)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.15 (2025-12-02)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.24.0. Notably this version of the library reduces the allocation footprint of the middleware system. We observe a ~10% reduction in allocations per SDK call with this change.
# v2.7.14 (2025-11-19.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.13 (2025-11-04)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.23.2 which should convey some passive reduction of overall allocations, especially when not using the metrics system.
# v2.7.12 (2025-10-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.11 (2025-10-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.10 (2025-10-16)
* **Dependency Update**: Bump minimum Go version to 1.23.
* **Dependency Update**: Updated to the latest SDK module versions
# v2.7.9 (2025-09-26)
* **Dependency Update**: Updated to the latest SDK module versions
+3 -3
View File
@@ -101,7 +101,7 @@ func (ps Partitions) ResolveEndpoint(region string, opts Options) (aws.Endpoint,
region = opts.ResolvedRegion
}
for i := 0; i < len(ps); i++ {
for i := range ps {
if !ps[i].canResolveEndpoint(region, opts) {
continue
}
@@ -290,8 +290,8 @@ func getByPriority(s []string, p []string, def string) string {
return def
}
for i := 0; i < len(p); i++ {
for j := 0; j < len(s); j++ {
for i := range p {
for j := range s {
if s[j] == p[i] {
return s[j]
}
@@ -3,4 +3,4 @@
package endpoints
// goModuleVersion is the tagged release for this module
const goModuleVersion = "2.7.9"
const goModuleVersion = "2.7.20"
+789
View File
@@ -0,0 +1,789 @@
# v1.63.5 (2026-03-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.63.4 (2026-03-03)
* **Dependency Update**: Bump minimum Go version to 1.24
* **Dependency Update**: Updated to the latest SDK module versions
# v1.63.3 (2026-02-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.63.2 (2026-01-14)
* **Documentation**: Cost Categories added support to BillingView data filter expressions through the new costCategories parameter, enabling users to filter billing views by AWS Cost Categories for more granular cost management and allocation.
# v1.63.1 (2026-01-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.63.0 (2026-01-06)
* **Feature**: This release updates existing reservation recommendations API to support deployment model.
# v1.62.0 (2025-12-08)
* **Feature**: Add support for Cost Category resource associations including filtering by resource type on ListCostCategoryDefinitions and new ListCostCategoryResourceAssociations API.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.61.0 (2025-12-02)
* **Feature**: This release updates existing Savings Plans Purchase Analyzer and Recommendations APIs to support Database Savings Plans.
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.24.0. Notably this version of the library reduces the allocation footprint of the middleware system. We observe a ~10% reduction in allocations per SDK call with this change.
# v1.60.2 (2025-11-25)
* **Bug Fix**: Add error check for endpoint param binding during auth scheme resolution to fix panic reported in #3234
# v1.60.1 (2025-11-19.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.60.0 (2025-11-19)
* **Feature**: Add support for COST_CATEGORY, TAG, and LINKED_ACCOUNT AWS managed cost anomaly detection monitors
# v1.59.4 (2025-11-12)
* **Bug Fix**: Further reduce allocation overhead when the metrics system isn't in-use.
* **Bug Fix**: Reduce allocation overhead when the client doesn't have any HTTP interceptors configured.
* **Bug Fix**: Remove blank trace spans towards the beginning of the request that added no additional information. This conveys a slight reduction in overall allocations.
# v1.59.3 (2025-11-11)
* **Bug Fix**: Return validation error if input region is not a valid host label.
# v1.59.2 (2025-11-04)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.23.2 which should convey some passive reduction of overall allocations, especially when not using the metrics system.
# v1.59.1 (2025-10-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.59.0 (2025-10-27)
* **Feature**: Updated endpoint for eusc-de-east-1 region.
# v1.58.1 (2025-10-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.58.0 (2025-10-22)
* **Feature**: Update endpoint ruleset parameters casing
# v1.57.1 (2025-10-16)
* **Dependency Update**: Bump minimum Go version to 1.23.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.57.0 (2025-09-26)
* **Feature**: Support for payer account dimension and billing view health status.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.56.1 (2025-09-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.56.0 (2025-09-15)
* **Feature**: Added endpoint support for eusc-de-east-1 region.
# v1.55.5 (2025-09-10)
* No change notes available for this release.
# v1.55.4 (2025-09-08)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.55.3 (2025-08-29)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.55.2 (2025-08-27)
* **Dependency Update**: Update to smithy-go v1.23.0.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.55.1 (2025-08-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.55.0 (2025-08-20)
* **Feature**: Remove incorrect endpoint tests
* **Bug Fix**: Remove unused deserialization code.
# v1.54.0 (2025-08-11)
* **Feature**: Add support for configuring per-service Options via callback on global config.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.53.0 (2025-08-04)
* **Feature**: Support configurable auth scheme preferences in service clients via AWS_AUTH_SCHEME_PREFERENCE in the environment, auth_scheme_preference in the config file, and through in-code settings on LoadDefaultConfig and client constructor methods.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.52.1 (2025-07-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.52.0 (2025-07-28)
* **Feature**: Add support for HTTP interceptors.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.51.3 (2025-07-19)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.51.2 (2025-06-17)
* **Dependency Update**: Update to smithy-go v1.22.4.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.51.1 (2025-06-10)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.51.0 (2025-06-09)
* **Feature**: Support dual-stack endpoints for ce api
# v1.50.0 (2025-05-27)
* **Feature**: This release introduces Cost Comparison feature (GetCostAndUsageComparisons, GetCostComparisonDrivers) allowing you find cost variations across multiple dimensions and identify key drivers of spending changes.
# v1.49.0 (2025-04-08)
* **Feature**: This release supports Pagination traits on Cost Anomaly Detection APIs.
# v1.48.1 (2025-04-03)
* No change notes available for this release.
# v1.48.0 (2025-03-10)
* **Feature**: Releasing minor partition endpoint updates.
# v1.47.1 (2025-03-04.2)
* **Bug Fix**: Add assurance test for operation order.
# v1.47.0 (2025-02-27)
* **Feature**: Track credential providers via User-Agent Feature ids
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.8 (2025-02-18)
* **Bug Fix**: Bump go version to 1.22
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.7 (2025-02-05)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.6 (2025-01-31)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.5 (2025-01-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.4 (2025-01-24)
* **Dependency Update**: Updated to the latest SDK module versions
* **Dependency Update**: Upgrade to smithy-go v1.22.2.
# v1.46.3 (2025-01-17)
* **Bug Fix**: Fix bug where credentials weren't refreshed during retry loop.
# v1.46.2 (2025-01-15)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.1 (2025-01-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.46.0 (2024-12-20)
* **Feature**: Support for retrieving cost, usage, and forecast for billing view.
# v1.45.2 (2024-12-19)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.45.1 (2024-12-02)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.45.0 (2024-11-22)
* **Feature**: This release adds the Impact field(contains Contribution field) to the GetAnomalies API response under RootCause
# v1.44.0 (2024-11-21)
* **Feature**: This release introduces three new APIs that enable you to estimate the cost, coverage, and utilization impact of Savings Plans you plan to purchase. The three APIs are StartCommitmentPurchaseAnalysis, GetCommitmentPurchaseAnalysis, and ListCommitmentPurchaseAnalyses.
# v1.43.6 (2024-11-18)
* **Dependency Update**: Update to smithy-go v1.22.1.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.43.5 (2024-11-07)
* **Bug Fix**: Adds case-insensitive handling of error message fields in service responses
# v1.43.4 (2024-11-06)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.43.3 (2024-10-28)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.43.2 (2024-10-08)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.43.1 (2024-10-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.43.0 (2024-10-04)
* **Feature**: Add support for HTTP client metrics.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.42.4 (2024-10-03)
* No change notes available for this release.
# v1.42.3 (2024-09-27)
* No change notes available for this release.
# v1.42.2 (2024-09-25)
* No change notes available for this release.
# v1.42.1 (2024-09-23)
* No change notes available for this release.
# v1.42.0 (2024-09-20)
* **Feature**: Add tracing and metrics support to service clients.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.41.0 (2024-09-18)
* **Feature**: This release extends the GetReservationPurchaseRecommendation API to support recommendations for Amazon DynamoDB reservations.
# v1.40.7 (2024-09-17)
* **Bug Fix**: **BREAKFIX**: Only generate AccountIDEndpointMode config for services that use it. This is a compiler break, but removes no actual functionality, as no services currently use the account ID in endpoint resolution.
# v1.40.6 (2024-09-04)
* No change notes available for this release.
# v1.40.5 (2024-09-03)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.40.4 (2024-08-15)
* **Dependency Update**: Bump minimum Go version to 1.21.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.40.3 (2024-07-10.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.40.2 (2024-07-10)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.40.1 (2024-06-28)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.40.0 (2024-06-26)
* **Feature**: Support list-of-string endpoint parameter.
# v1.39.1 (2024-06-19)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.39.0 (2024-06-18)
* **Feature**: Track usage of various AWS SDK features in user-agent string.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.7 (2024-06-17)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.6 (2024-06-07)
* **Bug Fix**: Add clock skew correction on all service clients
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.5 (2024-06-03)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.4 (2024-05-23)
* No change notes available for this release.
# v1.38.3 (2024-05-16)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.2 (2024-05-15)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.38.1 (2024-05-08)
* **Bug Fix**: GoDoc improvement
# v1.38.0 (2024-04-23)
* **Feature**: Added additional metadata that might be applicable to your reservation recommendations.
# v1.37.1 (2024-03-29)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.37.0 (2024-03-26)
* **Feature**: Adds support for backfill of cost allocation tags, with new StartCostAllocationTagBackfill and ListCostAllocationTagBackfillHistory API.
# v1.36.2 (2024-03-18)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.36.1 (2024-03-07)
* **Bug Fix**: Remove dependency on go-cmp.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.36.0 (2024-02-28)
* **Feature**: This release introduces the new API 'GetApproximateUsageRecords', which retrieves estimated usage records for hourly granularity or resource-level data at daily granularity.
# v1.35.1 (2024-02-23)
* **Bug Fix**: Move all common, SDK-side middleware stack ops into the service client module to prevent cross-module compatibility issues in the future.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.35.0 (2024-02-22)
* **Feature**: Add middleware stack snapshot tests.
# v1.34.3 (2024-02-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.34.2 (2024-02-20)
* **Bug Fix**: When sourcing values for a service's `EndpointParameters`, the lack of a configured region (i.e. `options.Region == ""`) will now translate to a `nil` value for `EndpointParameters.Region` instead of a pointer to the empty string `""`. This will result in a much more explicit error when calling an operation instead of an obscure hostname lookup failure.
# v1.34.1 (2024-02-15)
* **Bug Fix**: Correct failure to determine the error type in awsJson services that could occur when errors were modeled with a non-string `code` field.
# v1.34.0 (2024-02-13)
* **Feature**: Bump minimum Go version to 1.20 per our language support policy.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.33.6 (2024-01-04)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.33.5 (2023-12-08)
* **Bug Fix**: Reinstate presence of default Retryer in functional options, but still respect max attempts set therein.
# v1.33.4 (2023-12-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.33.3 (2023-12-06)
* **Bug Fix**: Restore pre-refactor auth behavior where all operations could technically be performed anonymously.
# v1.33.2 (2023-12-01)
* **Bug Fix**: Correct wrapping of errors in authentication workflow.
* **Bug Fix**: Correctly recognize cache-wrapped instances of AnonymousCredentials at client construction.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.33.1 (2023-11-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.33.0 (2023-11-29)
* **Feature**: Expose Options() accessor on service clients.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.32.5 (2023-11-28.2)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.32.4 (2023-11-28)
* **Bug Fix**: Respect setting RetryMaxAttempts in functional options at client construction.
# v1.32.3 (2023-11-20)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.32.2 (2023-11-15)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.32.1 (2023-11-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.32.0 (2023-11-06)
* **Feature**: This release extends the GetReservationPurchaseRecommendation API to support recommendations for Amazon MemoryDB reservations.
# v1.31.0 (2023-11-01)
* **Feature**: Adds support for configured endpoints via environment variables and the AWS shared configuration file.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.30.0 (2023-10-31)
* **Feature**: **BREAKING CHANGE**: Bump minimum go version to 1.19 per the revised [go version support policy](https://aws.amazon.com/blogs/developer/aws-sdk-for-go-aligns-with-go-release-policy-on-supported-runtimes/).
* **Dependency Update**: Updated to the latest SDK module versions
# v1.29.0 (2023-10-24)
* **Feature**: **BREAKFIX**: Correct nullability and default value representation of various input fields across a large number of services. Calling code that references one or more of the affected fields will need to update usage accordingly. See [2162](https://github.com/aws/aws-sdk-go-v2/issues/2162).
# v1.28.2 (2023-10-12)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.28.1 (2023-10-06)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.28.0 (2023-08-22)
* **Feature**: This release adds the LastUpdatedDate and LastUsedDate timestamps to help you manage your cost allocation tags.
# v1.27.5 (2023-08-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.27.4 (2023-08-18)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.27.3 (2023-08-17)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.27.2 (2023-08-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.27.1 (2023-08-01)
* No change notes available for this release.
# v1.27.0 (2023-07-31)
* **Feature**: Adds support for smithy-modeled endpoint resolution. A new rules-based endpoint resolution will be added to the SDK which will supercede and deprecate existing endpoint resolution. Specifically, EndpointResolver will be deprecated while BaseEndpoint and EndpointResolverV2 will take its place. For more information, please see the Endpoints section in our Developer Guide.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.26.1 (2023-07-28)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.26.0 (2023-07-24)
* **Feature**: This release introduces the new API 'GetSavingsPlanPurchaseRecommendationDetails', which retrieves the details for a Savings Plan recommendation. It also updates the existing API 'GetSavingsPlansPurchaseRecommendation' to include the recommendation detail ID.
# v1.25.13 (2023-07-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.12 (2023-06-15)
* No change notes available for this release.
# v1.25.11 (2023-06-13)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.10 (2023-05-04)
* No change notes available for this release.
# v1.25.9 (2023-04-24)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.8 (2023-04-10)
* No change notes available for this release.
# v1.25.7 (2023-04-07)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.6 (2023-03-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.5 (2023-03-10)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.4 (2023-02-22)
* **Bug Fix**: Prevent nil pointer dereference when retrieving error codes.
# v1.25.3 (2023-02-20)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.2 (2023-02-15)
* **Announcement**: When receiving an error response in restJson-based services, an incorrect error type may have been returned based on the content of the response. This has been fixed via PR #2012 tracked in issue #1910.
* **Bug Fix**: Correct error type parsing for restJson services.
# v1.25.1 (2023-02-03)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.25.0 (2023-01-05)
* **Feature**: Add `ErrorCodeOverride` field to all error structs (aws/smithy-go#401).
# v1.24.1 (2022-12-15)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.24.0 (2022-12-14)
* **Feature**: This release supports percentage-based thresholds on Cost Anomaly Detection alert subscriptions.
# v1.23.0 (2022-12-07)
* **Feature**: This release adds the LinkedAccountName field to the GetAnomalies API response under RootCause
# v1.22.0 (2022-12-05)
* **Feature**: This release introduces two new APIs that offer a 1-click experience to refresh Savings Plans recommendations. The two APIs are StartSavingsPlansPurchaseRecommendationGeneration and ListSavingsPlansPurchaseRecommendationGeneration.
# v1.21.3 (2022-12-02)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.2 (2022-10-24)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.1 (2022-10-21)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.21.0 (2022-09-27)
* **Feature**: This release is to support retroactive Cost Categories. The new field will enable you to retroactively apply new and existing cost category rules to previous months.
# v1.20.1 (2022-09-20)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.20.0 (2022-09-14)
* **Feature**: Fixed a bug in the API client generation which caused some operation parameters to be incorrectly generated as value types instead of pointer types. The service API always required these affected parameters to be nilable. This fixes the SDK client to match the expectations of the the service API.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.9 (2022-09-02)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.8 (2022-08-31)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.7 (2022-08-29)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.6 (2022-08-11)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.5 (2022-08-09)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.4 (2022-08-08)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.3 (2022-08-01)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.2 (2022-07-05)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.1 (2022-06-29)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.19.0 (2022-06-07)
* **Feature**: Added two new APIs to support cost allocation tags operations: ListCostAllocationTags, UpdateCostAllocationTagsStatus.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.5 (2022-05-17)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.4 (2022-04-25)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.3 (2022-03-30)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.2 (2022-03-24)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.1 (2022-03-23)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.18.0 (2022-03-22)
* **Feature**: Added three new APIs to support tagging and resource-level authorization on Cost Explorer resources: TagResource, UntagResource, ListTagsForResource. Added optional parameters to CreateCostCategoryDefinition, CreateAnomalySubscription and CreateAnomalyMonitor APIs to support Tag On Create.
# v1.17.0 (2022-03-08)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.16.0 (2022-02-24)
* **Feature**: API client updated
* **Feature**: Adds RetryMaxAttempts and RetryMod to API client Options. This allows the API clients' default Retryer to be configured from the shared configuration files or environment variables. Adding a new Retry mode of `Adaptive`. `Adaptive` retry mode is an experimental mode, adding client rate limiting when throttles reponses are received from an API. See [retry.AdaptiveMode](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry#AdaptiveMode) for more details, and configuration options.
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.15.0 (2022-01-14)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Documentation**: Updated API models
* **Dependency Update**: Updated to the latest SDK module versions
# v1.14.0 (2022-01-07)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.13.0 (2021-12-21)
* **Feature**: API Paginators now support specifying the initial starting token, and support stopping on empty string tokens.
# v1.12.2 (2021-12-02)
* **Bug Fix**: Fixes a bug that prevented aws.EndpointResolverWithOptions from being used by the service client. ([#1514](https://github.com/aws/aws-sdk-go-v2/pull/1514))
* **Dependency Update**: Updated to the latest SDK module versions
# v1.12.1 (2021-11-19)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.12.0 (2021-11-12)
* **Feature**: Service clients now support custom endpoints that have an initial URI path defined.
# v1.11.0 (2021-11-06)
* **Feature**: The SDK now supports configuration of FIPS and DualStack endpoints using environment variables, shared configuration, or programmatically.
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.10.0 (2021-10-21)
* **Feature**: Updated to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.9.2 (2021-10-11)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.9.1 (2021-09-17)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.9.0 (2021-08-27)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.8.0 (2021-08-19)
* **Feature**: API client updated
* **Dependency Update**: Updated to the latest SDK module versions
# v1.7.2 (2021-08-04)
* **Dependency Update**: Updated `github.com/aws/smithy-go` to latest version.
* **Dependency Update**: Updated to the latest SDK module versions
# v1.7.1 (2021-07-15)
* **Dependency Update**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.7.0 (2021-06-25)
* **Feature**: Updated `github.com/aws/smithy-go` to latest version
* **Dependency Update**: Updated to the latest SDK module versions
# v1.6.0 (2021-05-25)
* **Feature**: API client updated
# v1.5.1 (2021-05-20)
* **Dependency Update**: Updated to the latest SDK module versions
# v1.5.0 (2021-05-14)
* **Feature**: Constant has been added to modules to enable runtime version inspection for reporting.
* **Dependency Update**: Updated to the latest SDK module versions
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+950
View File
@@ -0,0 +1,950 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/defaults"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
internalauth "github.com/aws/aws-sdk-go-v2/internal/auth"
internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy"
internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources"
internalmiddleware "github.com/aws/aws-sdk-go-v2/internal/middleware"
smithy "github.com/aws/smithy-go"
smithyauth "github.com/aws/smithy-go/auth"
smithydocument "github.com/aws/smithy-go/document"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/metrics"
"github.com/aws/smithy-go/middleware"
"github.com/aws/smithy-go/tracing"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net"
"net/http"
"sync/atomic"
"time"
)
const ServiceID = "Cost Explorer"
const ServiceAPIVersion = "2017-10-25"
type operationMetrics struct {
Duration metrics.Float64Histogram
SerializeDuration metrics.Float64Histogram
ResolveIdentityDuration metrics.Float64Histogram
ResolveEndpointDuration metrics.Float64Histogram
SignRequestDuration metrics.Float64Histogram
DeserializeDuration metrics.Float64Histogram
}
func (m *operationMetrics) histogramFor(name string) metrics.Float64Histogram {
switch name {
case "client.call.duration":
return m.Duration
case "client.call.serialization_duration":
return m.SerializeDuration
case "client.call.resolve_identity_duration":
return m.ResolveIdentityDuration
case "client.call.resolve_endpoint_duration":
return m.ResolveEndpointDuration
case "client.call.signing_duration":
return m.SignRequestDuration
case "client.call.deserialization_duration":
return m.DeserializeDuration
default:
panic("unrecognized operation metric")
}
}
func timeOperationMetric[T any](
ctx context.Context, metric string, fn func() (T, error),
opts ...metrics.RecordMetricOption,
) (T, error) {
mm := getOperationMetrics(ctx)
if mm == nil { // not using the metrics system
return fn()
}
instr := mm.histogramFor(metric)
opts = append([]metrics.RecordMetricOption{withOperationMetadata(ctx)}, opts...)
start := time.Now()
v, err := fn()
end := time.Now()
elapsed := end.Sub(start)
instr.Record(ctx, float64(elapsed)/1e9, opts...)
return v, err
}
func startMetricTimer(ctx context.Context, metric string, opts ...metrics.RecordMetricOption) func() {
mm := getOperationMetrics(ctx)
if mm == nil { // not using the metrics system
return func() {}
}
instr := mm.histogramFor(metric)
opts = append([]metrics.RecordMetricOption{withOperationMetadata(ctx)}, opts...)
var ended bool
start := time.Now()
return func() {
if ended {
return
}
ended = true
end := time.Now()
elapsed := end.Sub(start)
instr.Record(ctx, float64(elapsed)/1e9, opts...)
}
}
func withOperationMetadata(ctx context.Context) metrics.RecordMetricOption {
return func(o *metrics.RecordMetricOptions) {
o.Properties.Set("rpc.service", middleware.GetServiceID(ctx))
o.Properties.Set("rpc.method", middleware.GetOperationName(ctx))
}
}
type operationMetricsKey struct{}
func withOperationMetrics(parent context.Context, mp metrics.MeterProvider) (context.Context, error) {
if _, ok := mp.(metrics.NopMeterProvider); ok {
// not using the metrics system - setting up the metrics context is a memory-intensive operation
// so we should skip it in this case
return parent, nil
}
meter := mp.Meter("github.com/aws/aws-sdk-go-v2/service/costexplorer")
om := &operationMetrics{}
var err error
om.Duration, err = operationMetricTimer(meter, "client.call.duration",
"Overall call duration (including retries and time to send or receive request and response body)")
if err != nil {
return nil, err
}
om.SerializeDuration, err = operationMetricTimer(meter, "client.call.serialization_duration",
"The time it takes to serialize a message body")
if err != nil {
return nil, err
}
om.ResolveIdentityDuration, err = operationMetricTimer(meter, "client.call.auth.resolve_identity_duration",
"The time taken to acquire an identity (AWS credentials, bearer token, etc) from an Identity Provider")
if err != nil {
return nil, err
}
om.ResolveEndpointDuration, err = operationMetricTimer(meter, "client.call.resolve_endpoint_duration",
"The time it takes to resolve an endpoint (endpoint resolver, not DNS) for the request")
if err != nil {
return nil, err
}
om.SignRequestDuration, err = operationMetricTimer(meter, "client.call.auth.signing_duration",
"The time it takes to sign a request")
if err != nil {
return nil, err
}
om.DeserializeDuration, err = operationMetricTimer(meter, "client.call.deserialization_duration",
"The time it takes to deserialize a message body")
if err != nil {
return nil, err
}
return context.WithValue(parent, operationMetricsKey{}, om), nil
}
func operationMetricTimer(m metrics.Meter, name, desc string) (metrics.Float64Histogram, error) {
return m.Float64Histogram(name, func(o *metrics.InstrumentOptions) {
o.UnitLabel = "s"
o.Description = desc
})
}
func getOperationMetrics(ctx context.Context) *operationMetrics {
if v := ctx.Value(operationMetricsKey{}); v != nil {
return v.(*operationMetrics)
}
return nil
}
func operationTracer(p tracing.TracerProvider) tracing.Tracer {
return p.Tracer("github.com/aws/aws-sdk-go-v2/service/costexplorer")
}
// Client provides the API client to make operations call for AWS Cost Explorer
// Service.
type Client struct {
options Options
// Difference between the time reported by the server and the client
timeOffset *atomic.Int64
}
// New returns an initialized Client based on the functional options. Provide
// additional functional options to further configure the behavior of the client,
// such as changing the client's endpoint or adding custom middleware behavior.
func New(options Options, optFns ...func(*Options)) *Client {
options = options.Copy()
resolveDefaultLogger(&options)
setResolvedDefaultsMode(&options)
resolveRetryer(&options)
resolveHTTPClient(&options)
resolveHTTPSignerV4(&options)
resolveEndpointResolverV2(&options)
resolveTracerProvider(&options)
resolveMeterProvider(&options)
resolveAuthSchemeResolver(&options)
for _, fn := range optFns {
fn(&options)
}
finalizeRetryMaxAttempts(&options)
ignoreAnonymousAuth(&options)
wrapWithAnonymousAuth(&options)
resolveAuthSchemes(&options)
client := &Client{
options: options,
}
initializeTimeOffsetResolver(client)
return client
}
// Options returns a copy of the client configuration.
//
// Callers SHOULD NOT perform mutations on any inner structures within client
// config. Config overrides should instead be made on a per-operation basis through
// functional options.
func (c *Client) Options() Options {
return c.options.Copy()
}
func (c *Client) invokeOperation(
ctx context.Context, opID string, params interface{}, optFns []func(*Options), stackFns ...func(*middleware.Stack, Options) error,
) (
result interface{}, metadata middleware.Metadata, err error,
) {
ctx = middleware.ClearStackValues(ctx)
ctx = middleware.WithServiceID(ctx, ServiceID)
ctx = middleware.WithOperationName(ctx, opID)
stack := middleware.NewStack(opID, smithyhttp.NewStackRequest)
options := c.options.Copy()
for _, fn := range optFns {
fn(&options)
}
finalizeOperationRetryMaxAttempts(&options, *c)
finalizeClientEndpointResolverOptions(&options)
for _, fn := range stackFns {
if err := fn(stack, options); err != nil {
return nil, metadata, err
}
}
for _, fn := range options.APIOptions {
if err := fn(stack); err != nil {
return nil, metadata, err
}
}
ctx, err = withOperationMetrics(ctx, options.MeterProvider)
if err != nil {
return nil, metadata, err
}
tracer := operationTracer(options.TracerProvider)
spanName := fmt.Sprintf("%s.%s", ServiceID, opID)
ctx = tracing.WithOperationTracer(ctx, tracer)
ctx, span := tracer.StartSpan(ctx, spanName, func(o *tracing.SpanOptions) {
o.Kind = tracing.SpanKindClient
o.Properties.Set("rpc.system", "aws-api")
o.Properties.Set("rpc.method", opID)
o.Properties.Set("rpc.service", ServiceID)
})
endTimer := startMetricTimer(ctx, "client.call.duration")
defer endTimer()
defer span.End()
handler := smithyhttp.NewClientHandlerWithOptions(options.HTTPClient, func(o *smithyhttp.ClientHandler) {
o.Meter = options.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/costexplorer")
})
decorated := middleware.DecorateHandler(handler, stack)
result, metadata, err = decorated.Handle(ctx, params)
if err != nil {
span.SetProperty("exception.type", fmt.Sprintf("%T", err))
span.SetProperty("exception.message", err.Error())
var aerr smithy.APIError
if errors.As(err, &aerr) {
span.SetProperty("api.error_code", aerr.ErrorCode())
span.SetProperty("api.error_message", aerr.ErrorMessage())
span.SetProperty("api.error_fault", aerr.ErrorFault().String())
}
err = &smithy.OperationError{
ServiceID: ServiceID,
OperationName: opID,
Err: err,
}
}
span.SetProperty("error", err != nil)
if err == nil {
span.SetStatus(tracing.SpanStatusOK)
} else {
span.SetStatus(tracing.SpanStatusError)
}
return result, metadata, err
}
type operationInputKey struct{}
func setOperationInput(ctx context.Context, input interface{}) context.Context {
return middleware.WithStackValue(ctx, operationInputKey{}, input)
}
func getOperationInput(ctx context.Context) interface{} {
return middleware.GetStackValue(ctx, operationInputKey{})
}
type setOperationInputMiddleware struct {
}
func (*setOperationInputMiddleware) ID() string {
return "setOperationInput"
}
func (m *setOperationInputMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
ctx = setOperationInput(ctx, in.Parameters)
return next.HandleSerialize(ctx, in)
}
func addProtocolFinalizerMiddlewares(stack *middleware.Stack, options Options, operation string) error {
if err := stack.Finalize.Add(&resolveAuthSchemeMiddleware{operation: operation, options: options}, middleware.Before); err != nil {
return fmt.Errorf("add ResolveAuthScheme: %w", err)
}
if err := stack.Finalize.Insert(&getIdentityMiddleware{options: options}, "ResolveAuthScheme", middleware.After); err != nil {
return fmt.Errorf("add GetIdentity: %v", err)
}
if err := stack.Finalize.Insert(&resolveEndpointV2Middleware{options: options}, "GetIdentity", middleware.After); err != nil {
return fmt.Errorf("add ResolveEndpointV2: %v", err)
}
if err := stack.Finalize.Insert(&signRequestMiddleware{options: options}, "ResolveEndpointV2", middleware.After); err != nil {
return fmt.Errorf("add Signing: %w", err)
}
return nil
}
func resolveAuthSchemeResolver(options *Options) {
if options.AuthSchemeResolver == nil {
options.AuthSchemeResolver = &defaultAuthSchemeResolver{}
}
}
func resolveAuthSchemes(options *Options) {
if options.AuthSchemes == nil {
options.AuthSchemes = []smithyhttp.AuthScheme{
internalauth.NewHTTPAuthScheme("aws.auth#sigv4", &internalauthsmithy.V4SignerAdapter{
Signer: options.HTTPSignerV4,
Logger: options.Logger,
LogSigning: options.ClientLogMode.IsSigning(),
}),
}
}
}
type noSmithyDocumentSerde = smithydocument.NoSerde
type legacyEndpointContextSetter struct {
LegacyResolver EndpointResolver
}
func (*legacyEndpointContextSetter) ID() string {
return "legacyEndpointContextSetter"
}
func (m *legacyEndpointContextSetter) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
if m.LegacyResolver != nil {
ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, true)
}
return next.HandleInitialize(ctx, in)
}
func addlegacyEndpointContextSetter(stack *middleware.Stack, o Options) error {
return stack.Initialize.Add(&legacyEndpointContextSetter{
LegacyResolver: o.EndpointResolver,
}, middleware.Before)
}
func resolveDefaultLogger(o *Options) {
if o.Logger != nil {
return
}
o.Logger = logging.Nop{}
}
func addSetLoggerMiddleware(stack *middleware.Stack, o Options) error {
return middleware.AddSetLoggerMiddleware(stack, o.Logger)
}
func setResolvedDefaultsMode(o *Options) {
if len(o.resolvedDefaultsMode) > 0 {
return
}
var mode aws.DefaultsMode
mode.SetFromString(string(o.DefaultsMode))
if mode == aws.DefaultsModeAuto {
mode = defaults.ResolveDefaultsModeAuto(o.Region, o.RuntimeEnvironment)
}
o.resolvedDefaultsMode = mode
}
// NewFromConfig returns a new client from the provided config.
func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client {
opts := Options{
Region: cfg.Region,
DefaultsMode: cfg.DefaultsMode,
RuntimeEnvironment: cfg.RuntimeEnvironment,
HTTPClient: cfg.HTTPClient,
Credentials: cfg.Credentials,
APIOptions: cfg.APIOptions,
Logger: cfg.Logger,
ClientLogMode: cfg.ClientLogMode,
AppID: cfg.AppID,
AuthSchemePreference: cfg.AuthSchemePreference,
}
resolveAWSRetryerProvider(cfg, &opts)
resolveAWSRetryMaxAttempts(cfg, &opts)
resolveAWSRetryMode(cfg, &opts)
resolveAWSEndpointResolver(cfg, &opts)
resolveInterceptors(cfg, &opts)
resolveUseDualStackEndpoint(cfg, &opts)
resolveUseFIPSEndpoint(cfg, &opts)
resolveBaseEndpoint(cfg, &opts)
return New(opts, func(o *Options) {
for _, opt := range cfg.ServiceOptions {
opt(ServiceID, o)
}
for _, opt := range optFns {
opt(o)
}
})
}
func resolveHTTPClient(o *Options) {
var buildable *awshttp.BuildableClient
if o.HTTPClient != nil {
var ok bool
buildable, ok = o.HTTPClient.(*awshttp.BuildableClient)
if !ok {
return
}
} else {
buildable = awshttp.NewBuildableClient()
}
modeConfig, err := defaults.GetModeConfiguration(o.resolvedDefaultsMode)
if err == nil {
buildable = buildable.WithDialerOptions(func(dialer *net.Dialer) {
if dialerTimeout, ok := modeConfig.GetConnectTimeout(); ok {
dialer.Timeout = dialerTimeout
}
})
buildable = buildable.WithTransportOptions(func(transport *http.Transport) {
if tlsHandshakeTimeout, ok := modeConfig.GetTLSNegotiationTimeout(); ok {
transport.TLSHandshakeTimeout = tlsHandshakeTimeout
}
})
}
o.HTTPClient = buildable
}
func resolveRetryer(o *Options) {
if o.Retryer != nil {
return
}
if len(o.RetryMode) == 0 {
modeConfig, err := defaults.GetModeConfiguration(o.resolvedDefaultsMode)
if err == nil {
o.RetryMode = modeConfig.RetryMode
}
}
if len(o.RetryMode) == 0 {
o.RetryMode = aws.RetryModeStandard
}
var standardOptions []func(*retry.StandardOptions)
if v := o.RetryMaxAttempts; v != 0 {
standardOptions = append(standardOptions, func(so *retry.StandardOptions) {
so.MaxAttempts = v
})
}
switch o.RetryMode {
case aws.RetryModeAdaptive:
var adaptiveOptions []func(*retry.AdaptiveModeOptions)
if len(standardOptions) != 0 {
adaptiveOptions = append(adaptiveOptions, func(ao *retry.AdaptiveModeOptions) {
ao.StandardOptions = append(ao.StandardOptions, standardOptions...)
})
}
o.Retryer = retry.NewAdaptiveMode(adaptiveOptions...)
default:
o.Retryer = retry.NewStandard(standardOptions...)
}
}
func resolveAWSRetryerProvider(cfg aws.Config, o *Options) {
if cfg.Retryer == nil {
return
}
o.Retryer = cfg.Retryer()
}
func resolveAWSRetryMode(cfg aws.Config, o *Options) {
if len(cfg.RetryMode) == 0 {
return
}
o.RetryMode = cfg.RetryMode
}
func resolveAWSRetryMaxAttempts(cfg aws.Config, o *Options) {
if cfg.RetryMaxAttempts == 0 {
return
}
o.RetryMaxAttempts = cfg.RetryMaxAttempts
}
func finalizeRetryMaxAttempts(o *Options) {
if o.RetryMaxAttempts == 0 {
return
}
o.Retryer = retry.AddWithMaxAttempts(o.Retryer, o.RetryMaxAttempts)
}
func finalizeOperationRetryMaxAttempts(o *Options, client Client) {
if v := o.RetryMaxAttempts; v == 0 || v == client.options.RetryMaxAttempts {
return
}
o.Retryer = retry.AddWithMaxAttempts(o.Retryer, o.RetryMaxAttempts)
}
func resolveAWSEndpointResolver(cfg aws.Config, o *Options) {
if cfg.EndpointResolver == nil && cfg.EndpointResolverWithOptions == nil {
return
}
o.EndpointResolver = withEndpointResolver(cfg.EndpointResolver, cfg.EndpointResolverWithOptions)
}
func resolveInterceptors(cfg aws.Config, o *Options) {
o.Interceptors = cfg.Interceptors.Copy()
}
func addClientUserAgent(stack *middleware.Stack, options Options) error {
ua, err := getOrAddRequestUserAgent(stack)
if err != nil {
return err
}
ua.AddSDKAgentKeyValue(awsmiddleware.APIMetadata, "costexplorer", goModuleVersion)
if len(options.AppID) > 0 {
ua.AddSDKAgentKey(awsmiddleware.ApplicationIdentifier, options.AppID)
}
return nil
}
func getOrAddRequestUserAgent(stack *middleware.Stack) (*awsmiddleware.RequestUserAgent, error) {
id := (*awsmiddleware.RequestUserAgent)(nil).ID()
mw, ok := stack.Build.Get(id)
if !ok {
mw = awsmiddleware.NewRequestUserAgent()
if err := stack.Build.Add(mw, middleware.After); err != nil {
return nil, err
}
}
ua, ok := mw.(*awsmiddleware.RequestUserAgent)
if !ok {
return nil, fmt.Errorf("%T for %s middleware did not match expected type", mw, id)
}
return ua, nil
}
type HTTPSignerV4 interface {
SignHTTP(ctx context.Context, credentials aws.Credentials, r *http.Request, payloadHash string, service string, region string, signingTime time.Time, optFns ...func(*v4.SignerOptions)) error
}
func resolveHTTPSignerV4(o *Options) {
if o.HTTPSignerV4 != nil {
return
}
o.HTTPSignerV4 = newDefaultV4Signer(*o)
}
func newDefaultV4Signer(o Options) *v4.Signer {
return v4.NewSigner(func(so *v4.SignerOptions) {
so.Logger = o.Logger
so.LogSigning = o.ClientLogMode.IsSigning()
})
}
func addClientRequestID(stack *middleware.Stack) error {
return stack.Build.Add(&awsmiddleware.ClientRequestID{}, middleware.After)
}
func addComputeContentLength(stack *middleware.Stack) error {
return stack.Build.Add(&smithyhttp.ComputeContentLength{}, middleware.After)
}
func addRawResponseToMetadata(stack *middleware.Stack) error {
return stack.Deserialize.Add(&awsmiddleware.AddRawResponse{}, middleware.Before)
}
func addRecordResponseTiming(stack *middleware.Stack) error {
return stack.Deserialize.Add(&awsmiddleware.RecordResponseTiming{}, middleware.After)
}
func addSpanRetryLoop(stack *middleware.Stack, options Options) error {
return stack.Finalize.Insert(&spanRetryLoop{options: options}, "Retry", middleware.Before)
}
type spanRetryLoop struct {
options Options
}
func (*spanRetryLoop) ID() string {
return "spanRetryLoop"
}
func (m *spanRetryLoop) HandleFinalize(
ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler,
) (
middleware.FinalizeOutput, middleware.Metadata, error,
) {
tracer := operationTracer(m.options.TracerProvider)
ctx, span := tracer.StartSpan(ctx, "RetryLoop")
defer span.End()
return next.HandleFinalize(ctx, in)
}
func addStreamingEventsPayload(stack *middleware.Stack) error {
return stack.Finalize.Add(&v4.StreamingEventsPayload{}, middleware.Before)
}
func addUnsignedPayload(stack *middleware.Stack) error {
return stack.Finalize.Insert(&v4.UnsignedPayload{}, "ResolveEndpointV2", middleware.After)
}
func addComputePayloadSHA256(stack *middleware.Stack) error {
return stack.Finalize.Insert(&v4.ComputePayloadSHA256{}, "ResolveEndpointV2", middleware.After)
}
func addContentSHA256Header(stack *middleware.Stack) error {
return stack.Finalize.Insert(&v4.ContentSHA256Header{}, (*v4.ComputePayloadSHA256)(nil).ID(), middleware.After)
}
func addIsWaiterUserAgent(o *Options) {
o.APIOptions = append(o.APIOptions, func(stack *middleware.Stack) error {
ua, err := getOrAddRequestUserAgent(stack)
if err != nil {
return err
}
ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureWaiter)
return nil
})
}
func addIsPaginatorUserAgent(o *Options) {
o.APIOptions = append(o.APIOptions, func(stack *middleware.Stack) error {
ua, err := getOrAddRequestUserAgent(stack)
if err != nil {
return err
}
ua.AddUserAgentFeature(awsmiddleware.UserAgentFeaturePaginator)
return nil
})
}
func addRetry(stack *middleware.Stack, o Options) error {
attempt := retry.NewAttemptMiddleware(o.Retryer, smithyhttp.RequestCloner, func(m *retry.Attempt) {
m.LogAttempts = o.ClientLogMode.IsRetries()
m.OperationMeter = o.MeterProvider.Meter("github.com/aws/aws-sdk-go-v2/service/costexplorer")
})
if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil {
return err
}
if err := stack.Finalize.Insert(&retry.MetricsHeader{}, attempt.ID(), middleware.After); err != nil {
return err
}
return nil
}
// resolves dual-stack endpoint configuration
func resolveUseDualStackEndpoint(cfg aws.Config, o *Options) error {
if len(cfg.ConfigSources) == 0 {
return nil
}
value, found, err := internalConfig.ResolveUseDualStackEndpoint(context.Background(), cfg.ConfigSources)
if err != nil {
return err
}
if found {
o.EndpointOptions.UseDualStackEndpoint = value
}
return nil
}
// resolves FIPS endpoint configuration
func resolveUseFIPSEndpoint(cfg aws.Config, o *Options) error {
if len(cfg.ConfigSources) == 0 {
return nil
}
value, found, err := internalConfig.ResolveUseFIPSEndpoint(context.Background(), cfg.ConfigSources)
if err != nil {
return err
}
if found {
o.EndpointOptions.UseFIPSEndpoint = value
}
return nil
}
func resolveAccountID(identity smithyauth.Identity, mode aws.AccountIDEndpointMode) *string {
if mode == aws.AccountIDEndpointModeDisabled {
return nil
}
if ca, ok := identity.(*internalauthsmithy.CredentialsAdapter); ok && ca.Credentials.AccountID != "" {
return aws.String(ca.Credentials.AccountID)
}
return nil
}
func addTimeOffsetBuild(stack *middleware.Stack, c *Client) error {
mw := internalmiddleware.AddTimeOffsetMiddleware{Offset: c.timeOffset}
if err := stack.Build.Add(&mw, middleware.After); err != nil {
return err
}
return stack.Deserialize.Insert(&mw, "RecordResponseTiming", middleware.Before)
}
func initializeTimeOffsetResolver(c *Client) {
c.timeOffset = new(atomic.Int64)
}
func addUserAgentRetryMode(stack *middleware.Stack, options Options) error {
ua, err := getOrAddRequestUserAgent(stack)
if err != nil {
return err
}
switch options.Retryer.(type) {
case *retry.Standard:
ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureRetryModeStandard)
case *retry.AdaptiveMode:
ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureRetryModeAdaptive)
}
return nil
}
type setCredentialSourceMiddleware struct {
ua *awsmiddleware.RequestUserAgent
options Options
}
func (m setCredentialSourceMiddleware) ID() string { return "SetCredentialSourceMiddleware" }
func (m setCredentialSourceMiddleware) HandleBuild(ctx context.Context, in middleware.BuildInput, next middleware.BuildHandler) (
out middleware.BuildOutput, metadata middleware.Metadata, err error,
) {
asProviderSource, ok := m.options.Credentials.(aws.CredentialProviderSource)
if !ok {
return next.HandleBuild(ctx, in)
}
providerSources := asProviderSource.ProviderSources()
for _, source := range providerSources {
m.ua.AddCredentialsSource(source)
}
return next.HandleBuild(ctx, in)
}
func addCredentialSource(stack *middleware.Stack, options Options) error {
ua, err := getOrAddRequestUserAgent(stack)
if err != nil {
return err
}
mw := setCredentialSourceMiddleware{ua: ua, options: options}
return stack.Build.Insert(&mw, "UserAgent", middleware.Before)
}
func resolveTracerProvider(options *Options) {
if options.TracerProvider == nil {
options.TracerProvider = &tracing.NopTracerProvider{}
}
}
func resolveMeterProvider(options *Options) {
if options.MeterProvider == nil {
options.MeterProvider = metrics.NopMeterProvider{}
}
}
func addRecursionDetection(stack *middleware.Stack) error {
return stack.Build.Add(&awsmiddleware.RecursionDetection{}, middleware.After)
}
func addRequestIDRetrieverMiddleware(stack *middleware.Stack) error {
return stack.Deserialize.Insert(&awsmiddleware.RequestIDRetriever{}, "OperationDeserializer", middleware.Before)
}
func addResponseErrorMiddleware(stack *middleware.Stack) error {
return stack.Deserialize.Insert(&awshttp.ResponseErrorWrapper{}, "RequestIDRetriever", middleware.Before)
}
func addRequestResponseLogging(stack *middleware.Stack, o Options) error {
return stack.Deserialize.Add(&smithyhttp.RequestResponseLogger{
LogRequest: o.ClientLogMode.IsRequest(),
LogRequestWithBody: o.ClientLogMode.IsRequestWithBody(),
LogResponse: o.ClientLogMode.IsResponse(),
LogResponseWithBody: o.ClientLogMode.IsResponseWithBody(),
}, middleware.After)
}
type disableHTTPSMiddleware struct {
DisableHTTPS bool
}
func (*disableHTTPSMiddleware) ID() string {
return "disableHTTPS"
}
func (m *disableHTTPSMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if m.DisableHTTPS && !smithyhttp.GetHostnameImmutable(ctx) {
req.URL.Scheme = "http"
}
return next.HandleFinalize(ctx, in)
}
func addDisableHTTPSMiddleware(stack *middleware.Stack, o Options) error {
return stack.Finalize.Insert(&disableHTTPSMiddleware{
DisableHTTPS: o.EndpointOptions.DisableHTTPS,
}, "ResolveEndpointV2", middleware.After)
}
func addInterceptBeforeRetryLoop(stack *middleware.Stack, opts Options) error {
return stack.Finalize.Insert(&smithyhttp.InterceptBeforeRetryLoop{
Interceptors: opts.Interceptors.BeforeRetryLoop,
}, "Retry", middleware.Before)
}
func addInterceptAttempt(stack *middleware.Stack, opts Options) error {
return stack.Finalize.Insert(&smithyhttp.InterceptAttempt{
BeforeAttempt: opts.Interceptors.BeforeAttempt,
AfterAttempt: opts.Interceptors.AfterAttempt,
}, "Retry", middleware.After)
}
func addInterceptors(stack *middleware.Stack, opts Options) error {
// middlewares are expensive, don't add all of these interceptor ones unless the caller
// actually has at least one interceptor configured
//
// at the moment it's all-or-nothing because some of the middlewares here are responsible for
// setting fields in the interceptor context for future ones
if len(opts.Interceptors.BeforeExecution) == 0 &&
len(opts.Interceptors.BeforeSerialization) == 0 && len(opts.Interceptors.AfterSerialization) == 0 &&
len(opts.Interceptors.BeforeRetryLoop) == 0 &&
len(opts.Interceptors.BeforeAttempt) == 0 &&
len(opts.Interceptors.BeforeSigning) == 0 && len(opts.Interceptors.AfterSigning) == 0 &&
len(opts.Interceptors.BeforeTransmit) == 0 && len(opts.Interceptors.AfterTransmit) == 0 &&
len(opts.Interceptors.BeforeDeserialization) == 0 && len(opts.Interceptors.AfterDeserialization) == 0 &&
len(opts.Interceptors.AfterAttempt) == 0 && len(opts.Interceptors.AfterExecution) == 0 {
return nil
}
return errors.Join(
stack.Initialize.Add(&smithyhttp.InterceptExecution{
BeforeExecution: opts.Interceptors.BeforeExecution,
AfterExecution: opts.Interceptors.AfterExecution,
}, middleware.Before),
stack.Serialize.Insert(&smithyhttp.InterceptBeforeSerialization{
Interceptors: opts.Interceptors.BeforeSerialization,
}, "OperationSerializer", middleware.Before),
stack.Serialize.Insert(&smithyhttp.InterceptAfterSerialization{
Interceptors: opts.Interceptors.AfterSerialization,
}, "OperationSerializer", middleware.After),
stack.Finalize.Insert(&smithyhttp.InterceptBeforeSigning{
Interceptors: opts.Interceptors.BeforeSigning,
}, "Signing", middleware.Before),
stack.Finalize.Insert(&smithyhttp.InterceptAfterSigning{
Interceptors: opts.Interceptors.AfterSigning,
}, "Signing", middleware.After),
stack.Deserialize.Add(&smithyhttp.InterceptTransmit{
BeforeTransmit: opts.Interceptors.BeforeTransmit,
AfterTransmit: opts.Interceptors.AfterTransmit,
}, middleware.After),
stack.Deserialize.Insert(&smithyhttp.InterceptBeforeDeserialization{
Interceptors: opts.Interceptors.BeforeDeserialization,
}, "OperationDeserializer", middleware.After), // (deserialize stack is called in reverse)
stack.Deserialize.Insert(&smithyhttp.InterceptAfterDeserialization{
Interceptors: opts.Interceptors.AfterDeserialization,
}, "OperationDeserializer", middleware.Before),
)
}
@@ -0,0 +1,187 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates a new cost anomaly detection monitor with the requested type and
// monitor specification.
func (c *Client) CreateAnomalyMonitor(ctx context.Context, params *CreateAnomalyMonitorInput, optFns ...func(*Options)) (*CreateAnomalyMonitorOutput, error) {
if params == nil {
params = &CreateAnomalyMonitorInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateAnomalyMonitor", params, optFns, c.addOperationCreateAnomalyMonitorMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateAnomalyMonitorOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateAnomalyMonitorInput struct {
// The cost anomaly detection monitor object that you want to create.
//
// This member is required.
AnomalyMonitor *types.AnomalyMonitor
// An optional list of tags to associate with the specified [AnomalyMonitor]AnomalyMonitor . You
// can use resource tags to control access to your monitor using IAM policies.
//
// Each tag consists of a key and a value, and each key must be unique for the
// resource. The following restrictions apply to resource tags:
//
// - Although the maximum number of array members is 200, you can assign a
// maximum of 50 user-tags to one resource. The remaining are reserved for Amazon
// Web Services use
//
// - The maximum length of a key is 128 characters
//
// - The maximum length of a value is 256 characters
//
// - Keys and values can only contain alphanumeric characters, spaces, and any
// of the following: _.:/=+@-
//
// - Keys and values are case sensitive
//
// - Keys and values are trimmed for any leading or trailing whitespaces
//
// - Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon
// Web Services use
//
// [AnomalyMonitor]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_AnomalyMonitor.html
ResourceTags []types.ResourceTag
noSmithyDocumentSerde
}
type CreateAnomalyMonitorOutput struct {
// The unique identifier of your newly created cost anomaly detection monitor.
//
// This member is required.
MonitorArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateAnomalyMonitorMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateAnomalyMonitor"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpCreateAnomalyMonitorValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateAnomalyMonitor(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateAnomalyMonitor(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "CreateAnomalyMonitor",
}
}
@@ -0,0 +1,190 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Adds an alert subscription to a cost anomaly detection monitor. You can use
// each subscription to define subscribers with email or SNS notifications. Email
// subscribers can set an absolute or percentage threshold and a time frequency for
// receiving notifications.
func (c *Client) CreateAnomalySubscription(ctx context.Context, params *CreateAnomalySubscriptionInput, optFns ...func(*Options)) (*CreateAnomalySubscriptionOutput, error) {
if params == nil {
params = &CreateAnomalySubscriptionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateAnomalySubscription", params, optFns, c.addOperationCreateAnomalySubscriptionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateAnomalySubscriptionOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateAnomalySubscriptionInput struct {
// The cost anomaly subscription object that you want to create.
//
// This member is required.
AnomalySubscription *types.AnomalySubscription
// An optional list of tags to associate with the specified [AnomalySubscription]AnomalySubscription .
// You can use resource tags to control access to your subscription using IAM
// policies.
//
// Each tag consists of a key and a value, and each key must be unique for the
// resource. The following restrictions apply to resource tags:
//
// - Although the maximum number of array members is 200, you can assign a
// maximum of 50 user-tags to one resource. The remaining are reserved for Amazon
// Web Services use
//
// - The maximum length of a key is 128 characters
//
// - The maximum length of a value is 256 characters
//
// - Keys and values can only contain alphanumeric characters, spaces, and any
// of the following: _.:/=+@-
//
// - Keys and values are case sensitive
//
// - Keys and values are trimmed for any leading or trailing whitespaces
//
// - Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon
// Web Services use
//
// [AnomalySubscription]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_AnomalySubscription.html
ResourceTags []types.ResourceTag
noSmithyDocumentSerde
}
type CreateAnomalySubscriptionOutput struct {
// The unique identifier of your newly created cost anomaly subscription.
//
// This member is required.
SubscriptionArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateAnomalySubscriptionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateAnomalySubscription"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpCreateAnomalySubscriptionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateAnomalySubscription(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateAnomalySubscription(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "CreateAnomalySubscription",
}
}
@@ -0,0 +1,213 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates a new cost category with the requested name and rules.
func (c *Client) CreateCostCategoryDefinition(ctx context.Context, params *CreateCostCategoryDefinitionInput, optFns ...func(*Options)) (*CreateCostCategoryDefinitionOutput, error) {
if params == nil {
params = &CreateCostCategoryDefinitionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "CreateCostCategoryDefinition", params, optFns, c.addOperationCreateCostCategoryDefinitionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*CreateCostCategoryDefinitionOutput)
out.ResultMetadata = metadata
return out, nil
}
type CreateCostCategoryDefinitionInput struct {
// The unique name of the cost category.
//
// This member is required.
Name *string
// The rule schema version in this particular cost category.
//
// This member is required.
RuleVersion types.CostCategoryRuleVersion
// The cost category rules used to categorize costs. For more information, see [CostCategoryRule].
//
// [CostCategoryRule]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html
//
// This member is required.
Rules []types.CostCategoryRule
// The default value for the cost category.
DefaultValue *string
// The cost category's effective start date. It can only be a billing start date
// (first day of the month). If the date isn't provided, it's the first day of the
// current month. Dates can't be before the previous twelve months, or in the
// future.
EffectiveStart *string
// An optional list of tags to associate with the specified [CostCategory]CostCategory . You can
// use resource tags to control access to your cost category using IAM policies.
//
// Each tag consists of a key and a value, and each key must be unique for the
// resource. The following restrictions apply to resource tags:
//
// - Although the maximum number of array members is 200, you can assign a
// maximum of 50 user-tags to one resource. The remaining are reserved for Amazon
// Web Services use
//
// - The maximum length of a key is 128 characters
//
// - The maximum length of a value is 256 characters
//
// - Keys and values can only contain alphanumeric characters, spaces, and any
// of the following: _.:/=+@-
//
// - Keys and values are case sensitive
//
// - Keys and values are trimmed for any leading or trailing whitespaces
//
// - Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon
// Web Services use
//
// [CostCategory]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategory.html
ResourceTags []types.ResourceTag
// The split charge rules used to allocate your charges between your cost
// category values.
SplitChargeRules []types.CostCategorySplitChargeRule
noSmithyDocumentSerde
}
type CreateCostCategoryDefinitionOutput struct {
// The unique identifier for your newly created cost category.
CostCategoryArn *string
// The cost category's effective start date. It can only be a billing start date
// (first day of the month).
EffectiveStart *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationCreateCostCategoryDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "CreateCostCategoryDefinition"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpCreateCostCategoryDefinitionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateCostCategoryDefinition(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opCreateCostCategoryDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "CreateCostCategoryDefinition",
}
}
@@ -0,0 +1,152 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Deletes a cost anomaly monitor.
func (c *Client) DeleteAnomalyMonitor(ctx context.Context, params *DeleteAnomalyMonitorInput, optFns ...func(*Options)) (*DeleteAnomalyMonitorOutput, error) {
if params == nil {
params = &DeleteAnomalyMonitorInput{}
}
result, metadata, err := c.invokeOperation(ctx, "DeleteAnomalyMonitor", params, optFns, c.addOperationDeleteAnomalyMonitorMiddlewares)
if err != nil {
return nil, err
}
out := result.(*DeleteAnomalyMonitorOutput)
out.ResultMetadata = metadata
return out, nil
}
type DeleteAnomalyMonitorInput struct {
// The unique identifier of the cost anomaly monitor that you want to delete.
//
// This member is required.
MonitorArn *string
noSmithyDocumentSerde
}
type DeleteAnomalyMonitorOutput struct {
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationDeleteAnomalyMonitorMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpDeleteAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDeleteAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteAnomalyMonitor"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpDeleteAnomalyMonitorValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteAnomalyMonitor(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opDeleteAnomalyMonitor(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "DeleteAnomalyMonitor",
}
}
@@ -0,0 +1,152 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Deletes a cost anomaly subscription.
func (c *Client) DeleteAnomalySubscription(ctx context.Context, params *DeleteAnomalySubscriptionInput, optFns ...func(*Options)) (*DeleteAnomalySubscriptionOutput, error) {
if params == nil {
params = &DeleteAnomalySubscriptionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "DeleteAnomalySubscription", params, optFns, c.addOperationDeleteAnomalySubscriptionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*DeleteAnomalySubscriptionOutput)
out.ResultMetadata = metadata
return out, nil
}
type DeleteAnomalySubscriptionInput struct {
// The unique identifier of the cost anomaly subscription that you want to delete.
//
// This member is required.
SubscriptionArn *string
noSmithyDocumentSerde
}
type DeleteAnomalySubscriptionOutput struct {
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationDeleteAnomalySubscriptionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpDeleteAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDeleteAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteAnomalySubscription"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpDeleteAnomalySubscriptionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteAnomalySubscription(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opDeleteAnomalySubscription(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "DeleteAnomalySubscription",
}
}
@@ -0,0 +1,161 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Deletes a cost category. Expenses from this month going forward will no longer
// be categorized with this cost category.
func (c *Client) DeleteCostCategoryDefinition(ctx context.Context, params *DeleteCostCategoryDefinitionInput, optFns ...func(*Options)) (*DeleteCostCategoryDefinitionOutput, error) {
if params == nil {
params = &DeleteCostCategoryDefinitionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "DeleteCostCategoryDefinition", params, optFns, c.addOperationDeleteCostCategoryDefinitionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*DeleteCostCategoryDefinitionOutput)
out.ResultMetadata = metadata
return out, nil
}
type DeleteCostCategoryDefinitionInput struct {
// The unique identifier for your cost category.
//
// This member is required.
CostCategoryArn *string
noSmithyDocumentSerde
}
type DeleteCostCategoryDefinitionOutput struct {
// The unique identifier for your cost category.
CostCategoryArn *string
// The effective end date of the cost category as a result of deleting it. No
// costs after this date is categorized by the deleted cost category.
EffectiveEnd *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationDeleteCostCategoryDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpDeleteCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDeleteCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteCostCategoryDefinition"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpDeleteCostCategoryDefinitionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteCostCategoryDefinition(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opDeleteCostCategoryDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "DeleteCostCategoryDefinition",
}
}
@@ -0,0 +1,167 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Returns the name, Amazon Resource Name (ARN), rules, definition, and effective
// dates of a cost category that's defined in the account.
//
// You have the option to use EffectiveOn to return a cost category that's active
// on a specific date. If there's no EffectiveOn specified, you see a Cost
// Category that's effective on the current date. If cost category is still
// effective, EffectiveEnd is omitted in the response.
func (c *Client) DescribeCostCategoryDefinition(ctx context.Context, params *DescribeCostCategoryDefinitionInput, optFns ...func(*Options)) (*DescribeCostCategoryDefinitionOutput, error) {
if params == nil {
params = &DescribeCostCategoryDefinitionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "DescribeCostCategoryDefinition", params, optFns, c.addOperationDescribeCostCategoryDefinitionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*DescribeCostCategoryDefinitionOutput)
out.ResultMetadata = metadata
return out, nil
}
type DescribeCostCategoryDefinitionInput struct {
// The unique identifier for your cost category.
//
// This member is required.
CostCategoryArn *string
// The date when the cost category was effective.
EffectiveOn *string
noSmithyDocumentSerde
}
type DescribeCostCategoryDefinitionOutput struct {
// The structure of Cost Categories. This includes detailed metadata and the set
// of rules for the CostCategory object.
CostCategory *types.CostCategory
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationDescribeCostCategoryDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "DescribeCostCategoryDefinition"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpDescribeCostCategoryDefinitionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeCostCategoryDefinition(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opDescribeCostCategoryDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "DescribeCostCategoryDefinition",
}
}
@@ -0,0 +1,279 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves all of the cost anomalies detected on your account during the time
// period that's specified by the DateInterval object. Anomalies are available for
// up to 90 days.
func (c *Client) GetAnomalies(ctx context.Context, params *GetAnomaliesInput, optFns ...func(*Options)) (*GetAnomaliesOutput, error) {
if params == nil {
params = &GetAnomaliesInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetAnomalies", params, optFns, c.addOperationGetAnomaliesMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetAnomaliesOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetAnomaliesInput struct {
// Assigns the start and end dates for retrieving cost anomalies. The returned
// anomaly object will have an AnomalyEndDate in the specified time range.
//
// This member is required.
DateInterval *types.AnomalyDateInterval
// Filters anomaly results by the feedback field on the anomaly object.
Feedback types.AnomalyFeedbackType
// The number of entries a paginated response contains.
MaxResults *int32
// Retrieves all of the cost anomalies detected for a specific cost anomaly
// monitor Amazon Resource Name (ARN).
MonitorArn *string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// Filters anomaly results by the total impact field on the anomaly object. For
// example, you can filter anomalies GREATER_THAN 200.00 to retrieve anomalies,
// with an estimated dollar impact greater than 200.
TotalImpact *types.TotalImpactFilter
noSmithyDocumentSerde
}
type GetAnomaliesOutput struct {
// A list of cost anomalies.
//
// This member is required.
Anomalies []types.Anomaly
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetAnomaliesMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetAnomalies{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetAnomalies{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetAnomalies"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetAnomaliesValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetAnomalies(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetAnomaliesPaginatorOptions is the paginator options for GetAnomalies
type GetAnomaliesPaginatorOptions struct {
// The number of entries a paginated response contains.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetAnomaliesPaginator is a paginator for GetAnomalies
type GetAnomaliesPaginator struct {
options GetAnomaliesPaginatorOptions
client GetAnomaliesAPIClient
params *GetAnomaliesInput
nextToken *string
firstPage bool
}
// NewGetAnomaliesPaginator returns a new GetAnomaliesPaginator
func NewGetAnomaliesPaginator(client GetAnomaliesAPIClient, params *GetAnomaliesInput, optFns ...func(*GetAnomaliesPaginatorOptions)) *GetAnomaliesPaginator {
if params == nil {
params = &GetAnomaliesInput{}
}
options := GetAnomaliesPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetAnomaliesPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetAnomaliesPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetAnomalies page.
func (p *GetAnomaliesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetAnomaliesOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetAnomalies(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetAnomaliesAPIClient is a client that implements the GetAnomalies operation.
type GetAnomaliesAPIClient interface {
GetAnomalies(context.Context, *GetAnomaliesInput, ...func(*Options)) (*GetAnomaliesOutput, error)
}
var _ GetAnomaliesAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetAnomalies(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetAnomalies",
}
}
@@ -0,0 +1,263 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the cost anomaly monitor definitions for your account. You can filter
// using a list of cost anomaly monitor Amazon Resource Names (ARNs).
func (c *Client) GetAnomalyMonitors(ctx context.Context, params *GetAnomalyMonitorsInput, optFns ...func(*Options)) (*GetAnomalyMonitorsOutput, error) {
if params == nil {
params = &GetAnomalyMonitorsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetAnomalyMonitors", params, optFns, c.addOperationGetAnomalyMonitorsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetAnomalyMonitorsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetAnomalyMonitorsInput struct {
// The number of entries that a paginated response contains.
MaxResults *int32
// A list of cost anomaly monitor ARNs.
MonitorArnList []string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
noSmithyDocumentSerde
}
type GetAnomalyMonitorsOutput struct {
// A list of cost anomaly monitors that includes the detailed metadata for each
// monitor.
//
// This member is required.
AnomalyMonitors []types.AnomalyMonitor
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetAnomalyMonitorsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetAnomalyMonitors{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetAnomalyMonitors{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetAnomalyMonitors"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetAnomalyMonitors(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetAnomalyMonitorsPaginatorOptions is the paginator options for
// GetAnomalyMonitors
type GetAnomalyMonitorsPaginatorOptions struct {
// The number of entries that a paginated response contains.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetAnomalyMonitorsPaginator is a paginator for GetAnomalyMonitors
type GetAnomalyMonitorsPaginator struct {
options GetAnomalyMonitorsPaginatorOptions
client GetAnomalyMonitorsAPIClient
params *GetAnomalyMonitorsInput
nextToken *string
firstPage bool
}
// NewGetAnomalyMonitorsPaginator returns a new GetAnomalyMonitorsPaginator
func NewGetAnomalyMonitorsPaginator(client GetAnomalyMonitorsAPIClient, params *GetAnomalyMonitorsInput, optFns ...func(*GetAnomalyMonitorsPaginatorOptions)) *GetAnomalyMonitorsPaginator {
if params == nil {
params = &GetAnomalyMonitorsInput{}
}
options := GetAnomalyMonitorsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetAnomalyMonitorsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetAnomalyMonitorsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetAnomalyMonitors page.
func (p *GetAnomalyMonitorsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetAnomalyMonitorsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetAnomalyMonitors(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetAnomalyMonitorsAPIClient is a client that implements the GetAnomalyMonitors
// operation.
type GetAnomalyMonitorsAPIClient interface {
GetAnomalyMonitors(context.Context, *GetAnomalyMonitorsInput, ...func(*Options)) (*GetAnomalyMonitorsOutput, error)
}
var _ GetAnomalyMonitorsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetAnomalyMonitors(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetAnomalyMonitors",
}
}
@@ -0,0 +1,267 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the cost anomaly subscription objects for your account. You can
// filter using a list of cost anomaly monitor Amazon Resource Names (ARNs).
func (c *Client) GetAnomalySubscriptions(ctx context.Context, params *GetAnomalySubscriptionsInput, optFns ...func(*Options)) (*GetAnomalySubscriptionsOutput, error) {
if params == nil {
params = &GetAnomalySubscriptionsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetAnomalySubscriptions", params, optFns, c.addOperationGetAnomalySubscriptionsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetAnomalySubscriptionsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetAnomalySubscriptionsInput struct {
// The number of entries a paginated response contains.
MaxResults *int32
// Cost anomaly monitor ARNs.
MonitorArn *string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// A list of cost anomaly subscription ARNs.
SubscriptionArnList []string
noSmithyDocumentSerde
}
type GetAnomalySubscriptionsOutput struct {
// A list of cost anomaly subscriptions that includes the detailed metadata for
// each one.
//
// This member is required.
AnomalySubscriptions []types.AnomalySubscription
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetAnomalySubscriptionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetAnomalySubscriptions{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetAnomalySubscriptions{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetAnomalySubscriptions"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetAnomalySubscriptions(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetAnomalySubscriptionsPaginatorOptions is the paginator options for
// GetAnomalySubscriptions
type GetAnomalySubscriptionsPaginatorOptions struct {
// The number of entries a paginated response contains.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetAnomalySubscriptionsPaginator is a paginator for GetAnomalySubscriptions
type GetAnomalySubscriptionsPaginator struct {
options GetAnomalySubscriptionsPaginatorOptions
client GetAnomalySubscriptionsAPIClient
params *GetAnomalySubscriptionsInput
nextToken *string
firstPage bool
}
// NewGetAnomalySubscriptionsPaginator returns a new
// GetAnomalySubscriptionsPaginator
func NewGetAnomalySubscriptionsPaginator(client GetAnomalySubscriptionsAPIClient, params *GetAnomalySubscriptionsInput, optFns ...func(*GetAnomalySubscriptionsPaginatorOptions)) *GetAnomalySubscriptionsPaginator {
if params == nil {
params = &GetAnomalySubscriptionsInput{}
}
options := GetAnomalySubscriptionsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetAnomalySubscriptionsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetAnomalySubscriptionsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetAnomalySubscriptions page.
func (p *GetAnomalySubscriptionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetAnomalySubscriptionsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetAnomalySubscriptions(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetAnomalySubscriptionsAPIClient is a client that implements the
// GetAnomalySubscriptions operation.
type GetAnomalySubscriptionsAPIClient interface {
GetAnomalySubscriptions(context.Context, *GetAnomalySubscriptionsInput, ...func(*Options)) (*GetAnomalySubscriptionsOutput, error)
}
var _ GetAnomalySubscriptionsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetAnomalySubscriptions(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetAnomalySubscriptions",
}
}
@@ -0,0 +1,176 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves estimated usage records for hourly granularity or resource-level data
// at daily granularity.
func (c *Client) GetApproximateUsageRecords(ctx context.Context, params *GetApproximateUsageRecordsInput, optFns ...func(*Options)) (*GetApproximateUsageRecordsOutput, error) {
if params == nil {
params = &GetApproximateUsageRecordsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetApproximateUsageRecords", params, optFns, c.addOperationGetApproximateUsageRecordsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetApproximateUsageRecordsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetApproximateUsageRecordsInput struct {
// The service to evaluate for the usage records. You can choose resource-level
// data at daily granularity, or hourly granularity with or without resource-level
// data.
//
// This member is required.
ApproximationDimension types.ApproximationDimension
// How granular you want the data to be. You can enable data at hourly or daily
// granularity.
//
// This member is required.
Granularity types.Granularity
// The service metadata for the service or services you want to query. If not
// specified, all elements are returned.
Services []string
noSmithyDocumentSerde
}
type GetApproximateUsageRecordsOutput struct {
// The lookback period that's used for the estimation.
LookbackPeriod *types.DateInterval
// The service metadata for the service or services in the response.
Services map[string]int64
// The total number of usage records for all services in the services list.
TotalRecords int64
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetApproximateUsageRecordsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetApproximateUsageRecords{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetApproximateUsageRecords{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetApproximateUsageRecords"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetApproximateUsageRecordsValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetApproximateUsageRecords(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetApproximateUsageRecords(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetApproximateUsageRecords",
}
}
@@ -0,0 +1,188 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves a commitment purchase analysis result based on the AnalysisId .
func (c *Client) GetCommitmentPurchaseAnalysis(ctx context.Context, params *GetCommitmentPurchaseAnalysisInput, optFns ...func(*Options)) (*GetCommitmentPurchaseAnalysisOutput, error) {
if params == nil {
params = &GetCommitmentPurchaseAnalysisInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCommitmentPurchaseAnalysis", params, optFns, c.addOperationGetCommitmentPurchaseAnalysisMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCommitmentPurchaseAnalysisOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCommitmentPurchaseAnalysisInput struct {
// The analysis ID that's associated with the commitment purchase analysis.
//
// This member is required.
AnalysisId *string
noSmithyDocumentSerde
}
type GetCommitmentPurchaseAnalysisOutput struct {
// The analysis ID that's associated with the commitment purchase analysis.
//
// This member is required.
AnalysisId *string
// The start time of the analysis.
//
// This member is required.
AnalysisStartedTime *string
// The status of the analysis.
//
// This member is required.
AnalysisStatus types.AnalysisStatus
// The configuration for the commitment purchase analysis.
//
// This member is required.
CommitmentPurchaseAnalysisConfiguration *types.CommitmentPurchaseAnalysisConfiguration
// The estimated time for when the analysis will complete.
//
// This member is required.
EstimatedCompletionTime *string
// The completion time of the analysis.
AnalysisCompletionTime *string
// Details about the analysis.
AnalysisDetails *types.AnalysisDetails
// The error code used for the analysis.
ErrorCode types.ErrorCode
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCommitmentPurchaseAnalysisMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCommitmentPurchaseAnalysis{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCommitmentPurchaseAnalysis{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCommitmentPurchaseAnalysis"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCommitmentPurchaseAnalysisValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCommitmentPurchaseAnalysis(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetCommitmentPurchaseAnalysis(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCommitmentPurchaseAnalysis",
}
}
@@ -0,0 +1,247 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves cost and usage metrics for your account. You can specify which cost
// and usage-related metric that you want the request to return. For example, you
// can specify BlendedCosts or UsageQuantity . You can also filter and group your
// data by various dimensions, such as SERVICE or AZ , in a specific time range.
// For a complete list of valid dimensions, see the [GetDimensionValues]operation. Management account
// in an organization in Organizations have access to all member accounts.
//
// For information about filter limitations, see [Quotas and restrictions] in the Billing and Cost
// Management User Guide.
//
// [GetDimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetDimensionValues.html
// [Quotas and restrictions]: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-limits.html
func (c *Client) GetCostAndUsage(ctx context.Context, params *GetCostAndUsageInput, optFns ...func(*Options)) (*GetCostAndUsageOutput, error) {
if params == nil {
params = &GetCostAndUsageInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostAndUsage", params, optFns, c.addOperationGetCostAndUsageMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostAndUsageOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostAndUsageInput struct {
// Sets the Amazon Web Services cost granularity to MONTHLY or DAILY , or HOURLY .
// If Granularity isn't set, the response object doesn't include the Granularity ,
// either MONTHLY or DAILY , or HOURLY .
//
// This member is required.
Granularity types.Granularity
// Which metrics are returned in the query. For more information about blended and
// unblended rates, see [Why does the "blended" annotation appear on some line items in my bill?].
//
// Valid values are AmortizedCost , BlendedCost , NetAmortizedCost ,
// NetUnblendedCost , NormalizedUsageAmount , UnblendedCost , and UsageQuantity .
//
// If you return the UsageQuantity metric, the service aggregates all usage
// numbers without taking into account the units. For example, if you aggregate
// usageQuantity across all of Amazon EC2, the results aren't meaningful because
// Amazon EC2 compute hours and data transfer are measured in different units (for
// example, hours and GB). To get more meaningful UsageQuantity metrics, filter by
// UsageType or UsageTypeGroups .
//
// Metrics is required for GetCostAndUsage requests.
//
// [Why does the "blended" annotation appear on some line items in my bill?]: http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/
//
// This member is required.
Metrics []string
// Sets the start date and end date for retrieving Amazon Web Services costs. The
// start date is inclusive, but the end date is exclusive. For example, if start
// is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved
// from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// Filters Amazon Web Services costs by different dimensions. For example, you can
// specify SERVICE and LINKED_ACCOUNT and get the costs that are associated with
// that account's usage of that service. You can nest Expression objects to define
// any combination of dimension filters. For more information, see [Expression].
//
// Valid values for MatchOptions for Dimensions are EQUALS and CASE_SENSITIVE .
//
// Valid values for MatchOptions for CostCategories and Tags are EQUALS , ABSENT ,
// and CASE_SENSITIVE . Default values are EQUALS and CASE_SENSITIVE .
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// You can group Amazon Web Services costs using up to two different groups,
// either dimensions, tag keys, cost categories, or any two group by types.
//
// Valid values for the DIMENSION type are AZ , INSTANCE_TYPE , LEGAL_ENTITY_NAME ,
// INVOICING_ENTITY , LINKED_ACCOUNT , OPERATION , PLATFORM , PURCHASE_TYPE ,
// SERVICE , TENANCY , RECORD_TYPE , and USAGE_TYPE .
//
// When you group by the TAG type and include a valid tag key, you get all tag
// values, including empty strings.
GroupBy []types.GroupDefinition
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
noSmithyDocumentSerde
}
type GetCostAndUsageOutput struct {
// The attributes that apply to a specific dimension value. For example, if the
// value is a linked account, the attribute is that account name.
DimensionValueAttributes []types.DimensionValuesWithAttributes
// The groups that are specified by the Filter or GroupBy parameters in the
// request.
GroupDefinitions []types.GroupDefinition
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// The time period that's covered by the results in the response.
ResultsByTime []types.ResultByTime
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostAndUsageMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostAndUsage{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostAndUsage{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostAndUsage"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostAndUsageValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostAndUsage(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetCostAndUsage(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostAndUsage",
}
}
@@ -0,0 +1,375 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves cost and usage comparisons for your account between two periods
// within the last 13 months. If you have enabled multi-year data at monthly
// granularity, you can go back up to 38 months.
func (c *Client) GetCostAndUsageComparisons(ctx context.Context, params *GetCostAndUsageComparisonsInput, optFns ...func(*Options)) (*GetCostAndUsageComparisonsOutput, error) {
if params == nil {
params = &GetCostAndUsageComparisonsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostAndUsageComparisons", params, optFns, c.addOperationGetCostAndUsageComparisonsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostAndUsageComparisonsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostAndUsageComparisonsInput struct {
// The reference time period for comparison. This time period serves as the
// baseline against which other cost and usage data will be compared. The interval
// must start and end on the first day of a month, with a duration of exactly one
// month.
//
// This member is required.
BaselineTimePeriod *types.DateInterval
// The comparison time period for analysis. This time period's cost and usage data
// will be compared against the baseline time period. The interval must start and
// end on the first day of a month, with a duration of exactly one month.
//
// This member is required.
ComparisonTimePeriod *types.DateInterval
// The cost and usage metric to compare. Valid values are AmortizedCost ,
// BlendedCost , NetAmortizedCost , NetUnblendedCost , NormalizedUsageAmount ,
// UnblendedCost , and UsageQuantity .
//
// This member is required.
MetricForComparison *string
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// You can group results using the attributes DIMENSION , TAG , and COST_CATEGORY .
GroupBy []types.GroupDefinition
// The maximum number of results that are returned for the request.
MaxResults *int32
// The token to retrieve the next set of paginated results.
NextPageToken *string
noSmithyDocumentSerde
}
type GetCostAndUsageComparisonsOutput struct {
// An array of comparison results showing cost and usage metrics between
// BaselineTimePeriod and ComparisonTimePeriod .
CostAndUsageComparisons []types.CostAndUsageComparison
// The token to retrieve the next set of paginated results.
NextPageToken *string
// A summary of the total cost and usage, comparing amounts between
// BaselineTimePeriod and ComparisonTimePeriod and their differences. This total
// represents the aggregate total across all paginated results, if the response
// spans multiple pages.
TotalCostAndUsage map[string]types.ComparisonMetricValue
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostAndUsageComparisonsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostAndUsageComparisons{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostAndUsageComparisons{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostAndUsageComparisons"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostAndUsageComparisonsValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostAndUsageComparisons(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetCostAndUsageComparisonsPaginatorOptions is the paginator options for
// GetCostAndUsageComparisons
type GetCostAndUsageComparisonsPaginatorOptions struct {
// The maximum number of results that are returned for the request.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetCostAndUsageComparisonsPaginator is a paginator for
// GetCostAndUsageComparisons
type GetCostAndUsageComparisonsPaginator struct {
options GetCostAndUsageComparisonsPaginatorOptions
client GetCostAndUsageComparisonsAPIClient
params *GetCostAndUsageComparisonsInput
nextToken *string
firstPage bool
}
// NewGetCostAndUsageComparisonsPaginator returns a new
// GetCostAndUsageComparisonsPaginator
func NewGetCostAndUsageComparisonsPaginator(client GetCostAndUsageComparisonsAPIClient, params *GetCostAndUsageComparisonsInput, optFns ...func(*GetCostAndUsageComparisonsPaginatorOptions)) *GetCostAndUsageComparisonsPaginator {
if params == nil {
params = &GetCostAndUsageComparisonsInput{}
}
options := GetCostAndUsageComparisonsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetCostAndUsageComparisonsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetCostAndUsageComparisonsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetCostAndUsageComparisons page.
func (p *GetCostAndUsageComparisonsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetCostAndUsageComparisonsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetCostAndUsageComparisons(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetCostAndUsageComparisonsAPIClient is a client that implements the
// GetCostAndUsageComparisons operation.
type GetCostAndUsageComparisonsAPIClient interface {
GetCostAndUsageComparisons(context.Context, *GetCostAndUsageComparisonsInput, ...func(*Options)) (*GetCostAndUsageComparisonsOutput, error)
}
var _ GetCostAndUsageComparisonsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetCostAndUsageComparisons(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostAndUsageComparisons",
}
}
@@ -0,0 +1,252 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves cost and usage metrics with resources for your account. You can
// specify which cost and usage-related metric, such as BlendedCosts or
// UsageQuantity , that you want the request to return. You can also filter and
// group your data by various dimensions, such as SERVICE or AZ , in a specific
// time range. For a complete list of valid dimensions, see the [GetDimensionValues]operation.
// Management account in an organization in Organizations have access to all member
// accounts.
//
// Hourly granularity is only available for EC2-Instances (Elastic Compute Cloud)
// resource-level data. All other resource-level data is available at daily
// granularity.
//
// This is an opt-in only feature. You can enable this feature from the Cost
// Explorer Settings page. For information about how to access the Settings page,
// see [Controlling Access for Cost Explorer]in the Billing and Cost Management User Guide.
//
// [GetDimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetDimensionValues.html
// [Controlling Access for Cost Explorer]: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-access.html
func (c *Client) GetCostAndUsageWithResources(ctx context.Context, params *GetCostAndUsageWithResourcesInput, optFns ...func(*Options)) (*GetCostAndUsageWithResourcesOutput, error) {
if params == nil {
params = &GetCostAndUsageWithResourcesInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostAndUsageWithResources", params, optFns, c.addOperationGetCostAndUsageWithResourcesMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostAndUsageWithResourcesOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostAndUsageWithResourcesInput struct {
// Filters Amazon Web Services costs by different dimensions. For example, you can
// specify SERVICE and LINKED_ACCOUNT and get the costs that are associated with
// that account's usage of that service. You can nest Expression objects to define
// any combination of dimension filters. For more information, see [Expression].
//
// The GetCostAndUsageWithResources operation requires that you either group by or
// filter by a ResourceId . It requires the [Expression]"SERVICE = Amazon Elastic Compute
// Cloud - Compute" in the filter.
//
// Valid values for MatchOptions for Dimensions are EQUALS and CASE_SENSITIVE .
//
// Valid values for MatchOptions for CostCategories and Tags are EQUALS , ABSENT ,
// and CASE_SENSITIVE . Default values are EQUALS and CASE_SENSITIVE .
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
//
// This member is required.
Filter *types.Expression
// Sets the Amazon Web Services cost granularity to MONTHLY , DAILY , or HOURLY .
// If Granularity isn't set, the response object doesn't include the Granularity ,
// MONTHLY , DAILY , or HOURLY .
//
// This member is required.
Granularity types.Granularity
// Sets the start and end dates for retrieving Amazon Web Services costs. The
// range must be within the last 14 days (the start date cannot be earlier than 14
// days ago). The start date is inclusive, but the end date is exclusive. For
// example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage
// data is retrieved from 2017-01-01 up to and including 2017-04-30 but not
// including 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// You can group Amazon Web Services costs using up to two different groups:
// DIMENSION , TAG , COST_CATEGORY .
GroupBy []types.GroupDefinition
// Which metrics are returned in the query. For more information about blended and
// unblended rates, see [Why does the "blended" annotation appear on some line items in my bill?].
//
// Valid values are AmortizedCost , BlendedCost , NetAmortizedCost ,
// NetUnblendedCost , NormalizedUsageAmount , UnblendedCost , and UsageQuantity .
//
// If you return the UsageQuantity metric, the service aggregates all usage
// numbers without taking the units into account. For example, if you aggregate
// usageQuantity across all of Amazon EC2, the results aren't meaningful because
// Amazon EC2 compute hours and data transfer are measured in different units (for
// example, hour or GB). To get more meaningful UsageQuantity metrics, filter by
// UsageType or UsageTypeGroups .
//
// Metrics is required for GetCostAndUsageWithResources requests.
//
// [Why does the "blended" annotation appear on some line items in my bill?]: http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/
Metrics []string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
noSmithyDocumentSerde
}
type GetCostAndUsageWithResourcesOutput struct {
// The attributes that apply to a specific dimension value. For example, if the
// value is a linked account, the attribute is that account name.
DimensionValueAttributes []types.DimensionValuesWithAttributes
// The groups that are specified by the Filter or GroupBy parameters in the
// request.
GroupDefinitions []types.GroupDefinition
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// The time period that's covered by the results in the response.
ResultsByTime []types.ResultByTime
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostAndUsageWithResourcesMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostAndUsageWithResources{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostAndUsageWithResources{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostAndUsageWithResources"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostAndUsageWithResourcesValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostAndUsageWithResources(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetCostAndUsageWithResources(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostAndUsageWithResources",
}
}
@@ -0,0 +1,317 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves an array of cost category names and values incurred cost.
//
// If some cost category names and values are not associated with any cost, they
// will not be returned by this API.
func (c *Client) GetCostCategories(ctx context.Context, params *GetCostCategoriesInput, optFns ...func(*Options)) (*GetCostCategoriesOutput, error) {
if params == nil {
params = &GetCostCategoriesInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostCategories", params, optFns, c.addOperationGetCostCategoriesMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostCategoriesOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostCategoriesInput struct {
// The time period of the request.
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// The unique name of the cost category.
CostCategoryName *string
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// This field is only used when the SortBy value is provided in the request.
//
// The maximum number of objects that are returned for this request. If MaxResults
// isn't specified with the SortBy value, the request returns 1000 results as the
// default value for this parameter.
//
// For GetCostCategories , MaxResults has an upper quota of 1000.
MaxResults *int32
// If the number of objects that are still available for retrieval exceeds the
// quota, Amazon Web Services returns a NextPageToken value in the response. To
// retrieve the next batch of objects, provide the NextPageToken from the previous
// call in your next request.
NextPageToken *string
// The value that you want to search the filter values for.
//
// If you don't specify a CostCategoryName , SearchString is used to filter cost
// category names that match the SearchString pattern. If you specify a
// CostCategoryName , SearchString is used to filter cost category values that
// match the SearchString pattern.
SearchString *string
// The value that you sort the data by.
//
// The key represents the cost and usage metrics. The following values are
// supported:
//
// - BlendedCost
//
// - UnblendedCost
//
// - AmortizedCost
//
// - NetAmortizedCost
//
// - NetUnblendedCost
//
// - UsageQuantity
//
// - NormalizedUsageAmount
//
// The supported key values for the SortOrder value are ASCENDING and DESCENDING .
//
// When you use the SortBy value, the NextPageToken and SearchString key values
// aren't supported.
SortBy []types.SortDefinition
noSmithyDocumentSerde
}
type GetCostCategoriesOutput struct {
// The number of objects that are returned.
//
// This member is required.
ReturnSize *int32
// The total number of objects.
//
// This member is required.
TotalSize *int32
// The names of the cost categories.
CostCategoryNames []string
// The cost category values.
//
// If the CostCategoryName key isn't specified in the request, the
// CostCategoryValues fields aren't returned.
CostCategoryValues []string
// If the number of objects that are still available for retrieval exceeds the
// quota, Amazon Web Services returns a NextPageToken value in the response. To
// retrieve the next batch of objects, provide the marker from the prior call in
// your next request.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostCategoriesMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostCategories{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostCategories{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostCategories"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostCategoriesValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostCategories(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetCostCategories(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostCategories",
}
}
@@ -0,0 +1,371 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves key factors driving cost changes between two time periods within the
// last 13 months, such as usage changes, discount changes, and commitment-based
// savings. If you have enabled multi-year data at monthly granularity, you can go
// back up to 38 months.
func (c *Client) GetCostComparisonDrivers(ctx context.Context, params *GetCostComparisonDriversInput, optFns ...func(*Options)) (*GetCostComparisonDriversOutput, error) {
if params == nil {
params = &GetCostComparisonDriversInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostComparisonDrivers", params, optFns, c.addOperationGetCostComparisonDriversMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostComparisonDriversOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostComparisonDriversInput struct {
// The reference time period for comparison. This time period serves as the
// baseline against which other cost and usage data will be compared. The interval
// must start and end on the first day of a month, with a duration of exactly one
// month.
//
// This member is required.
BaselineTimePeriod *types.DateInterval
// The comparison time period for analysis. This time period's cost and usage data
// will be compared against the baseline time period. The interval must start and
// end on the first day of a month, with a duration of exactly one month.
//
// This member is required.
ComparisonTimePeriod *types.DateInterval
// The cost and usage metric to compare. Valid values are AmortizedCost ,
// BlendedCost , NetAmortizedCost , NetUnblendedCost , NormalizedUsageAmount ,
// UnblendedCost , and UsageQuantity .
//
// This member is required.
MetricForComparison *string
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// You can group results using the attributes DIMENSION , TAG , and COST_CATEGORY .
// Note that SERVICE and USAGE_TYPE dimensions are automatically included in the
// cost comparison drivers analysis.
GroupBy []types.GroupDefinition
// The maximum number of results that are returned for the request.
MaxResults *int32
// The token to retrieve the next set of paginated results.
NextPageToken *string
noSmithyDocumentSerde
}
type GetCostComparisonDriversOutput struct {
// An array of comparison results showing factors that drive significant cost
// differences between BaselineTimePeriod and ComparisonTimePeriod .
CostComparisonDrivers []types.CostComparisonDriver
// The token to retrieve the next set of paginated results.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostComparisonDriversMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostComparisonDrivers{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostComparisonDrivers{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostComparisonDrivers"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostComparisonDriversValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostComparisonDrivers(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetCostComparisonDriversPaginatorOptions is the paginator options for
// GetCostComparisonDrivers
type GetCostComparisonDriversPaginatorOptions struct {
// The maximum number of results that are returned for the request.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetCostComparisonDriversPaginator is a paginator for GetCostComparisonDrivers
type GetCostComparisonDriversPaginator struct {
options GetCostComparisonDriversPaginatorOptions
client GetCostComparisonDriversAPIClient
params *GetCostComparisonDriversInput
nextToken *string
firstPage bool
}
// NewGetCostComparisonDriversPaginator returns a new
// GetCostComparisonDriversPaginator
func NewGetCostComparisonDriversPaginator(client GetCostComparisonDriversAPIClient, params *GetCostComparisonDriversInput, optFns ...func(*GetCostComparisonDriversPaginatorOptions)) *GetCostComparisonDriversPaginator {
if params == nil {
params = &GetCostComparisonDriversInput{}
}
options := GetCostComparisonDriversPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetCostComparisonDriversPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetCostComparisonDriversPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetCostComparisonDrivers page.
func (p *GetCostComparisonDriversPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetCostComparisonDriversOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetCostComparisonDrivers(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetCostComparisonDriversAPIClient is a client that implements the
// GetCostComparisonDrivers operation.
type GetCostComparisonDriversAPIClient interface {
GetCostComparisonDrivers(context.Context, *GetCostComparisonDriversInput, ...func(*Options)) (*GetCostComparisonDriversOutput, error)
}
var _ GetCostComparisonDriversAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetCostComparisonDrivers(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostComparisonDrivers",
}
}
@@ -0,0 +1,253 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves a forecast for how much Amazon Web Services predicts that you will
// spend over the forecast time period that you select, based on your past costs.
func (c *Client) GetCostForecast(ctx context.Context, params *GetCostForecastInput, optFns ...func(*Options)) (*GetCostForecastOutput, error) {
if params == nil {
params = &GetCostForecastInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCostForecast", params, optFns, c.addOperationGetCostForecastMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetCostForecastOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetCostForecastInput struct {
// How granular you want the forecast to be. You can get 3 months of DAILY
// forecasts or 18 months of MONTHLY forecasts.
//
// The GetCostForecast operation supports only DAILY and MONTHLY granularities.
//
// This member is required.
Granularity types.Granularity
// Which metric Cost Explorer uses to create your forecast. For more information
// about blended and unblended rates, see [Why does the "blended" annotation appear on some line items in my bill?].
//
// Valid values for a GetCostForecast call are the following:
//
// - AMORTIZED_COST
//
// - BLENDED_COST
//
// - NET_AMORTIZED_COST
//
// - NET_UNBLENDED_COST
//
// - UNBLENDED_COST
//
// [Why does the "blended" annotation appear on some line items in my bill?]: http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/
//
// This member is required.
Metric types.Metric
// The period of time that you want the forecast to cover. The start date must be
// equal to or no later than the current date to avoid a validation error.
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// The filters that you want to use to filter your forecast. The GetCostForecast
// API supports filtering by the following dimensions:
//
// - AZ
//
// - INSTANCE_TYPE
//
// - LINKED_ACCOUNT
//
// - OPERATION
//
// - PURCHASE_TYPE
//
// - REGION
//
// - SERVICE
//
// - USAGE_TYPE
//
// - USAGE_TYPE_GROUP
//
// - RECORD_TYPE
//
// - OPERATING_SYSTEM
//
// - TENANCY
//
// - SCOPE
//
// - PLATFORM
//
// - SUBSCRIPTION_ID
//
// - LEGAL_ENTITY_NAME
//
// - DEPLOYMENT_OPTION
//
// - DATABASE_ENGINE
//
// - INSTANCE_TYPE_FAMILY
//
// - BILLING_ENTITY
//
// - RESERVATION_ID
//
// - SAVINGS_PLAN_ARN
Filter *types.Expression
// Cost Explorer always returns the mean forecast as a single point. You can
// request a prediction interval around the mean by specifying a confidence level.
// The higher the confidence level, the more confident Cost Explorer is about the
// actual value falling in the prediction interval. Higher confidence levels result
// in wider prediction intervals.
PredictionIntervalLevel *int32
noSmithyDocumentSerde
}
type GetCostForecastOutput struct {
// The forecasts for your query, in order. For DAILY forecasts, this is a list of
// days. For MONTHLY forecasts, this is a list of months.
ForecastResultsByTime []types.ForecastResult
// How much you are forecasted to spend over the forecast period, in USD .
Total *types.MetricValue
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetCostForecastMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostForecast{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostForecast{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostForecast"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetCostForecastValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostForecast(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetCostForecast(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetCostForecast",
}
}
@@ -0,0 +1,539 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves all available filter values for a specified filter over a period of
// time. You can search the dimension values for an arbitrary string.
func (c *Client) GetDimensionValues(ctx context.Context, params *GetDimensionValuesInput, optFns ...func(*Options)) (*GetDimensionValuesOutput, error) {
if params == nil {
params = &GetDimensionValuesInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetDimensionValues", params, optFns, c.addOperationGetDimensionValuesMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetDimensionValuesOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetDimensionValuesInput struct {
// The name of the dimension. Each Dimension is available for a different Context .
// For more information, see Context . LINK_ACCOUNT_NAME and SERVICE_CODE can only
// be used in [CostCategoryRule].
//
// [CostCategoryRule]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/AAPI_CostCategoryRule.html
//
// This member is required.
Dimension types.Dimension
// The start date and end date for retrieving the dimension values. The start date
// is inclusive, but the end date is exclusive. For example, if start is 2017-01-01
// and end is 2017-05-01 , then the cost and usage data is retrieved from
// 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// The context for the call to GetDimensionValues . This can be RESERVATIONS or
// COST_AND_USAGE . The default value is COST_AND_USAGE . If the context is set to
// RESERVATIONS , the resulting dimension values can be used in the
// GetReservationUtilization operation. If the context is set to COST_AND_USAGE ,
// the resulting dimension values can be used in the GetCostAndUsage operation.
//
// If you set the context to COST_AND_USAGE , you can use the following dimensions
// for searching:
//
// - AZ - The Availability Zone. An example is us-east-1a .
//
// - BILLING_ENTITY - The Amazon Web Services seller that your account is with.
// Possible values are the following:
//
// - Amazon Web Services(Amazon Web Services): The entity that sells Amazon Web
// Services services.
//
// - AISPL (Amazon Internet Services Pvt. Ltd.): The local Indian entity that's an
// acting reseller for Amazon Web Services services in India.
//
// - Amazon Web Services Marketplace: The entity that supports the sale of
// solutions that are built on Amazon Web Services by third-party software
// providers.
//
// - CACHE_ENGINE - The Amazon ElastiCache operating system. Examples are
// Windows or Linux.
//
// - DEPLOYMENT_OPTION - The scope of Amazon Relational Database Service
// deployments. Valid values are SingleAZ and MultiAZ .
//
// - DATABASE_ENGINE - The Amazon Relational Database Service database. Examples
// are Aurora or MySQL.
//
// - INSTANCE_TYPE - The type of Amazon EC2 instance. An example is m4.xlarge .
//
// - INSTANCE_TYPE_FAMILY - A family of instance types optimized to fit
// different use cases. Examples are Compute Optimized (for example, C4 , C5 ,
// C6g , and C7g ), Memory Optimization (for example, R4 , R5n , R5b , and R6g ).
//
// - INVOICING_ENTITY - The name of the entity that issues the Amazon Web
// Services invoice.
//
// - LEGAL_ENTITY_NAME - The name of the organization that sells you Amazon Web
// Services services, such as Amazon Web Services.
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - OPERATING_SYSTEM - The operating system. Examples are Windows or Linux.
//
// - OPERATION - The action performed. Examples include RunInstance and
// CreateBucket .
//
// - PLATFORM - The Amazon EC2 operating system. Examples are Windows or Linux.
//
// - PURCHASE_TYPE - The reservation type of the purchase that this usage is
// related to. Examples include On-Demand Instances and Standard Reserved
// Instances.
//
// - RESERVATION_ID - The unique identifier for an Amazon Web Services
// Reservation Instance.
//
// - SAVINGS_PLAN_ARN - The unique identifier for your Savings Plans.
//
// - SAVINGS_PLANS_TYPE - Type of Savings Plans (EC2 Instance or Compute).
//
// - SERVICE - The Amazon Web Services service such as Amazon DynamoDB.
//
// - TENANCY - The tenancy of a resource. Examples are shared or dedicated.
//
// - USAGE_TYPE - The type of usage. An example is DataTransfer-In-Bytes. The
// response for the GetDimensionValues operation includes a unit attribute.
// Examples include GB and Hrs.
//
// - USAGE_TYPE_GROUP - The grouping of common usage types. An example is Amazon
// EC2: CloudWatch – Alarms. The response for this operation includes a unit
// attribute.
//
// - REGION - The Amazon Web Services Region.
//
// - RECORD_TYPE - The different types of charges such as Reserved Instance (RI)
// fees, usage costs, tax refunds, and credits.
//
// - RESOURCE_ID - The unique identifier of the resource. ResourceId is an
// opt-in feature only available for last 14 days for EC2-Compute Service.
//
// If you set the context to RESERVATIONS , you can use the following dimensions
// for searching:
//
// - AZ - The Availability Zone. An example is us-east-1a .
//
// - CACHE_ENGINE - The Amazon ElastiCache operating system. Examples are
// Windows or Linux.
//
// - DEPLOYMENT_OPTION - The scope of Amazon Relational Database Service
// deployments. Valid values are SingleAZ and MultiAZ .
//
// - INSTANCE_TYPE - The type of Amazon EC2 instance. An example is m4.xlarge .
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - PLATFORM - The Amazon EC2 operating system. Examples are Windows or Linux.
//
// - REGION - The Amazon Web Services Region.
//
// - SCOPE (Utilization only) - The scope of a Reserved Instance (RI). Values
// are regional or a single Availability Zone.
//
// - TAG (Coverage only) - The tags that are associated with a Reserved Instance
// (RI).
//
// - TENANCY - The tenancy of a resource. Examples are shared or dedicated.
//
// If you set the context to SAVINGS_PLANS , you can use the following dimensions
// for searching:
//
// - SAVINGS_PLANS_TYPE - Type of Savings Plans (EC2 Instance or Compute)
//
// - PAYMENT_OPTION - The payment option for the given Savings Plans (for
// example, All Upfront)
//
// - REGION - The Amazon Web Services Region.
//
// - INSTANCE_TYPE_FAMILY - The family of instances (For example, m5 )
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - SAVINGS_PLAN_ARN - The unique identifier for your Savings Plans.
Context types.Context
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// This field is only used when SortBy is provided in the request. The maximum
// number of objects that are returned for this request. If MaxResults isn't
// specified with SortBy, the request returns 1000 results as the default value for
// this parameter.
//
// For GetDimensionValues , MaxResults has an upper limit of 1000.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// The value that you want to search the filter values for.
SearchString *string
// The value that you want to sort the data by.
//
// The key represents cost and usage metrics. The following values are supported:
//
// - BlendedCost
//
// - UnblendedCost
//
// - AmortizedCost
//
// - NetAmortizedCost
//
// - NetUnblendedCost
//
// - UsageQuantity
//
// - NormalizedUsageAmount
//
// The supported values for the SortOrder key are ASCENDING or DESCENDING .
//
// When you specify a SortBy paramater, the context must be COST_AND_USAGE .
// Further, when using SortBy , NextPageToken and SearchString aren't supported.
SortBy []types.SortDefinition
noSmithyDocumentSerde
}
type GetDimensionValuesOutput struct {
// The filters that you used to filter your request. Some dimensions are available
// only for a specific context.
//
// If you set the context to COST_AND_USAGE , you can use the following dimensions
// for searching:
//
// - AZ - The Availability Zone. An example is us-east-1a .
//
// - DATABASE_ENGINE - The Amazon Relational Database Service database. Examples
// are Aurora or MySQL.
//
// - INSTANCE_TYPE - The type of Amazon EC2 instance. An example is m4.xlarge .
//
// - LEGAL_ENTITY_NAME - The name of the organization that sells you Amazon Web
// Services services, such as Amazon Web Services.
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - OPERATING_SYSTEM - The operating system. Examples are Windows or Linux.
//
// - OPERATION - The action performed. Examples include RunInstance and
// CreateBucket .
//
// - PLATFORM - The Amazon EC2 operating system. Examples are Windows or Linux.
//
// - PURCHASE_TYPE - The reservation type of the purchase to which this usage is
// related. Examples include On-Demand Instances and Standard Reserved Instances.
//
// - SERVICE - The Amazon Web Services service such as Amazon DynamoDB.
//
// - USAGE_TYPE - The type of usage. An example is DataTransfer-In-Bytes. The
// response for the GetDimensionValues operation includes a unit attribute.
// Examples include GB and Hrs.
//
// - USAGE_TYPE_GROUP - The grouping of common usage types. An example is Amazon
// EC2: CloudWatch – Alarms. The response for this operation includes a unit
// attribute.
//
// - RECORD_TYPE - The different types of charges such as RI fees, usage costs,
// tax refunds, and credits.
//
// - RESOURCE_ID - The unique identifier of the resource. ResourceId is an
// opt-in feature only available for last 14 days for EC2-Compute Service. You can
// opt-in by enabling Hourly and Resource Level Data in Cost Management Console
// preferences.
//
// If you set the context to RESERVATIONS , you can use the following dimensions
// for searching:
//
// - AZ - The Availability Zone. An example is us-east-1a .
//
// - CACHE_ENGINE - The Amazon ElastiCache operating system. Examples are
// Windows or Linux.
//
// - DEPLOYMENT_OPTION - The scope of Amazon Relational Database Service
// deployments. Valid values are SingleAZ and MultiAZ .
//
// - INSTANCE_TYPE - The type of Amazon EC2 instance. An example is m4.xlarge .
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - PLATFORM - The Amazon EC2 operating system. Examples are Windows or Linux.
//
// - REGION - The Amazon Web Services Region.
//
// - SCOPE (Utilization only) - The scope of a Reserved Instance (RI). Values
// are regional or a single Availability Zone.
//
// - TAG (Coverage only) - The tags that are associated with a Reserved Instance
// (RI).
//
// - TENANCY - The tenancy of a resource. Examples are shared or dedicated.
//
// If you set the context to SAVINGS_PLANS , you can use the following dimensions
// for searching:
//
// - SAVINGS_PLANS_TYPE - Type of Savings Plans (EC2 Instance or Compute)
//
// - PAYMENT_OPTION - Payment option for the given Savings Plans (for example,
// All Upfront)
//
// - REGION - The Amazon Web Services Region.
//
// - INSTANCE_TYPE_FAMILY - The family of instances (For example, m5 )
//
// - LINKED_ACCOUNT - The description in the attribute map that includes the
// full name of the member account. The value field contains the Amazon Web
// Services ID of the member account.
//
// - SAVINGS_PLAN_ARN - The unique identifier for your Savings Plan
//
// This member is required.
DimensionValues []types.DimensionValuesWithAttributes
// The number of results that Amazon Web Services returned at one time.
//
// This member is required.
ReturnSize *int32
// The total number of search results.
//
// This member is required.
TotalSize *int32
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetDimensionValuesMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetDimensionValues{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetDimensionValues{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetDimensionValues"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetDimensionValuesValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetDimensionValues(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetDimensionValues(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetDimensionValues",
}
}
@@ -0,0 +1,324 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the reservation coverage for your account, which you can use to see
// how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon
// Relational Database Service, or Amazon Redshift usage is covered by a
// reservation. An organization's management account can see the coverage of the
// associated member accounts. This supports dimensions, cost categories, and
// nested expressions. For any time period, you can filter data about reservation
// usage by the following dimensions:
//
// - AZ
//
// - CACHE_ENGINE
//
// - DATABASE_ENGINE
//
// - DEPLOYMENT_OPTION
//
// - INSTANCE_TYPE
//
// - LINKED_ACCOUNT
//
// - OPERATING_SYSTEM
//
// - PLATFORM
//
// - REGION
//
// - SERVICE
//
// - TAG
//
// - TENANCY
//
// To determine valid values for a dimension, use the GetDimensionValues
// operation.
func (c *Client) GetReservationCoverage(ctx context.Context, params *GetReservationCoverageInput, optFns ...func(*Options)) (*GetReservationCoverageOutput, error) {
if params == nil {
params = &GetReservationCoverageInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetReservationCoverage", params, optFns, c.addOperationGetReservationCoverageMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetReservationCoverageOutput)
out.ResultMetadata = metadata
return out, nil
}
// You can use the following request parameters to query for how much of your
// instance usage a reservation covered.
type GetReservationCoverageInput struct {
// The start and end dates of the period that you want to retrieve data about
// reservation coverage for. You can retrieve data for a maximum of 13 months: the
// last 12 months and the current month. The start date is inclusive, but the end
// date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 ,
// then the cost and usage data is retrieved from 2017-01-01 up to and including
// 2017-04-30 but not including 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// Filters utilization data by dimensions. You can filter by the following
// dimensions:
//
// - AZ
//
// - CACHE_ENGINE
//
// - DATABASE_ENGINE
//
// - DEPLOYMENT_OPTION
//
// - INSTANCE_TYPE
//
// - LINKED_ACCOUNT
//
// - OPERATING_SYSTEM
//
// - PLATFORM
//
// - REGION
//
// - SERVICE
//
// - TAG
//
// - TENANCY
//
// GetReservationCoverage uses the same [Expression] object as the other operations, but only
// AND is supported among each dimension. You can nest only one level deep. If
// there are multiple values for a dimension, they are OR'd together.
//
// If you don't provide a SERVICE filter, Cost Explorer defaults to EC2.
//
// Cost category is also supported.
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// The granularity of the Amazon Web Services cost data for the reservation. Valid
// values are MONTHLY and DAILY .
//
// If GroupBy is set, Granularity can't be set. If Granularity isn't set, the
// response object doesn't include Granularity , either MONTHLY or DAILY .
//
// The GetReservationCoverage operation supports only DAILY and MONTHLY
// granularities.
Granularity types.Granularity
// You can group the data by the following attributes:
//
// - AZ
//
// - CACHE_ENGINE
//
// - DATABASE_ENGINE
//
// - DEPLOYMENT_OPTION
//
// - INSTANCE_TYPE
//
// - INVOICING_ENTITY
//
// - LINKED_ACCOUNT
//
// - OPERATING_SYSTEM
//
// - PLATFORM
//
// - REGION
//
// - TENANCY
GroupBy []types.GroupDefinition
// The maximum number of objects that you returned for this request. If more
// objects are available, in the response, Amazon Web Services provides a
// NextPageToken value that you can use in a subsequent call to get the next batch
// of objects.
MaxResults *int32
// The measurement that you want your reservation coverage reported in.
//
// Valid values are Hour , Unit , and Cost . You can use multiple values in a
// request.
Metrics []string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// The value by which you want to sort the data.
//
// The following values are supported for Key :
//
// - OnDemandCost
//
// - CoverageHoursPercentage
//
// - OnDemandHours
//
// - ReservedHours
//
// - TotalRunningHours
//
// - CoverageNormalizedUnitsPercentage
//
// - OnDemandNormalizedUnits
//
// - ReservedNormalizedUnits
//
// - TotalRunningNormalizedUnits
//
// - Time
//
// Supported values for SortOrder are ASCENDING or DESCENDING .
SortBy *types.SortDefinition
noSmithyDocumentSerde
}
type GetReservationCoverageOutput struct {
// The amount of time that your reservations covered.
//
// This member is required.
CoveragesByTime []types.CoverageByTime
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// The total amount of instance usage that a reservation covered.
Total *types.Coverage
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetReservationCoverageMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetReservationCoverage{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetReservationCoverage{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetReservationCoverage"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetReservationCoverageValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetReservationCoverage(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetReservationCoverage(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetReservationCoverage",
}
}
@@ -0,0 +1,384 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Gets recommendations for reservation purchases. These recommendations might
// help you to reduce your costs. Reservations provide a discounted hourly rate (up
// to 75%) compared to On-Demand pricing.
//
// Amazon Web Services generates your recommendations by identifying your
// On-Demand usage during a specific time period and collecting your usage into
// categories that are eligible for a reservation. After Amazon Web Services has
// these categories, it simulates every combination of reservations in each
// category of usage to identify the best number of each type of Reserved Instance
// (RI) to purchase to maximize your estimated savings.
//
// For example, Amazon Web Services automatically aggregates your Amazon EC2
// Linux, shared tenancy, and c4 family usage in the US West (Oregon) Region and
// recommends that you buy size-flexible regional reservations to apply to the c4
// family usage. Amazon Web Services recommends the smallest size instance in an
// instance family. This makes it easier to purchase a size-flexible Reserved
// Instance (RI). Amazon Web Services also shows the equal number of normalized
// units. This way, you can purchase any instance size that you want. For this
// example, your RI recommendation is for c4.large because that is the smallest
// size instance in the c4 instance family.
func (c *Client) GetReservationPurchaseRecommendation(ctx context.Context, params *GetReservationPurchaseRecommendationInput, optFns ...func(*Options)) (*GetReservationPurchaseRecommendationOutput, error) {
if params == nil {
params = &GetReservationPurchaseRecommendationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetReservationPurchaseRecommendation", params, optFns, c.addOperationGetReservationPurchaseRecommendationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetReservationPurchaseRecommendationOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetReservationPurchaseRecommendationInput struct {
// The specific service that you want recommendations for.
//
// This member is required.
Service *string
// The account ID that's associated with the recommendation.
AccountId *string
// The account scope that you want your recommendations for. Amazon Web Services
// calculates recommendations including the management account and member accounts
// if the value is set to PAYER . If the value is LINKED , recommendations are
// calculated for individual member accounts only.
AccountScope types.AccountScope
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// The number of previous days that you want Amazon Web Services to consider when
// it calculates your recommendations.
LookbackPeriodInDays types.LookbackPeriodInDays
// The pagination token that indicates the next set of results that you want to
// retrieve.
NextPageToken *string
// The number of recommendations that you want returned in a single response
// object.
PageSize int32
// The reservation purchase option that you want recommendations for.
PaymentOption types.PaymentOption
// The hardware specifications for the service instances that you want
// recommendations for, such as standard or convertible Amazon EC2 instances.
ServiceSpecification *types.ServiceSpecification
// The reservation term that you want recommendations for.
TermInYears types.TermInYears
noSmithyDocumentSerde
}
type GetReservationPurchaseRecommendationOutput struct {
// Information about this specific recommendation call, such as the time stamp for
// when Cost Explorer generated this recommendation.
Metadata *types.ReservationPurchaseRecommendationMetadata
// The pagination token for the next set of retrievable results.
NextPageToken *string
// Recommendations for reservations to purchase.
Recommendations []types.ReservationPurchaseRecommendation
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetReservationPurchaseRecommendationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetReservationPurchaseRecommendation{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetReservationPurchaseRecommendation{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetReservationPurchaseRecommendation"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetReservationPurchaseRecommendationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetReservationPurchaseRecommendation(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetReservationPurchaseRecommendationPaginatorOptions is the paginator options
// for GetReservationPurchaseRecommendation
type GetReservationPurchaseRecommendationPaginatorOptions struct {
// The number of recommendations that you want returned in a single response
// object.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetReservationPurchaseRecommendationPaginator is a paginator for
// GetReservationPurchaseRecommendation
type GetReservationPurchaseRecommendationPaginator struct {
options GetReservationPurchaseRecommendationPaginatorOptions
client GetReservationPurchaseRecommendationAPIClient
params *GetReservationPurchaseRecommendationInput
nextToken *string
firstPage bool
}
// NewGetReservationPurchaseRecommendationPaginator returns a new
// GetReservationPurchaseRecommendationPaginator
func NewGetReservationPurchaseRecommendationPaginator(client GetReservationPurchaseRecommendationAPIClient, params *GetReservationPurchaseRecommendationInput, optFns ...func(*GetReservationPurchaseRecommendationPaginatorOptions)) *GetReservationPurchaseRecommendationPaginator {
if params == nil {
params = &GetReservationPurchaseRecommendationInput{}
}
options := GetReservationPurchaseRecommendationPaginatorOptions{}
if params.PageSize != 0 {
options.Limit = params.PageSize
}
for _, fn := range optFns {
fn(&options)
}
return &GetReservationPurchaseRecommendationPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetReservationPurchaseRecommendationPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetReservationPurchaseRecommendation page.
func (p *GetReservationPurchaseRecommendationPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetReservationPurchaseRecommendationOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
params.PageSize = p.options.Limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetReservationPurchaseRecommendation(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetReservationPurchaseRecommendationAPIClient is a client that implements the
// GetReservationPurchaseRecommendation operation.
type GetReservationPurchaseRecommendationAPIClient interface {
GetReservationPurchaseRecommendation(context.Context, *GetReservationPurchaseRecommendationInput, ...func(*Options)) (*GetReservationPurchaseRecommendationOutput, error)
}
var _ GetReservationPurchaseRecommendationAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetReservationPurchaseRecommendation(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetReservationPurchaseRecommendation",
}
}
@@ -0,0 +1,276 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the reservation utilization for your account. Management account in
// an organization have access to member accounts. You can filter data by
// dimensions in a time period. You can use GetDimensionValues to determine the
// possible dimension values. Currently, you can group only by SUBSCRIPTION_ID .
func (c *Client) GetReservationUtilization(ctx context.Context, params *GetReservationUtilizationInput, optFns ...func(*Options)) (*GetReservationUtilizationOutput, error) {
if params == nil {
params = &GetReservationUtilizationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetReservationUtilization", params, optFns, c.addOperationGetReservationUtilizationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetReservationUtilizationOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetReservationUtilizationInput struct {
// Sets the start and end dates for retrieving Reserved Instance (RI) utilization.
// The start date is inclusive, but the end date is exclusive. For example, if
// start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is
// retrieved from 2017-01-01 up to and including 2017-04-30 but not including
// 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// Filters utilization data by dimensions. You can filter by the following
// dimensions:
//
// - AZ
//
// - CACHE_ENGINE
//
// - DEPLOYMENT_OPTION
//
// - INSTANCE_TYPE
//
// - LINKED_ACCOUNT
//
// - OPERATING_SYSTEM
//
// - PLATFORM
//
// - REGION
//
// - SERVICE
//
// If not specified, the SERVICE filter defaults to Amazon Elastic Compute Cloud -
// Compute. Supported values for SERVICE are Amazon Elastic Compute Cloud -
// Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon
// Redshift, and Amazon Elasticsearch Service. The value for the SERVICE filter
// should not exceed "1".
//
// - SCOPE
//
// - TENANCY
//
// GetReservationUtilization uses the same [Expression] object as the other operations, but
// only AND is supported among each dimension, and nesting is supported up to only
// one level deep. If there are multiple values for a dimension, they are OR'd
// together.
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// If GroupBy is set, Granularity can't be set. If Granularity isn't set, the
// response object doesn't include Granularity , either MONTHLY or DAILY . If both
// GroupBy and Granularity aren't set, GetReservationUtilization defaults to DAILY .
//
// The GetReservationUtilization operation supports only DAILY and MONTHLY
// granularities.
Granularity types.Granularity
// Groups only by SUBSCRIPTION_ID . Metadata is included.
GroupBy []types.GroupDefinition
// The maximum number of objects that you returned for this request. If more
// objects are available, in the response, Amazon Web Services provides a
// NextPageToken value that you can use in a subsequent call to get the next batch
// of objects.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// The value that you want to sort the data by.
//
// The following values are supported for Key :
//
// - UtilizationPercentage
//
// - UtilizationPercentageInUnits
//
// - PurchasedHours
//
// - PurchasedUnits
//
// - TotalActualHours
//
// - TotalActualUnits
//
// - UnusedHours
//
// - UnusedUnits
//
// - OnDemandCostOfRIHoursUsed
//
// - NetRISavings
//
// - TotalPotentialRISavings
//
// - AmortizedUpfrontFee
//
// - AmortizedRecurringFee
//
// - TotalAmortizedFee
//
// - RICostForUnusedHours
//
// - RealizedSavings
//
// - UnrealizedSavings
//
// The supported values for SortOrder are ASCENDING and DESCENDING .
SortBy *types.SortDefinition
noSmithyDocumentSerde
}
type GetReservationUtilizationOutput struct {
// The amount of time that you used your Reserved Instances (RIs).
//
// This member is required.
UtilizationsByTime []types.UtilizationByTime
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// The total amount of time that you used your Reserved Instances (RIs).
Total *types.ReservationAggregates
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetReservationUtilizationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetReservationUtilization{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetReservationUtilization{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetReservationUtilization"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetReservationUtilizationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetReservationUtilization(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetReservationUtilization(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetReservationUtilization",
}
}
@@ -0,0 +1,366 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Creates recommendations that help you save cost by identifying idle and
// underutilized Amazon EC2 instances.
//
// Recommendations are generated to either downsize or terminate instances, along
// with providing savings detail and metrics. For more information about
// calculation and function, see [Optimizing Your Cost with Rightsizing Recommendations]in the Billing and Cost Management User Guide.
//
// [Optimizing Your Cost with Rightsizing Recommendations]: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-rightsizing.html
func (c *Client) GetRightsizingRecommendation(ctx context.Context, params *GetRightsizingRecommendationInput, optFns ...func(*Options)) (*GetRightsizingRecommendationOutput, error) {
if params == nil {
params = &GetRightsizingRecommendationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetRightsizingRecommendation", params, optFns, c.addOperationGetRightsizingRecommendationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetRightsizingRecommendationOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetRightsizingRecommendationInput struct {
// The specific service that you want recommendations for. The only valid value
// for GetRightsizingRecommendation is " AmazonEC2 ".
//
// This member is required.
Service *string
// You can use Configuration to customize recommendations across two attributes.
// You can choose to view recommendations for instances within the same instance
// families or across different instance families. You can also choose to view your
// estimated savings that are associated with recommendations with consideration of
// existing Savings Plans or RI benefits, or neither.
Configuration *types.RightsizingRecommendationConfiguration
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// The pagination token that indicates the next set of results that you want to
// retrieve.
NextPageToken *string
// The number of recommendations that you want returned in a single response
// object.
PageSize int32
noSmithyDocumentSerde
}
type GetRightsizingRecommendationOutput struct {
// You can use Configuration to customize recommendations across two attributes.
// You can choose to view recommendations for instances within the same instance
// families or across different instance families. You can also choose to view your
// estimated savings that are associated with recommendations with consideration of
// existing Savings Plans or RI benefits, or neither.
Configuration *types.RightsizingRecommendationConfiguration
// Information regarding this specific recommendation set.
Metadata *types.RightsizingRecommendationMetadata
// The token to retrieve the next set of results.
NextPageToken *string
// Recommendations to rightsize resources.
RightsizingRecommendations []types.RightsizingRecommendation
// Summary of this recommendation set.
Summary *types.RightsizingRecommendationSummary
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetRightsizingRecommendationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetRightsizingRecommendation{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetRightsizingRecommendation{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetRightsizingRecommendation"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetRightsizingRecommendationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetRightsizingRecommendation(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetRightsizingRecommendationPaginatorOptions is the paginator options for
// GetRightsizingRecommendation
type GetRightsizingRecommendationPaginatorOptions struct {
// The number of recommendations that you want returned in a single response
// object.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetRightsizingRecommendationPaginator is a paginator for
// GetRightsizingRecommendation
type GetRightsizingRecommendationPaginator struct {
options GetRightsizingRecommendationPaginatorOptions
client GetRightsizingRecommendationAPIClient
params *GetRightsizingRecommendationInput
nextToken *string
firstPage bool
}
// NewGetRightsizingRecommendationPaginator returns a new
// GetRightsizingRecommendationPaginator
func NewGetRightsizingRecommendationPaginator(client GetRightsizingRecommendationAPIClient, params *GetRightsizingRecommendationInput, optFns ...func(*GetRightsizingRecommendationPaginatorOptions)) *GetRightsizingRecommendationPaginator {
if params == nil {
params = &GetRightsizingRecommendationInput{}
}
options := GetRightsizingRecommendationPaginatorOptions{}
if params.PageSize != 0 {
options.Limit = params.PageSize
}
for _, fn := range optFns {
fn(&options)
}
return &GetRightsizingRecommendationPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetRightsizingRecommendationPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetRightsizingRecommendation page.
func (p *GetRightsizingRecommendationPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetRightsizingRecommendationOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
params.PageSize = p.options.Limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetRightsizingRecommendation(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetRightsizingRecommendationAPIClient is a client that implements the
// GetRightsizingRecommendation operation.
type GetRightsizingRecommendationAPIClient interface {
GetRightsizingRecommendation(context.Context, *GetRightsizingRecommendationInput, ...func(*Options)) (*GetRightsizingRecommendationOutput, error)
}
var _ GetRightsizingRecommendationAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetRightsizingRecommendation(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetRightsizingRecommendation",
}
}
@@ -0,0 +1,162 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the details for a Savings Plan recommendation. These details include
// the hourly data-points that construct the cost, coverage, and utilization
// charts.
func (c *Client) GetSavingsPlanPurchaseRecommendationDetails(ctx context.Context, params *GetSavingsPlanPurchaseRecommendationDetailsInput, optFns ...func(*Options)) (*GetSavingsPlanPurchaseRecommendationDetailsOutput, error) {
if params == nil {
params = &GetSavingsPlanPurchaseRecommendationDetailsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetSavingsPlanPurchaseRecommendationDetails", params, optFns, c.addOperationGetSavingsPlanPurchaseRecommendationDetailsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetSavingsPlanPurchaseRecommendationDetailsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetSavingsPlanPurchaseRecommendationDetailsInput struct {
// The ID that is associated with the Savings Plan recommendation.
//
// This member is required.
RecommendationDetailId *string
noSmithyDocumentSerde
}
type GetSavingsPlanPurchaseRecommendationDetailsOutput struct {
// Contains detailed information about a specific Savings Plan recommendation.
RecommendationDetailData *types.RecommendationDetailData
// The ID that is associated with the Savings Plan recommendation.
RecommendationDetailId *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetSavingsPlanPurchaseRecommendationDetailsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetSavingsPlanPurchaseRecommendationDetails{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetSavingsPlanPurchaseRecommendationDetails{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetSavingsPlanPurchaseRecommendationDetails"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetSavingsPlanPurchaseRecommendationDetailsValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetSavingsPlanPurchaseRecommendationDetails(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetSavingsPlanPurchaseRecommendationDetails(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetSavingsPlanPurchaseRecommendationDetails",
}
}
@@ -0,0 +1,341 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the Savings Plans covered for your account. This enables you to see
// how much of your cost is covered by a Savings Plan. An organization’s management
// account can see the coverage of the associated member accounts. This supports
// dimensions, cost categories, and nested expressions. For any time period, you
// can filter data for Savings Plans usage with the following dimensions:
//
// - LINKED_ACCOUNT
//
// - REGION
//
// - SERVICE
//
// - INSTANCE_FAMILY
//
// To determine valid values for a dimension, use the GetDimensionValues operation.
func (c *Client) GetSavingsPlansCoverage(ctx context.Context, params *GetSavingsPlansCoverageInput, optFns ...func(*Options)) (*GetSavingsPlansCoverageOutput, error) {
if params == nil {
params = &GetSavingsPlansCoverageInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetSavingsPlansCoverage", params, optFns, c.addOperationGetSavingsPlansCoverageMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetSavingsPlansCoverageOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetSavingsPlansCoverageInput struct {
// The time period that you want the usage and costs for. The Start date must be
// within 13 months. The End date must be after the Start date, and before the
// current date. Future dates can't be used as an End date.
//
// This member is required.
TimePeriod *types.DateInterval
// Filters Savings Plans coverage data by dimensions. You can filter data for
// Savings Plans usage with the following dimensions:
//
// - LINKED_ACCOUNT
//
// - REGION
//
// - SERVICE
//
// - INSTANCE_FAMILY
//
// GetSavingsPlansCoverage uses the same [Expression] object as the other operations, but only
// AND is supported among each dimension. If there are multiple values for a
// dimension, they are OR'd together.
//
// Cost category is also supported.
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// The granularity of the Amazon Web Services cost data for your Savings Plans.
// Granularity can't be set if GroupBy is set.
//
// The GetSavingsPlansCoverage operation supports only DAILY and MONTHLY
// granularities.
Granularity types.Granularity
// You can group the data using the attributes INSTANCE_FAMILY , REGION , or
// SERVICE .
GroupBy []types.GroupDefinition
// The number of items to be returned in a response. The default is 20 , with a
// minimum value of 1 .
MaxResults *int32
// The measurement that you want your Savings Plans coverage reported in. The only
// valid value is SpendCoveredBySavingsPlans .
Metrics []string
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// The value that you want to sort the data by.
//
// The following values are supported for Key :
//
// - SpendCoveredBySavingsPlan
//
// - OnDemandCost
//
// - CoveragePercentage
//
// - TotalCost
//
// - InstanceFamily
//
// - Region
//
// - Service
//
// The supported values for SortOrder are ASCENDING and DESCENDING .
SortBy *types.SortDefinition
noSmithyDocumentSerde
}
type GetSavingsPlansCoverageOutput struct {
// The amount of spend that your Savings Plans covered.
//
// This member is required.
SavingsPlansCoverages []types.SavingsPlansCoverage
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetSavingsPlansCoverageMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetSavingsPlansCoverage{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetSavingsPlansCoverage{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetSavingsPlansCoverage"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetSavingsPlansCoverageValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetSavingsPlansCoverage(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetSavingsPlansCoveragePaginatorOptions is the paginator options for
// GetSavingsPlansCoverage
type GetSavingsPlansCoveragePaginatorOptions struct {
// The number of items to be returned in a response. The default is 20 , with a
// minimum value of 1 .
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetSavingsPlansCoveragePaginator is a paginator for GetSavingsPlansCoverage
type GetSavingsPlansCoveragePaginator struct {
options GetSavingsPlansCoveragePaginatorOptions
client GetSavingsPlansCoverageAPIClient
params *GetSavingsPlansCoverageInput
nextToken *string
firstPage bool
}
// NewGetSavingsPlansCoveragePaginator returns a new
// GetSavingsPlansCoveragePaginator
func NewGetSavingsPlansCoveragePaginator(client GetSavingsPlansCoverageAPIClient, params *GetSavingsPlansCoverageInput, optFns ...func(*GetSavingsPlansCoveragePaginatorOptions)) *GetSavingsPlansCoveragePaginator {
if params == nil {
params = &GetSavingsPlansCoverageInput{}
}
options := GetSavingsPlansCoveragePaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetSavingsPlansCoveragePaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetSavingsPlansCoveragePaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetSavingsPlansCoverage page.
func (p *GetSavingsPlansCoveragePaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetSavingsPlansCoverageOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetSavingsPlansCoverage(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetSavingsPlansCoverageAPIClient is a client that implements the
// GetSavingsPlansCoverage operation.
type GetSavingsPlansCoverageAPIClient interface {
GetSavingsPlansCoverage(context.Context, *GetSavingsPlansCoverageInput, ...func(*Options)) (*GetSavingsPlansCoverageOutput, error)
}
var _ GetSavingsPlansCoverageAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetSavingsPlansCoverage(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetSavingsPlansCoverage",
}
}
@@ -0,0 +1,212 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the Savings Plans recommendations for your account. First use
// StartSavingsPlansPurchaseRecommendationGeneration to generate a new set of
// recommendations, and then use GetSavingsPlansPurchaseRecommendation to retrieve
// them.
func (c *Client) GetSavingsPlansPurchaseRecommendation(ctx context.Context, params *GetSavingsPlansPurchaseRecommendationInput, optFns ...func(*Options)) (*GetSavingsPlansPurchaseRecommendationOutput, error) {
if params == nil {
params = &GetSavingsPlansPurchaseRecommendationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetSavingsPlansPurchaseRecommendation", params, optFns, c.addOperationGetSavingsPlansPurchaseRecommendationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetSavingsPlansPurchaseRecommendationOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetSavingsPlansPurchaseRecommendationInput struct {
// The lookback period that's used to generate the recommendation.
//
// This member is required.
LookbackPeriodInDays types.LookbackPeriodInDays
// The payment option that's used to generate these recommendations.
//
// This member is required.
PaymentOption types.PaymentOption
// The Savings Plans recommendation type that's requested.
//
// This member is required.
SavingsPlansType types.SupportedSavingsPlansType
// The savings plan recommendation term that's used to generate these
// recommendations.
//
// This member is required.
TermInYears types.TermInYears
// The account scope that you want your recommendations for. Amazon Web Services
// calculates recommendations including the management account and member accounts
// if the value is set to PAYER . If the value is LINKED , recommendations are
// calculated for individual member accounts only.
AccountScope types.AccountScope
// You can filter your recommendations by Account ID with the LINKED_ACCOUNT
// dimension. To filter your recommendations by Account ID, specify Key as
// LINKED_ACCOUNT and Value as the comma-separated Acount ID(s) that you want to
// see Savings Plans purchase recommendations for.
//
// For GetSavingsPlansPurchaseRecommendation, the Filter doesn't include
// CostCategories or Tags . It only includes Dimensions . With Dimensions , Key
// must be LINKED_ACCOUNT and Value can be a single Account ID or multiple
// comma-separated Account IDs that you want to see Savings Plans Purchase
// Recommendations for. AND and OR operators are not supported.
Filter *types.Expression
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// The number of recommendations that you want returned in a single response
// object.
PageSize int32
noSmithyDocumentSerde
}
type GetSavingsPlansPurchaseRecommendationOutput struct {
// Information that regards this specific recommendation set.
Metadata *types.SavingsPlansPurchaseRecommendationMetadata
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// Contains your request parameters, Savings Plan Recommendations Summary, and
// Details.
SavingsPlansPurchaseRecommendation *types.SavingsPlansPurchaseRecommendation
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetSavingsPlansPurchaseRecommendationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetSavingsPlansPurchaseRecommendation{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetSavingsPlansPurchaseRecommendation{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetSavingsPlansPurchaseRecommendation"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetSavingsPlansPurchaseRecommendationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetSavingsPlansPurchaseRecommendation(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetSavingsPlansPurchaseRecommendation(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetSavingsPlansPurchaseRecommendation",
}
}
@@ -0,0 +1,216 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves the Savings Plans utilization for your account across date ranges
// with daily or monthly granularity. Management account in an organization have
// access to member accounts. You can use GetDimensionValues in SAVINGS_PLANS to
// determine the possible dimension values.
//
// You can't group by any dimension values for GetSavingsPlansUtilization .
func (c *Client) GetSavingsPlansUtilization(ctx context.Context, params *GetSavingsPlansUtilizationInput, optFns ...func(*Options)) (*GetSavingsPlansUtilizationOutput, error) {
if params == nil {
params = &GetSavingsPlansUtilizationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetSavingsPlansUtilization", params, optFns, c.addOperationGetSavingsPlansUtilizationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetSavingsPlansUtilizationOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetSavingsPlansUtilizationInput struct {
// The time period that you want the usage and costs for. The Start date must be
// within 13 months. The End date must be after the Start date, and before the
// current date. Future dates can't be used as an End date.
//
// This member is required.
TimePeriod *types.DateInterval
// Filters Savings Plans utilization coverage data for active Savings Plans
// dimensions. You can filter data with the following dimensions:
//
// - LINKED_ACCOUNT
//
// - SAVINGS_PLAN_ARN
//
// - SAVINGS_PLANS_TYPE
//
// - REGION
//
// - PAYMENT_OPTION
//
// - INSTANCE_TYPE_FAMILY
//
// GetSavingsPlansUtilization uses the same [Expression] object as the other operations, but
// only AND is supported among each dimension.
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// The granularity of the Amazon Web Services utillization data for your Savings
// Plans.
//
// The GetSavingsPlansUtilization operation supports only DAILY and MONTHLY
// granularities.
Granularity types.Granularity
// The value that you want to sort the data by.
//
// The following values are supported for Key :
//
// - UtilizationPercentage
//
// - TotalCommitment
//
// - UsedCommitment
//
// - UnusedCommitment
//
// - NetSavings
//
// The supported values for SortOrder are ASCENDING and DESCENDING .
SortBy *types.SortDefinition
noSmithyDocumentSerde
}
type GetSavingsPlansUtilizationOutput struct {
// The total amount of cost/commitment that you used your Savings Plans,
// regardless of date ranges.
//
// This member is required.
Total *types.SavingsPlansUtilizationAggregates
// The amount of cost/commitment that you used your Savings Plans. You can use it
// to specify date ranges.
SavingsPlansUtilizationsByTime []types.SavingsPlansUtilizationByTime
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetSavingsPlansUtilizationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetSavingsPlansUtilization{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetSavingsPlansUtilization{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetSavingsPlansUtilization"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetSavingsPlansUtilizationValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetSavingsPlansUtilization(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetSavingsPlansUtilization(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetSavingsPlansUtilization",
}
}
@@ -0,0 +1,332 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves attribute data along with aggregate utilization and savings data for
// a given time period. This doesn't support granular or grouped data
// (daily/monthly) in response. You can't retrieve data by dates in a single
// response similar to GetSavingsPlanUtilization , but you have the option to make
// multiple calls to GetSavingsPlanUtilizationDetails by providing individual
// dates. You can use GetDimensionValues in SAVINGS_PLANS to determine the
// possible dimension values.
//
// GetSavingsPlanUtilizationDetails internally groups data by SavingsPlansArn .
func (c *Client) GetSavingsPlansUtilizationDetails(ctx context.Context, params *GetSavingsPlansUtilizationDetailsInput, optFns ...func(*Options)) (*GetSavingsPlansUtilizationDetailsOutput, error) {
if params == nil {
params = &GetSavingsPlansUtilizationDetailsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetSavingsPlansUtilizationDetails", params, optFns, c.addOperationGetSavingsPlansUtilizationDetailsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetSavingsPlansUtilizationDetailsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetSavingsPlansUtilizationDetailsInput struct {
// The time period that you want the usage and costs for. The Start date must be
// within 13 months. The End date must be after the Start date, and before the
// current date. Future dates can't be used as an End date.
//
// This member is required.
TimePeriod *types.DateInterval
// The data type.
DataType []types.SavingsPlansDataType
// Filters Savings Plans utilization coverage data for active Savings Plans
// dimensions. You can filter data with the following dimensions:
//
// - LINKED_ACCOUNT
//
// - SAVINGS_PLAN_ARN
//
// - REGION
//
// - PAYMENT_OPTION
//
// - INSTANCE_TYPE_FAMILY
//
// GetSavingsPlansUtilizationDetails uses the same [Expression] object as the other
// operations, but only AND is supported among each dimension.
//
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
Filter *types.Expression
// The number of items to be returned in a response. The default is 20 , with a
// minimum value of 1 .
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// The value that you want to sort the data by.
//
// The following values are supported for Key :
//
// - UtilizationPercentage
//
// - TotalCommitment
//
// - UsedCommitment
//
// - UnusedCommitment
//
// - NetSavings
//
// - AmortizedRecurringCommitment
//
// - AmortizedUpfrontCommitment
//
// The supported values for SortOrder are ASCENDING and DESCENDING .
SortBy *types.SortDefinition
noSmithyDocumentSerde
}
type GetSavingsPlansUtilizationDetailsOutput struct {
// Retrieves a single daily or monthly Savings Plans utilization rate and details
// for your account.
//
// This member is required.
SavingsPlansUtilizationDetails []types.SavingsPlansUtilizationDetail
// The time period of the request.
//
// This member is required.
TimePeriod *types.DateInterval
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// The total Savings Plans utilization, regardless of time period.
Total *types.SavingsPlansUtilizationAggregates
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetSavingsPlansUtilizationDetailsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetSavingsPlansUtilizationDetails{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetSavingsPlansUtilizationDetails{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetSavingsPlansUtilizationDetails"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetSavingsPlansUtilizationDetailsValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetSavingsPlansUtilizationDetails(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// GetSavingsPlansUtilizationDetailsPaginatorOptions is the paginator options for
// GetSavingsPlansUtilizationDetails
type GetSavingsPlansUtilizationDetailsPaginatorOptions struct {
// The number of items to be returned in a response. The default is 20 , with a
// minimum value of 1 .
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// GetSavingsPlansUtilizationDetailsPaginator is a paginator for
// GetSavingsPlansUtilizationDetails
type GetSavingsPlansUtilizationDetailsPaginator struct {
options GetSavingsPlansUtilizationDetailsPaginatorOptions
client GetSavingsPlansUtilizationDetailsAPIClient
params *GetSavingsPlansUtilizationDetailsInput
nextToken *string
firstPage bool
}
// NewGetSavingsPlansUtilizationDetailsPaginator returns a new
// GetSavingsPlansUtilizationDetailsPaginator
func NewGetSavingsPlansUtilizationDetailsPaginator(client GetSavingsPlansUtilizationDetailsAPIClient, params *GetSavingsPlansUtilizationDetailsInput, optFns ...func(*GetSavingsPlansUtilizationDetailsPaginatorOptions)) *GetSavingsPlansUtilizationDetailsPaginator {
if params == nil {
params = &GetSavingsPlansUtilizationDetailsInput{}
}
options := GetSavingsPlansUtilizationDetailsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &GetSavingsPlansUtilizationDetailsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *GetSavingsPlansUtilizationDetailsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next GetSavingsPlansUtilizationDetails page.
func (p *GetSavingsPlansUtilizationDetailsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetSavingsPlansUtilizationDetailsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.GetSavingsPlansUtilizationDetails(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// GetSavingsPlansUtilizationDetailsAPIClient is a client that implements the
// GetSavingsPlansUtilizationDetails operation.
type GetSavingsPlansUtilizationDetailsAPIClient interface {
GetSavingsPlansUtilizationDetails(context.Context, *GetSavingsPlansUtilizationDetailsInput, ...func(*Options)) (*GetSavingsPlansUtilizationDetailsOutput, error)
}
var _ GetSavingsPlansUtilizationDetailsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opGetSavingsPlansUtilizationDetails(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetSavingsPlansUtilizationDetails",
}
}
@@ -0,0 +1,304 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Queries for available tag keys and tag values for a specified period. You can
// search the tag values for an arbitrary string.
func (c *Client) GetTags(ctx context.Context, params *GetTagsInput, optFns ...func(*Options)) (*GetTagsOutput, error) {
if params == nil {
params = &GetTagsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetTags", params, optFns, c.addOperationGetTagsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetTagsOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetTagsInput struct {
// The start and end dates for retrieving the dimension values. The start date is
// inclusive, but the end date is exclusive. For example, if start is 2017-01-01
// and end is 2017-05-01 , then the cost and usage data is retrieved from
// 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// Use Expression to filter in various Cost Explorer APIs.
//
// Not all Expression types are supported in each API. Refer to the documentation
// for each specific API to see what is supported.
//
// There are two patterns:
//
// - Simple dimension values.
//
// - There are three types of simple dimension values: CostCategories , Tags ,
// and Dimensions .
//
// - Specify the CostCategories field to define a filter that acts on Cost
// Categories.
//
// - Specify the Tags field to define a filter that acts on Cost Allocation Tags.
//
// - Specify the Dimensions field to define a filter that acts on the [DimensionValues]
// DimensionValues .
//
// - For each filter type, you can set the dimension name and values for the
// filters that you plan to use.
//
// - For example, you can filter for REGION==us-east-1 OR REGION==us-west-1 . For
// GetRightsizingRecommendation , the Region is a full name (for example,
// REGION==US East (N. Virginia) .
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] } }
//
// - As shown in the previous example, lists of dimension values are combined
// with OR when applying the filter.
//
// - You can also set different match options to further control how the filter
// behaves. Not all APIs support match options. Refer to the documentation for each
// specific API to see what is supported.
//
// - For example, you can filter for linked account names that start with "a".
//
// - The corresponding Expression for this example is as follows: {
// "Dimensions": { "Key": "LINKED_ACCOUNT_NAME", "MatchOptions": [ "STARTS_WITH" ],
// "Values": [ "a" ] } }
//
// - Compound Expression types with logical operations.
//
// - You can use multiple Expression types and the logical operators AND/OR/NOT
// to create a list of one or more Expression objects. By doing this, you can
// filter by more advanced options.
//
// - For example, you can filter by ((REGION == us-east-1 OR REGION ==
// us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) .
//
// - The corresponding Expression for this example is as follows: { "And": [
// {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1"
// ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not":
// {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }
//
// Because each Expression can have only one operator, the service returns an error
// if more than one is specified. The following example shows an Expression
// object that creates an error: { "And": [ ... ], "Dimensions": { "Key":
// "USAGE_TYPE", "Values": [ "DataTransfer" ] } }
//
// The following is an example of the corresponding error message: "Expression has
// more than one roots. Only one root operator is allowed for each expression: And,
// Or, Not, Dimensions, Tags, CostCategories"
//
// For the GetRightsizingRecommendation action, a combination of OR and NOT isn't
// supported. OR isn't supported between different dimensions, or dimensions and
// tags. NOT operators aren't supported. Dimensions are also limited to
// LINKED_ACCOUNT , REGION , or RIGHTSIZING_TYPE .
//
// For the GetReservationPurchaseRecommendation action, only NOT is supported. AND
// and OR aren't supported. Dimensions are limited to LINKED_ACCOUNT .
//
// [DimensionValues]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_DimensionValues.html
Filter *types.Expression
// This field is only used when SortBy is provided in the request. The maximum
// number of objects that are returned for this request. If MaxResults isn't
// specified with SortBy, the request returns 1000 results as the default value for
// this parameter.
//
// For GetTags , MaxResults has an upper quota of 1000.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextPageToken *string
// The value that you want to search for.
SearchString *string
// The value that you want to sort the data by.
//
// The key represents cost and usage metrics. The following values are supported:
//
// - BlendedCost
//
// - UnblendedCost
//
// - AmortizedCost
//
// - NetAmortizedCost
//
// - NetUnblendedCost
//
// - UsageQuantity
//
// - NormalizedUsageAmount
//
// The supported values for SortOrder are ASCENDING and DESCENDING .
//
// When you use SortBy , NextPageToken and SearchString aren't supported.
SortBy []types.SortDefinition
// The key of the tag that you want to return values for.
TagKey *string
noSmithyDocumentSerde
}
type GetTagsOutput struct {
// The number of query results that Amazon Web Services returns at a time.
//
// This member is required.
ReturnSize *int32
// The tags that match your request.
//
// This member is required.
Tags []string
// The total number of query results.
//
// This member is required.
TotalSize *int32
// The token for the next set of retrievable results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetTagsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetTags{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetTags{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetTags"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetTagsValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetTags(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetTags(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetTags",
}
}
@@ -0,0 +1,250 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves a forecast for how much Amazon Web Services predicts that you will
// use over the forecast time period that you select, based on your past usage.
func (c *Client) GetUsageForecast(ctx context.Context, params *GetUsageForecastInput, optFns ...func(*Options)) (*GetUsageForecastOutput, error) {
if params == nil {
params = &GetUsageForecastInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetUsageForecast", params, optFns, c.addOperationGetUsageForecastMiddlewares)
if err != nil {
return nil, err
}
out := result.(*GetUsageForecastOutput)
out.ResultMetadata = metadata
return out, nil
}
type GetUsageForecastInput struct {
// How granular you want the forecast to be. You can get 3 months of DAILY
// forecasts or 18 months of MONTHLY forecasts.
//
// The GetUsageForecast operation supports only DAILY and MONTHLY granularities.
//
// This member is required.
Granularity types.Granularity
// Which metric Cost Explorer uses to create your forecast.
//
// Valid values for a GetUsageForecast call are the following:
//
// - USAGE_QUANTITY
//
// - NORMALIZED_USAGE_AMOUNT
//
// This member is required.
Metric types.Metric
// The start and end dates of the period that you want to retrieve usage forecast
// for. The start date is included in the period, but the end date isn't included
// in the period. For example, if start is 2017-01-01 and end is 2017-05-01 , then
// the cost and usage data is retrieved from 2017-01-01 up to and including
// 2017-04-30 but not including 2017-05-01 . The start date must be equal to or
// later than the current date to avoid a validation error.
//
// This member is required.
TimePeriod *types.DateInterval
// The Amazon Resource Name (ARN) that uniquely identifies a specific billing
// view. The ARN is used to specify which particular billing view you want to
// interact with or retrieve information from when making API calls related to
// Amazon Web Services Billing and Cost Management features. The BillingViewArn can
// be retrieved by calling the ListBillingViews API.
BillingViewArn *string
// The filters that you want to use to filter your forecast. The GetUsageForecast
// API supports filtering by the following dimensions:
//
// - AZ
//
// - INSTANCE_TYPE
//
// - LINKED_ACCOUNT
//
// - LINKED_ACCOUNT_NAME
//
// - OPERATION
//
// - PURCHASE_TYPE
//
// - REGION
//
// - SERVICE
//
// - USAGE_TYPE
//
// - USAGE_TYPE_GROUP
//
// - RECORD_TYPE
//
// - OPERATING_SYSTEM
//
// - TENANCY
//
// - SCOPE
//
// - PLATFORM
//
// - SUBSCRIPTION_ID
//
// - LEGAL_ENTITY_NAME
//
// - DEPLOYMENT_OPTION
//
// - DATABASE_ENGINE
//
// - INSTANCE_TYPE_FAMILY
//
// - BILLING_ENTITY
//
// - RESERVATION_ID
//
// - SAVINGS_PLAN_ARN
Filter *types.Expression
// Amazon Web Services Cost Explorer always returns the mean forecast as a single
// point. You can request a prediction interval around the mean by specifying a
// confidence level. The higher the confidence level, the more confident Cost
// Explorer is about the actual value falling in the prediction interval. Higher
// confidence levels result in wider prediction intervals.
PredictionIntervalLevel *int32
noSmithyDocumentSerde
}
type GetUsageForecastOutput struct {
// The forecasts for your query, in order. For DAILY forecasts, this is a list of
// days. For MONTHLY forecasts, this is a list of months.
ForecastResultsByTime []types.ForecastResult
// How much you're forecasted to use over the forecast period.
Total *types.MetricValue
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationGetUsageForecastMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetUsageForecast{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetUsageForecast{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "GetUsageForecast"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpGetUsageForecastValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetUsageForecast(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opGetUsageForecast(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "GetUsageForecast",
}
}
@@ -0,0 +1,256 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Lists the commitment purchase analyses for your account.
func (c *Client) ListCommitmentPurchaseAnalyses(ctx context.Context, params *ListCommitmentPurchaseAnalysesInput, optFns ...func(*Options)) (*ListCommitmentPurchaseAnalysesOutput, error) {
if params == nil {
params = &ListCommitmentPurchaseAnalysesInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListCommitmentPurchaseAnalyses", params, optFns, c.addOperationListCommitmentPurchaseAnalysesMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListCommitmentPurchaseAnalysesOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListCommitmentPurchaseAnalysesInput struct {
// The analysis IDs associated with the commitment purchase analyses.
AnalysisIds []string
// The status of the analysis.
AnalysisStatus types.AnalysisStatus
// The token to retrieve the next set of results.
NextPageToken *string
// The number of analyses that you want returned in a single response object.
PageSize int32
noSmithyDocumentSerde
}
type ListCommitmentPurchaseAnalysesOutput struct {
// The list of analyses.
AnalysisSummaryList []types.AnalysisSummary
// The token to retrieve the next set of results.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListCommitmentPurchaseAnalysesMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCommitmentPurchaseAnalyses{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCommitmentPurchaseAnalyses{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListCommitmentPurchaseAnalyses"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCommitmentPurchaseAnalyses(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListCommitmentPurchaseAnalysesPaginatorOptions is the paginator options for
// ListCommitmentPurchaseAnalyses
type ListCommitmentPurchaseAnalysesPaginatorOptions struct {
// The number of analyses that you want returned in a single response object.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListCommitmentPurchaseAnalysesPaginator is a paginator for
// ListCommitmentPurchaseAnalyses
type ListCommitmentPurchaseAnalysesPaginator struct {
options ListCommitmentPurchaseAnalysesPaginatorOptions
client ListCommitmentPurchaseAnalysesAPIClient
params *ListCommitmentPurchaseAnalysesInput
nextToken *string
firstPage bool
}
// NewListCommitmentPurchaseAnalysesPaginator returns a new
// ListCommitmentPurchaseAnalysesPaginator
func NewListCommitmentPurchaseAnalysesPaginator(client ListCommitmentPurchaseAnalysesAPIClient, params *ListCommitmentPurchaseAnalysesInput, optFns ...func(*ListCommitmentPurchaseAnalysesPaginatorOptions)) *ListCommitmentPurchaseAnalysesPaginator {
if params == nil {
params = &ListCommitmentPurchaseAnalysesInput{}
}
options := ListCommitmentPurchaseAnalysesPaginatorOptions{}
if params.PageSize != 0 {
options.Limit = params.PageSize
}
for _, fn := range optFns {
fn(&options)
}
return &ListCommitmentPurchaseAnalysesPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListCommitmentPurchaseAnalysesPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListCommitmentPurchaseAnalyses page.
func (p *ListCommitmentPurchaseAnalysesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCommitmentPurchaseAnalysesOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
params.PageSize = p.options.Limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListCommitmentPurchaseAnalyses(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListCommitmentPurchaseAnalysesAPIClient is a client that implements the
// ListCommitmentPurchaseAnalyses operation.
type ListCommitmentPurchaseAnalysesAPIClient interface {
ListCommitmentPurchaseAnalyses(context.Context, *ListCommitmentPurchaseAnalysesInput, ...func(*Options)) (*ListCommitmentPurchaseAnalysesOutput, error)
}
var _ ListCommitmentPurchaseAnalysesAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListCommitmentPurchaseAnalyses(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListCommitmentPurchaseAnalyses",
}
}
@@ -0,0 +1,258 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves a list of your historical cost allocation tag backfill requests.
func (c *Client) ListCostAllocationTagBackfillHistory(ctx context.Context, params *ListCostAllocationTagBackfillHistoryInput, optFns ...func(*Options)) (*ListCostAllocationTagBackfillHistoryOutput, error) {
if params == nil {
params = &ListCostAllocationTagBackfillHistoryInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListCostAllocationTagBackfillHistory", params, optFns, c.addOperationListCostAllocationTagBackfillHistoryMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListCostAllocationTagBackfillHistoryOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListCostAllocationTagBackfillHistoryInput struct {
// The maximum number of objects that are returned for this request.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextToken *string
noSmithyDocumentSerde
}
type ListCostAllocationTagBackfillHistoryOutput struct {
// The list of historical cost allocation tag backfill requests.
BackfillRequests []types.CostAllocationTagBackfillRequest
// The token to retrieve the next set of results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListCostAllocationTagBackfillHistoryMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCostAllocationTagBackfillHistory{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCostAllocationTagBackfillHistory{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListCostAllocationTagBackfillHistory"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCostAllocationTagBackfillHistory(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListCostAllocationTagBackfillHistoryPaginatorOptions is the paginator options
// for ListCostAllocationTagBackfillHistory
type ListCostAllocationTagBackfillHistoryPaginatorOptions struct {
// The maximum number of objects that are returned for this request.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListCostAllocationTagBackfillHistoryPaginator is a paginator for
// ListCostAllocationTagBackfillHistory
type ListCostAllocationTagBackfillHistoryPaginator struct {
options ListCostAllocationTagBackfillHistoryPaginatorOptions
client ListCostAllocationTagBackfillHistoryAPIClient
params *ListCostAllocationTagBackfillHistoryInput
nextToken *string
firstPage bool
}
// NewListCostAllocationTagBackfillHistoryPaginator returns a new
// ListCostAllocationTagBackfillHistoryPaginator
func NewListCostAllocationTagBackfillHistoryPaginator(client ListCostAllocationTagBackfillHistoryAPIClient, params *ListCostAllocationTagBackfillHistoryInput, optFns ...func(*ListCostAllocationTagBackfillHistoryPaginatorOptions)) *ListCostAllocationTagBackfillHistoryPaginator {
if params == nil {
params = &ListCostAllocationTagBackfillHistoryInput{}
}
options := ListCostAllocationTagBackfillHistoryPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &ListCostAllocationTagBackfillHistoryPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListCostAllocationTagBackfillHistoryPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListCostAllocationTagBackfillHistory page.
func (p *ListCostAllocationTagBackfillHistoryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCostAllocationTagBackfillHistoryOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListCostAllocationTagBackfillHistory(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListCostAllocationTagBackfillHistoryAPIClient is a client that implements the
// ListCostAllocationTagBackfillHistory operation.
type ListCostAllocationTagBackfillHistoryAPIClient interface {
ListCostAllocationTagBackfillHistory(context.Context, *ListCostAllocationTagBackfillHistoryInput, ...func(*Options)) (*ListCostAllocationTagBackfillHistoryOutput, error)
}
var _ ListCostAllocationTagBackfillHistoryAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListCostAllocationTagBackfillHistory(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListCostAllocationTagBackfillHistory",
}
}
@@ -0,0 +1,272 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Get a list of cost allocation tags. All inputs in the API are optional and
// serve as filters. By default, all cost allocation tags are returned.
func (c *Client) ListCostAllocationTags(ctx context.Context, params *ListCostAllocationTagsInput, optFns ...func(*Options)) (*ListCostAllocationTagsOutput, error) {
if params == nil {
params = &ListCostAllocationTagsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListCostAllocationTags", params, optFns, c.addOperationListCostAllocationTagsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListCostAllocationTagsOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListCostAllocationTagsInput struct {
// The maximum number of objects that are returned for this request. By default,
// the request returns 100 results.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// The status of cost allocation tag keys that are returned for this request.
Status types.CostAllocationTagStatus
// The list of cost allocation tag keys that are returned for this request.
TagKeys []string
// The type of CostAllocationTag object that are returned for this request. The
// AWSGenerated type tags are tags that Amazon Web Services defines and applies to
// support Amazon Web Services resources for cost allocation purposes. The
// UserDefined type tags are tags that you define, create, and apply to resources.
Type types.CostAllocationTagType
noSmithyDocumentSerde
}
type ListCostAllocationTagsOutput struct {
// A list of cost allocation tags that includes the detailed metadata for each
// one.
CostAllocationTags []types.CostAllocationTag
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListCostAllocationTagsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCostAllocationTags{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCostAllocationTags{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListCostAllocationTags"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCostAllocationTags(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListCostAllocationTagsPaginatorOptions is the paginator options for
// ListCostAllocationTags
type ListCostAllocationTagsPaginatorOptions struct {
// The maximum number of objects that are returned for this request. By default,
// the request returns 100 results.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListCostAllocationTagsPaginator is a paginator for ListCostAllocationTags
type ListCostAllocationTagsPaginator struct {
options ListCostAllocationTagsPaginatorOptions
client ListCostAllocationTagsAPIClient
params *ListCostAllocationTagsInput
nextToken *string
firstPage bool
}
// NewListCostAllocationTagsPaginator returns a new ListCostAllocationTagsPaginator
func NewListCostAllocationTagsPaginator(client ListCostAllocationTagsAPIClient, params *ListCostAllocationTagsInput, optFns ...func(*ListCostAllocationTagsPaginatorOptions)) *ListCostAllocationTagsPaginator {
if params == nil {
params = &ListCostAllocationTagsInput{}
}
options := ListCostAllocationTagsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &ListCostAllocationTagsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListCostAllocationTagsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListCostAllocationTags page.
func (p *ListCostAllocationTagsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCostAllocationTagsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListCostAllocationTags(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListCostAllocationTagsAPIClient is a client that implements the
// ListCostAllocationTags operation.
type ListCostAllocationTagsAPIClient interface {
ListCostAllocationTags(context.Context, *ListCostAllocationTagsInput, ...func(*Options)) (*ListCostAllocationTagsOutput, error)
}
var _ ListCostAllocationTagsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListCostAllocationTags(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListCostAllocationTags",
}
}
@@ -0,0 +1,276 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Returns the name, Amazon Resource Name (ARN), NumberOfRules and effective dates
// of all cost categories defined in the account. You have the option to use
// EffectiveOn and SupportedResourceTypes to return a list of cost categories that
// were active on a specific date. If there is no EffectiveOn specified, you’ll
// see cost categories that are effective on the current date. If cost category is
// still effective, EffectiveEnd is omitted in the response.
// ListCostCategoryDefinitions supports pagination. The request can have a
// MaxResults range up to 100.
func (c *Client) ListCostCategoryDefinitions(ctx context.Context, params *ListCostCategoryDefinitionsInput, optFns ...func(*Options)) (*ListCostCategoryDefinitionsOutput, error) {
if params == nil {
params = &ListCostCategoryDefinitionsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListCostCategoryDefinitions", params, optFns, c.addOperationListCostCategoryDefinitionsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListCostCategoryDefinitionsOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListCostCategoryDefinitionsInput struct {
// The date when the cost category was effective.
EffectiveOn *string
// The number of entries a paginated response contains.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// Filter cost category definitions that are supported by given resource types
// based on the latest version. If the filter is present, the result only includes
// Cost Categories that supports input resource type. If the filter isn't provided,
// no filtering is applied. The valid values are billing:rispgroupsharing and
// billing:billingview .
SupportedResourceTypes []string
noSmithyDocumentSerde
}
type ListCostCategoryDefinitionsOutput struct {
// A reference to a cost category that contains enough information to identify the
// Cost Category.
CostCategoryReferences []types.CostCategoryReference
// The token to retrieve the next set of results. Amazon Web Services provides the
// token when the response from a previous call has more results than the maximum
// page size.
NextToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListCostCategoryDefinitionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCostCategoryDefinitions{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCostCategoryDefinitions{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListCostCategoryDefinitions"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCostCategoryDefinitions(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListCostCategoryDefinitionsPaginatorOptions is the paginator options for
// ListCostCategoryDefinitions
type ListCostCategoryDefinitionsPaginatorOptions struct {
// The number of entries a paginated response contains.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListCostCategoryDefinitionsPaginator is a paginator for
// ListCostCategoryDefinitions
type ListCostCategoryDefinitionsPaginator struct {
options ListCostCategoryDefinitionsPaginatorOptions
client ListCostCategoryDefinitionsAPIClient
params *ListCostCategoryDefinitionsInput
nextToken *string
firstPage bool
}
// NewListCostCategoryDefinitionsPaginator returns a new
// ListCostCategoryDefinitionsPaginator
func NewListCostCategoryDefinitionsPaginator(client ListCostCategoryDefinitionsAPIClient, params *ListCostCategoryDefinitionsInput, optFns ...func(*ListCostCategoryDefinitionsPaginatorOptions)) *ListCostCategoryDefinitionsPaginator {
if params == nil {
params = &ListCostCategoryDefinitionsInput{}
}
options := ListCostCategoryDefinitionsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &ListCostCategoryDefinitionsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListCostCategoryDefinitionsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListCostCategoryDefinitions page.
func (p *ListCostCategoryDefinitionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCostCategoryDefinitionsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListCostCategoryDefinitions(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListCostCategoryDefinitionsAPIClient is a client that implements the
// ListCostCategoryDefinitions operation.
type ListCostCategoryDefinitionsAPIClient interface {
ListCostCategoryDefinitions(context.Context, *ListCostCategoryDefinitionsInput, ...func(*Options)) (*ListCostCategoryDefinitionsOutput, error)
}
var _ ListCostCategoryDefinitionsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListCostCategoryDefinitions(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListCostCategoryDefinitions",
}
}
@@ -0,0 +1,265 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Returns resource associations of all cost categories defined in the account.
// You have the option to use CostCategoryArn to get the association for a
// specific cost category. ListCostCategoryResourceAssociations supports
// pagination. The request can have a MaxResults range up to 100.
func (c *Client) ListCostCategoryResourceAssociations(ctx context.Context, params *ListCostCategoryResourceAssociationsInput, optFns ...func(*Options)) (*ListCostCategoryResourceAssociationsOutput, error) {
if params == nil {
params = &ListCostCategoryResourceAssociationsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListCostCategoryResourceAssociations", params, optFns, c.addOperationListCostCategoryResourceAssociationsMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListCostCategoryResourceAssociationsOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListCostCategoryResourceAssociationsInput struct {
// The unique identifier for your cost category.
CostCategoryArn *string
// The number of entries a paginated response contains.
MaxResults *int32
// The token to retrieve the next set of results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextToken *string
noSmithyDocumentSerde
}
type ListCostCategoryResourceAssociationsOutput struct {
// A reference to a cost category association that contains information on an
// associated resource.
CostCategoryResourceAssociations []types.CostCategoryResourceAssociation
// The token to retrieve the next set of results. Amazon Web Services provides
// the token when the response from a previous call has more results than the
// maximum page size.
NextToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListCostCategoryResourceAssociationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListCostCategoryResourceAssociations{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListCostCategoryResourceAssociations{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListCostCategoryResourceAssociations"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCostCategoryResourceAssociations(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListCostCategoryResourceAssociationsPaginatorOptions is the paginator options
// for ListCostCategoryResourceAssociations
type ListCostCategoryResourceAssociationsPaginatorOptions struct {
// The number of entries a paginated response contains.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListCostCategoryResourceAssociationsPaginator is a paginator for
// ListCostCategoryResourceAssociations
type ListCostCategoryResourceAssociationsPaginator struct {
options ListCostCategoryResourceAssociationsPaginatorOptions
client ListCostCategoryResourceAssociationsAPIClient
params *ListCostCategoryResourceAssociationsInput
nextToken *string
firstPage bool
}
// NewListCostCategoryResourceAssociationsPaginator returns a new
// ListCostCategoryResourceAssociationsPaginator
func NewListCostCategoryResourceAssociationsPaginator(client ListCostCategoryResourceAssociationsAPIClient, params *ListCostCategoryResourceAssociationsInput, optFns ...func(*ListCostCategoryResourceAssociationsPaginatorOptions)) *ListCostCategoryResourceAssociationsPaginator {
if params == nil {
params = &ListCostCategoryResourceAssociationsInput{}
}
options := ListCostCategoryResourceAssociationsPaginatorOptions{}
if params.MaxResults != nil {
options.Limit = *params.MaxResults
}
for _, fn := range optFns {
fn(&options)
}
return &ListCostCategoryResourceAssociationsPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListCostCategoryResourceAssociationsPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListCostCategoryResourceAssociations page.
func (p *ListCostCategoryResourceAssociationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCostCategoryResourceAssociationsOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextToken = p.nextToken
var limit *int32
if p.options.Limit > 0 {
limit = &p.options.Limit
}
params.MaxResults = limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListCostCategoryResourceAssociations(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListCostCategoryResourceAssociationsAPIClient is a client that implements the
// ListCostCategoryResourceAssociations operation.
type ListCostCategoryResourceAssociationsAPIClient interface {
ListCostCategoryResourceAssociations(context.Context, *ListCostCategoryResourceAssociationsInput, ...func(*Options)) (*ListCostCategoryResourceAssociationsOutput, error)
}
var _ ListCostCategoryResourceAssociationsAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListCostCategoryResourceAssociations(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListCostCategoryResourceAssociations",
}
}
@@ -0,0 +1,260 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Retrieves a list of your historical recommendation generations within the past
// 30 days.
func (c *Client) ListSavingsPlansPurchaseRecommendationGeneration(ctx context.Context, params *ListSavingsPlansPurchaseRecommendationGenerationInput, optFns ...func(*Options)) (*ListSavingsPlansPurchaseRecommendationGenerationOutput, error) {
if params == nil {
params = &ListSavingsPlansPurchaseRecommendationGenerationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListSavingsPlansPurchaseRecommendationGeneration", params, optFns, c.addOperationListSavingsPlansPurchaseRecommendationGenerationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListSavingsPlansPurchaseRecommendationGenerationOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListSavingsPlansPurchaseRecommendationGenerationInput struct {
// The status of the recommendation generation.
GenerationStatus types.GenerationStatus
// The token to retrieve the next set of results.
NextPageToken *string
// The number of recommendations that you want returned in a single response
// object.
PageSize int32
// The IDs for each specific recommendation.
RecommendationIds []string
noSmithyDocumentSerde
}
type ListSavingsPlansPurchaseRecommendationGenerationOutput struct {
// The list of historical recommendation generations.
GenerationSummaryList []types.GenerationSummary
// The token to retrieve the next set of results.
NextPageToken *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListSavingsPlansPurchaseRecommendationGenerationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListSavingsPlansPurchaseRecommendationGeneration{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListSavingsPlansPurchaseRecommendationGeneration{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListSavingsPlansPurchaseRecommendationGeneration"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListSavingsPlansPurchaseRecommendationGeneration(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
// ListSavingsPlansPurchaseRecommendationGenerationPaginatorOptions is the
// paginator options for ListSavingsPlansPurchaseRecommendationGeneration
type ListSavingsPlansPurchaseRecommendationGenerationPaginatorOptions struct {
// The number of recommendations that you want returned in a single response
// object.
Limit int32
// Set to true if pagination should stop if the service returns a pagination token
// that matches the most recent token provided to the service.
StopOnDuplicateToken bool
}
// ListSavingsPlansPurchaseRecommendationGenerationPaginator is a paginator for
// ListSavingsPlansPurchaseRecommendationGeneration
type ListSavingsPlansPurchaseRecommendationGenerationPaginator struct {
options ListSavingsPlansPurchaseRecommendationGenerationPaginatorOptions
client ListSavingsPlansPurchaseRecommendationGenerationAPIClient
params *ListSavingsPlansPurchaseRecommendationGenerationInput
nextToken *string
firstPage bool
}
// NewListSavingsPlansPurchaseRecommendationGenerationPaginator returns a new
// ListSavingsPlansPurchaseRecommendationGenerationPaginator
func NewListSavingsPlansPurchaseRecommendationGenerationPaginator(client ListSavingsPlansPurchaseRecommendationGenerationAPIClient, params *ListSavingsPlansPurchaseRecommendationGenerationInput, optFns ...func(*ListSavingsPlansPurchaseRecommendationGenerationPaginatorOptions)) *ListSavingsPlansPurchaseRecommendationGenerationPaginator {
if params == nil {
params = &ListSavingsPlansPurchaseRecommendationGenerationInput{}
}
options := ListSavingsPlansPurchaseRecommendationGenerationPaginatorOptions{}
if params.PageSize != 0 {
options.Limit = params.PageSize
}
for _, fn := range optFns {
fn(&options)
}
return &ListSavingsPlansPurchaseRecommendationGenerationPaginator{
options: options,
client: client,
params: params,
firstPage: true,
nextToken: params.NextPageToken,
}
}
// HasMorePages returns a boolean indicating whether more pages are available
func (p *ListSavingsPlansPurchaseRecommendationGenerationPaginator) HasMorePages() bool {
return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
}
// NextPage retrieves the next ListSavingsPlansPurchaseRecommendationGeneration
// page.
func (p *ListSavingsPlansPurchaseRecommendationGenerationPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListSavingsPlansPurchaseRecommendationGenerationOutput, error) {
if !p.HasMorePages() {
return nil, fmt.Errorf("no more pages available")
}
params := *p.params
params.NextPageToken = p.nextToken
params.PageSize = p.options.Limit
optFns = append([]func(*Options){
addIsPaginatorUserAgent,
}, optFns...)
result, err := p.client.ListSavingsPlansPurchaseRecommendationGeneration(ctx, &params, optFns...)
if err != nil {
return nil, err
}
p.firstPage = false
prevToken := p.nextToken
p.nextToken = result.NextPageToken
if p.options.StopOnDuplicateToken &&
prevToken != nil &&
p.nextToken != nil &&
*prevToken == *p.nextToken {
p.nextToken = nil
}
return result, nil
}
// ListSavingsPlansPurchaseRecommendationGenerationAPIClient is a client that
// implements the ListSavingsPlansPurchaseRecommendationGeneration operation.
type ListSavingsPlansPurchaseRecommendationGenerationAPIClient interface {
ListSavingsPlansPurchaseRecommendationGeneration(context.Context, *ListSavingsPlansPurchaseRecommendationGenerationInput, ...func(*Options)) (*ListSavingsPlansPurchaseRecommendationGenerationOutput, error)
}
var _ ListSavingsPlansPurchaseRecommendationGenerationAPIClient = (*Client)(nil)
func newServiceMetadataMiddleware_opListSavingsPlansPurchaseRecommendationGeneration(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListSavingsPlansPurchaseRecommendationGeneration",
}
}
@@ -0,0 +1,161 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Returns a list of resource tags associated with the resource specified by the
// Amazon Resource Name (ARN).
func (c *Client) ListTagsForResource(ctx context.Context, params *ListTagsForResourceInput, optFns ...func(*Options)) (*ListTagsForResourceOutput, error) {
if params == nil {
params = &ListTagsForResourceInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ListTagsForResource", params, optFns, c.addOperationListTagsForResourceMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ListTagsForResourceOutput)
out.ResultMetadata = metadata
return out, nil
}
type ListTagsForResourceInput struct {
// The Amazon Resource Name (ARN) of the resource. For a list of supported
// resources, see [ResourceTag].
//
// [ResourceTag]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_ResourceTag.html
//
// This member is required.
ResourceArn *string
noSmithyDocumentSerde
}
type ListTagsForResourceOutput struct {
// A list of tag key value pairs that are associated with the resource.
ResourceTags []types.ResourceTag
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationListTagsForResourceMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpListTagsForResource{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListTagsForResource{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ListTagsForResource"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpListTagsForResourceValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListTagsForResource(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opListTagsForResource(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ListTagsForResource",
}
}
@@ -0,0 +1,165 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Modifies the feedback property of a given cost anomaly.
func (c *Client) ProvideAnomalyFeedback(ctx context.Context, params *ProvideAnomalyFeedbackInput, optFns ...func(*Options)) (*ProvideAnomalyFeedbackOutput, error) {
if params == nil {
params = &ProvideAnomalyFeedbackInput{}
}
result, metadata, err := c.invokeOperation(ctx, "ProvideAnomalyFeedback", params, optFns, c.addOperationProvideAnomalyFeedbackMiddlewares)
if err != nil {
return nil, err
}
out := result.(*ProvideAnomalyFeedbackOutput)
out.ResultMetadata = metadata
return out, nil
}
type ProvideAnomalyFeedbackInput struct {
// A cost anomaly ID.
//
// This member is required.
AnomalyId *string
// Describes whether the cost anomaly was a planned activity or you considered it
// an anomaly.
//
// This member is required.
Feedback types.AnomalyFeedbackType
noSmithyDocumentSerde
}
type ProvideAnomalyFeedbackOutput struct {
// The ID of the modified cost anomaly.
//
// This member is required.
AnomalyId *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationProvideAnomalyFeedbackMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpProvideAnomalyFeedback{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpProvideAnomalyFeedback{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "ProvideAnomalyFeedback"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpProvideAnomalyFeedbackValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opProvideAnomalyFeedback(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opProvideAnomalyFeedback(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "ProvideAnomalyFeedback",
}
}
@@ -0,0 +1,171 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Specifies the parameters of a planned commitment purchase and starts the
// generation of the analysis. This enables you to estimate the cost, coverage, and
// utilization impact of your planned commitment purchases.
func (c *Client) StartCommitmentPurchaseAnalysis(ctx context.Context, params *StartCommitmentPurchaseAnalysisInput, optFns ...func(*Options)) (*StartCommitmentPurchaseAnalysisOutput, error) {
if params == nil {
params = &StartCommitmentPurchaseAnalysisInput{}
}
result, metadata, err := c.invokeOperation(ctx, "StartCommitmentPurchaseAnalysis", params, optFns, c.addOperationStartCommitmentPurchaseAnalysisMiddlewares)
if err != nil {
return nil, err
}
out := result.(*StartCommitmentPurchaseAnalysisOutput)
out.ResultMetadata = metadata
return out, nil
}
type StartCommitmentPurchaseAnalysisInput struct {
// The configuration for the commitment purchase analysis.
//
// This member is required.
CommitmentPurchaseAnalysisConfiguration *types.CommitmentPurchaseAnalysisConfiguration
noSmithyDocumentSerde
}
type StartCommitmentPurchaseAnalysisOutput struct {
// The analysis ID that's associated with the commitment purchase analysis.
//
// This member is required.
AnalysisId *string
// The start time of the analysis.
//
// This member is required.
AnalysisStartedTime *string
// The estimated time for when the analysis will complete.
//
// This member is required.
EstimatedCompletionTime *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationStartCommitmentPurchaseAnalysisMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartCommitmentPurchaseAnalysis{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartCommitmentPurchaseAnalysis{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "StartCommitmentPurchaseAnalysis"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpStartCommitmentPurchaseAnalysisValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartCommitmentPurchaseAnalysis(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opStartCommitmentPurchaseAnalysis(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "StartCommitmentPurchaseAnalysis",
}
}
@@ -0,0 +1,164 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Request a cost allocation tag backfill. This will backfill the activation
//
// status (either active or inactive ) for all tag keys from para:BackfillFrom up
// to the time this request is made.
//
// You can request a backfill once every 24 hours.
func (c *Client) StartCostAllocationTagBackfill(ctx context.Context, params *StartCostAllocationTagBackfillInput, optFns ...func(*Options)) (*StartCostAllocationTagBackfillOutput, error) {
if params == nil {
params = &StartCostAllocationTagBackfillInput{}
}
result, metadata, err := c.invokeOperation(ctx, "StartCostAllocationTagBackfill", params, optFns, c.addOperationStartCostAllocationTagBackfillMiddlewares)
if err != nil {
return nil, err
}
out := result.(*StartCostAllocationTagBackfillOutput)
out.ResultMetadata = metadata
return out, nil
}
type StartCostAllocationTagBackfillInput struct {
// The date you want the backfill to start from. The date can only be a first day
// of the month (a billing start date). Dates can't precede the previous twelve
// months, or in the future.
//
// This member is required.
BackfillFrom *string
noSmithyDocumentSerde
}
type StartCostAllocationTagBackfillOutput struct {
// An object containing detailed metadata of your new backfill request.
BackfillRequest *types.CostAllocationTagBackfillRequest
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationStartCostAllocationTagBackfillMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartCostAllocationTagBackfill{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartCostAllocationTagBackfill{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "StartCostAllocationTagBackfill"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpStartCostAllocationTagBackfillValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartCostAllocationTagBackfill(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opStartCostAllocationTagBackfill(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "StartCostAllocationTagBackfill",
}
}
@@ -0,0 +1,160 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Requests a Savings Plans recommendation generation. This enables you to
// calculate a fresh set of Savings Plans recommendations that takes your latest
// usage data and current Savings Plans inventory into account. You can refresh
// Savings Plans recommendations up to three times daily for a consolidated billing
// family.
//
// StartSavingsPlansPurchaseRecommendationGeneration has no request syntax because
// no input parameters are needed to support this operation.
func (c *Client) StartSavingsPlansPurchaseRecommendationGeneration(ctx context.Context, params *StartSavingsPlansPurchaseRecommendationGenerationInput, optFns ...func(*Options)) (*StartSavingsPlansPurchaseRecommendationGenerationOutput, error) {
if params == nil {
params = &StartSavingsPlansPurchaseRecommendationGenerationInput{}
}
result, metadata, err := c.invokeOperation(ctx, "StartSavingsPlansPurchaseRecommendationGeneration", params, optFns, c.addOperationStartSavingsPlansPurchaseRecommendationGenerationMiddlewares)
if err != nil {
return nil, err
}
out := result.(*StartSavingsPlansPurchaseRecommendationGenerationOutput)
out.ResultMetadata = metadata
return out, nil
}
type StartSavingsPlansPurchaseRecommendationGenerationInput struct {
noSmithyDocumentSerde
}
type StartSavingsPlansPurchaseRecommendationGenerationOutput struct {
// The estimated time for when the recommendation generation will complete.
EstimatedCompletionTime *string
// The start time of the recommendation generation.
GenerationStartedTime *string
// The ID for this specific recommendation.
RecommendationId *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationStartSavingsPlansPurchaseRecommendationGenerationMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartSavingsPlansPurchaseRecommendationGeneration{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartSavingsPlansPurchaseRecommendationGeneration{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "StartSavingsPlansPurchaseRecommendationGeneration"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartSavingsPlansPurchaseRecommendationGeneration(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opStartSavingsPlansPurchaseRecommendationGeneration(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "StartSavingsPlansPurchaseRecommendationGeneration",
}
}
@@ -0,0 +1,191 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// An API operation for adding one or more tags (key-value pairs) to a resource.
//
// You can use the TagResource operation with a resource that already has tags. If
// you specify a new tag key for the resource, this tag is appended to the list of
// tags associated with the resource. If you specify a tag key that is already
// associated with the resource, the new tag value you specify replaces the
// previous value for that tag.
//
// Although the maximum number of array members is 200, user-tag maximum is 50.
// The remaining are reserved for Amazon Web Services use.
func (c *Client) TagResource(ctx context.Context, params *TagResourceInput, optFns ...func(*Options)) (*TagResourceOutput, error) {
if params == nil {
params = &TagResourceInput{}
}
result, metadata, err := c.invokeOperation(ctx, "TagResource", params, optFns, c.addOperationTagResourceMiddlewares)
if err != nil {
return nil, err
}
out := result.(*TagResourceOutput)
out.ResultMetadata = metadata
return out, nil
}
type TagResourceInput struct {
// The Amazon Resource Name (ARN) of the resource. For a list of supported
// resources, see [ResourceTag].
//
// [ResourceTag]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_ResourceTag.html
//
// This member is required.
ResourceArn *string
// A list of tag key-value pairs to be added to the resource.
//
// Each tag consists of a key and a value, and each key must be unique for the
// resource. The following restrictions apply to resource tags:
//
// - Although the maximum number of array members is 200, you can assign a
// maximum of 50 user-tags to one resource. The remaining are reserved for Amazon
// Web Services use
//
// - The maximum length of a key is 128 characters
//
// - The maximum length of a value is 256 characters
//
// - Keys and values can only contain alphanumeric characters, spaces, and any
// of the following: _.:/=+@-
//
// - Keys and values are case sensitive
//
// - Keys and values are trimmed for any leading or trailing whitespaces
//
// - Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon
// Web Services use
//
// This member is required.
ResourceTags []types.ResourceTag
noSmithyDocumentSerde
}
type TagResourceOutput struct {
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationTagResourceMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpTagResource{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpTagResource{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "TagResource"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpTagResourceValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opTagResource(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opTagResource(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "TagResource",
}
}
@@ -0,0 +1,164 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Removes one or more tags from a resource. Specify only tag keys in your
// request. Don't specify the value.
func (c *Client) UntagResource(ctx context.Context, params *UntagResourceInput, optFns ...func(*Options)) (*UntagResourceOutput, error) {
if params == nil {
params = &UntagResourceInput{}
}
result, metadata, err := c.invokeOperation(ctx, "UntagResource", params, optFns, c.addOperationUntagResourceMiddlewares)
if err != nil {
return nil, err
}
out := result.(*UntagResourceOutput)
out.ResultMetadata = metadata
return out, nil
}
type UntagResourceInput struct {
// The Amazon Resource Name (ARN) of the resource. For a list of supported
// resources, see [ResourceTag].
//
// [ResourceTag]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_ResourceTag.html
//
// This member is required.
ResourceArn *string
// A list of tag keys associated with tags that need to be removed from the
// resource. If you specify a tag key that doesn't exist, it's ignored. Although
// the maximum number of array members is 200, user-tag maximum is 50. The
// remaining are reserved for Amazon Web Services use.
//
// This member is required.
ResourceTagKeys []string
noSmithyDocumentSerde
}
type UntagResourceOutput struct {
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationUntagResourceMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpUntagResource{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUntagResource{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "UntagResource"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpUntagResourceValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUntagResource(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opUntagResource(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "UntagResource",
}
}
@@ -0,0 +1,162 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Updates an existing cost anomaly monitor. The changes made are applied going
// forward, and doesn't change anomalies detected in the past.
func (c *Client) UpdateAnomalyMonitor(ctx context.Context, params *UpdateAnomalyMonitorInput, optFns ...func(*Options)) (*UpdateAnomalyMonitorOutput, error) {
if params == nil {
params = &UpdateAnomalyMonitorInput{}
}
result, metadata, err := c.invokeOperation(ctx, "UpdateAnomalyMonitor", params, optFns, c.addOperationUpdateAnomalyMonitorMiddlewares)
if err != nil {
return nil, err
}
out := result.(*UpdateAnomalyMonitorOutput)
out.ResultMetadata = metadata
return out, nil
}
type UpdateAnomalyMonitorInput struct {
// Cost anomaly monitor Amazon Resource Names (ARNs).
//
// This member is required.
MonitorArn *string
// The new name for the cost anomaly monitor.
MonitorName *string
noSmithyDocumentSerde
}
type UpdateAnomalyMonitorOutput struct {
// A cost anomaly monitor ARN.
//
// This member is required.
MonitorArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationUpdateAnomalyMonitorMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateAnomalyMonitor{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateAnomalyMonitor"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpUpdateAnomalyMonitorValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateAnomalyMonitor(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opUpdateAnomalyMonitor(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "UpdateAnomalyMonitor",
}
}
@@ -0,0 +1,227 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Updates an existing cost anomaly subscription. Specify the fields that you want
// to update. Omitted fields are unchanged.
//
// The JSON below describes the generic construct for each type. See [Request Parameters] for possible
// values as they apply to AnomalySubscription .
//
// [Request Parameters]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_UpdateAnomalySubscription.html#API_UpdateAnomalySubscription_RequestParameters
func (c *Client) UpdateAnomalySubscription(ctx context.Context, params *UpdateAnomalySubscriptionInput, optFns ...func(*Options)) (*UpdateAnomalySubscriptionOutput, error) {
if params == nil {
params = &UpdateAnomalySubscriptionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "UpdateAnomalySubscription", params, optFns, c.addOperationUpdateAnomalySubscriptionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*UpdateAnomalySubscriptionOutput)
out.ResultMetadata = metadata
return out, nil
}
type UpdateAnomalySubscriptionInput struct {
// A cost anomaly subscription Amazon Resource Name (ARN).
//
// This member is required.
SubscriptionArn *string
// The update to the frequency value that subscribers receive notifications.
Frequency types.AnomalySubscriptionFrequency
// A list of cost anomaly monitor ARNs.
MonitorArnList []string
// The update to the subscriber list.
Subscribers []types.Subscriber
// The new name of the subscription.
SubscriptionName *string
// (deprecated)
//
// The update to the threshold value for receiving notifications.
//
// This field has been deprecated. To update a threshold, use ThresholdExpression.
// Continued use of Threshold will be treated as shorthand syntax for a
// ThresholdExpression.
//
// You can specify either Threshold or ThresholdExpression, but not both.
//
// Deprecated: Threshold has been deprecated in favor of ThresholdExpression
Threshold *float64
// The update to the [Expression] object used to specify the anomalies that you want to
// generate alerts for. This supports dimensions and nested expressions. The
// supported dimensions are ANOMALY_TOTAL_IMPACT_ABSOLUTE and
// ANOMALY_TOTAL_IMPACT_PERCENTAGE , corresponding to an anomaly’s TotalImpact and
// TotalImpactPercentage, respectively (see [Impact]for more details). The supported
// nested expression types are AND and OR . The match option GREATER_THAN_OR_EQUAL
// is required. Values must be numbers between 0 and 10,000,000,000 in string
// format.
//
// You can specify either Threshold or ThresholdExpression, but not both.
//
// The following are examples of valid ThresholdExpressions:
//
// - Absolute threshold: { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } }
//
// - Percentage threshold: { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } }
//
// - AND two thresholds together: { "And": [ { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } }, { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } } ] }
//
// - OR two thresholds together: { "Or": [ { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } }, { "Dimensions": { "Key":
// "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ],
// "Values": [ "100" ] } } ] }
//
// [Impact]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Impact.html
// [Expression]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html
ThresholdExpression *types.Expression
noSmithyDocumentSerde
}
type UpdateAnomalySubscriptionOutput struct {
// A cost anomaly subscription ARN.
//
// This member is required.
SubscriptionArn *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationUpdateAnomalySubscriptionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateAnomalySubscription{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateAnomalySubscription"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpUpdateAnomalySubscriptionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateAnomalySubscription(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opUpdateAnomalySubscription(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "UpdateAnomalySubscription",
}
}
@@ -0,0 +1,163 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Updates status for cost allocation tags in bulk, with maximum batch size of 20.
// If the tag status that's updated is the same as the existing tag status, the
// request doesn't fail. Instead, it doesn't have any effect on the tag status (for
// example, activating the active tag).
func (c *Client) UpdateCostAllocationTagsStatus(ctx context.Context, params *UpdateCostAllocationTagsStatusInput, optFns ...func(*Options)) (*UpdateCostAllocationTagsStatusOutput, error) {
if params == nil {
params = &UpdateCostAllocationTagsStatusInput{}
}
result, metadata, err := c.invokeOperation(ctx, "UpdateCostAllocationTagsStatus", params, optFns, c.addOperationUpdateCostAllocationTagsStatusMiddlewares)
if err != nil {
return nil, err
}
out := result.(*UpdateCostAllocationTagsStatusOutput)
out.ResultMetadata = metadata
return out, nil
}
type UpdateCostAllocationTagsStatusInput struct {
// The list of CostAllocationTagStatusEntry objects that are used to update cost
// allocation tags status for this request.
//
// This member is required.
CostAllocationTagsStatus []types.CostAllocationTagStatusEntry
noSmithyDocumentSerde
}
type UpdateCostAllocationTagsStatusOutput struct {
// A list of UpdateCostAllocationTagsStatusError objects with error details about
// each cost allocation tag that can't be updated. If there's no failure, an empty
// array returns.
Errors []types.UpdateCostAllocationTagsStatusError
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationUpdateCostAllocationTagsStatusMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateCostAllocationTagsStatus{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateCostAllocationTagsStatus{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateCostAllocationTagsStatus"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpUpdateCostAllocationTagsStatusValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateCostAllocationTagsStatus(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opUpdateCostAllocationTagsStatus(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "UpdateCostAllocationTagsStatus",
}
}
@@ -0,0 +1,188 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/costexplorer/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Updates an existing cost category. Changes made to the cost category rules will
// be used to categorize the current month’s expenses and future expenses. This
// won’t change categorization for the previous months.
func (c *Client) UpdateCostCategoryDefinition(ctx context.Context, params *UpdateCostCategoryDefinitionInput, optFns ...func(*Options)) (*UpdateCostCategoryDefinitionOutput, error) {
if params == nil {
params = &UpdateCostCategoryDefinitionInput{}
}
result, metadata, err := c.invokeOperation(ctx, "UpdateCostCategoryDefinition", params, optFns, c.addOperationUpdateCostCategoryDefinitionMiddlewares)
if err != nil {
return nil, err
}
out := result.(*UpdateCostCategoryDefinitionOutput)
out.ResultMetadata = metadata
return out, nil
}
type UpdateCostCategoryDefinitionInput struct {
// The unique identifier for your cost category.
//
// This member is required.
CostCategoryArn *string
// The rule schema version in this particular cost category.
//
// This member is required.
RuleVersion types.CostCategoryRuleVersion
// The Expression object used to categorize costs. For more information, see [CostCategoryRule].
//
// [CostCategoryRule]: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html
//
// This member is required.
Rules []types.CostCategoryRule
// The default value for the cost category.
DefaultValue *string
// The cost category's effective start date. It can only be a billing start date
// (first day of the month). If the date isn't provided, it's the first day of the
// current month. Dates can't be before the previous twelve months, or in the
// future.
EffectiveStart *string
// The split charge rules used to allocate your charges between your cost
// category values.
SplitChargeRules []types.CostCategorySplitChargeRule
noSmithyDocumentSerde
}
type UpdateCostCategoryDefinitionOutput struct {
// The unique identifier for your cost category.
CostCategoryArn *string
// The cost category's effective start date. It can only be a billing start date
// (first day of the month).
EffectiveStart *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationUpdateCostCategoryDefinitionMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateCostCategoryDefinition{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateCostCategoryDefinition"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addSpanRetryLoop(stack, options); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addTimeOffsetBuild(stack, c); err != nil {
return err
}
if err = addUserAgentRetryMode(stack, options); err != nil {
return err
}
if err = addCredentialSource(stack, options); err != nil {
return err
}
if err = addOpUpdateCostCategoryDefinitionValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateCostCategoryDefinition(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
return err
}
if err = addInterceptAttempt(stack, options); err != nil {
return err
}
if err = addInterceptors(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opUpdateCostCategoryDefinition(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "UpdateCostCategoryDefinition",
}
}
+345
View File
@@ -0,0 +1,345 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
smithy "github.com/aws/smithy-go"
smithyauth "github.com/aws/smithy-go/auth"
"github.com/aws/smithy-go/metrics"
"github.com/aws/smithy-go/middleware"
"github.com/aws/smithy-go/tracing"
smithyhttp "github.com/aws/smithy-go/transport/http"
"slices"
"strings"
)
func bindAuthParamsRegion(_ interface{}, params *AuthResolverParameters, _ interface{}, options Options) error {
params.Region = options.Region
return nil
}
type setLegacyContextSigningOptionsMiddleware struct {
}
func (*setLegacyContextSigningOptionsMiddleware) ID() string {
return "setLegacyContextSigningOptions"
}
func (m *setLegacyContextSigningOptionsMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
rscheme := getResolvedAuthScheme(ctx)
schemeID := rscheme.Scheme.SchemeID()
if sn := awsmiddleware.GetSigningName(ctx); sn != "" {
if schemeID == "aws.auth#sigv4" {
smithyhttp.SetSigV4SigningName(&rscheme.SignerProperties, sn)
} else if schemeID == "aws.auth#sigv4a" {
smithyhttp.SetSigV4ASigningName(&rscheme.SignerProperties, sn)
}
}
if sr := awsmiddleware.GetSigningRegion(ctx); sr != "" {
if schemeID == "aws.auth#sigv4" {
smithyhttp.SetSigV4SigningRegion(&rscheme.SignerProperties, sr)
} else if schemeID == "aws.auth#sigv4a" {
smithyhttp.SetSigV4ASigningRegions(&rscheme.SignerProperties, []string{sr})
}
}
return next.HandleFinalize(ctx, in)
}
func addSetLegacyContextSigningOptionsMiddleware(stack *middleware.Stack) error {
return stack.Finalize.Insert(&setLegacyContextSigningOptionsMiddleware{}, "Signing", middleware.Before)
}
type withAnonymous struct {
resolver AuthSchemeResolver
}
var _ AuthSchemeResolver = (*withAnonymous)(nil)
func (v *withAnonymous) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) {
opts, err := v.resolver.ResolveAuthSchemes(ctx, params)
if err != nil {
return nil, err
}
opts = append(opts, &smithyauth.Option{
SchemeID: smithyauth.SchemeIDAnonymous,
})
return opts, nil
}
func wrapWithAnonymousAuth(options *Options) {
if _, ok := options.AuthSchemeResolver.(*defaultAuthSchemeResolver); !ok {
return
}
options.AuthSchemeResolver = &withAnonymous{
resolver: options.AuthSchemeResolver,
}
}
// AuthResolverParameters contains the set of inputs necessary for auth scheme
// resolution.
type AuthResolverParameters struct {
// The name of the operation being invoked.
Operation string
// The region in which the operation is being invoked.
Region string
}
func bindAuthResolverParams(ctx context.Context, operation string, input interface{}, options Options) (*AuthResolverParameters, error) {
params := &AuthResolverParameters{
Operation: operation,
}
if err := bindAuthParamsRegion(ctx, params, input, options); err != nil {
return nil, err
}
return params, nil
}
// AuthSchemeResolver returns a set of possible authentication options for an
// operation.
type AuthSchemeResolver interface {
ResolveAuthSchemes(context.Context, *AuthResolverParameters) ([]*smithyauth.Option, error)
}
type defaultAuthSchemeResolver struct{}
var _ AuthSchemeResolver = (*defaultAuthSchemeResolver)(nil)
func (*defaultAuthSchemeResolver) ResolveAuthSchemes(ctx context.Context, params *AuthResolverParameters) ([]*smithyauth.Option, error) {
if overrides, ok := operationAuthOptions[params.Operation]; ok {
return overrides(params), nil
}
return serviceAuthOptions(params), nil
}
var operationAuthOptions = map[string]func(*AuthResolverParameters) []*smithyauth.Option{}
func serviceAuthOptions(params *AuthResolverParameters) []*smithyauth.Option {
return []*smithyauth.Option{
{
SchemeID: smithyauth.SchemeIDSigV4,
SignerProperties: func() smithy.Properties {
var props smithy.Properties
smithyhttp.SetSigV4SigningName(&props, "ce")
smithyhttp.SetSigV4SigningRegion(&props, params.Region)
return props
}(),
},
}
}
type resolveAuthSchemeMiddleware struct {
operation string
options Options
}
func (*resolveAuthSchemeMiddleware) ID() string {
return "ResolveAuthScheme"
}
func (m *resolveAuthSchemeMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
_, span := tracing.StartSpan(ctx, "ResolveAuthScheme")
defer span.End()
params, err := bindAuthResolverParams(ctx, m.operation, getOperationInput(ctx), m.options)
if err != nil {
return out, metadata, fmt.Errorf("bind auth scheme params: %w", err)
}
options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params)
if err != nil {
return out, metadata, fmt.Errorf("resolve auth scheme: %w", err)
}
scheme, ok := m.selectScheme(options)
if !ok {
return out, metadata, fmt.Errorf("could not select an auth scheme")
}
ctx = setResolvedAuthScheme(ctx, scheme)
span.SetProperty("auth.scheme_id", scheme.Scheme.SchemeID())
span.End()
return next.HandleFinalize(ctx, in)
}
func (m *resolveAuthSchemeMiddleware) selectScheme(options []*smithyauth.Option) (*resolvedAuthScheme, bool) {
sorted := sortAuthOptions(options, m.options.AuthSchemePreference)
for _, option := range sorted {
if option.SchemeID == smithyauth.SchemeIDAnonymous {
return newResolvedAuthScheme(smithyhttp.NewAnonymousScheme(), option), true
}
for _, scheme := range m.options.AuthSchemes {
if scheme.SchemeID() != option.SchemeID {
continue
}
if scheme.IdentityResolver(m.options) != nil {
return newResolvedAuthScheme(scheme, option), true
}
}
}
return nil, false
}
func sortAuthOptions(options []*smithyauth.Option, preferred []string) []*smithyauth.Option {
byPriority := make([]*smithyauth.Option, 0, len(options))
for _, prefName := range preferred {
for _, option := range options {
optName := option.SchemeID
if parts := strings.Split(option.SchemeID, "#"); len(parts) == 2 {
optName = parts[1]
}
if prefName == optName {
byPriority = append(byPriority, option)
}
}
}
for _, option := range options {
if !slices.ContainsFunc(byPriority, func(o *smithyauth.Option) bool {
return o.SchemeID == option.SchemeID
}) {
byPriority = append(byPriority, option)
}
}
return byPriority
}
type resolvedAuthSchemeKey struct{}
type resolvedAuthScheme struct {
Scheme smithyhttp.AuthScheme
IdentityProperties smithy.Properties
SignerProperties smithy.Properties
}
func newResolvedAuthScheme(scheme smithyhttp.AuthScheme, option *smithyauth.Option) *resolvedAuthScheme {
return &resolvedAuthScheme{
Scheme: scheme,
IdentityProperties: option.IdentityProperties,
SignerProperties: option.SignerProperties,
}
}
func setResolvedAuthScheme(ctx context.Context, scheme *resolvedAuthScheme) context.Context {
return middleware.WithStackValue(ctx, resolvedAuthSchemeKey{}, scheme)
}
func getResolvedAuthScheme(ctx context.Context) *resolvedAuthScheme {
v, _ := middleware.GetStackValue(ctx, resolvedAuthSchemeKey{}).(*resolvedAuthScheme)
return v
}
type getIdentityMiddleware struct {
options Options
}
func (*getIdentityMiddleware) ID() string {
return "GetIdentity"
}
func (m *getIdentityMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
innerCtx, span := tracing.StartSpan(ctx, "GetIdentity")
defer span.End()
rscheme := getResolvedAuthScheme(innerCtx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
resolver := rscheme.Scheme.IdentityResolver(m.options)
if resolver == nil {
return out, metadata, fmt.Errorf("no identity resolver")
}
identity, err := timeOperationMetric(ctx, "client.call.resolve_identity_duration",
func() (smithyauth.Identity, error) {
return resolver.GetIdentity(innerCtx, rscheme.IdentityProperties)
},
func(o *metrics.RecordMetricOptions) {
o.Properties.Set("auth.scheme_id", rscheme.Scheme.SchemeID())
})
if err != nil {
return out, metadata, fmt.Errorf("get identity: %w", err)
}
ctx = setIdentity(ctx, identity)
span.End()
return next.HandleFinalize(ctx, in)
}
type identityKey struct{}
func setIdentity(ctx context.Context, identity smithyauth.Identity) context.Context {
return middleware.WithStackValue(ctx, identityKey{}, identity)
}
func getIdentity(ctx context.Context) smithyauth.Identity {
v, _ := middleware.GetStackValue(ctx, identityKey{}).(smithyauth.Identity)
return v
}
type signRequestMiddleware struct {
options Options
}
func (*signRequestMiddleware) ID() string {
return "Signing"
}
func (m *signRequestMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
_, span := tracing.StartSpan(ctx, "SignRequest")
defer span.End()
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unexpected transport type %T", in.Request)
}
rscheme := getResolvedAuthScheme(ctx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
identity := getIdentity(ctx)
if identity == nil {
return out, metadata, fmt.Errorf("no identity")
}
signer := rscheme.Scheme.Signer()
if signer == nil {
return out, metadata, fmt.Errorf("no signer")
}
_, err = timeOperationMetric(ctx, "client.call.signing_duration", func() (any, error) {
return nil, signer.SignRequest(ctx, req, identity, rscheme.SignerProperties)
}, func(o *metrics.RecordMetricOptions) {
o.Properties.Set("auth.scheme_id", rscheme.Scheme.SchemeID())
})
if err != nil {
return out, metadata, fmt.Errorf("sign request: %w", err)
}
span.End()
return next.HandleFinalize(ctx, in)
}
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
// Package costexplorer provides the API client, operations, and parameter types
// for AWS Cost Explorer Service.
//
// You can use the Cost Explorer API to programmatically query your cost and usage
// data. You can query for aggregated data such as total monthly costs or total
// daily usage. You can also query for granular data. This might include the number
// of daily write operations for Amazon DynamoDB database tables in your production
// environment.
//
// # Service Endpoint
//
// The Cost Explorer API provides the following endpoint:
//
// - https://ce.us-east-1.amazonaws.com
//
// For information about the costs that are associated with the Cost Explorer API,
// see [Amazon Web Services Cost Management Pricing].
//
// [Amazon Web Services Cost Management Pricing]: http://aws.amazon.com/aws-cost-management/pricing/
package costexplorer
+860
View File
@@ -0,0 +1,860 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
internalConfig "github.com/aws/aws-sdk-go-v2/internal/configsources"
"github.com/aws/aws-sdk-go-v2/internal/endpoints"
"github.com/aws/aws-sdk-go-v2/internal/endpoints/awsrulesfn"
internalendpoints "github.com/aws/aws-sdk-go-v2/service/costexplorer/internal/endpoints"
smithy "github.com/aws/smithy-go"
smithyauth "github.com/aws/smithy-go/auth"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/aws/smithy-go/endpoints/private/rulesfn"
"github.com/aws/smithy-go/middleware"
"github.com/aws/smithy-go/ptr"
"github.com/aws/smithy-go/tracing"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net/http"
"net/url"
"os"
"strings"
)
// EndpointResolverOptions is the service endpoint resolver options
type EndpointResolverOptions = internalendpoints.Options
// EndpointResolver interface for resolving service endpoints.
type EndpointResolver interface {
ResolveEndpoint(region string, options EndpointResolverOptions) (aws.Endpoint, error)
}
var _ EndpointResolver = &internalendpoints.Resolver{}
// NewDefaultEndpointResolver constructs a new service endpoint resolver
func NewDefaultEndpointResolver() *internalendpoints.Resolver {
return internalendpoints.New()
}
// EndpointResolverFunc is a helper utility that wraps a function so it satisfies
// the EndpointResolver interface. This is useful when you want to add additional
// endpoint resolving logic, or stub out specific endpoints with custom values.
type EndpointResolverFunc func(region string, options EndpointResolverOptions) (aws.Endpoint, error)
func (fn EndpointResolverFunc) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) {
return fn(region, options)
}
// EndpointResolverFromURL returns an EndpointResolver configured using the
// provided endpoint url. By default, the resolved endpoint resolver uses the
// client region as signing region, and the endpoint source is set to
// EndpointSourceCustom.You can provide functional options to configure endpoint
// values for the resolved endpoint.
func EndpointResolverFromURL(url string, optFns ...func(*aws.Endpoint)) EndpointResolver {
e := aws.Endpoint{URL: url, Source: aws.EndpointSourceCustom}
for _, fn := range optFns {
fn(&e)
}
return EndpointResolverFunc(
func(region string, options EndpointResolverOptions) (aws.Endpoint, error) {
if len(e.SigningRegion) == 0 {
e.SigningRegion = region
}
return e, nil
},
)
}
type ResolveEndpoint struct {
Resolver EndpointResolver
Options EndpointResolverOptions
}
func (*ResolveEndpoint) ID() string {
return "ResolveEndpoint"
}
func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
out middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
if !awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
return next.HandleSerialize(ctx, in)
}
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if m.Resolver == nil {
return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil")
}
eo := m.Options
eo.Logger = middleware.GetLogger(ctx)
var endpoint aws.Endpoint
endpoint, err = m.Resolver.ResolveEndpoint(awsmiddleware.GetRegion(ctx), eo)
if err != nil {
nf := (&aws.EndpointNotFoundError{})
if errors.As(err, &nf) {
ctx = awsmiddleware.SetRequiresLegacyEndpoints(ctx, false)
return next.HandleSerialize(ctx, in)
}
return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
}
req.URL, err = url.Parse(endpoint.URL)
if err != nil {
return out, metadata, fmt.Errorf("failed to parse endpoint URL: %w", err)
}
if len(awsmiddleware.GetSigningName(ctx)) == 0 {
signingName := endpoint.SigningName
if len(signingName) == 0 {
signingName = "ce"
}
ctx = awsmiddleware.SetSigningName(ctx, signingName)
}
ctx = awsmiddleware.SetEndpointSource(ctx, endpoint.Source)
ctx = smithyhttp.SetHostnameImmutable(ctx, endpoint.HostnameImmutable)
ctx = awsmiddleware.SetSigningRegion(ctx, endpoint.SigningRegion)
ctx = awsmiddleware.SetPartitionID(ctx, endpoint.PartitionID)
return next.HandleSerialize(ctx, in)
}
func addResolveEndpointMiddleware(stack *middleware.Stack, o Options) error {
return stack.Serialize.Insert(&ResolveEndpoint{
Resolver: o.EndpointResolver,
Options: o.EndpointOptions,
}, "OperationSerializer", middleware.Before)
}
func removeResolveEndpointMiddleware(stack *middleware.Stack) error {
_, err := stack.Serialize.Remove((&ResolveEndpoint{}).ID())
return err
}
type wrappedEndpointResolver struct {
awsResolver aws.EndpointResolverWithOptions
}
func (w *wrappedEndpointResolver) ResolveEndpoint(region string, options EndpointResolverOptions) (endpoint aws.Endpoint, err error) {
return w.awsResolver.ResolveEndpoint(ServiceID, region, options)
}
type awsEndpointResolverAdaptor func(service, region string) (aws.Endpoint, error)
func (a awsEndpointResolverAdaptor) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) {
return a(service, region)
}
var _ aws.EndpointResolverWithOptions = awsEndpointResolverAdaptor(nil)
// withEndpointResolver returns an aws.EndpointResolverWithOptions that first delegates endpoint resolution to the awsResolver.
// If awsResolver returns aws.EndpointNotFoundError error, the v1 resolver middleware will swallow the error,
// and set an appropriate context flag such that fallback will occur when EndpointResolverV2 is invoked
// via its middleware.
//
// If another error (besides aws.EndpointNotFoundError) is returned, then that error will be propagated.
func withEndpointResolver(awsResolver aws.EndpointResolver, awsResolverWithOptions aws.EndpointResolverWithOptions) EndpointResolver {
var resolver aws.EndpointResolverWithOptions
if awsResolverWithOptions != nil {
resolver = awsResolverWithOptions
} else if awsResolver != nil {
resolver = awsEndpointResolverAdaptor(awsResolver.ResolveEndpoint)
}
return &wrappedEndpointResolver{
awsResolver: resolver,
}
}
func finalizeClientEndpointResolverOptions(options *Options) {
options.EndpointOptions.LogDeprecated = options.ClientLogMode.IsDeprecatedUsage()
if len(options.EndpointOptions.ResolvedRegion) == 0 {
const fipsInfix = "-fips-"
const fipsPrefix = "fips-"
const fipsSuffix = "-fips"
if strings.Contains(options.Region, fipsInfix) ||
strings.Contains(options.Region, fipsPrefix) ||
strings.Contains(options.Region, fipsSuffix) {
options.EndpointOptions.ResolvedRegion = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(
options.Region, fipsInfix, "-"), fipsPrefix, ""), fipsSuffix, "")
options.EndpointOptions.UseFIPSEndpoint = aws.FIPSEndpointStateEnabled
}
}
}
func resolveEndpointResolverV2(options *Options) {
if options.EndpointResolverV2 == nil {
options.EndpointResolverV2 = NewDefaultEndpointResolverV2()
}
}
func resolveBaseEndpoint(cfg aws.Config, o *Options) {
if cfg.BaseEndpoint != nil {
o.BaseEndpoint = cfg.BaseEndpoint
}
_, g := os.LookupEnv("AWS_ENDPOINT_URL")
_, s := os.LookupEnv("AWS_ENDPOINT_URL_COST_EXPLORER")
if g && !s {
return
}
value, found, err := internalConfig.ResolveServiceBaseEndpoint(context.Background(), "Cost Explorer", cfg.ConfigSources)
if found && err == nil {
o.BaseEndpoint = &value
}
}
func bindRegion(region string) (*string, error) {
if region == "" {
return nil, nil
}
if !rulesfn.IsValidHostLabel(region, true) {
return nil, fmt.Errorf("invalid input region %s", region)
}
return aws.String(endpoints.MapFIPSRegion(region)), nil
}
// EndpointParameters provides the parameters that influence how endpoints are
// resolved.
type EndpointParameters struct {
// When true, use the dual-stack endpoint. If the configured endpoint does not
// support dual-stack, dispatching the request MAY return an error.
//
// Defaults to
// false if no value is provided.
//
// AWS::UseDualStack
UseDualStack *bool
// 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.
//
// Defaults to false if no value is
// provided.
//
// AWS::UseFIPS
UseFIPS *bool
// Override the endpoint used to send this request
//
// Parameter is
// required.
//
// SDK::Endpoint
Endpoint *string
// The AWS region used to dispatch the request.
//
// Parameter is
// required.
//
// AWS::Region
Region *string
}
// ValidateRequired validates required parameters are set.
func (p EndpointParameters) ValidateRequired() error {
if p.UseDualStack == nil {
return fmt.Errorf("parameter UseDualStack is required")
}
if p.UseFIPS == nil {
return fmt.Errorf("parameter UseFIPS is required")
}
return nil
}
// WithDefaults returns a shallow copy of EndpointParameterswith default values
// applied to members where applicable.
func (p EndpointParameters) WithDefaults() EndpointParameters {
if p.UseDualStack == nil {
p.UseDualStack = ptr.Bool(false)
}
if p.UseFIPS == nil {
p.UseFIPS = ptr.Bool(false)
}
return p
}
type stringSlice []string
func (s stringSlice) Get(i int) *string {
if i < 0 || i >= len(s) {
return nil
}
v := s[i]
return &v
}
// EndpointResolverV2 provides the interface for resolving service endpoints.
type EndpointResolverV2 interface {
// ResolveEndpoint attempts to resolve the endpoint with the provided options,
// returning the endpoint if found. Otherwise an error is returned.
ResolveEndpoint(ctx context.Context, params EndpointParameters) (
smithyendpoints.Endpoint, error,
)
}
// resolver provides the implementation for resolving endpoints.
type resolver struct{}
func NewDefaultEndpointResolverV2() EndpointResolverV2 {
return &resolver{}
}
// ResolveEndpoint attempts to resolve the endpoint with the provided options,
// returning the endpoint if found. Otherwise an error is returned.
func (r *resolver) ResolveEndpoint(
ctx context.Context, params EndpointParameters,
) (
endpoint smithyendpoints.Endpoint, err error,
) {
params = params.WithDefaults()
if err = params.ValidateRequired(); err != nil {
return endpoint, fmt.Errorf("endpoint parameters are not valid, %w", err)
}
_UseDualStack := *params.UseDualStack
_ = _UseDualStack
_UseFIPS := *params.UseFIPS
_ = _UseFIPS
if exprVal := params.Endpoint; exprVal != nil {
_Endpoint := *exprVal
_ = _Endpoint
if _UseFIPS == true {
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: FIPS and custom endpoint are not supported")
}
if _UseDualStack == true {
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Dualstack and custom endpoint are not supported")
}
uriString := _Endpoint
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
}, nil
}
if exprVal := params.Region; exprVal != nil {
_Region := *exprVal
_ = _Region
if exprVal := awsrulesfn.GetPartition(_Region); exprVal != nil {
_PartitionResult := *exprVal
_ = _PartitionResult
if _PartitionResult.Name == "aws" {
if _UseFIPS == false {
if _UseDualStack == true {
uriString := "https://ce.us-east-1.api.aws"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-cn" {
if _UseFIPS == false {
if _UseDualStack == true {
uriString := "https://ce.cn-northwest-1.api.amazonwebservices.com.cn"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "cn-northwest-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-iso" {
if _UseFIPS == false {
if _UseDualStack == false {
uriString := "https://ce.us-iso-east-1.c2s.ic.gov"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "us-iso-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-iso-b" {
if _UseFIPS == false {
if _UseDualStack == false {
uriString := "https://ce.us-isob-east-1.sc2s.sgov.gov"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "us-isob-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-iso-e" {
if _UseFIPS == false {
if _UseDualStack == false {
uriString := "https://ce.eu-isoe-west-1.cloud.adc-e.uk"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "eu-isoe-west-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-iso-f" {
if _UseFIPS == false {
if _UseDualStack == false {
uriString := "https://ce.us-isof-south-1.csp.hci.ic.gov"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "us-isof-south-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-eusc" {
if _UseFIPS == false {
if _UseDualStack == true {
uriString := "https://ce.eusc-de-east-1.api.amazonwebservices.eu"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "eusc-de-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _PartitionResult.Name == "aws-eusc" {
if _UseFIPS == false {
if _UseDualStack == false {
uriString := "https://ce.eusc-de-east-1.api.amazonwebservices.eu"
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, "eusc-de-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}
}
}
if _UseFIPS == true {
if _UseDualStack == true {
if true == _PartitionResult.SupportsFIPS {
if true == _PartitionResult.SupportsDualStack {
uriString := func() string {
var out strings.Builder
out.WriteString("https://ce-fips.")
out.WriteString(_PartitionResult.ImplicitGlobalRegion)
out.WriteString(".")
out.WriteString(_PartitionResult.DualStackDnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, _PartitionResult.ImplicitGlobalRegion)
return sp
}(),
},
})
return out
}(),
}, nil
}
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS and DualStack are enabled, but this partition does not support one or both")
}
}
if _UseFIPS == true {
if _UseDualStack == false {
if _PartitionResult.SupportsFIPS == true {
uriString := func() string {
var out strings.Builder
out.WriteString("https://ce-fips.")
out.WriteString(_PartitionResult.ImplicitGlobalRegion)
out.WriteString(".")
out.WriteString(_PartitionResult.DnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, _PartitionResult.ImplicitGlobalRegion)
return sp
}(),
},
})
return out
}(),
}, nil
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "FIPS is enabled but this partition does not support FIPS")
}
}
if _UseFIPS == false {
if _UseDualStack == true {
if true == _PartitionResult.SupportsDualStack {
uriString := func() string {
var out strings.Builder
out.WriteString("https://ce.")
out.WriteString(_PartitionResult.ImplicitGlobalRegion)
out.WriteString(".")
out.WriteString(_PartitionResult.DualStackDnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, _PartitionResult.ImplicitGlobalRegion)
return sp
}(),
},
})
return out
}(),
}, nil
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "DualStack is enabled but this partition does not support DualStack")
}
}
uriString := func() string {
var out strings.Builder
out.WriteString("https://ce.")
out.WriteString(_PartitionResult.ImplicitGlobalRegion)
out.WriteString(".")
out.WriteString(_PartitionResult.DnsSuffix)
return out.String()
}()
uri, err := url.Parse(uriString)
if err != nil {
return endpoint, fmt.Errorf("Failed to parse uri: %s", uriString)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningRegion(&sp, _PartitionResult.ImplicitGlobalRegion)
return sp
}(),
},
})
return out
}(),
}, nil
}
return endpoint, fmt.Errorf("Endpoint resolution failed. Invalid operation or environment input.")
}
return endpoint, fmt.Errorf("endpoint rule error, %s", "Invalid Configuration: Missing Region")
}
type endpointParamsBinder interface {
bindEndpointParams(*EndpointParameters)
}
func bindEndpointParams(ctx context.Context, input interface{}, options Options) (*EndpointParameters, error) {
params := &EndpointParameters{}
params.UseDualStack = aws.Bool(options.EndpointOptions.UseDualStackEndpoint == aws.DualStackEndpointStateEnabled)
params.UseFIPS = aws.Bool(options.EndpointOptions.UseFIPSEndpoint == aws.FIPSEndpointStateEnabled)
params.Endpoint = options.BaseEndpoint
region, err := bindRegion(options.Region)
if err != nil {
return nil, err
}
params.Region = region
if b, ok := input.(endpointParamsBinder); ok {
b.bindEndpointParams(params)
}
return params, nil
}
type resolveEndpointV2Middleware struct {
options Options
}
func (*resolveEndpointV2Middleware) ID() string {
return "ResolveEndpointV2"
}
func (m *resolveEndpointV2Middleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
_, span := tracing.StartSpan(ctx, "ResolveEndpoint")
defer span.End()
if awsmiddleware.GetRequiresLegacyEndpoints(ctx) {
return next.HandleFinalize(ctx, in)
}
req, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if m.options.EndpointResolverV2 == nil {
return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil")
}
params, err := bindEndpointParams(ctx, getOperationInput(ctx), m.options)
if err != nil {
return out, metadata, fmt.Errorf("failed to bind endpoint params, %w", err)
}
endpt, err := timeOperationMetric(ctx, "client.call.resolve_endpoint_duration",
func() (smithyendpoints.Endpoint, error) {
return m.options.EndpointResolverV2.ResolveEndpoint(ctx, *params)
})
if err != nil {
return out, metadata, fmt.Errorf("failed to resolve service endpoint, %w", err)
}
span.SetProperty("client.call.resolved_endpoint", endpt.URI.String())
if endpt.URI.RawPath == "" && req.URL.RawPath != "" {
endpt.URI.RawPath = endpt.URI.Path
}
req.URL.Scheme = endpt.URI.Scheme
req.URL.Host = endpt.URI.Host
req.URL.Path = smithyhttp.JoinPath(endpt.URI.Path, req.URL.Path)
req.URL.RawPath = smithyhttp.JoinPath(endpt.URI.RawPath, req.URL.RawPath)
for k := range endpt.Headers {
req.Header.Set(k, endpt.Headers.Get(k))
}
rscheme := getResolvedAuthScheme(ctx)
if rscheme == nil {
return out, metadata, fmt.Errorf("no resolved auth scheme")
}
opts, _ := smithyauth.GetAuthOptions(&endpt.Properties)
for _, o := range opts {
rscheme.SignerProperties.SetAll(&o.SignerProperties)
}
span.End()
return next.HandleFinalize(ctx, in)
}
@@ -0,0 +1,79 @@
{
"dependencies": {
"github.com/aws/aws-sdk-go-v2": "v1.4.0",
"github.com/aws/aws-sdk-go-v2/internal/configsources": "v0.0.0-00010101000000-000000000000",
"github.com/aws/aws-sdk-go-v2/internal/endpoints/v2": "v2.0.0-00010101000000-000000000000",
"github.com/aws/smithy-go": "v1.4.0"
},
"files": [
"api_client.go",
"api_client_test.go",
"api_op_CreateAnomalyMonitor.go",
"api_op_CreateAnomalySubscription.go",
"api_op_CreateCostCategoryDefinition.go",
"api_op_DeleteAnomalyMonitor.go",
"api_op_DeleteAnomalySubscription.go",
"api_op_DeleteCostCategoryDefinition.go",
"api_op_DescribeCostCategoryDefinition.go",
"api_op_GetAnomalies.go",
"api_op_GetAnomalyMonitors.go",
"api_op_GetAnomalySubscriptions.go",
"api_op_GetApproximateUsageRecords.go",
"api_op_GetCommitmentPurchaseAnalysis.go",
"api_op_GetCostAndUsage.go",
"api_op_GetCostAndUsageComparisons.go",
"api_op_GetCostAndUsageWithResources.go",
"api_op_GetCostCategories.go",
"api_op_GetCostComparisonDrivers.go",
"api_op_GetCostForecast.go",
"api_op_GetDimensionValues.go",
"api_op_GetReservationCoverage.go",
"api_op_GetReservationPurchaseRecommendation.go",
"api_op_GetReservationUtilization.go",
"api_op_GetRightsizingRecommendation.go",
"api_op_GetSavingsPlanPurchaseRecommendationDetails.go",
"api_op_GetSavingsPlansCoverage.go",
"api_op_GetSavingsPlansPurchaseRecommendation.go",
"api_op_GetSavingsPlansUtilization.go",
"api_op_GetSavingsPlansUtilizationDetails.go",
"api_op_GetTags.go",
"api_op_GetUsageForecast.go",
"api_op_ListCommitmentPurchaseAnalyses.go",
"api_op_ListCostAllocationTagBackfillHistory.go",
"api_op_ListCostAllocationTags.go",
"api_op_ListCostCategoryDefinitions.go",
"api_op_ListCostCategoryResourceAssociations.go",
"api_op_ListSavingsPlansPurchaseRecommendationGeneration.go",
"api_op_ListTagsForResource.go",
"api_op_ProvideAnomalyFeedback.go",
"api_op_StartCommitmentPurchaseAnalysis.go",
"api_op_StartCostAllocationTagBackfill.go",
"api_op_StartSavingsPlansPurchaseRecommendationGeneration.go",
"api_op_TagResource.go",
"api_op_UntagResource.go",
"api_op_UpdateAnomalyMonitor.go",
"api_op_UpdateAnomalySubscription.go",
"api_op_UpdateCostAllocationTagsStatus.go",
"api_op_UpdateCostCategoryDefinition.go",
"auth.go",
"deserializers.go",
"doc.go",
"endpoints.go",
"endpoints_config_test.go",
"endpoints_test.go",
"generated.json",
"internal/endpoints/endpoints.go",
"internal/endpoints/endpoints_test.go",
"options.go",
"serializers.go",
"snapshot_test.go",
"sra_operation_order_test.go",
"types/enums.go",
"types/errors.go",
"types/types.go",
"validators.go"
],
"go": "1.24",
"module": "github.com/aws/aws-sdk-go-v2/service/costexplorer",
"unstable": false
}
@@ -0,0 +1,6 @@
// Code generated by internal/repotools/cmd/updatemodulemeta DO NOT EDIT.
package costexplorer
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.63.5"
@@ -0,0 +1,388 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package endpoints
import (
"github.com/aws/aws-sdk-go-v2/aws"
endpoints "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2"
"github.com/aws/smithy-go/logging"
"regexp"
)
// Options is the endpoint resolver configuration options
type Options struct {
// Logger is a logging implementation that log events should be sent to.
Logger logging.Logger
// LogDeprecated indicates that deprecated endpoints should be logged to the
// provided logger.
LogDeprecated bool
// ResolvedRegion is used to override the region to be resolved, rather then the
// using the value passed to the ResolveEndpoint method. This value is used by the
// SDK to translate regions like fips-us-east-1 or us-east-1-fips to an alternative
// name. You must not set this value directly in your application.
ResolvedRegion string
// DisableHTTPS informs the resolver to return an endpoint that does not use the
// HTTPS scheme.
DisableHTTPS bool
// UseDualStackEndpoint specifies the resolver must resolve a dual-stack endpoint.
UseDualStackEndpoint aws.DualStackEndpointState
// UseFIPSEndpoint specifies the resolver must resolve a FIPS endpoint.
UseFIPSEndpoint aws.FIPSEndpointState
}
func (o Options) GetResolvedRegion() string {
return o.ResolvedRegion
}
func (o Options) GetDisableHTTPS() bool {
return o.DisableHTTPS
}
func (o Options) GetUseDualStackEndpoint() aws.DualStackEndpointState {
return o.UseDualStackEndpoint
}
func (o Options) GetUseFIPSEndpoint() aws.FIPSEndpointState {
return o.UseFIPSEndpoint
}
func transformToSharedOptions(options Options) endpoints.Options {
return endpoints.Options{
Logger: options.Logger,
LogDeprecated: options.LogDeprecated,
ResolvedRegion: options.ResolvedRegion,
DisableHTTPS: options.DisableHTTPS,
UseDualStackEndpoint: options.UseDualStackEndpoint,
UseFIPSEndpoint: options.UseFIPSEndpoint,
}
}
// Resolver Cost Explorer endpoint resolver
type Resolver struct {
partitions endpoints.Partitions
}
// ResolveEndpoint resolves the service endpoint for the given region and options
func (r *Resolver) ResolveEndpoint(region string, options Options) (endpoint aws.Endpoint, err error) {
if len(region) == 0 {
return endpoint, &aws.MissingRegionError{}
}
opt := transformToSharedOptions(options)
return r.partitions.ResolveEndpoint(region, opt)
}
// New returns a new Resolver
func New() *Resolver {
return &Resolver{
partitions: defaultPartitions,
}
}
var partitionRegexp = struct {
Aws *regexp.Regexp
AwsCn *regexp.Regexp
AwsEusc *regexp.Regexp
AwsIso *regexp.Regexp
AwsIsoB *regexp.Regexp
AwsIsoE *regexp.Regexp
AwsIsoF *regexp.Regexp
AwsUsGov *regexp.Regexp
}{
Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$"),
AwsCn: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"),
AwsEusc: regexp.MustCompile("^eusc\\-(de)\\-\\w+\\-\\d+$"),
AwsIso: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"),
AwsIsoB: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"),
AwsIsoE: regexp.MustCompile("^eu\\-isoe\\-\\w+\\-\\d+$"),
AwsIsoF: regexp.MustCompile("^us\\-isof\\-\\w+\\-\\d+$"),
AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"),
}
var defaultPartitions = endpoints.Partitions{
{
ID: "aws",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.DualStackVariant,
}: {
Hostname: "ce.{region}.api.aws",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.amazonaws.com",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
}: {
Hostname: "ce-fips.{region}.api.aws",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.amazonaws.com",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.Aws,
IsRegionalized: false,
PartitionEndpoint: "aws-global",
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "aws-global",
}: endpoints.Endpoint{
Hostname: "ce.us-east-1.amazonaws.com",
CredentialScope: endpoints.CredentialScope{
Region: "us-east-1",
},
},
},
},
{
ID: "aws-cn",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.DualStackVariant,
}: {
Hostname: "ce.{region}.api.amazonwebservices.com.cn",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.amazonaws.com.cn",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
}: {
Hostname: "ce-fips.{region}.api.amazonwebservices.com.cn",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.amazonaws.com.cn",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsCn,
IsRegionalized: false,
PartitionEndpoint: "aws-cn-global",
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "aws-cn-global",
}: endpoints.Endpoint{
Hostname: "ce.cn-northwest-1.amazonaws.com.cn",
CredentialScope: endpoints.CredentialScope{
Region: "cn-northwest-1",
},
},
},
},
{
ID: "aws-eusc",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.DualStackVariant,
}: {
Hostname: "ce.{region}.api.amazonwebservices.eu",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.amazonaws.eu",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
}: {
Hostname: "ce-fips.{region}.api.amazonwebservices.eu",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.amazonaws.eu",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsEusc,
IsRegionalized: true,
},
{
ID: "aws-iso",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.c2s.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.c2s.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIso,
IsRegionalized: false,
PartitionEndpoint: "aws-iso-global",
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "aws-iso-global",
}: endpoints.Endpoint{
Hostname: "ce.us-iso-east-1.c2s.ic.gov",
CredentialScope: endpoints.CredentialScope{
Region: "us-iso-east-1",
},
},
},
},
{
ID: "aws-iso-b",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.sc2s.sgov.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.sc2s.sgov.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIsoB,
IsRegionalized: false,
PartitionEndpoint: "aws-iso-b-global",
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "aws-iso-b-global",
}: endpoints.Endpoint{
Hostname: "ce.us-isob-east-1.sc2s.sgov.gov",
CredentialScope: endpoints.CredentialScope{
Region: "us-isob-east-1",
},
},
},
},
{
ID: "aws-iso-e",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.cloud.adc-e.uk",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.cloud.adc-e.uk",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIsoE,
IsRegionalized: true,
},
{
ID: "aws-iso-f",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.csp.hci.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.csp.hci.ic.gov",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsIsoF,
IsRegionalized: false,
PartitionEndpoint: "aws-iso-f-global",
Endpoints: endpoints.Endpoints{
endpoints.EndpointKey{
Region: "aws-iso-f-global",
}: endpoints.Endpoint{
Hostname: "ce.us-isof-south-1.csp.hci.ic.gov",
CredentialScope: endpoints.CredentialScope{
Region: "us-isof-south-1",
},
},
},
},
{
ID: "aws-us-gov",
Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
{
Variant: endpoints.DualStackVariant,
}: {
Hostname: "ce.{region}.api.aws",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant,
}: {
Hostname: "ce-fips.{region}.amazonaws.com",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
}: {
Hostname: "ce-fips.{region}.api.aws",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
{
Variant: 0,
}: {
Hostname: "ce.{region}.amazonaws.com",
Protocols: []string{"https"},
SignatureVersions: []string{"v4"},
},
},
RegionRegex: partitionRegexp.AwsUsGov,
IsRegionalized: true,
},
}
+238
View File
@@ -0,0 +1,238 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package costexplorer
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
internalauthsmithy "github.com/aws/aws-sdk-go-v2/internal/auth/smithy"
smithyauth "github.com/aws/smithy-go/auth"
"github.com/aws/smithy-go/logging"
"github.com/aws/smithy-go/metrics"
"github.com/aws/smithy-go/middleware"
"github.com/aws/smithy-go/tracing"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net/http"
)
type HTTPClient interface {
Do(*http.Request) (*http.Response, error)
}
type Options struct {
// Set of options to modify how an operation is invoked. These apply to all
// operations invoked for this client. Use functional options on operation call to
// modify this list for per operation behavior.
APIOptions []func(*middleware.Stack) error
// The optional application specific identifier appended to the User-Agent header.
AppID string
// This endpoint will be given as input to an EndpointResolverV2. It is used for
// providing a custom base endpoint that is subject to modifications by the
// processing EndpointResolverV2.
BaseEndpoint *string
// Configures the events that will be sent to the configured logger.
ClientLogMode aws.ClientLogMode
// The credentials object to use when signing requests.
Credentials aws.CredentialsProvider
// The configuration DefaultsMode that the SDK should use when constructing the
// clients initial default settings.
DefaultsMode aws.DefaultsMode
// The endpoint options to be used when attempting to resolve an endpoint.
EndpointOptions EndpointResolverOptions
// The service endpoint resolver.
//
// Deprecated: Deprecated: EndpointResolver and WithEndpointResolver. Providing a
// value for this field will likely prevent you from using any endpoint-related
// service features released after the introduction of EndpointResolverV2 and
// BaseEndpoint.
//
// To migrate an EndpointResolver implementation that uses a custom endpoint, set
// the client option BaseEndpoint instead.
EndpointResolver EndpointResolver
// Resolves the endpoint used for a particular service operation.
EndpointResolverV2 EndpointResolverV2
// Signature Version 4 (SigV4) Signer
HTTPSignerV4 HTTPSignerV4
// The logger writer interface to write logging messages to.
Logger logging.Logger
// The client meter provider.
MeterProvider metrics.MeterProvider
// The region to send requests to. (Required)
Region string
// RetryMaxAttempts specifies the maximum number attempts an API client will call
// an operation that fails with a retryable error. A value of 0 is ignored, and
// will not be used to configure the API client created default retryer, or modify
// per operation call's retry max attempts.
//
// If specified in an operation call's functional options with a value that is
// different than the constructed client's Options, the Client's Retryer will be
// wrapped to use the operation's specific RetryMaxAttempts value.
RetryMaxAttempts int
// RetryMode specifies the retry mode the API client will be created with, if
// Retryer option is not also specified.
//
// When creating a new API Clients this member will only be used if the Retryer
// Options member is nil. This value will be ignored if Retryer is not nil.
//
// Currently does not support per operation call overrides, may in the future.
RetryMode aws.RetryMode
// Retryer guides how HTTP requests should be retried in case of recoverable
// failures. When nil the API client will use a default retryer. The kind of
// default retry created by the API client can be changed with the RetryMode
// option.
Retryer aws.Retryer
// The RuntimeEnvironment configuration, only populated if the DefaultsMode is set
// to DefaultsModeAuto and is initialized using config.LoadDefaultConfig . You
// should not populate this structure programmatically, or rely on the values here
// within your applications.
RuntimeEnvironment aws.RuntimeEnvironment
// The client tracer provider.
TracerProvider tracing.TracerProvider
// The initial DefaultsMode used when the client options were constructed. If the
// DefaultsMode was set to aws.DefaultsModeAuto this will store what the resolved
// value was at that point in time.
//
// Currently does not support per operation call overrides, may in the future.
resolvedDefaultsMode aws.DefaultsMode
// The HTTP client to invoke API calls with. Defaults to client's default HTTP
// implementation if nil.
HTTPClient HTTPClient
// Client registry of operation interceptors.
Interceptors smithyhttp.InterceptorRegistry
// The auth scheme resolver which determines how to authenticate for each
// operation.
AuthSchemeResolver AuthSchemeResolver
// The list of auth schemes supported by the client.
AuthSchemes []smithyhttp.AuthScheme
// Priority list of preferred auth scheme names (e.g. sigv4a).
AuthSchemePreference []string
}
// Copy creates a clone where the APIOptions list is deep copied.
func (o Options) Copy() Options {
to := o
to.APIOptions = make([]func(*middleware.Stack) error, len(o.APIOptions))
copy(to.APIOptions, o.APIOptions)
to.Interceptors = o.Interceptors.Copy()
return to
}
func (o Options) GetIdentityResolver(schemeID string) smithyauth.IdentityResolver {
if schemeID == "aws.auth#sigv4" {
return getSigV4IdentityResolver(o)
}
if schemeID == "smithy.api#noAuth" {
return &smithyauth.AnonymousIdentityResolver{}
}
return nil
}
// WithAPIOptions returns a functional option for setting the Client's APIOptions
// option.
func WithAPIOptions(optFns ...func(*middleware.Stack) error) func(*Options) {
return func(o *Options) {
o.APIOptions = append(o.APIOptions, optFns...)
}
}
// Deprecated: EndpointResolver and WithEndpointResolver. Providing a value for
// this field will likely prevent you from using any endpoint-related service
// features released after the introduction of EndpointResolverV2 and BaseEndpoint.
//
// To migrate an EndpointResolver implementation that uses a custom endpoint, set
// the client option BaseEndpoint instead.
func WithEndpointResolver(v EndpointResolver) func(*Options) {
return func(o *Options) {
o.EndpointResolver = v
}
}
// WithEndpointResolverV2 returns a functional option for setting the Client's
// EndpointResolverV2 option.
func WithEndpointResolverV2(v EndpointResolverV2) func(*Options) {
return func(o *Options) {
o.EndpointResolverV2 = v
}
}
func getSigV4IdentityResolver(o Options) smithyauth.IdentityResolver {
if o.Credentials != nil {
return &internalauthsmithy.CredentialsProviderAdapter{Provider: o.Credentials}
}
return nil
}
// WithSigV4SigningName applies an override to the authentication workflow to
// use the given signing name for SigV4-authenticated operations.
//
// This is an advanced setting. The value here is FINAL, taking precedence over
// the resolved signing name from both auth scheme resolution and endpoint
// resolution.
func WithSigV4SigningName(name string) func(*Options) {
fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
return next.HandleInitialize(awsmiddleware.SetSigningName(ctx, name), in)
}
return func(o *Options) {
o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
return s.Initialize.Add(
middleware.InitializeMiddlewareFunc("withSigV4SigningName", fn),
middleware.Before,
)
})
}
}
// WithSigV4SigningRegion applies an override to the authentication workflow to
// use the given signing region for SigV4-authenticated operations.
//
// This is an advanced setting. The value here is FINAL, taking precedence over
// the resolved signing region from both auth scheme resolution and endpoint
// resolution.
func WithSigV4SigningRegion(region string) func(*Options) {
fn := func(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
return next.HandleInitialize(awsmiddleware.SetSigningRegion(ctx, region), in)
}
return func(o *Options) {
o.APIOptions = append(o.APIOptions, func(s *middleware.Stack) error {
return s.Initialize.Add(
middleware.InitializeMiddlewareFunc("withSigV4SigningRegion", fn),
middleware.Before,
)
})
}
}
func ignoreAnonymousAuth(options *Options) {
if aws.IsCredentialsProvider(options.Credentials, (*aws.AnonymousCredentials)(nil)) {
options.Credentials = nil
}
}
File diff suppressed because it is too large Load Diff
+938
View File
@@ -0,0 +1,938 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package types
type AccountScope string
// Enum values for AccountScope
const (
AccountScopePayer AccountScope = "PAYER"
AccountScopeLinked AccountScope = "LINKED"
)
// Values returns all known values for AccountScope. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (AccountScope) Values() []AccountScope {
return []AccountScope{
"PAYER",
"LINKED",
}
}
type AnalysisStatus string
// Enum values for AnalysisStatus
const (
AnalysisStatusSucceeded AnalysisStatus = "SUCCEEDED"
AnalysisStatusProcessing AnalysisStatus = "PROCESSING"
AnalysisStatusFailed AnalysisStatus = "FAILED"
)
// Values returns all known values for AnalysisStatus. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (AnalysisStatus) Values() []AnalysisStatus {
return []AnalysisStatus{
"SUCCEEDED",
"PROCESSING",
"FAILED",
}
}
type AnalysisType string
// Enum values for AnalysisType
const (
AnalysisTypeMaxSavings AnalysisType = "MAX_SAVINGS"
AnalysisTypeCustomCommitment AnalysisType = "CUSTOM_COMMITMENT"
)
// Values returns all known values for AnalysisType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (AnalysisType) Values() []AnalysisType {
return []AnalysisType{
"MAX_SAVINGS",
"CUSTOM_COMMITMENT",
}
}
type AnomalyFeedbackType string
// Enum values for AnomalyFeedbackType
const (
AnomalyFeedbackTypeYes AnomalyFeedbackType = "YES"
AnomalyFeedbackTypeNo AnomalyFeedbackType = "NO"
AnomalyFeedbackTypePlannedActivity AnomalyFeedbackType = "PLANNED_ACTIVITY"
)
// Values returns all known values for AnomalyFeedbackType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (AnomalyFeedbackType) Values() []AnomalyFeedbackType {
return []AnomalyFeedbackType{
"YES",
"NO",
"PLANNED_ACTIVITY",
}
}
type AnomalySubscriptionFrequency string
// Enum values for AnomalySubscriptionFrequency
const (
AnomalySubscriptionFrequencyDaily AnomalySubscriptionFrequency = "DAILY"
AnomalySubscriptionFrequencyImmediate AnomalySubscriptionFrequency = "IMMEDIATE"
AnomalySubscriptionFrequencyWeekly AnomalySubscriptionFrequency = "WEEKLY"
)
// Values returns all known values for AnomalySubscriptionFrequency. Note that
// this can be expanded in the future, and so it is only as up to date as the
// client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (AnomalySubscriptionFrequency) Values() []AnomalySubscriptionFrequency {
return []AnomalySubscriptionFrequency{
"DAILY",
"IMMEDIATE",
"WEEKLY",
}
}
type ApproximationDimension string
// Enum values for ApproximationDimension
const (
ApproximationDimensionService ApproximationDimension = "SERVICE"
ApproximationDimensionResource ApproximationDimension = "RESOURCE"
)
// Values returns all known values for ApproximationDimension. Note that this can
// be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (ApproximationDimension) Values() []ApproximationDimension {
return []ApproximationDimension{
"SERVICE",
"RESOURCE",
}
}
type Context string
// Enum values for Context
const (
ContextCostAndUsage Context = "COST_AND_USAGE"
ContextReservations Context = "RESERVATIONS"
ContextSavingsPlans Context = "SAVINGS_PLANS"
)
// Values returns all known values for Context. Note that this can be expanded in
// the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (Context) Values() []Context {
return []Context{
"COST_AND_USAGE",
"RESERVATIONS",
"SAVINGS_PLANS",
}
}
type CostAllocationTagBackfillStatus string
// Enum values for CostAllocationTagBackfillStatus
const (
CostAllocationTagBackfillStatusSucceeded CostAllocationTagBackfillStatus = "SUCCEEDED"
CostAllocationTagBackfillStatusProcessing CostAllocationTagBackfillStatus = "PROCESSING"
CostAllocationTagBackfillStatusFailed CostAllocationTagBackfillStatus = "FAILED"
)
// Values returns all known values for CostAllocationTagBackfillStatus. Note that
// this can be expanded in the future, and so it is only as up to date as the
// client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostAllocationTagBackfillStatus) Values() []CostAllocationTagBackfillStatus {
return []CostAllocationTagBackfillStatus{
"SUCCEEDED",
"PROCESSING",
"FAILED",
}
}
type CostAllocationTagStatus string
// Enum values for CostAllocationTagStatus
const (
CostAllocationTagStatusActive CostAllocationTagStatus = "Active"
CostAllocationTagStatusInactive CostAllocationTagStatus = "Inactive"
)
// Values returns all known values for CostAllocationTagStatus. Note that this can
// be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostAllocationTagStatus) Values() []CostAllocationTagStatus {
return []CostAllocationTagStatus{
"Active",
"Inactive",
}
}
type CostAllocationTagType string
// Enum values for CostAllocationTagType
const (
CostAllocationTagTypeAwsGenerated CostAllocationTagType = "AWSGenerated"
CostAllocationTagTypeUserDefined CostAllocationTagType = "UserDefined"
)
// Values returns all known values for CostAllocationTagType. Note that this can
// be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostAllocationTagType) Values() []CostAllocationTagType {
return []CostAllocationTagType{
"AWSGenerated",
"UserDefined",
}
}
type CostCategoryInheritedValueDimensionName string
// Enum values for CostCategoryInheritedValueDimensionName
const (
CostCategoryInheritedValueDimensionNameLinkedAccountName CostCategoryInheritedValueDimensionName = "LINKED_ACCOUNT_NAME"
CostCategoryInheritedValueDimensionNameTag CostCategoryInheritedValueDimensionName = "TAG"
)
// Values returns all known values for CostCategoryInheritedValueDimensionName.
// Note that this can be expanded in the future, and so it is only as up to date as
// the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategoryInheritedValueDimensionName) Values() []CostCategoryInheritedValueDimensionName {
return []CostCategoryInheritedValueDimensionName{
"LINKED_ACCOUNT_NAME",
"TAG",
}
}
type CostCategoryRuleType string
// Enum values for CostCategoryRuleType
const (
CostCategoryRuleTypeRegular CostCategoryRuleType = "REGULAR"
CostCategoryRuleTypeInheritedValue CostCategoryRuleType = "INHERITED_VALUE"
)
// Values returns all known values for CostCategoryRuleType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategoryRuleType) Values() []CostCategoryRuleType {
return []CostCategoryRuleType{
"REGULAR",
"INHERITED_VALUE",
}
}
type CostCategoryRuleVersion string
// Enum values for CostCategoryRuleVersion
const (
CostCategoryRuleVersionCostCategoryExpressionV1 CostCategoryRuleVersion = "CostCategoryExpression.v1"
)
// Values returns all known values for CostCategoryRuleVersion. Note that this can
// be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategoryRuleVersion) Values() []CostCategoryRuleVersion {
return []CostCategoryRuleVersion{
"CostCategoryExpression.v1",
}
}
type CostCategorySplitChargeMethod string
// Enum values for CostCategorySplitChargeMethod
const (
CostCategorySplitChargeMethodFixed CostCategorySplitChargeMethod = "FIXED"
CostCategorySplitChargeMethodProportional CostCategorySplitChargeMethod = "PROPORTIONAL"
CostCategorySplitChargeMethodEven CostCategorySplitChargeMethod = "EVEN"
)
// Values returns all known values for CostCategorySplitChargeMethod. Note that
// this can be expanded in the future, and so it is only as up to date as the
// client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategorySplitChargeMethod) Values() []CostCategorySplitChargeMethod {
return []CostCategorySplitChargeMethod{
"FIXED",
"PROPORTIONAL",
"EVEN",
}
}
type CostCategorySplitChargeRuleParameterType string
// Enum values for CostCategorySplitChargeRuleParameterType
const (
CostCategorySplitChargeRuleParameterTypeAllocationPercentages CostCategorySplitChargeRuleParameterType = "ALLOCATION_PERCENTAGES"
)
// Values returns all known values for CostCategorySplitChargeRuleParameterType.
// Note that this can be expanded in the future, and so it is only as up to date as
// the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategorySplitChargeRuleParameterType) Values() []CostCategorySplitChargeRuleParameterType {
return []CostCategorySplitChargeRuleParameterType{
"ALLOCATION_PERCENTAGES",
}
}
type CostCategoryStatus string
// Enum values for CostCategoryStatus
const (
CostCategoryStatusProcessing CostCategoryStatus = "PROCESSING"
CostCategoryStatusApplied CostCategoryStatus = "APPLIED"
)
// Values returns all known values for CostCategoryStatus. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategoryStatus) Values() []CostCategoryStatus {
return []CostCategoryStatus{
"PROCESSING",
"APPLIED",
}
}
type CostCategoryStatusComponent string
// Enum values for CostCategoryStatusComponent
const (
CostCategoryStatusComponentCostExplorer CostCategoryStatusComponent = "COST_EXPLORER"
)
// Values returns all known values for CostCategoryStatusComponent. Note that this
// can be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (CostCategoryStatusComponent) Values() []CostCategoryStatusComponent {
return []CostCategoryStatusComponent{
"COST_EXPLORER",
}
}
type Dimension string
// Enum values for Dimension
const (
DimensionAz Dimension = "AZ"
DimensionInstanceType Dimension = "INSTANCE_TYPE"
DimensionLinkedAccount Dimension = "LINKED_ACCOUNT"
DimensionPayerAccount Dimension = "PAYER_ACCOUNT"
DimensionLinkedAccountName Dimension = "LINKED_ACCOUNT_NAME"
DimensionOperation Dimension = "OPERATION"
DimensionPurchaseType Dimension = "PURCHASE_TYPE"
DimensionRegion Dimension = "REGION"
DimensionService Dimension = "SERVICE"
DimensionServiceCode Dimension = "SERVICE_CODE"
DimensionUsageType Dimension = "USAGE_TYPE"
DimensionUsageTypeGroup Dimension = "USAGE_TYPE_GROUP"
DimensionRecordType Dimension = "RECORD_TYPE"
DimensionOperatingSystem Dimension = "OPERATING_SYSTEM"
DimensionTenancy Dimension = "TENANCY"
DimensionScope Dimension = "SCOPE"
DimensionPlatform Dimension = "PLATFORM"
DimensionSubscriptionId Dimension = "SUBSCRIPTION_ID"
DimensionLegalEntityName Dimension = "LEGAL_ENTITY_NAME"
DimensionDeploymentOption Dimension = "DEPLOYMENT_OPTION"
DimensionDatabaseEngine Dimension = "DATABASE_ENGINE"
DimensionCacheEngine Dimension = "CACHE_ENGINE"
DimensionInstanceTypeFamily Dimension = "INSTANCE_TYPE_FAMILY"
DimensionBillingEntity Dimension = "BILLING_ENTITY"
DimensionReservationId Dimension = "RESERVATION_ID"
DimensionResourceId Dimension = "RESOURCE_ID"
DimensionRightsizingType Dimension = "RIGHTSIZING_TYPE"
DimensionSavingsPlansType Dimension = "SAVINGS_PLANS_TYPE"
DimensionSavingsPlanArn Dimension = "SAVINGS_PLAN_ARN"
DimensionPaymentOption Dimension = "PAYMENT_OPTION"
DimensionAgreementEndDateTimeAfter Dimension = "AGREEMENT_END_DATE_TIME_AFTER"
DimensionAgreementEndDateTimeBefore Dimension = "AGREEMENT_END_DATE_TIME_BEFORE"
DimensionInvoicingEntity Dimension = "INVOICING_ENTITY"
DimensionAnomalyTotalImpactAbsolute Dimension = "ANOMALY_TOTAL_IMPACT_ABSOLUTE"
DimensionAnomalyTotalImpactPercentage Dimension = "ANOMALY_TOTAL_IMPACT_PERCENTAGE"
)
// Values returns all known values for Dimension. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (Dimension) Values() []Dimension {
return []Dimension{
"AZ",
"INSTANCE_TYPE",
"LINKED_ACCOUNT",
"PAYER_ACCOUNT",
"LINKED_ACCOUNT_NAME",
"OPERATION",
"PURCHASE_TYPE",
"REGION",
"SERVICE",
"SERVICE_CODE",
"USAGE_TYPE",
"USAGE_TYPE_GROUP",
"RECORD_TYPE",
"OPERATING_SYSTEM",
"TENANCY",
"SCOPE",
"PLATFORM",
"SUBSCRIPTION_ID",
"LEGAL_ENTITY_NAME",
"DEPLOYMENT_OPTION",
"DATABASE_ENGINE",
"CACHE_ENGINE",
"INSTANCE_TYPE_FAMILY",
"BILLING_ENTITY",
"RESERVATION_ID",
"RESOURCE_ID",
"RIGHTSIZING_TYPE",
"SAVINGS_PLANS_TYPE",
"SAVINGS_PLAN_ARN",
"PAYMENT_OPTION",
"AGREEMENT_END_DATE_TIME_AFTER",
"AGREEMENT_END_DATE_TIME_BEFORE",
"INVOICING_ENTITY",
"ANOMALY_TOTAL_IMPACT_ABSOLUTE",
"ANOMALY_TOTAL_IMPACT_PERCENTAGE",
}
}
type ErrorCode string
// Enum values for ErrorCode
const (
ErrorCodeNoUsageFound ErrorCode = "NO_USAGE_FOUND"
ErrorCodeInternalFailure ErrorCode = "INTERNAL_FAILURE"
ErrorCodeInvalidSavingsPlansToAdd ErrorCode = "INVALID_SAVINGS_PLANS_TO_ADD"
ErrorCodeInvalidSavingsPlansToExclude ErrorCode = "INVALID_SAVINGS_PLANS_TO_EXCLUDE"
ErrorCodeInvalidAccountId ErrorCode = "INVALID_ACCOUNT_ID"
)
// Values returns all known values for ErrorCode. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (ErrorCode) Values() []ErrorCode {
return []ErrorCode{
"NO_USAGE_FOUND",
"INTERNAL_FAILURE",
"INVALID_SAVINGS_PLANS_TO_ADD",
"INVALID_SAVINGS_PLANS_TO_EXCLUDE",
"INVALID_ACCOUNT_ID",
}
}
type FindingReasonCode string
// Enum values for FindingReasonCode
const (
FindingReasonCodeCpuOverProvisioned FindingReasonCode = "CPU_OVER_PROVISIONED"
FindingReasonCodeCpuUnderProvisioned FindingReasonCode = "CPU_UNDER_PROVISIONED"
FindingReasonCodeMemoryOverProvisioned FindingReasonCode = "MEMORY_OVER_PROVISIONED"
FindingReasonCodeMemoryUnderProvisioned FindingReasonCode = "MEMORY_UNDER_PROVISIONED"
FindingReasonCodeEbsThroughputOverProvisioned FindingReasonCode = "EBS_THROUGHPUT_OVER_PROVISIONED"
FindingReasonCodeEbsThroughputUnderProvisioned FindingReasonCode = "EBS_THROUGHPUT_UNDER_PROVISIONED"
FindingReasonCodeEbsIopsOverProvisioned FindingReasonCode = "EBS_IOPS_OVER_PROVISIONED"
FindingReasonCodeEbsIopsUnderProvisioned FindingReasonCode = "EBS_IOPS_UNDER_PROVISIONED"
FindingReasonCodeNetworkBandwidthOverProvisioned FindingReasonCode = "NETWORK_BANDWIDTH_OVER_PROVISIONED"
FindingReasonCodeNetworkBandwidthUnderProvisioned FindingReasonCode = "NETWORK_BANDWIDTH_UNDER_PROVISIONED"
FindingReasonCodeNetworkPpsOverProvisioned FindingReasonCode = "NETWORK_PPS_OVER_PROVISIONED"
FindingReasonCodeNetworkPpsUnderProvisioned FindingReasonCode = "NETWORK_PPS_UNDER_PROVISIONED"
FindingReasonCodeDiskIopsOverProvisioned FindingReasonCode = "DISK_IOPS_OVER_PROVISIONED"
FindingReasonCodeDiskIopsUnderProvisioned FindingReasonCode = "DISK_IOPS_UNDER_PROVISIONED"
FindingReasonCodeDiskThroughputOverProvisioned FindingReasonCode = "DISK_THROUGHPUT_OVER_PROVISIONED"
FindingReasonCodeDiskThroughputUnderProvisioned FindingReasonCode = "DISK_THROUGHPUT_UNDER_PROVISIONED"
)
// Values returns all known values for FindingReasonCode. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (FindingReasonCode) Values() []FindingReasonCode {
return []FindingReasonCode{
"CPU_OVER_PROVISIONED",
"CPU_UNDER_PROVISIONED",
"MEMORY_OVER_PROVISIONED",
"MEMORY_UNDER_PROVISIONED",
"EBS_THROUGHPUT_OVER_PROVISIONED",
"EBS_THROUGHPUT_UNDER_PROVISIONED",
"EBS_IOPS_OVER_PROVISIONED",
"EBS_IOPS_UNDER_PROVISIONED",
"NETWORK_BANDWIDTH_OVER_PROVISIONED",
"NETWORK_BANDWIDTH_UNDER_PROVISIONED",
"NETWORK_PPS_OVER_PROVISIONED",
"NETWORK_PPS_UNDER_PROVISIONED",
"DISK_IOPS_OVER_PROVISIONED",
"DISK_IOPS_UNDER_PROVISIONED",
"DISK_THROUGHPUT_OVER_PROVISIONED",
"DISK_THROUGHPUT_UNDER_PROVISIONED",
}
}
type GenerationStatus string
// Enum values for GenerationStatus
const (
GenerationStatusSucceeded GenerationStatus = "SUCCEEDED"
GenerationStatusProcessing GenerationStatus = "PROCESSING"
GenerationStatusFailed GenerationStatus = "FAILED"
)
// Values returns all known values for GenerationStatus. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (GenerationStatus) Values() []GenerationStatus {
return []GenerationStatus{
"SUCCEEDED",
"PROCESSING",
"FAILED",
}
}
type Granularity string
// Enum values for Granularity
const (
GranularityDaily Granularity = "DAILY"
GranularityMonthly Granularity = "MONTHLY"
GranularityHourly Granularity = "HOURLY"
)
// Values returns all known values for Granularity. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (Granularity) Values() []Granularity {
return []Granularity{
"DAILY",
"MONTHLY",
"HOURLY",
}
}
type GroupDefinitionType string
// Enum values for GroupDefinitionType
const (
GroupDefinitionTypeDimension GroupDefinitionType = "DIMENSION"
GroupDefinitionTypeTag GroupDefinitionType = "TAG"
GroupDefinitionTypeCostCategory GroupDefinitionType = "COST_CATEGORY"
)
// Values returns all known values for GroupDefinitionType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (GroupDefinitionType) Values() []GroupDefinitionType {
return []GroupDefinitionType{
"DIMENSION",
"TAG",
"COST_CATEGORY",
}
}
type LookbackPeriodInDays string
// Enum values for LookbackPeriodInDays
const (
LookbackPeriodInDaysSevenDays LookbackPeriodInDays = "SEVEN_DAYS"
LookbackPeriodInDaysThirtyDays LookbackPeriodInDays = "THIRTY_DAYS"
LookbackPeriodInDaysSixtyDays LookbackPeriodInDays = "SIXTY_DAYS"
)
// Values returns all known values for LookbackPeriodInDays. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (LookbackPeriodInDays) Values() []LookbackPeriodInDays {
return []LookbackPeriodInDays{
"SEVEN_DAYS",
"THIRTY_DAYS",
"SIXTY_DAYS",
}
}
type MatchOption string
// Enum values for MatchOption
const (
MatchOptionEquals MatchOption = "EQUALS"
MatchOptionAbsent MatchOption = "ABSENT"
MatchOptionStartsWith MatchOption = "STARTS_WITH"
MatchOptionEndsWith MatchOption = "ENDS_WITH"
MatchOptionContains MatchOption = "CONTAINS"
MatchOptionCaseSensitive MatchOption = "CASE_SENSITIVE"
MatchOptionCaseInsensitive MatchOption = "CASE_INSENSITIVE"
MatchOptionGreaterThanOrEqual MatchOption = "GREATER_THAN_OR_EQUAL"
)
// Values returns all known values for MatchOption. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (MatchOption) Values() []MatchOption {
return []MatchOption{
"EQUALS",
"ABSENT",
"STARTS_WITH",
"ENDS_WITH",
"CONTAINS",
"CASE_SENSITIVE",
"CASE_INSENSITIVE",
"GREATER_THAN_OR_EQUAL",
}
}
type Metric string
// Enum values for Metric
const (
MetricBlendedCost Metric = "BLENDED_COST"
MetricUnblendedCost Metric = "UNBLENDED_COST"
MetricAmortizedCost Metric = "AMORTIZED_COST"
MetricNetUnblendedCost Metric = "NET_UNBLENDED_COST"
MetricNetAmortizedCost Metric = "NET_AMORTIZED_COST"
MetricUsageQuantity Metric = "USAGE_QUANTITY"
MetricNormalizedUsageAmount Metric = "NORMALIZED_USAGE_AMOUNT"
)
// Values returns all known values for Metric. Note that this can be expanded in
// the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (Metric) Values() []Metric {
return []Metric{
"BLENDED_COST",
"UNBLENDED_COST",
"AMORTIZED_COST",
"NET_UNBLENDED_COST",
"NET_AMORTIZED_COST",
"USAGE_QUANTITY",
"NORMALIZED_USAGE_AMOUNT",
}
}
type MonitorDimension string
// Enum values for MonitorDimension
const (
MonitorDimensionService MonitorDimension = "SERVICE"
MonitorDimensionLinkedAccount MonitorDimension = "LINKED_ACCOUNT"
MonitorDimensionTag MonitorDimension = "TAG"
MonitorDimensionCostCategory MonitorDimension = "COST_CATEGORY"
)
// Values returns all known values for MonitorDimension. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (MonitorDimension) Values() []MonitorDimension {
return []MonitorDimension{
"SERVICE",
"LINKED_ACCOUNT",
"TAG",
"COST_CATEGORY",
}
}
type MonitorType string
// Enum values for MonitorType
const (
MonitorTypeDimensional MonitorType = "DIMENSIONAL"
MonitorTypeCustom MonitorType = "CUSTOM"
)
// Values returns all known values for MonitorType. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (MonitorType) Values() []MonitorType {
return []MonitorType{
"DIMENSIONAL",
"CUSTOM",
}
}
type NumericOperator string
// Enum values for NumericOperator
const (
NumericOperatorEqual NumericOperator = "EQUAL"
NumericOperatorGreaterThanOrEqual NumericOperator = "GREATER_THAN_OR_EQUAL"
NumericOperatorLessThanOrEqual NumericOperator = "LESS_THAN_OR_EQUAL"
NumericOperatorGreaterThan NumericOperator = "GREATER_THAN"
NumericOperatorLessThan NumericOperator = "LESS_THAN"
NumericOperatorBetween NumericOperator = "BETWEEN"
)
// Values returns all known values for NumericOperator. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (NumericOperator) Values() []NumericOperator {
return []NumericOperator{
"EQUAL",
"GREATER_THAN_OR_EQUAL",
"LESS_THAN_OR_EQUAL",
"GREATER_THAN",
"LESS_THAN",
"BETWEEN",
}
}
type OfferingClass string
// Enum values for OfferingClass
const (
OfferingClassStandard OfferingClass = "STANDARD"
OfferingClassConvertible OfferingClass = "CONVERTIBLE"
)
// Values returns all known values for OfferingClass. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (OfferingClass) Values() []OfferingClass {
return []OfferingClass{
"STANDARD",
"CONVERTIBLE",
}
}
type PaymentOption string
// Enum values for PaymentOption
const (
PaymentOptionNoUpfront PaymentOption = "NO_UPFRONT"
PaymentOptionPartialUpfront PaymentOption = "PARTIAL_UPFRONT"
PaymentOptionAllUpfront PaymentOption = "ALL_UPFRONT"
PaymentOptionLightUtilization PaymentOption = "LIGHT_UTILIZATION"
PaymentOptionMediumUtilization PaymentOption = "MEDIUM_UTILIZATION"
PaymentOptionHeavyUtilization PaymentOption = "HEAVY_UTILIZATION"
)
// Values returns all known values for PaymentOption. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (PaymentOption) Values() []PaymentOption {
return []PaymentOption{
"NO_UPFRONT",
"PARTIAL_UPFRONT",
"ALL_UPFRONT",
"LIGHT_UTILIZATION",
"MEDIUM_UTILIZATION",
"HEAVY_UTILIZATION",
}
}
type PlatformDifference string
// Enum values for PlatformDifference
const (
PlatformDifferenceHypervisor PlatformDifference = "HYPERVISOR"
PlatformDifferenceNetworkInterface PlatformDifference = "NETWORK_INTERFACE"
PlatformDifferenceStorageInterface PlatformDifference = "STORAGE_INTERFACE"
PlatformDifferenceInstanceStoreAvailability PlatformDifference = "INSTANCE_STORE_AVAILABILITY"
PlatformDifferenceVirtualizationType PlatformDifference = "VIRTUALIZATION_TYPE"
)
// Values returns all known values for PlatformDifference. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (PlatformDifference) Values() []PlatformDifference {
return []PlatformDifference{
"HYPERVISOR",
"NETWORK_INTERFACE",
"STORAGE_INTERFACE",
"INSTANCE_STORE_AVAILABILITY",
"VIRTUALIZATION_TYPE",
}
}
type RecommendationTarget string
// Enum values for RecommendationTarget
const (
RecommendationTargetSameInstanceFamily RecommendationTarget = "SAME_INSTANCE_FAMILY"
RecommendationTargetCrossInstanceFamily RecommendationTarget = "CROSS_INSTANCE_FAMILY"
)
// Values returns all known values for RecommendationTarget. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (RecommendationTarget) Values() []RecommendationTarget {
return []RecommendationTarget{
"SAME_INSTANCE_FAMILY",
"CROSS_INSTANCE_FAMILY",
}
}
type RightsizingType string
// Enum values for RightsizingType
const (
RightsizingTypeTerminate RightsizingType = "TERMINATE"
RightsizingTypeModify RightsizingType = "MODIFY"
)
// Values returns all known values for RightsizingType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (RightsizingType) Values() []RightsizingType {
return []RightsizingType{
"TERMINATE",
"MODIFY",
}
}
type SavingsPlansDataType string
// Enum values for SavingsPlansDataType
const (
SavingsPlansDataTypeAttributes SavingsPlansDataType = "ATTRIBUTES"
SavingsPlansDataTypeUtilization SavingsPlansDataType = "UTILIZATION"
SavingsPlansDataTypeAmortizedCommitment SavingsPlansDataType = "AMORTIZED_COMMITMENT"
SavingsPlansDataTypeSavings SavingsPlansDataType = "SAVINGS"
)
// Values returns all known values for SavingsPlansDataType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (SavingsPlansDataType) Values() []SavingsPlansDataType {
return []SavingsPlansDataType{
"ATTRIBUTES",
"UTILIZATION",
"AMORTIZED_COMMITMENT",
"SAVINGS",
}
}
type SortOrder string
// Enum values for SortOrder
const (
SortOrderAscending SortOrder = "ASCENDING"
SortOrderDescending SortOrder = "DESCENDING"
)
// Values returns all known values for SortOrder. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (SortOrder) Values() []SortOrder {
return []SortOrder{
"ASCENDING",
"DESCENDING",
}
}
type SubscriberStatus string
// Enum values for SubscriberStatus
const (
SubscriberStatusConfirmed SubscriberStatus = "CONFIRMED"
SubscriberStatusDeclined SubscriberStatus = "DECLINED"
)
// Values returns all known values for SubscriberStatus. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (SubscriberStatus) Values() []SubscriberStatus {
return []SubscriberStatus{
"CONFIRMED",
"DECLINED",
}
}
type SubscriberType string
// Enum values for SubscriberType
const (
SubscriberTypeEmail SubscriberType = "EMAIL"
SubscriberTypeSns SubscriberType = "SNS"
)
// Values returns all known values for SubscriberType. Note that this can be
// expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (SubscriberType) Values() []SubscriberType {
return []SubscriberType{
"EMAIL",
"SNS",
}
}
type SupportedSavingsPlansType string
// Enum values for SupportedSavingsPlansType
const (
SupportedSavingsPlansTypeComputeSp SupportedSavingsPlansType = "COMPUTE_SP"
SupportedSavingsPlansTypeEc2InstanceSp SupportedSavingsPlansType = "EC2_INSTANCE_SP"
SupportedSavingsPlansTypeSagemakerSp SupportedSavingsPlansType = "SAGEMAKER_SP"
SupportedSavingsPlansTypeDatabaseSp SupportedSavingsPlansType = "DATABASE_SP"
)
// Values returns all known values for SupportedSavingsPlansType. Note that this
// can be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (SupportedSavingsPlansType) Values() []SupportedSavingsPlansType {
return []SupportedSavingsPlansType{
"COMPUTE_SP",
"EC2_INSTANCE_SP",
"SAGEMAKER_SP",
"DATABASE_SP",
}
}
type TermInYears string
// Enum values for TermInYears
const (
TermInYearsOneYear TermInYears = "ONE_YEAR"
TermInYearsThreeYears TermInYears = "THREE_YEARS"
)
// Values returns all known values for TermInYears. Note that this can be expanded
// in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (TermInYears) Values() []TermInYears {
return []TermInYears{
"ONE_YEAR",
"THREE_YEARS",
}
}
@@ -0,0 +1,412 @@
// Code generated by smithy-go-codegen DO NOT EDIT.
package types
import (
"fmt"
smithy "github.com/aws/smithy-go"
)
// The requested analysis can't be found.
type AnalysisNotFoundException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *AnalysisNotFoundException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *AnalysisNotFoundException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *AnalysisNotFoundException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "AnalysisNotFoundException"
}
return *e.ErrorCodeOverride
}
func (e *AnalysisNotFoundException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// A request to backfill is already in progress. Once the previous request is
//
// complete, you can create another request.
type BackfillLimitExceededException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *BackfillLimitExceededException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *BackfillLimitExceededException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *BackfillLimitExceededException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "BackfillLimitExceededException"
}
return *e.ErrorCodeOverride
}
func (e *BackfillLimitExceededException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The requested report expired. Update the date interval and try again.
type BillExpirationException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *BillExpirationException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *BillExpirationException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *BillExpirationException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "BillExpirationException"
}
return *e.ErrorCodeOverride
}
func (e *BillExpirationException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The billing view status must be HEALTHY to perform this action. Try again when
//
// the status is HEALTHY .
type BillingViewHealthStatusException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *BillingViewHealthStatusException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *BillingViewHealthStatusException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *BillingViewHealthStatusException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "BillingViewHealthStatusException"
}
return *e.ErrorCodeOverride
}
func (e *BillingViewHealthStatusException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The requested data is unavailable.
type DataUnavailableException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *DataUnavailableException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *DataUnavailableException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *DataUnavailableException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "DataUnavailableException"
}
return *e.ErrorCodeOverride
}
func (e *DataUnavailableException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// A request to generate a recommendation or analysis is already in progress.
type GenerationExistsException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *GenerationExistsException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *GenerationExistsException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *GenerationExistsException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "GenerationExistsException"
}
return *e.ErrorCodeOverride
}
func (e *GenerationExistsException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The pagination token is invalid. Try again without a pagination token.
type InvalidNextTokenException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *InvalidNextTokenException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *InvalidNextTokenException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *InvalidNextTokenException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "InvalidNextTokenException"
}
return *e.ErrorCodeOverride
}
func (e *InvalidNextTokenException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// You made too many calls in a short period of time. Try again later.
type LimitExceededException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *LimitExceededException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *LimitExceededException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *LimitExceededException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "LimitExceededException"
}
return *e.ErrorCodeOverride
}
func (e *LimitExceededException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Your request parameters changed between pages. Try again with the old
// parameters or without a pagination token.
type RequestChangedException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *RequestChangedException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *RequestChangedException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *RequestChangedException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "RequestChangedException"
}
return *e.ErrorCodeOverride
}
func (e *RequestChangedException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The specified ARN in the request doesn't exist.
type ResourceNotFoundException struct {
Message *string
ErrorCodeOverride *string
ResourceName *string
noSmithyDocumentSerde
}
func (e *ResourceNotFoundException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *ResourceNotFoundException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *ResourceNotFoundException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "ResourceNotFoundException"
}
return *e.ErrorCodeOverride
}
func (e *ResourceNotFoundException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// You've reached the limit on the number of resources you can create, or
//
// exceeded the size of an individual resource.
type ServiceQuotaExceededException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *ServiceQuotaExceededException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *ServiceQuotaExceededException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *ServiceQuotaExceededException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "ServiceQuotaExceededException"
}
return *e.ErrorCodeOverride
}
func (e *ServiceQuotaExceededException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Can occur if you specify a number of tags for a resource greater than the
// maximum 50 user tags per resource.
type TooManyTagsException struct {
Message *string
ErrorCodeOverride *string
ResourceName *string
noSmithyDocumentSerde
}
func (e *TooManyTagsException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *TooManyTagsException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *TooManyTagsException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "TooManyTagsException"
}
return *e.ErrorCodeOverride
}
func (e *TooManyTagsException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The cost anomaly monitor does not exist for the account.
type UnknownMonitorException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *UnknownMonitorException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *UnknownMonitorException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *UnknownMonitorException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "UnknownMonitorException"
}
return *e.ErrorCodeOverride
}
func (e *UnknownMonitorException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// The cost anomaly subscription does not exist for the account.
type UnknownSubscriptionException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *UnknownSubscriptionException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *UnknownSubscriptionException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *UnknownSubscriptionException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "UnknownSubscriptionException"
}
return *e.ErrorCodeOverride
}
func (e *UnknownSubscriptionException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
// Cost Explorer was unable to identify the usage unit. Provide
// UsageType/UsageTypeGroup filter selections that contain matching units, for
// example: hours .
type UnresolvableUsageUnitException struct {
Message *string
ErrorCodeOverride *string
noSmithyDocumentSerde
}
func (e *UnresolvableUsageUnitException) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage())
}
func (e *UnresolvableUsageUnitException) ErrorMessage() string {
if e.Message == nil {
return ""
}
return *e.Message
}
func (e *UnresolvableUsageUnitException) ErrorCode() string {
if e == nil || e.ErrorCodeOverride == nil {
return "UnresolvableUsageUnitException"
}
return *e.ErrorCodeOverride
}
func (e *UnresolvableUsageUnitException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+45
View File
@@ -1,3 +1,48 @@
# Release (2026-02-27)
## General Highlights
* **Dependency Update**: Updated to the latest SDK module versions
# Release (2026-02-20)
## General Highlights
* **Dependency Update**: Updated to the latest SDK module versions
## Module Highlights
* `github.com/aws/smithy-go`: v1.24.1
* **Feature**: Add new middleware functions to get event stream output from middleware
# Release (2025-12-01)
## General Highlights
* **Dependency Update**: Updated to the latest SDK module versions
## Module Highlights
* `github.com/aws/smithy-go`: v1.24.0
* **Feature**: Improve allocation footprint of the middleware stack. This should convey a ~10% reduction in allocations per SDK request.
# Release (2025-11-03)
## General Highlights
* **Dependency Update**: Updated to the latest SDK module versions
## Module Highlights
* `github.com/aws/smithy-go`: v1.23.2
* **Bug Fix**: Adjust the initial sizes of each middleware phase to avoid some unnecessary reallocation.
* **Bug Fix**: Avoid unnecessary allocation overhead from the metrics system when not in use.
# Release (2025-10-15)
## General Highlights
* **Dependency Update**: Bump minimum go version to 1.23.
* **Dependency Update**: Updated to the latest SDK module versions
# Release (2025-09-18)
## Module Highlights
* `github.com/aws/smithy-go/aws-http-auth`: [v1.1.0](aws-http-auth/CHANGELOG.md#v110-2025-09-18)
* **Feature**: Added support for SIG4/SIGV4A querystring authentication.
# Release (2025-08-27)
## General Highlights
+18 -13
View File
@@ -13,6 +13,7 @@ REPOTOOLS_CMD_GENERATE_CHANGELOG = ${REPOTOOLS_MODULE}/cmd/generatechangelog@${R
REPOTOOLS_CMD_CHANGELOG = ${REPOTOOLS_MODULE}/cmd/changelog@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_TAG_RELEASE = ${REPOTOOLS_MODULE}/cmd/tagrelease@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_MODULE_VERSION = ${REPOTOOLS_MODULE}/cmd/moduleversion@${REPOTOOLS_VERSION}
REPOTOOLS_CMD_EACHMODULE = ${REPOTOOLS_MODULE}/cmd/eachmodule@${REPOTOOLS_VERSION}
UNIT_TEST_TAGS=
BUILD_TAGS=
@@ -55,8 +56,11 @@ ensure-gradle-up:
verify: vet
vet:
go vet ${BUILD_TAGS} --all ./...
vet: vet-modules-.
vet-modules-%:
go run ${REPOTOOLS_CMD_EACHMODULE} -p $(subst vet-modules-,,$@) \
"go vet ${BUILD_TAGS} --all ./..."
cover:
go test ${BUILD_TAGS} -coverprofile c.out ./...
@@ -66,21 +70,22 @@ cover:
################
# Unit Testing #
################
.PHONY: unit unit-race unit-test unit-race-test
.PHONY: test unit unit-race
unit: verify
go test ${BUILD_TAGS} ${RUN_NONE} ./... && \
go test -timeout=1m ${UNIT_TEST_TAGS} ./...
test: unit-race
unit-race: verify
go test ${BUILD_TAGS} ${RUN_NONE} ./... && \
go test -timeout=1m ${UNIT_TEST_TAGS} -race -cpu=4 ./...
unit: verify unit-modules-.
unit-test: verify
go test -timeout=1m ${UNIT_TEST_TAGS} ./...
unit-modules-%:
go run ${REPOTOOLS_CMD_EACHMODULE} -p $(subst unit-modules-,,$@) \
"go test -timeout=1m ${UNIT_TEST_TAGS} ./..."
unit-race: verify unit-race-modules-.
unit-race-modules-%:
go run ${REPOTOOLS_CMD_EACHMODULE} -p $(subst unit-race-modules-,,$@) \
"go test -timeout=1m ${UNIT_TEST_TAGS} -race -cpu=4 ./..."
unit-race-test: verify
go test -timeout=1m ${UNIT_TEST_TAGS} -race -cpu=4 ./...
#####################
# Release Process #
+2 -2
View File
@@ -4,7 +4,7 @@
[Smithy](https://smithy.io/) code generators for Go and the accompanying smithy-go runtime.
The smithy-go runtime requires a minimum version of Go 1.22.
The smithy-go runtime requires a minimum version of Go 1.24.
**WARNING: All interfaces are subject to change.**
@@ -80,7 +80,7 @@ example created from `smithy init`:
"service": "example.weather#Weather",
"module": "github.com/example/weather",
"generateGoMod": true,
"goDirective": "1.22"
"goDirective": "1.24"
}
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
package smithy
// goModuleVersion is the tagged release for this module
const goModuleVersion = "1.23.0"
const goModuleVersion = "1.24.2"
+62 -31
View File
@@ -9,54 +9,82 @@ var _ MeterProvider = (*NopMeterProvider)(nil)
// Meter returns a meter which creates no-op instruments.
func (NopMeterProvider) Meter(string, ...MeterOption) Meter {
return nopMeter{}
return NopMeter{}
}
type nopMeter struct{}
// NopMeter creates no-op instruments.
type NopMeter struct{}
var _ Meter = (*nopMeter)(nil)
var _ Meter = (*NopMeter)(nil)
func (nopMeter) Int64Counter(string, ...InstrumentOption) (Int64Counter, error) {
return nopInstrument[int64]{}, nil
// Int64Counter creates a no-op instrument.
func (NopMeter) Int64Counter(string, ...InstrumentOption) (Int64Counter, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64UpDownCounter(string, ...InstrumentOption) (Int64UpDownCounter, error) {
return nopInstrument[int64]{}, nil
// Int64UpDownCounter creates a no-op instrument.
func (NopMeter) Int64UpDownCounter(string, ...InstrumentOption) (Int64UpDownCounter, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64Gauge(string, ...InstrumentOption) (Int64Gauge, error) {
return nopInstrument[int64]{}, nil
// Int64Gauge creates a no-op instrument.
func (NopMeter) Int64Gauge(string, ...InstrumentOption) (Int64Gauge, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64Histogram(string, ...InstrumentOption) (Int64Histogram, error) {
return nopInstrument[int64]{}, nil
// Int64Histogram creates a no-op instrument.
func (NopMeter) Int64Histogram(string, ...InstrumentOption) (Int64Histogram, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64AsyncCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[int64]{}, nil
// Int64AsyncCounter creates a no-op instrument.
func (NopMeter) Int64AsyncCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64AsyncUpDownCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[int64]{}, nil
// Int64AsyncUpDownCounter creates a no-op instrument.
func (NopMeter) Int64AsyncUpDownCounter(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Int64AsyncGauge(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[int64]{}, nil
// Int64AsyncGauge creates a no-op instrument.
func (NopMeter) Int64AsyncGauge(string, Int64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentInt64, nil
}
func (nopMeter) Float64Counter(string, ...InstrumentOption) (Float64Counter, error) {
return nopInstrument[float64]{}, nil
// Float64Counter creates a no-op instrument.
func (NopMeter) Float64Counter(string, ...InstrumentOption) (Float64Counter, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64UpDownCounter(string, ...InstrumentOption) (Float64UpDownCounter, error) {
return nopInstrument[float64]{}, nil
// Float64UpDownCounter creates a no-op instrument.
func (NopMeter) Float64UpDownCounter(string, ...InstrumentOption) (Float64UpDownCounter, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64Gauge(string, ...InstrumentOption) (Float64Gauge, error) {
return nopInstrument[float64]{}, nil
// Float64Gauge creates a no-op instrument.
func (NopMeter) Float64Gauge(string, ...InstrumentOption) (Float64Gauge, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64Histogram(string, ...InstrumentOption) (Float64Histogram, error) {
return nopInstrument[float64]{}, nil
// Float64Histogram creates a no-op instrument.
func (NopMeter) Float64Histogram(string, ...InstrumentOption) (Float64Histogram, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64AsyncCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[float64]{}, nil
// Float64AsyncCounter creates a no-op instrument.
func (NopMeter) Float64AsyncCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64AsyncUpDownCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[float64]{}, nil
// Float64AsyncUpDownCounter creates a no-op instrument.
func (NopMeter) Float64AsyncUpDownCounter(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentFloat64, nil
}
func (nopMeter) Float64AsyncGauge(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrument[float64]{}, nil
// Float64AsyncGauge creates a no-op instrument.
func (NopMeter) Float64AsyncGauge(string, Float64Callback, ...InstrumentOption) (AsyncInstrument, error) {
return nopInstrumentFloat64, nil
}
type nopInstrument[N any] struct{}
@@ -65,3 +93,6 @@ func (nopInstrument[N]) Add(context.Context, N, ...RecordMetricOption) {}
func (nopInstrument[N]) Sample(context.Context, N, ...RecordMetricOption) {}
func (nopInstrument[N]) Record(context.Context, N, ...RecordMetricOption) {}
func (nopInstrument[_]) Stop() {}
var nopInstrumentInt64 = nopInstrument[int64]{}
var nopInstrumentFloat64 = nopInstrument[float64]{}
+21
View File
@@ -0,0 +1,21 @@
package middleware
type eventStreamOutputKey struct{}
func AddEventStreamOutputToMetadata(metadata *Metadata, output any) {
metadata.Set(eventStreamOutputKey{}, output)
}
func GetEventStreamOutputToMetadata[T any](metadata *Metadata) (*T, bool) {
val := metadata.Get(eventStreamOutputKey{})
// not found
if val == nil {
return nil, false
}
// wrong type
res, ok := val.(*T)
if !ok {
return nil, false
}
return res, true
}
+8 -6
View File
@@ -23,12 +23,14 @@ type orderedIDs struct {
items map[string]ider
}
const baseOrderedItems = 5
// selected based on the general upper bound of # of middlewares in each step
// in the downstream aws-sdk-go-v2
const baseOrderedItems = 8
func newOrderedIDs() *orderedIDs {
func newOrderedIDs(cap int) *orderedIDs {
return &orderedIDs{
order: newRelativeOrder(),
items: make(map[string]ider, baseOrderedItems),
order: newRelativeOrder(cap),
items: make(map[string]ider, cap),
}
}
@@ -141,9 +143,9 @@ type relativeOrder struct {
order []string
}
func newRelativeOrder() *relativeOrder {
func newRelativeOrder(cap int) *relativeOrder {
return &relativeOrder{
order: make([]string, 0, baseOrderedItems),
order: make([]string, 0, cap),
}
}
+136 -49
View File
@@ -1,7 +1,9 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import (
"context"
"fmt"
)
// BuildInput provides the input parameters for the BuildMiddleware to consume.
@@ -25,14 +27,14 @@ type BuildHandler interface {
}
// BuildMiddleware provides the interface for middleware specific to the
// serialize step. Delegates to the next BuildHandler for further
// build step. Delegates to the next BuildHandler for further
// processing.
type BuildMiddleware interface {
// Unique ID for the middleware in theBuildStep. The step does not allow
// duplicate IDs.
// ID returns a unique ID for the middleware in the BuildStep. The step does not
// allow duplicate IDs.
ID() string
// Invokes the middleware behavior which must delegate to the next handler
// HandleBuild invokes the middleware behavior which must delegate to the next handler
// for the middleware chain to continue. The method must return a result or
// error to its caller.
HandleBuild(ctx context.Context, in BuildInput, next BuildHandler) (
@@ -54,7 +56,9 @@ type buildMiddlewareFunc struct {
id string
// Middleware function to be called.
fn func(context.Context, BuildInput, BuildHandler) (BuildOutput, Metadata, error)
fn func(context.Context, BuildInput, BuildHandler) (
BuildOutput, Metadata, error,
)
}
// ID returns the unique ID for the middleware.
@@ -69,23 +73,22 @@ func (s buildMiddlewareFunc) HandleBuild(ctx context.Context, in BuildInput, nex
var _ BuildMiddleware = (buildMiddlewareFunc{})
// BuildStep provides the ordered grouping of BuildMiddleware to be invoked on
// a handler.
// BuildStep provides the ordered grouping of BuildMiddleware to be
// invoked on a handler.
type BuildStep struct {
ids *orderedIDs
head *decoratedBuildHandler
tail *decoratedBuildHandler
}
// NewBuildStep returns a BuildStep ready to have middleware for
// initialization added to it.
// NewBuildStep returns an BuildStep ready to have middleware for
// build added to it.
func NewBuildStep() *BuildStep {
return &BuildStep{
ids: newOrderedIDs(),
}
return &BuildStep{}
}
var _ Middleware = (*BuildStep)(nil)
// ID returns the unique name of the step as a middleware.
// ID returns the unique ID of the step as a middleware.
func (s *BuildStep) ID() string {
return "Build stack step"
}
@@ -97,77 +100,161 @@ func (s *BuildStep) ID() string {
func (s *BuildStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h BuildHandler = buildWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedBuildHandler{
Next: h,
With: order[i].(BuildMiddleware),
}
}
sIn := BuildInput{
Request: in,
}
res, metadata, err := h.HandleBuild(ctx, sIn)
wh := &buildWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleBuild(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleBuild(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *BuildStep) Get(id string) (BuildMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(BuildMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *BuildStep) Add(m BuildMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedBuildHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedBuildHandler{s.head, m}
} else {
tail := &decoratedBuildHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware id.
// Returns an error if the original middleware does not exist, or the middleware
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *BuildStep) Insert(m BuildMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedBuildHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedBuildHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedBuildHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedBuildHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or an error if the middleware to be removed
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *BuildStep) Swap(id string, m BuildMiddleware) (BuildMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(BuildMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *BuildStep) Remove(id string) (BuildMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(BuildMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedBuildHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *BuildStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *buildWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedBuildHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *BuildStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *BuildStep) get(id string) (found, prev *decoratedBuildHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *buildWrapHandler
h, _ = h.Next.(*decoratedBuildHandler)
}
return
}
type buildWrapHandler struct {
@@ -176,7 +263,7 @@ type buildWrapHandler struct {
var _ BuildHandler = (*buildWrapHandler)(nil)
// Implements BuildHandler, converts types and delegates to underlying
// HandleBuild implements BuildHandler, converts types and delegates to underlying
// generic handler.
func (w buildWrapHandler) HandleBuild(ctx context.Context, in BuildInput) (
out BuildOutput, metadata Metadata, err error,
@@ -200,12 +287,12 @@ func (h decoratedBuildHandler) HandleBuild(ctx context.Context, in BuildInput) (
return h.With.HandleBuild(ctx, in, h.Next)
}
// BuildHandlerFunc provides a wrapper around a function to be used as a build middleware handler.
// BuildHandlerFunc provides a wrapper around a function to be used as buildMiddleware.
type BuildHandlerFunc func(context.Context, BuildInput) (BuildOutput, Metadata, error)
// HandleBuild invokes the wrapped function with the provided arguments.
func (b BuildHandlerFunc) HandleBuild(ctx context.Context, in BuildInput) (BuildOutput, Metadata, error) {
return b(ctx, in)
// HandleBuild calls the wrapped function with the provided arguments.
func (f BuildHandlerFunc) HandleBuild(ctx context.Context, in BuildInput) (BuildOutput, Metadata, error) {
return f(ctx, in)
}
var _ BuildHandler = BuildHandlerFunc(nil)
+129 -46
View File
@@ -1,7 +1,9 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import (
"context"
"fmt"
)
// DeserializeInput provides the input parameters for the DeserializeInput to
@@ -11,10 +13,7 @@ type DeserializeInput struct {
Request interface{}
}
// DeserializeOutput provides the result returned by the next
// DeserializeHandler. The DeserializeMiddleware should deserialize the
// RawResponse into a Result that can be consumed by middleware higher up in
// the stack.
// DeserializeOutput provides the result returned by the next DeserializeHandler.
type DeserializeOutput struct {
RawResponse interface{}
Result interface{}
@@ -29,7 +28,7 @@ type DeserializeHandler interface {
}
// DeserializeMiddleware provides the interface for middleware specific to the
// serialize step. Delegates to the next DeserializeHandler for further
// deserialize step. Delegates to the next DeserializeHandler for further
// processing.
type DeserializeMiddleware interface {
// ID returns a unique ID for the middleware in the DeserializeStep. The step does not
@@ -44,8 +43,8 @@ type DeserializeMiddleware interface {
)
}
// DeserializeMiddlewareFunc returns a DeserializeMiddleware with the unique ID
// provided, and the func to be invoked.
// DeserializeMiddlewareFunc returns a DeserializeMiddleware with the unique ID provided,
// and the func to be invoked.
func DeserializeMiddlewareFunc(id string, fn func(context.Context, DeserializeInput, DeserializeHandler) (DeserializeOutput, Metadata, error)) DeserializeMiddleware {
return deserializeMiddlewareFunc{
id: id,
@@ -78,15 +77,14 @@ var _ DeserializeMiddleware = (deserializeMiddlewareFunc{})
// DeserializeStep provides the ordered grouping of DeserializeMiddleware to be
// invoked on a handler.
type DeserializeStep struct {
ids *orderedIDs
head *decoratedDeserializeHandler
tail *decoratedDeserializeHandler
}
// NewDeserializeStep returns a DeserializeStep ready to have middleware for
// initialization added to it.
// NewDeserializeStep returns an DeserializeStep ready to have middleware for
// deserialize added to it.
func NewDeserializeStep() *DeserializeStep {
return &DeserializeStep{
ids: newOrderedIDs(),
}
return &DeserializeStep{}
}
var _ Middleware = (*DeserializeStep)(nil)
@@ -103,77 +101,161 @@ func (s *DeserializeStep) ID() string {
func (s *DeserializeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h DeserializeHandler = deserializeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedDeserializeHandler{
Next: h,
With: order[i].(DeserializeMiddleware),
}
}
sIn := DeserializeInput{
Request: in,
}
res, metadata, err := h.HandleDeserialize(ctx, sIn)
wh := &deserializeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleDeserialize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleDeserialize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *DeserializeStep) Get(id string) (DeserializeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(DeserializeMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *DeserializeStep) Add(m DeserializeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedDeserializeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedDeserializeHandler{s.head, m}
} else {
tail := &decoratedDeserializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *DeserializeStep) Insert(m DeserializeMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedDeserializeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedDeserializeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedDeserializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedDeserializeHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *DeserializeStep) Swap(id string, m DeserializeMiddleware) (DeserializeMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(DeserializeMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *DeserializeStep) Remove(id string) (DeserializeMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(DeserializeMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedDeserializeHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *DeserializeStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *deserializeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedDeserializeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *DeserializeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *DeserializeStep) get(id string) (found, prev *decoratedDeserializeHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *deserializeWrapHandler
h, _ = h.Next.(*decoratedDeserializeHandler)
}
return
}
type deserializeWrapHandler struct {
@@ -187,9 +269,10 @@ var _ DeserializeHandler = (*deserializeWrapHandler)(nil)
func (w deserializeWrapHandler) HandleDeserialize(ctx context.Context, in DeserializeInput) (
out DeserializeOutput, metadata Metadata, err error,
) {
resp, metadata, err := w.Next.Handle(ctx, in.Request)
res, metadata, err := w.Next.Handle(ctx, in.Request)
return DeserializeOutput{
RawResponse: resp,
RawResponse: res,
Result: nil,
}, metadata, err
}
@@ -206,12 +289,12 @@ func (h decoratedDeserializeHandler) HandleDeserialize(ctx context.Context, in D
return h.With.HandleDeserialize(ctx, in, h.Next)
}
// DeserializeHandlerFunc provides a wrapper around a function to be used as a deserialize middleware handler.
// DeserializeHandlerFunc provides a wrapper around a function to be used as deserializeMiddleware.
type DeserializeHandlerFunc func(context.Context, DeserializeInput) (DeserializeOutput, Metadata, error)
// HandleDeserialize invokes the wrapped function with the given arguments.
func (d DeserializeHandlerFunc) HandleDeserialize(ctx context.Context, in DeserializeInput) (DeserializeOutput, Metadata, error) {
return d(ctx, in)
// HandleDeserialize calls the wrapped function with the provided arguments.
func (f DeserializeHandlerFunc) HandleDeserialize(ctx context.Context, in DeserializeInput) (DeserializeOutput, Metadata, error) {
return f(ctx, in)
}
var _ DeserializeHandler = DeserializeHandlerFunc(nil)
+127 -40
View File
@@ -1,6 +1,10 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import "context"
import (
"context"
"fmt"
)
// FinalizeInput provides the input parameters for the FinalizeMiddleware to
// consume. FinalizeMiddleware may modify the Request value before forwarding
@@ -23,7 +27,7 @@ type FinalizeHandler interface {
}
// FinalizeMiddleware provides the interface for middleware specific to the
// serialize step. Delegates to the next FinalizeHandler for further
// finalize step. Delegates to the next FinalizeHandler for further
// processing.
type FinalizeMiddleware interface {
// ID returns a unique ID for the middleware in the FinalizeStep. The step does not
@@ -38,8 +42,8 @@ type FinalizeMiddleware interface {
)
}
// FinalizeMiddlewareFunc returns a FinalizeMiddleware with the unique ID
// provided, and the func to be invoked.
// FinalizeMiddlewareFunc returns a FinalizeMiddleware with the unique ID provided,
// and the func to be invoked.
func FinalizeMiddlewareFunc(id string, fn func(context.Context, FinalizeInput, FinalizeHandler) (FinalizeOutput, Metadata, error)) FinalizeMiddleware {
return finalizeMiddlewareFunc{
id: id,
@@ -72,20 +76,19 @@ var _ FinalizeMiddleware = (finalizeMiddlewareFunc{})
// FinalizeStep provides the ordered grouping of FinalizeMiddleware to be
// invoked on a handler.
type FinalizeStep struct {
ids *orderedIDs
head *decoratedFinalizeHandler
tail *decoratedFinalizeHandler
}
// NewFinalizeStep returns a FinalizeStep ready to have middleware for
// initialization added to it.
// NewFinalizeStep returns an FinalizeStep ready to have middleware for
// finalize added to it.
func NewFinalizeStep() *FinalizeStep {
return &FinalizeStep{
ids: newOrderedIDs(),
}
return &FinalizeStep{}
}
var _ Middleware = (*FinalizeStep)(nil)
// ID returns the unique id of the step as a middleware.
// ID returns the unique ID of the step as a middleware.
func (s *FinalizeStep) ID() string {
return "Finalize stack step"
}
@@ -97,77 +100,161 @@ func (s *FinalizeStep) ID() string {
func (s *FinalizeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h FinalizeHandler = finalizeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedFinalizeHandler{
Next: h,
With: order[i].(FinalizeMiddleware),
}
}
sIn := FinalizeInput{
Request: in,
}
res, metadata, err := h.HandleFinalize(ctx, sIn)
wh := &finalizeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleFinalize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleFinalize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *FinalizeStep) Get(id string) (FinalizeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(FinalizeMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *FinalizeStep) Add(m FinalizeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedFinalizeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedFinalizeHandler{s.head, m}
} else {
tail := &decoratedFinalizeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *FinalizeStep) Insert(m FinalizeMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedFinalizeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedFinalizeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedFinalizeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedFinalizeHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *FinalizeStep) Swap(id string, m FinalizeMiddleware) (FinalizeMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(FinalizeMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *FinalizeStep) Remove(id string) (FinalizeMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(FinalizeMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedFinalizeHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *FinalizeStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *finalizeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedFinalizeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *FinalizeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *FinalizeStep) get(id string) (found, prev *decoratedFinalizeHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *finalizeWrapHandler
h, _ = h.Next.(*decoratedFinalizeHandler)
}
return
}
type finalizeWrapHandler struct {
@@ -200,10 +287,10 @@ func (h decoratedFinalizeHandler) HandleFinalize(ctx context.Context, in Finaliz
return h.With.HandleFinalize(ctx, in, h.Next)
}
// FinalizeHandlerFunc provides a wrapper around a function to be used as a finalize middleware handler.
// FinalizeHandlerFunc provides a wrapper around a function to be used as finalizeMiddleware.
type FinalizeHandlerFunc func(context.Context, FinalizeInput) (FinalizeOutput, Metadata, error)
// HandleFinalize invokes the wrapped function with the given arguments.
// HandleFinalize calls the wrapped function with the provided arguments.
func (f FinalizeHandlerFunc) HandleFinalize(ctx context.Context, in FinalizeInput) (FinalizeOutput, Metadata, error) {
return f(ctx, in)
}
+124 -36
View File
@@ -1,10 +1,15 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import "context"
import (
"context"
"fmt"
)
// InitializeInput wraps the input parameters for the InitializeMiddlewares to
// consume. InitializeMiddleware may modify the parameter value before
// forwarding it along to the next InitializeHandler.
type InitializeInput struct {
Parameters interface{}
}
@@ -72,15 +77,14 @@ var _ InitializeMiddleware = (initializeMiddlewareFunc{})
// InitializeStep provides the ordered grouping of InitializeMiddleware to be
// invoked on a handler.
type InitializeStep struct {
ids *orderedIDs
head *decoratedInitializeHandler
tail *decoratedInitializeHandler
}
// NewInitializeStep returns an InitializeStep ready to have middleware for
// initialization added to it.
// initialize added to it.
func NewInitializeStep() *InitializeStep {
return &InitializeStep{
ids: newOrderedIDs(),
}
return &InitializeStep{}
}
var _ Middleware = (*InitializeStep)(nil)
@@ -97,77 +101,161 @@ func (s *InitializeStep) ID() string {
func (s *InitializeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h InitializeHandler = initializeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedInitializeHandler{
Next: h,
With: order[i].(InitializeMiddleware),
}
}
sIn := InitializeInput{
Parameters: in,
}
res, metadata, err := h.HandleInitialize(ctx, sIn)
wh := &initializeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleInitialize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleInitialize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *InitializeStep) Get(id string) (InitializeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(InitializeMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *InitializeStep) Add(m InitializeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedInitializeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedInitializeHandler{s.head, m}
} else {
tail := &decoratedInitializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *InitializeStep) Insert(m InitializeMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedInitializeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedInitializeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedInitializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedInitializeHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *InitializeStep) Swap(id string, m InitializeMiddleware) (InitializeMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(InitializeMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *InitializeStep) Remove(id string) (InitializeMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(InitializeMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedInitializeHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *InitializeStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *initializeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedInitializeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *InitializeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *InitializeStep) get(id string) (found, prev *decoratedInitializeHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *initializeWrapHandler
h, _ = h.Next.(*decoratedInitializeHandler)
}
return
}
type initializeWrapHandler struct {
@@ -200,12 +288,12 @@ func (h decoratedInitializeHandler) HandleInitialize(ctx context.Context, in Ini
return h.With.HandleInitialize(ctx, in, h.Next)
}
// InitializeHandlerFunc provides a wrapper around a function to be used as an initialize middleware handler.
// InitializeHandlerFunc provides a wrapper around a function to be used as initializeMiddleware.
type InitializeHandlerFunc func(context.Context, InitializeInput) (InitializeOutput, Metadata, error)
// HandleInitialize calls the wrapped function with the provided arguments.
func (i InitializeHandlerFunc) HandleInitialize(ctx context.Context, in InitializeInput) (InitializeOutput, Metadata, error) {
return i(ctx, in)
func (f InitializeHandlerFunc) HandleInitialize(ctx context.Context, in InitializeInput) (InitializeOutput, Metadata, error) {
return f(ctx, in)
}
var _ InitializeHandler = InitializeHandlerFunc(nil)
+126 -40
View File
@@ -1,6 +1,10 @@
// Code generated by smithy-go/middleware/generate.go DO NOT EDIT.
package middleware
import "context"
import (
"context"
"fmt"
)
// SerializeInput provides the input parameters for the SerializeMiddleware to
// consume. SerializeMiddleware may modify the Request value before forwarding
@@ -41,8 +45,8 @@ type SerializeMiddleware interface {
)
}
// SerializeMiddlewareFunc returns a SerializeMiddleware with the unique ID
// provided, and the func to be invoked.
// SerializeMiddlewareFunc returns a SerializeMiddleware with the unique ID provided,
// and the func to be invoked.
func SerializeMiddlewareFunc(id string, fn func(context.Context, SerializeInput, SerializeHandler) (SerializeOutput, Metadata, error)) SerializeMiddleware {
return serializeMiddlewareFunc{
id: id,
@@ -75,17 +79,15 @@ var _ SerializeMiddleware = (serializeMiddlewareFunc{})
// SerializeStep provides the ordered grouping of SerializeMiddleware to be
// invoked on a handler.
type SerializeStep struct {
head *decoratedSerializeHandler
tail *decoratedSerializeHandler
newRequest func() interface{}
ids *orderedIDs
}
// NewSerializeStep returns a SerializeStep ready to have middleware for
// initialization added to it. The newRequest func parameter is used to
// initialize the transport specific request for the stack SerializeStep to
// serialize the input parameters into.
// NewSerializeStep returns an SerializeStep ready to have middleware for
// serialize added to it.
func NewSerializeStep(newRequest func() interface{}) *SerializeStep {
return &SerializeStep{
ids: newOrderedIDs(),
newRequest: newRequest,
}
}
@@ -104,78 +106,162 @@ func (s *SerializeStep) ID() string {
func (s *SerializeStep) HandleMiddleware(ctx context.Context, in interface{}, next Handler) (
out interface{}, metadata Metadata, err error,
) {
order := s.ids.GetOrder()
var h SerializeHandler = serializeWrapHandler{Next: next}
for i := len(order) - 1; i >= 0; i-- {
h = decoratedSerializeHandler{
Next: h,
With: order[i].(SerializeMiddleware),
}
}
sIn := SerializeInput{
Parameters: in,
Request: s.newRequest(),
}
res, metadata, err := h.HandleSerialize(ctx, sIn)
wh := &serializeWrapHandler{next}
if s.head == nil {
res, metadata, err := wh.HandleSerialize(ctx, sIn)
return res.Result, metadata, err
}
s.tail.Next = wh
res, metadata, err := s.head.HandleSerialize(ctx, sIn)
return res.Result, metadata, err
}
// Get retrieves the middleware identified by id. If the middleware is not present, returns false.
func (s *SerializeStep) Get(id string) (SerializeMiddleware, bool) {
get, ok := s.ids.Get(id)
if !ok {
found, _ := s.get(id)
if found == nil {
return nil, false
}
return get.(SerializeMiddleware), ok
return found.With, true
}
// Add injects the middleware to the relative position of the middleware group.
// Returns an error if the middleware already exists.
//
// Add never returns an error. It used to for duplicate phases but this
// behavior has since been removed as part of a performance optimization. The
// return value from Add can be ignored.
func (s *SerializeStep) Add(m SerializeMiddleware, pos RelativePosition) error {
return s.ids.Add(m, pos)
if s.head == nil {
s.head = &decoratedSerializeHandler{nil, m}
s.tail = s.head
return nil
}
if pos == Before {
s.head = &decoratedSerializeHandler{s.head, m}
} else {
tail := &decoratedSerializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
}
return nil
}
// Insert injects the middleware relative to an existing middleware ID.
// Returns error if the original middleware does not exist, or the middleware
// being added already exists.
func (s *SerializeStep) Insert(m SerializeMiddleware, relativeTo string, pos RelativePosition) error {
return s.ids.Insert(m, relativeTo, pos)
found, prev := s.get(relativeTo)
if found == nil {
return fmt.Errorf("not found: %s", m.ID())
}
if pos == Before {
if prev == nil { // at the front
s.head = &decoratedSerializeHandler{s.head, m}
} else { // somewhere in the middle
prev.Next = &decoratedSerializeHandler{found, m}
}
} else {
if found.Next == nil { // at the end
tail := &decoratedSerializeHandler{nil, m}
s.tail.Next = tail
s.tail = tail
} else { // somewhere in the middle
found.Next = &decoratedSerializeHandler{found.Next, m}
}
}
return nil
}
// Swap removes the middleware by id, replacing it with the new middleware.
// Returns the middleware removed, or error if the middleware to be removed
// doesn't exist.
func (s *SerializeStep) Swap(id string, m SerializeMiddleware) (SerializeMiddleware, error) {
removed, err := s.ids.Swap(id, m)
if err != nil {
return nil, err
found, _ := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", m.ID())
}
return removed.(SerializeMiddleware), nil
swapped := found.With
found.With = m
return swapped, nil
}
// Remove removes the middleware by id. Returns error if the middleware
// doesn't exist.
func (s *SerializeStep) Remove(id string) (SerializeMiddleware, error) {
removed, err := s.ids.Remove(id)
if err != nil {
return nil, err
found, prev := s.get(id)
if found == nil {
return nil, fmt.Errorf("not found: %s", id)
}
return removed.(SerializeMiddleware), nil
if s.head == s.tail { // it's the only one
s.head = nil
s.tail = nil
} else if found == s.head { // at the front
s.head = s.head.Next.(*decoratedSerializeHandler)
} else if found == s.tail { // at the end
prev.Next = nil
s.tail = prev
} else {
prev.Next = found.Next // somewhere in the middle
}
return found.With, nil
}
// List returns a list of the middleware in the step.
func (s *SerializeStep) List() []string {
return s.ids.List()
var ids []string
for h := s.head; h != nil; {
ids = append(ids, h.With.ID())
if h.Next == nil {
break
}
// once executed, tail.Next of the list will be set to an
// *serializeWrapHandler, make sure to check for that
if hnext, ok := h.Next.(*decoratedSerializeHandler); ok {
h = hnext
} else {
break
}
}
return ids
}
// Clear removes all middleware in the step.
func (s *SerializeStep) Clear() {
s.ids.Clear()
s.head = nil
s.tail = nil
}
func (s *SerializeStep) get(id string) (found, prev *decoratedSerializeHandler) {
for h := s.head; h != nil; {
if h.With.ID() == id {
found = h
return
}
prev = h
if h.Next == nil {
return
}
// once executed, tail.Next of the list will be set to an
// *serializeWrapHandler
h, _ = h.Next.(*decoratedSerializeHandler)
}
return
}
type serializeWrapHandler struct {
@@ -184,7 +270,7 @@ type serializeWrapHandler struct {
var _ SerializeHandler = (*serializeWrapHandler)(nil)
// Implements SerializeHandler, converts types and delegates to underlying
// HandleSerialize implements SerializeHandler, converts types and delegates to underlying
// generic handler.
func (w serializeWrapHandler) HandleSerialize(ctx context.Context, in SerializeInput) (
out SerializeOutput, metadata Metadata, err error,
@@ -208,12 +294,12 @@ func (h decoratedSerializeHandler) HandleSerialize(ctx context.Context, in Seria
return h.With.HandleSerialize(ctx, in, h.Next)
}
// SerializeHandlerFunc provides a wrapper around a function to be used as a serialize middleware handler.
// SerializeHandlerFunc provides a wrapper around a function to be used as serializeMiddleware.
type SerializeHandlerFunc func(context.Context, SerializeInput) (SerializeOutput, Metadata, error)
// HandleSerialize calls the wrapped function with the provided arguments.
func (s SerializeHandlerFunc) HandleSerialize(ctx context.Context, in SerializeInput) (SerializeOutput, Metadata, error) {
return s(ctx, in)
func (f SerializeHandlerFunc) HandleSerialize(ctx context.Context, in SerializeInput) (SerializeOutput, Metadata, error) {
return f(ctx, in)
}
var _ SerializeHandler = SerializeHandlerFunc(nil)
+6
View File
@@ -17,6 +17,12 @@ var now = time.Now
func withMetrics(parent context.Context, client ClientDo, meter metrics.Meter) (
context.Context, ClientDo, error,
) {
// WithClientTrace is an expensive operation - avoid calling it if we're
// not actually using a metrics sink.
if _, ok := meter.(metrics.NopMeter); ok {
return parent, client, nil
}
hm, err := newHTTPMetrics(meter)
if err != nil {
return nil, nil, err