From 80b4ff138438a5d550e4c62cedc6c661f9e3a290 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 1 Nov 2022 14:12:07 +0000 Subject: [PATCH 1/4] fix(client-s3-control): restrict Bucket param dedupe to S3 only --- .../src/protocols/Aws_restXml.ts | 33 ++++++++++++------- .../aws/typescript/codegen/AwsRestXml.java | 17 ++++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/clients/client-s3-control/src/protocols/Aws_restXml.ts b/clients/client-s3-control/src/protocols/Aws_restXml.ts index 164c35b09e19..b13b8cf6647a 100644 --- a/clients/client-s3-control/src/protocols/Aws_restXml.ts +++ b/clients/client-s3-control/src/protocols/Aws_restXml.ts @@ -435,7 +435,8 @@ export const serializeAws_restXmlCreateBucketCommand = async ( ], "x-amz-outpost-id": input.OutpostId!, }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; if (input.CreateBucketConfiguration !== undefined) { @@ -742,7 +743,8 @@ export const serializeAws_restXmlDeleteBucketCommand = async ( const headers: any = map({}, isSerializableHeaderValue, { "x-amz-account-id": input.AccountId!, }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -776,7 +778,8 @@ export const serializeAws_restXmlDeleteBucketLifecycleConfigurationCommand = asy "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + + "/v20180820/bucket/{Bucket}/lifecycleconfiguration"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -809,7 +812,8 @@ export const serializeAws_restXmlDeleteBucketPolicyCommand = async ( const headers: any = map({}, isSerializableHeaderValue, { "x-amz-account-id": input.AccountId!, }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -843,7 +847,7 @@ export const serializeAws_restXmlDeleteBucketTaggingCommand = async ( "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -1379,7 +1383,8 @@ export const serializeAws_restXmlGetBucketCommand = async ( const headers: any = map({}, isSerializableHeaderValue, { "x-amz-account-id": input.AccountId!, }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -1413,7 +1418,8 @@ export const serializeAws_restXmlGetBucketLifecycleConfigurationCommand = async "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + + "/v20180820/bucket/{Bucket}/lifecycleconfiguration"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -1446,7 +1452,8 @@ export const serializeAws_restXmlGetBucketPolicyCommand = async ( const headers: any = map({}, isSerializableHeaderValue, { "x-amz-account-id": input.AccountId!, }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -1480,7 +1487,7 @@ export const serializeAws_restXmlGetBucketTaggingCommand = async ( "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; let { hostname: resolvedHostname } = await context.endpoint(); @@ -2145,7 +2152,8 @@ export const serializeAws_restXmlPutBucketLifecycleConfigurationCommand = async "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + + "/v20180820/bucket/{Bucket}/lifecycleconfiguration"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; if (input.LifecycleConfiguration !== undefined) { @@ -2193,7 +2201,8 @@ export const serializeAws_restXmlPutBucketPolicyCommand = async ( () => input.ConfirmRemoveSelfBucketAccess!.toString(), ], }); - let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy"; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; body = ''; @@ -2236,7 +2245,7 @@ export const serializeAws_restXmlPutBucketTaggingCommand = async ( "x-amz-account-id": input.AccountId!, }); let resolvedPath = - `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging"; + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging"; resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false); let body: any; if (input.Tagging !== undefined) { diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 75a450db27bd..23bfd7f57d80 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -17,8 +17,11 @@ import static software.amazon.smithy.aws.typescript.codegen.propertyaccess.PropertyAccessor.getFrom; +import java.util.Collections; import java.util.List; import java.util.Set; + +import software.amazon.smithy.aws.traits.ServiceTrait; import software.amazon.smithy.aws.traits.protocols.RestXmlTrait; import software.amazon.smithy.codegen.core.SymbolProvider; import software.amazon.smithy.codegen.core.SymbolReference; @@ -368,6 +371,20 @@ private void deserializeDocumentBody( } } + @Override + public void generateRequestSerializers(GenerationContext context) { + String serviceId = context.getService() + .getTrait(ServiceTrait.class) + .map(ServiceTrait::getSdkId) + .orElse(""); + if (serviceId.equals("S3")) { + setContextParamDeduplicationParamControlSet(Collections.singleton("Bucket")); + } else { + setContextParamDeduplicationParamControlSet(Collections.emptySet()); + } + super.generateRequestSerializers(context); + } + @Override public void generateProtocolTests(GenerationContext context) { AwsProtocolUtils.generateProtocolTests(this, context); From f550937c8c677329879cc6bb1d0a28a0685603c2 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 1 Nov 2022 12:45:40 -0400 Subject: [PATCH 2/4] fix(s3-control): no-op rerun status checks --- .../amazon/smithy/aws/typescript/codegen/AwsRestXml.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 23bfd7f57d80..34e9979cc223 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -377,7 +377,8 @@ public void generateRequestSerializers(GenerationContext context) { .getTrait(ServiceTrait.class) .map(ServiceTrait::getSdkId) .orElse(""); - if (serviceId.equals("S3")) { + +if (serviceId.equals("S3")) { setContextParamDeduplicationParamControlSet(Collections.singleton("Bucket")); } else { setContextParamDeduplicationParamControlSet(Collections.emptySet()); From 4202b37e95a8cd3fee891013911477fff858b0ff Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 1 Nov 2022 12:46:29 -0400 Subject: [PATCH 3/4] chore(formatting): fix indentation --- .../amazon/smithy/aws/typescript/codegen/AwsRestXml.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 34e9979cc223..20ff26a14a5d 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -378,7 +378,7 @@ public void generateRequestSerializers(GenerationContext context) { .map(ServiceTrait::getSdkId) .orElse(""); -if (serviceId.equals("S3")) { + if (serviceId.equals("S3")) { setContextParamDeduplicationParamControlSet(Collections.singleton("Bucket")); } else { setContextParamDeduplicationParamControlSet(Collections.emptySet()); From 1fd8f517c42b019def637802f44ab44285859bb4 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 1 Nov 2022 13:27:39 -0400 Subject: [PATCH 4/4] chore(format): delete empty line --- .../amazon/smithy/aws/typescript/codegen/AwsRestXml.java | 1 - 1 file changed, 1 deletion(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 20ff26a14a5d..f4aa1b2bab4a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.List; import java.util.Set; - import software.amazon.smithy.aws.traits.ServiceTrait; import software.amazon.smithy.aws.traits.protocols.RestXmlTrait; import software.amazon.smithy.codegen.core.SymbolProvider;