From 68c46490c32137ae1449ff3a33e88337b814903d Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:14:18 -0500 Subject: [PATCH] Track accountID endpoint mode in user-agent (#3000) --- .../1c8f914e6b9a4aef9418a60e7fe62de2.json | 8 ++ aws/middleware/user_agent.go | 55 +++++++------ .../AccountIdEndpointModeUserAgent.java | 69 ++++++++++++++++ ...mithy.go.codegen.integration.GoIntegration | 1 + service/dynamodb/api_client.go | 17 ++++ .../dynamodb/api_op_BatchExecuteStatement.go | 3 + service/dynamodb/api_op_BatchGetItem.go | 3 + service/dynamodb/api_op_BatchWriteItem.go | 3 + service/dynamodb/api_op_CreateBackup.go | 3 + service/dynamodb/api_op_CreateGlobalTable.go | 3 + service/dynamodb/api_op_CreateTable.go | 3 + service/dynamodb/api_op_DeleteBackup.go | 3 + service/dynamodb/api_op_DeleteItem.go | 3 + .../dynamodb/api_op_DeleteResourcePolicy.go | 3 + service/dynamodb/api_op_DeleteTable.go | 3 + service/dynamodb/api_op_DescribeBackup.go | 3 + .../api_op_DescribeContinuousBackups.go | 3 + .../api_op_DescribeContributorInsights.go | 3 + service/dynamodb/api_op_DescribeEndpoints.go | 3 + service/dynamodb/api_op_DescribeExport.go | 3 + .../dynamodb/api_op_DescribeGlobalTable.go | 3 + .../api_op_DescribeGlobalTableSettings.go | 3 + service/dynamodb/api_op_DescribeImport.go | 3 + ..._op_DescribeKinesisStreamingDestination.go | 3 + service/dynamodb/api_op_DescribeLimits.go | 3 + service/dynamodb/api_op_DescribeTable.go | 3 + .../api_op_DescribeTableReplicaAutoScaling.go | 3 + service/dynamodb/api_op_DescribeTimeToLive.go | 3 + ...i_op_DisableKinesisStreamingDestination.go | 3 + ...pi_op_EnableKinesisStreamingDestination.go | 3 + service/dynamodb/api_op_ExecuteStatement.go | 3 + service/dynamodb/api_op_ExecuteTransaction.go | 3 + .../api_op_ExportTableToPointInTime.go | 3 + service/dynamodb/api_op_GetItem.go | 3 + service/dynamodb/api_op_GetResourcePolicy.go | 3 + service/dynamodb/api_op_ImportTable.go | 3 + service/dynamodb/api_op_ListBackups.go | 3 + .../api_op_ListContributorInsights.go | 3 + service/dynamodb/api_op_ListExports.go | 3 + service/dynamodb/api_op_ListGlobalTables.go | 3 + service/dynamodb/api_op_ListImports.go | 3 + service/dynamodb/api_op_ListTables.go | 3 + service/dynamodb/api_op_ListTagsOfResource.go | 3 + service/dynamodb/api_op_PutItem.go | 3 + service/dynamodb/api_op_PutResourcePolicy.go | 3 + service/dynamodb/api_op_Query.go | 3 + .../dynamodb/api_op_RestoreTableFromBackup.go | 3 + .../api_op_RestoreTableToPointInTime.go | 3 + service/dynamodb/api_op_Scan.go | 3 + service/dynamodb/api_op_TagResource.go | 3 + service/dynamodb/api_op_TransactGetItems.go | 3 + service/dynamodb/api_op_TransactWriteItems.go | 3 + service/dynamodb/api_op_UntagResource.go | 3 + .../api_op_UpdateContinuousBackups.go | 3 + .../api_op_UpdateContributorInsights.go | 3 + service/dynamodb/api_op_UpdateGlobalTable.go | 3 + .../api_op_UpdateGlobalTableSettings.go | 3 + service/dynamodb/api_op_UpdateItem.go | 3 + ...pi_op_UpdateKinesisStreamingDestination.go | 3 + service/dynamodb/api_op_UpdateTable.go | 3 + .../api_op_UpdateTableReplicaAutoScaling.go | 3 + service/dynamodb/api_op_UpdateTimeToLive.go | 3 + .../useragent_accountidendpointmode_test.go | 79 +++++++++++++++++++ 63 files changed, 378 insertions(+), 22 deletions(-) create mode 100644 .changelog/1c8f914e6b9a4aef9418a60e7fe62de2.json create mode 100644 codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AccountIdEndpointModeUserAgent.java create mode 100644 service/dynamodb/useragent_accountidendpointmode_test.go diff --git a/.changelog/1c8f914e6b9a4aef9418a60e7fe62de2.json b/.changelog/1c8f914e6b9a4aef9418a60e7fe62de2.json new file mode 100644 index 00000000000..acdd9d3c3e0 --- /dev/null +++ b/.changelog/1c8f914e6b9a4aef9418a60e7fe62de2.json @@ -0,0 +1,8 @@ +{ + "id": "1c8f914e-6b9a-4aef-9418-a60e7fe62de2", + "type": "feature", + "description": "Track AccountID endpoint mode in user-agent.", + "modules": [ + "service/dynamodb" + ] +} \ No newline at end of file diff --git a/aws/middleware/user_agent.go b/aws/middleware/user_agent.go index 01d758d5ff8..95b6268f49e 100644 --- a/aws/middleware/user_agent.go +++ b/aws/middleware/user_agent.go @@ -76,28 +76,39 @@ type UserAgentFeature string // Enumerates UserAgentFeature. const ( - UserAgentFeatureResourceModel UserAgentFeature = "A" // n/a (we don't generate separate resource types) - UserAgentFeatureWaiter = "B" - UserAgentFeaturePaginator = "C" - UserAgentFeatureRetryModeLegacy = "D" // n/a (equivalent to standard) - UserAgentFeatureRetryModeStandard = "E" - UserAgentFeatureRetryModeAdaptive = "F" - UserAgentFeatureS3Transfer = "G" - UserAgentFeatureS3CryptoV1N = "H" // n/a (crypto client is external) - UserAgentFeatureS3CryptoV2 = "I" // n/a - UserAgentFeatureS3ExpressBucket = "J" - UserAgentFeatureS3AccessGrants = "K" // not yet implemented - UserAgentFeatureGZIPRequestCompression = "L" - UserAgentFeatureProtocolRPCV2CBOR = "M" - UserAgentFeatureRequestChecksumCRC32 = "U" - UserAgentFeatureRequestChecksumCRC32C = "V" - UserAgentFeatureRequestChecksumCRC64 = "W" - UserAgentFeatureRequestChecksumSHA1 = "X" - UserAgentFeatureRequestChecksumSHA256 = "Y" - UserAgentFeatureRequestChecksumWhenSupported = "Z" - UserAgentFeatureRequestChecksumWhenRequired = "a" - UserAgentFeatureResponseChecksumWhenSupported = "b" - UserAgentFeatureResponseChecksumWhenRequired = "c" + UserAgentFeatureResourceModel UserAgentFeature = "A" // n/a (we don't generate separate resource types) + + UserAgentFeatureWaiter = "B" + UserAgentFeaturePaginator = "C" + + UserAgentFeatureRetryModeLegacy = "D" // n/a (equivalent to standard) + UserAgentFeatureRetryModeStandard = "E" + UserAgentFeatureRetryModeAdaptive = "F" + + UserAgentFeatureS3Transfer = "G" + UserAgentFeatureS3CryptoV1N = "H" // n/a (crypto client is external) + UserAgentFeatureS3CryptoV2 = "I" // n/a + UserAgentFeatureS3ExpressBucket = "J" + UserAgentFeatureS3AccessGrants = "K" // not yet implemented + + UserAgentFeatureGZIPRequestCompression = "L" + + UserAgentFeatureProtocolRPCV2CBOR = "M" + + UserAgentFeatureAccountIDEndpoint = "O" // DO NOT IMPLEMENT: rules output is not currently defined. SDKs should not parse endpoints for feature information. + UserAgentFeatureAccountIDModePreferred = "P" + UserAgentFeatureAccountIDModeDisabled = "Q" + UserAgentFeatureAccountIDModeRequired = "R" + + UserAgentFeatureRequestChecksumCRC32 = "U" + UserAgentFeatureRequestChecksumCRC32C = "V" + UserAgentFeatureRequestChecksumCRC64 = "W" + UserAgentFeatureRequestChecksumSHA1 = "X" + UserAgentFeatureRequestChecksumSHA256 = "Y" + UserAgentFeatureRequestChecksumWhenSupported = "Z" + UserAgentFeatureRequestChecksumWhenRequired = "a" + UserAgentFeatureResponseChecksumWhenSupported = "b" + UserAgentFeatureResponseChecksumWhenRequired = "c" ) // RequestUserAgent is a build middleware that set the User-Agent for the request. diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AccountIdEndpointModeUserAgent.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AccountIdEndpointModeUserAgent.java new file mode 100644 index 00000000000..5a50709bc23 --- /dev/null +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AccountIdEndpointModeUserAgent.java @@ -0,0 +1,69 @@ +package software.amazon.smithy.aws.go.codegen.customization; + +import java.util.List; +import java.util.Map; +import software.amazon.smithy.aws.go.codegen.AwsGoDependency; +import software.amazon.smithy.codegen.core.SymbolProvider; +import software.amazon.smithy.go.codegen.GoCodegenContext; +import software.amazon.smithy.go.codegen.GoDelegator; +import software.amazon.smithy.go.codegen.GoSettings; +import software.amazon.smithy.go.codegen.SmithyGoDependency; +import software.amazon.smithy.go.codegen.integration.GoIntegration; +import software.amazon.smithy.go.codegen.integration.MiddlewareRegistrar; +import software.amazon.smithy.go.codegen.integration.RuntimeClientPlugin; +import software.amazon.smithy.model.Model; + +import static software.amazon.smithy.aws.go.codegen.customization.AccountIDEndpointRouting.hasAccountIdEndpoints; +import static software.amazon.smithy.go.codegen.GoWriter.goTemplate; +import static software.amazon.smithy.go.codegen.SymbolUtils.buildPackageSymbol; + +/** + * Tracks the retry mode being used by the caller. + */ +public class AccountIdEndpointModeUserAgent implements GoIntegration { + private static final MiddlewareRegistrar MIDDLEWARE = MiddlewareRegistrar.builder() + .resolvedFunction(buildPackageSymbol("addUserAgentAccountIDEndpointMode")) + .useClientOptions() + .build(); + + @Override + public List getClientPlugins() { + return List.of( + RuntimeClientPlugin.builder() + .servicePredicate(AccountIDEndpointRouting::hasAccountIdEndpoints) + .registerMiddleware(MIDDLEWARE) + .build() + ); + } + + @Override + public void writeAdditionalFiles(GoCodegenContext ctx) { + if (!hasAccountIdEndpoints(ctx.model(), ctx.settings().getService(ctx.model()))) { + return; + } + + ctx.writerDelegator().useFileWriter("api_client.go", ctx.settings().getModuleName(), goTemplate(""" + $aws:D $awsMiddleware:D + func addUserAgentAccountIDEndpointMode(stack $stack:P, options Options) error { + ua, err := getOrAddRequestUserAgent(stack) + if err != nil { + return err + } + + switch options.AccountIDEndpointMode { + case aws.AccountIDEndpointModePreferred: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModePreferred) + case aws.AccountIDEndpointModeRequired: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModeRequired) + case aws.AccountIDEndpointModeDisabled: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModeDisabled) + } + return nil + }""", + Map.of( + "aws", AwsGoDependency.AWS_CORE, + "awsMiddleware", AwsGoDependency.AWS_MIDDLEWARE, + "stack", SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Stack") + ))); + } +} diff --git a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration index 5d68fdd4c27..5fea5e1d7b1 100644 --- a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration +++ b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration @@ -88,3 +88,4 @@ software.amazon.smithy.aws.go.codegen.customization.BackfillRequiredTrait software.amazon.smithy.aws.go.codegen.customization.DeprecateService software.amazon.smithy.aws.go.codegen.customization.BasicUserAgentFeatures software.amazon.smithy.aws.go.codegen.customization.ChecksumMetricsTracking +software.amazon.smithy.aws.go.codegen.customization.AccountIdEndpointModeUserAgent diff --git a/service/dynamodb/api_client.go b/service/dynamodb/api_client.go index 5e7f574cfe7..c423299063a 100644 --- a/service/dynamodb/api_client.go +++ b/service/dynamodb/api_client.go @@ -887,6 +887,23 @@ func addUserAgentRetryMode(stack *middleware.Stack, options Options) error { return nil } +func addUserAgentAccountIDEndpointMode(stack *middleware.Stack, options Options) error { + ua, err := getOrAddRequestUserAgent(stack) + if err != nil { + return err + } + + switch options.AccountIDEndpointMode { + case aws.AccountIDEndpointModePreferred: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModePreferred) + case aws.AccountIDEndpointModeRequired: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModeRequired) + case aws.AccountIDEndpointModeDisabled: + ua.AddUserAgentFeature(awsmiddleware.UserAgentFeatureAccountIDModeDisabled) + } + return nil +} + func resolveTracerProvider(options *Options) { if options.TracerProvider == nil { options.TracerProvider = &tracing.NopTracerProvider{} diff --git a/service/dynamodb/api_op_BatchExecuteStatement.go b/service/dynamodb/api_op_BatchExecuteStatement.go index 30771109284..e470ac6fe04 100644 --- a/service/dynamodb/api_op_BatchExecuteStatement.go +++ b/service/dynamodb/api_op_BatchExecuteStatement.go @@ -148,6 +148,9 @@ func (c *Client) addOperationBatchExecuteStatementMiddlewares(stack *middleware. if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpBatchExecuteStatementValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_BatchGetItem.go b/service/dynamodb/api_op_BatchGetItem.go index 9b914ac72ff..ee5ac89da60 100644 --- a/service/dynamodb/api_op_BatchGetItem.go +++ b/service/dynamodb/api_op_BatchGetItem.go @@ -283,6 +283,9 @@ func (c *Client) addOperationBatchGetItemMiddlewares(stack *middleware.Stack, op if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpBatchGetItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_BatchWriteItem.go b/service/dynamodb/api_op_BatchWriteItem.go index c641b209e6d..15d9e3cc32f 100644 --- a/service/dynamodb/api_op_BatchWriteItem.go +++ b/service/dynamodb/api_op_BatchWriteItem.go @@ -306,6 +306,9 @@ func (c *Client) addOperationBatchWriteItemMiddlewares(stack *middleware.Stack, if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpBatchWriteItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_CreateBackup.go b/service/dynamodb/api_op_CreateBackup.go index d89a528f9c1..c8d7b3ac8b7 100644 --- a/service/dynamodb/api_op_CreateBackup.go +++ b/service/dynamodb/api_op_CreateBackup.go @@ -151,6 +151,9 @@ func (c *Client) addOperationCreateBackupMiddlewares(stack *middleware.Stack, op if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpCreateBackupValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_CreateGlobalTable.go b/service/dynamodb/api_op_CreateGlobalTable.go index 20b4c0b9be5..9ae4611076c 100644 --- a/service/dynamodb/api_op_CreateGlobalTable.go +++ b/service/dynamodb/api_op_CreateGlobalTable.go @@ -173,6 +173,9 @@ func (c *Client) addOperationCreateGlobalTableMiddlewares(stack *middleware.Stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpCreateGlobalTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_CreateTable.go b/service/dynamodb/api_op_CreateTable.go index fa592994d73..5c27f1ad411 100644 --- a/service/dynamodb/api_op_CreateTable.go +++ b/service/dynamodb/api_op_CreateTable.go @@ -332,6 +332,9 @@ func (c *Client) addOperationCreateTableMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpCreateTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DeleteBackup.go b/service/dynamodb/api_op_DeleteBackup.go index f8acfa3cfc4..7ba82719858 100644 --- a/service/dynamodb/api_op_DeleteBackup.go +++ b/service/dynamodb/api_op_DeleteBackup.go @@ -118,6 +118,9 @@ func (c *Client) addOperationDeleteBackupMiddlewares(stack *middleware.Stack, op if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDeleteBackupValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DeleteItem.go b/service/dynamodb/api_op_DeleteItem.go index e759e6023af..dec6c0bfc19 100644 --- a/service/dynamodb/api_op_DeleteItem.go +++ b/service/dynamodb/api_op_DeleteItem.go @@ -314,6 +314,9 @@ func (c *Client) addOperationDeleteItemMiddlewares(stack *middleware.Stack, opti if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDeleteItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DeleteResourcePolicy.go b/service/dynamodb/api_op_DeleteResourcePolicy.go index eebb81e5534..b8b4a9151f3 100644 --- a/service/dynamodb/api_op_DeleteResourcePolicy.go +++ b/service/dynamodb/api_op_DeleteResourcePolicy.go @@ -145,6 +145,9 @@ func (c *Client) addOperationDeleteResourcePolicyMiddlewares(stack *middleware.S if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDeleteResourcePolicyValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DeleteTable.go b/service/dynamodb/api_op_DeleteTable.go index 016bf3dd567..d355afe4f7f 100644 --- a/service/dynamodb/api_op_DeleteTable.go +++ b/service/dynamodb/api_op_DeleteTable.go @@ -142,6 +142,9 @@ func (c *Client) addOperationDeleteTableMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDeleteTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeBackup.go b/service/dynamodb/api_op_DescribeBackup.go index 2dae2fe211f..710bc3ab3ed 100644 --- a/service/dynamodb/api_op_DescribeBackup.go +++ b/service/dynamodb/api_op_DescribeBackup.go @@ -118,6 +118,9 @@ func (c *Client) addOperationDescribeBackupMiddlewares(stack *middleware.Stack, if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeBackupValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeContinuousBackups.go b/service/dynamodb/api_op_DescribeContinuousBackups.go index 13942c528b9..0af2a854fde 100644 --- a/service/dynamodb/api_op_DescribeContinuousBackups.go +++ b/service/dynamodb/api_op_DescribeContinuousBackups.go @@ -134,6 +134,9 @@ func (c *Client) addOperationDescribeContinuousBackupsMiddlewares(stack *middlew if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeContinuousBackupsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeContributorInsights.go b/service/dynamodb/api_op_DescribeContributorInsights.go index ed40afce86d..f99f17a18c6 100644 --- a/service/dynamodb/api_op_DescribeContributorInsights.go +++ b/service/dynamodb/api_op_DescribeContributorInsights.go @@ -148,6 +148,9 @@ func (c *Client) addOperationDescribeContributorInsightsMiddlewares(stack *middl if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeContributorInsightsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeEndpoints.go b/service/dynamodb/api_op_DescribeEndpoints.go index defd23827c1..f1264a68d09 100644 --- a/service/dynamodb/api_op_DescribeEndpoints.go +++ b/service/dynamodb/api_op_DescribeEndpoints.go @@ -111,6 +111,9 @@ func (c *Client) addOperationDescribeEndpointsMiddlewares(stack *middleware.Stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeEndpoints(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeExport.go b/service/dynamodb/api_op_DescribeExport.go index 1bb2e241e21..5fa027b9915 100644 --- a/service/dynamodb/api_op_DescribeExport.go +++ b/service/dynamodb/api_op_DescribeExport.go @@ -112,6 +112,9 @@ func (c *Client) addOperationDescribeExportMiddlewares(stack *middleware.Stack, if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeExportValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeGlobalTable.go b/service/dynamodb/api_op_DescribeGlobalTable.go index 0e68a856f35..8a88378cf1b 100644 --- a/service/dynamodb/api_op_DescribeGlobalTable.go +++ b/service/dynamodb/api_op_DescribeGlobalTable.go @@ -128,6 +128,9 @@ func (c *Client) addOperationDescribeGlobalTableMiddlewares(stack *middleware.St if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeGlobalTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeGlobalTableSettings.go b/service/dynamodb/api_op_DescribeGlobalTableSettings.go index 54df4a3c98a..eaae074b67f 100644 --- a/service/dynamodb/api_op_DescribeGlobalTableSettings.go +++ b/service/dynamodb/api_op_DescribeGlobalTableSettings.go @@ -131,6 +131,9 @@ func (c *Client) addOperationDescribeGlobalTableSettingsMiddlewares(stack *middl if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeGlobalTableSettingsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeImport.go b/service/dynamodb/api_op_DescribeImport.go index 3258b6e35ac..cc28013942d 100644 --- a/service/dynamodb/api_op_DescribeImport.go +++ b/service/dynamodb/api_op_DescribeImport.go @@ -116,6 +116,9 @@ func (c *Client) addOperationDescribeImportMiddlewares(stack *middleware.Stack, if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeImportValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go b/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go index 3de2bd91666..2b10814001d 100644 --- a/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go +++ b/service/dynamodb/api_op_DescribeKinesisStreamingDestination.go @@ -120,6 +120,9 @@ func (c *Client) addOperationDescribeKinesisStreamingDestinationMiddlewares(stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeLimits.go b/service/dynamodb/api_op_DescribeLimits.go index 62c8b172b06..78a1be8626e 100644 --- a/service/dynamodb/api_op_DescribeLimits.go +++ b/service/dynamodb/api_op_DescribeLimits.go @@ -185,6 +185,9 @@ func (c *Client) addOperationDescribeLimitsMiddlewares(stack *middleware.Stack, if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeLimits(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeTable.go b/service/dynamodb/api_op_DescribeTable.go index ba453ee8879..ff49313cc5c 100644 --- a/service/dynamodb/api_op_DescribeTable.go +++ b/service/dynamodb/api_op_DescribeTable.go @@ -133,6 +133,9 @@ func (c *Client) addOperationDescribeTableMiddlewares(stack *middleware.Stack, o if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go b/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go index 5980deddcfe..4546a8725f4 100644 --- a/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go +++ b/service/dynamodb/api_op_DescribeTableReplicaAutoScaling.go @@ -116,6 +116,9 @@ func (c *Client) addOperationDescribeTableReplicaAutoScalingMiddlewares(stack *m if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeTableReplicaAutoScalingValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DescribeTimeToLive.go b/service/dynamodb/api_op_DescribeTimeToLive.go index 86d1da83487..aa74a5169fa 100644 --- a/service/dynamodb/api_op_DescribeTimeToLive.go +++ b/service/dynamodb/api_op_DescribeTimeToLive.go @@ -117,6 +117,9 @@ func (c *Client) addOperationDescribeTimeToLiveMiddlewares(stack *middleware.Sta if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDescribeTimeToLiveValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_DisableKinesisStreamingDestination.go b/service/dynamodb/api_op_DisableKinesisStreamingDestination.go index 85f44ce1df6..d57e396bee9 100644 --- a/service/dynamodb/api_op_DisableKinesisStreamingDestination.go +++ b/service/dynamodb/api_op_DisableKinesisStreamingDestination.go @@ -135,6 +135,9 @@ func (c *Client) addOperationDisableKinesisStreamingDestinationMiddlewares(stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpDisableKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_EnableKinesisStreamingDestination.go b/service/dynamodb/api_op_EnableKinesisStreamingDestination.go index e6d88121a1f..3e5041bdcea 100644 --- a/service/dynamodb/api_op_EnableKinesisStreamingDestination.go +++ b/service/dynamodb/api_op_EnableKinesisStreamingDestination.go @@ -137,6 +137,9 @@ func (c *Client) addOperationEnableKinesisStreamingDestinationMiddlewares(stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpEnableKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_ExecuteStatement.go b/service/dynamodb/api_op_ExecuteStatement.go index c9c5e952721..3a052533ea2 100644 --- a/service/dynamodb/api_op_ExecuteStatement.go +++ b/service/dynamodb/api_op_ExecuteStatement.go @@ -196,6 +196,9 @@ func (c *Client) addOperationExecuteStatementMiddlewares(stack *middleware.Stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpExecuteStatementValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_ExecuteTransaction.go b/service/dynamodb/api_op_ExecuteTransaction.go index 08ea283fb5b..590a4151b8a 100644 --- a/service/dynamodb/api_op_ExecuteTransaction.go +++ b/service/dynamodb/api_op_ExecuteTransaction.go @@ -135,6 +135,9 @@ func (c *Client) addOperationExecuteTransactionMiddlewares(stack *middleware.Sta if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addIdempotencyToken_opExecuteTransactionMiddleware(stack, options); err != nil { return err } diff --git a/service/dynamodb/api_op_ExportTableToPointInTime.go b/service/dynamodb/api_op_ExportTableToPointInTime.go index 9e49c6c1775..750e646d407 100644 --- a/service/dynamodb/api_op_ExportTableToPointInTime.go +++ b/service/dynamodb/api_op_ExportTableToPointInTime.go @@ -175,6 +175,9 @@ func (c *Client) addOperationExportTableToPointInTimeMiddlewares(stack *middlewa if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addIdempotencyToken_opExportTableToPointInTimeMiddleware(stack, options); err != nil { return err } diff --git a/service/dynamodb/api_op_GetItem.go b/service/dynamodb/api_op_GetItem.go index 5e8f59ae6b2..9f0d6a7b1b7 100644 --- a/service/dynamodb/api_op_GetItem.go +++ b/service/dynamodb/api_op_GetItem.go @@ -224,6 +224,9 @@ func (c *Client) addOperationGetItemMiddlewares(stack *middleware.Stack, options if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpGetItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_GetResourcePolicy.go b/service/dynamodb/api_op_GetResourcePolicy.go index 20e7a28f19c..73724d0e7a5 100644 --- a/service/dynamodb/api_op_GetResourcePolicy.go +++ b/service/dynamodb/api_op_GetResourcePolicy.go @@ -150,6 +150,9 @@ func (c *Client) addOperationGetResourcePolicyMiddlewares(stack *middleware.Stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpGetResourcePolicyValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_ImportTable.go b/service/dynamodb/api_op_ImportTable.go index 76be601ac4c..1e15e53973f 100644 --- a/service/dynamodb/api_op_ImportTable.go +++ b/service/dynamodb/api_op_ImportTable.go @@ -146,6 +146,9 @@ func (c *Client) addOperationImportTableMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addIdempotencyToken_opImportTableMiddleware(stack, options); err != nil { return err } diff --git a/service/dynamodb/api_op_ListBackups.go b/service/dynamodb/api_op_ListBackups.go index e6378019ccd..b82553164ae 100644 --- a/service/dynamodb/api_op_ListBackups.go +++ b/service/dynamodb/api_op_ListBackups.go @@ -173,6 +173,9 @@ func (c *Client) addOperationListBackupsMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListBackups(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListContributorInsights.go b/service/dynamodb/api_op_ListContributorInsights.go index 70b0f32a52b..0ac4cf8515f 100644 --- a/service/dynamodb/api_op_ListContributorInsights.go +++ b/service/dynamodb/api_op_ListContributorInsights.go @@ -121,6 +121,9 @@ func (c *Client) addOperationListContributorInsightsMiddlewares(stack *middlewar if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListContributorInsights(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListExports.go b/service/dynamodb/api_op_ListExports.go index c3269f1b93e..f681dfe5392 100644 --- a/service/dynamodb/api_op_ListExports.go +++ b/service/dynamodb/api_op_ListExports.go @@ -122,6 +122,9 @@ func (c *Client) addOperationListExportsMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListExports(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListGlobalTables.go b/service/dynamodb/api_op_ListGlobalTables.go index 8d85b5725ca..1903fe9dfcf 100644 --- a/service/dynamodb/api_op_ListGlobalTables.go +++ b/service/dynamodb/api_op_ListGlobalTables.go @@ -141,6 +141,9 @@ func (c *Client) addOperationListGlobalTablesMiddlewares(stack *middleware.Stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListGlobalTables(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListImports.go b/service/dynamodb/api_op_ListImports.go index 69a508baed5..baeb7e815ff 100644 --- a/service/dynamodb/api_op_ListImports.go +++ b/service/dynamodb/api_op_ListImports.go @@ -122,6 +122,9 @@ func (c *Client) addOperationListImportsMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListImports(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListTables.go b/service/dynamodb/api_op_ListTables.go index 94357ac8c2b..e9c44c611b6 100644 --- a/service/dynamodb/api_op_ListTables.go +++ b/service/dynamodb/api_op_ListTables.go @@ -136,6 +136,9 @@ func (c *Client) addOperationListTablesMiddlewares(stack *middleware.Stack, opti if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListTables(options.Region), middleware.Before); err != nil { return err } diff --git a/service/dynamodb/api_op_ListTagsOfResource.go b/service/dynamodb/api_op_ListTagsOfResource.go index d897d36ca01..4544bfa036c 100644 --- a/service/dynamodb/api_op_ListTagsOfResource.go +++ b/service/dynamodb/api_op_ListTagsOfResource.go @@ -132,6 +132,9 @@ func (c *Client) addOperationListTagsOfResourceMiddlewares(stack *middleware.Sta if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpListTagsOfResourceValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_PutItem.go b/service/dynamodb/api_op_PutItem.go index bd0757937fe..ca55b472cc4 100644 --- a/service/dynamodb/api_op_PutItem.go +++ b/service/dynamodb/api_op_PutItem.go @@ -347,6 +347,9 @@ func (c *Client) addOperationPutItemMiddlewares(stack *middleware.Stack, options if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpPutItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_PutResourcePolicy.go b/service/dynamodb/api_op_PutResourcePolicy.go index e843615cac2..2937a3d7d88 100644 --- a/service/dynamodb/api_op_PutResourcePolicy.go +++ b/service/dynamodb/api_op_PutResourcePolicy.go @@ -174,6 +174,9 @@ func (c *Client) addOperationPutResourcePolicyMiddlewares(stack *middleware.Stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpPutResourcePolicyValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_Query.go b/service/dynamodb/api_op_Query.go index cbaf16b7d26..e8bf1897820 100644 --- a/service/dynamodb/api_op_Query.go +++ b/service/dynamodb/api_op_Query.go @@ -516,6 +516,9 @@ func (c *Client) addOperationQueryMiddlewares(stack *middleware.Stack, options O if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpQueryValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_RestoreTableFromBackup.go b/service/dynamodb/api_op_RestoreTableFromBackup.go index b0e9ea79be7..1071e74fdd6 100644 --- a/service/dynamodb/api_op_RestoreTableFromBackup.go +++ b/service/dynamodb/api_op_RestoreTableFromBackup.go @@ -162,6 +162,9 @@ func (c *Client) addOperationRestoreTableFromBackupMiddlewares(stack *middleware if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpRestoreTableFromBackupValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_RestoreTableToPointInTime.go b/service/dynamodb/api_op_RestoreTableToPointInTime.go index 2c06755813c..6373c8b5ea0 100644 --- a/service/dynamodb/api_op_RestoreTableToPointInTime.go +++ b/service/dynamodb/api_op_RestoreTableToPointInTime.go @@ -194,6 +194,9 @@ func (c *Client) addOperationRestoreTableToPointInTimeMiddlewares(stack *middlew if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpRestoreTableToPointInTimeValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_Scan.go b/service/dynamodb/api_op_Scan.go index 8dfb0f79cfa..bf6060afae6 100644 --- a/service/dynamodb/api_op_Scan.go +++ b/service/dynamodb/api_op_Scan.go @@ -447,6 +447,9 @@ func (c *Client) addOperationScanMiddlewares(stack *middleware.Stack, options Op if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpScanValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_TagResource.go b/service/dynamodb/api_op_TagResource.go index 5dcd57b168f..aa829a76cf4 100644 --- a/service/dynamodb/api_op_TagResource.go +++ b/service/dynamodb/api_op_TagResource.go @@ -137,6 +137,9 @@ func (c *Client) addOperationTagResourceMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpTagResourceValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_TransactGetItems.go b/service/dynamodb/api_op_TransactGetItems.go index 14a312a1f10..edb9e4136a2 100644 --- a/service/dynamodb/api_op_TransactGetItems.go +++ b/service/dynamodb/api_op_TransactGetItems.go @@ -153,6 +153,9 @@ func (c *Client) addOperationTransactGetItemsMiddlewares(stack *middleware.Stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpTransactGetItemsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_TransactWriteItems.go b/service/dynamodb/api_op_TransactWriteItems.go index 81dd0cd6dcc..fa757eb503e 100644 --- a/service/dynamodb/api_op_TransactWriteItems.go +++ b/service/dynamodb/api_op_TransactWriteItems.go @@ -220,6 +220,9 @@ func (c *Client) addOperationTransactWriteItemsMiddlewares(stack *middleware.Sta if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addIdempotencyToken_opTransactWriteItemsMiddleware(stack, options); err != nil { return err } diff --git a/service/dynamodb/api_op_UntagResource.go b/service/dynamodb/api_op_UntagResource.go index 688114c9fe8..53023c12e83 100644 --- a/service/dynamodb/api_op_UntagResource.go +++ b/service/dynamodb/api_op_UntagResource.go @@ -135,6 +135,9 @@ func (c *Client) addOperationUntagResourceMiddlewares(stack *middleware.Stack, o if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUntagResourceValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateContinuousBackups.go b/service/dynamodb/api_op_UpdateContinuousBackups.go index 6064307bfaa..8f7f7dde495 100644 --- a/service/dynamodb/api_op_UpdateContinuousBackups.go +++ b/service/dynamodb/api_op_UpdateContinuousBackups.go @@ -135,6 +135,9 @@ func (c *Client) addOperationUpdateContinuousBackupsMiddlewares(stack *middlewar if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateContinuousBackupsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateContributorInsights.go b/service/dynamodb/api_op_UpdateContributorInsights.go index 3e5bca7b9c4..5c257cd7d8c 100644 --- a/service/dynamodb/api_op_UpdateContributorInsights.go +++ b/service/dynamodb/api_op_UpdateContributorInsights.go @@ -133,6 +133,9 @@ func (c *Client) addOperationUpdateContributorInsightsMiddlewares(stack *middlew if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateContributorInsightsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateGlobalTable.go b/service/dynamodb/api_op_UpdateGlobalTable.go index 9718645d35a..82ad203bd5f 100644 --- a/service/dynamodb/api_op_UpdateGlobalTable.go +++ b/service/dynamodb/api_op_UpdateGlobalTable.go @@ -158,6 +158,9 @@ func (c *Client) addOperationUpdateGlobalTableMiddlewares(stack *middleware.Stac if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateGlobalTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateGlobalTableSettings.go b/service/dynamodb/api_op_UpdateGlobalTableSettings.go index 764138dadfa..699f2fedf1a 100644 --- a/service/dynamodb/api_op_UpdateGlobalTableSettings.go +++ b/service/dynamodb/api_op_UpdateGlobalTableSettings.go @@ -159,6 +159,9 @@ func (c *Client) addOperationUpdateGlobalTableSettingsMiddlewares(stack *middlew if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateGlobalTableSettingsValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateItem.go b/service/dynamodb/api_op_UpdateItem.go index 61bec1ce91a..8ba14f75de8 100644 --- a/service/dynamodb/api_op_UpdateItem.go +++ b/service/dynamodb/api_op_UpdateItem.go @@ -400,6 +400,9 @@ func (c *Client) addOperationUpdateItemMiddlewares(stack *middleware.Stack, opti if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateItemValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go b/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go index 2cb502024a3..dbd4934405f 100644 --- a/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go +++ b/service/dynamodb/api_op_UpdateKinesisStreamingDestination.go @@ -134,6 +134,9 @@ func (c *Client) addOperationUpdateKinesisStreamingDestinationMiddlewares(stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateKinesisStreamingDestinationValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateTable.go b/service/dynamodb/api_op_UpdateTable.go index 87308e7d59d..0538b4bcf03 100644 --- a/service/dynamodb/api_op_UpdateTable.go +++ b/service/dynamodb/api_op_UpdateTable.go @@ -235,6 +235,9 @@ func (c *Client) addOperationUpdateTableMiddlewares(stack *middleware.Stack, opt if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateTableValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go b/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go index fdd0c6acb65..6d4e2a42e46 100644 --- a/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go +++ b/service/dynamodb/api_op_UpdateTableReplicaAutoScaling.go @@ -128,6 +128,9 @@ func (c *Client) addOperationUpdateTableReplicaAutoScalingMiddlewares(stack *mid if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateTableReplicaAutoScalingValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/api_op_UpdateTimeToLive.go b/service/dynamodb/api_op_UpdateTimeToLive.go index 2ff1fcc9570..ee9debab5e0 100644 --- a/service/dynamodb/api_op_UpdateTimeToLive.go +++ b/service/dynamodb/api_op_UpdateTimeToLive.go @@ -152,6 +152,9 @@ func (c *Client) addOperationUpdateTimeToLiveMiddlewares(stack *middleware.Stack if err = addUserAgentRetryMode(stack, options); err != nil { return err } + if err = addUserAgentAccountIDEndpointMode(stack, options); err != nil { + return err + } if err = addOpUpdateTimeToLiveValidationMiddleware(stack); err != nil { return err } diff --git a/service/dynamodb/useragent_accountidendpointmode_test.go b/service/dynamodb/useragent_accountidendpointmode_test.go new file mode 100644 index 00000000000..4ac6184f72c --- /dev/null +++ b/service/dynamodb/useragent_accountidendpointmode_test.go @@ -0,0 +1,79 @@ +package dynamodb + +import ( + "context" + "net/http" + "strings" + "testing" + + "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" +) + +type captureUserAgentFeatures struct { + ua string + features []string +} + +func (u *captureUserAgentFeatures) Do(r *http.Request) (*http.Response, error) { + u.ua = r.Header.Get("User-Agent") + parts := strings.Split(u.ua, " ") + + var features string + for _, part := range parts { + if strings.HasPrefix(part, "m/") { + features = part + break + } + } + + if len(features) > 2 { + u.features = strings.Split(features[2:], ",") + } + return &http.Response{StatusCode: 403, Body: http.NoBody}, nil +} + +type mockCredentials struct{} + +// bypass the "do you have an account ID if necessary" checker +func (mockCredentials) Retrieve(ctx context.Context) (aws.Credentials, error) { + return aws.Credentials{ + AccountID: "1234567890", + }, nil +} + +func TestUserAgent_AccountIDEndpointMode(t *testing.T) { + for name, tt := range map[string]struct { + Config aws.AccountIDEndpointMode + Expect awsmiddleware.UserAgentFeature + }{ + "preferred": {aws.AccountIDEndpointModePreferred, awsmiddleware.UserAgentFeatureAccountIDModePreferred}, + "required": {aws.AccountIDEndpointModeRequired, awsmiddleware.UserAgentFeatureAccountIDModeRequired}, + "disabled": {aws.AccountIDEndpointModeDisabled, awsmiddleware.UserAgentFeatureAccountIDModeDisabled}, + } { + t.Run(name, func(t *testing.T) { + var ua captureUserAgentFeatures + client := New(Options{ + Region: "us-east-1", + AccountIDEndpointMode: tt.Config, + HTTPClient: &ua, + Credentials: mockCredentials{}, + }) + + client.Scan(context.Background(), &ScanInput{ + TableName: aws.String("foo"), + }) + expectContains(t, ua.features, string(tt.Expect)) + }) + } +} + +func expectContains(t *testing.T, have []string, want string) { + t.Helper() + for _, s := range have { + if s == want { + return + } + } + t.Errorf("[]string %v did not contain %s", have, want) +}