Skip to content

Commit 80634b7

Browse files
authored
fix(client-s3-control): restrict Bucket param dedupe to S3 only (#4132)
1 parent 33f5ef6 commit 80634b7

File tree

2 files changed

+38
-12
lines changed
  • clients/client-s3-control/src/protocols
  • codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen

2 files changed

+38
-12
lines changed

clients/client-s3-control/src/protocols/Aws_restXml.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ export const serializeAws_restXmlCreateBucketCommand = async (
435435
],
436436
"x-amz-outpost-id": input.OutpostId!,
437437
});
438-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket";
438+
let resolvedPath =
439+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}";
439440
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
440441
let body: any;
441442
if (input.CreateBucketConfiguration !== undefined) {
@@ -742,7 +743,8 @@ export const serializeAws_restXmlDeleteBucketCommand = async (
742743
const headers: any = map({}, isSerializableHeaderValue, {
743744
"x-amz-account-id": input.AccountId!,
744745
});
745-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket";
746+
let resolvedPath =
747+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}";
746748
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
747749
let body: any;
748750
let { hostname: resolvedHostname } = await context.endpoint();
@@ -776,7 +778,8 @@ export const serializeAws_restXmlDeleteBucketLifecycleConfigurationCommand = asy
776778
"x-amz-account-id": input.AccountId!,
777779
});
778780
let resolvedPath =
779-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration";
781+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
782+
"/v20180820/bucket/{Bucket}/lifecycleconfiguration";
780783
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
781784
let body: any;
782785
let { hostname: resolvedHostname } = await context.endpoint();
@@ -809,7 +812,8 @@ export const serializeAws_restXmlDeleteBucketPolicyCommand = async (
809812
const headers: any = map({}, isSerializableHeaderValue, {
810813
"x-amz-account-id": input.AccountId!,
811814
});
812-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy";
815+
let resolvedPath =
816+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy";
813817
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
814818
let body: any;
815819
let { hostname: resolvedHostname } = await context.endpoint();
@@ -843,7 +847,7 @@ export const serializeAws_restXmlDeleteBucketTaggingCommand = async (
843847
"x-amz-account-id": input.AccountId!,
844848
});
845849
let resolvedPath =
846-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging";
850+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging";
847851
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
848852
let body: any;
849853
let { hostname: resolvedHostname } = await context.endpoint();
@@ -1379,7 +1383,8 @@ export const serializeAws_restXmlGetBucketCommand = async (
13791383
const headers: any = map({}, isSerializableHeaderValue, {
13801384
"x-amz-account-id": input.AccountId!,
13811385
});
1382-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket";
1386+
let resolvedPath =
1387+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}";
13831388
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
13841389
let body: any;
13851390
let { hostname: resolvedHostname } = await context.endpoint();
@@ -1413,7 +1418,8 @@ export const serializeAws_restXmlGetBucketLifecycleConfigurationCommand = async
14131418
"x-amz-account-id": input.AccountId!,
14141419
});
14151420
let resolvedPath =
1416-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration";
1421+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
1422+
"/v20180820/bucket/{Bucket}/lifecycleconfiguration";
14171423
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
14181424
let body: any;
14191425
let { hostname: resolvedHostname } = await context.endpoint();
@@ -1446,7 +1452,8 @@ export const serializeAws_restXmlGetBucketPolicyCommand = async (
14461452
const headers: any = map({}, isSerializableHeaderValue, {
14471453
"x-amz-account-id": input.AccountId!,
14481454
});
1449-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy";
1455+
let resolvedPath =
1456+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy";
14501457
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
14511458
let body: any;
14521459
let { hostname: resolvedHostname } = await context.endpoint();
@@ -1480,7 +1487,7 @@ export const serializeAws_restXmlGetBucketTaggingCommand = async (
14801487
"x-amz-account-id": input.AccountId!,
14811488
});
14821489
let resolvedPath =
1483-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging";
1490+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging";
14841491
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
14851492
let body: any;
14861493
let { hostname: resolvedHostname } = await context.endpoint();
@@ -2145,7 +2152,8 @@ export const serializeAws_restXmlPutBucketLifecycleConfigurationCommand = async
21452152
"x-amz-account-id": input.AccountId!,
21462153
});
21472154
let resolvedPath =
2148-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/lifecycleconfiguration";
2155+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
2156+
"/v20180820/bucket/{Bucket}/lifecycleconfiguration";
21492157
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
21502158
let body: any;
21512159
if (input.LifecycleConfiguration !== undefined) {
@@ -2193,7 +2201,8 @@ export const serializeAws_restXmlPutBucketPolicyCommand = async (
21932201
() => input.ConfirmRemoveSelfBucketAccess!.toString(),
21942202
],
21952203
});
2196-
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/policy";
2204+
let resolvedPath =
2205+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/policy";
21972206
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
21982207
let body: any;
21992208
body = '<?xml version="1.0" encoding="UTF-8"?>';
@@ -2236,7 +2245,7 @@ export const serializeAws_restXmlPutBucketTaggingCommand = async (
22362245
"x-amz-account-id": input.AccountId!,
22372246
});
22382247
let resolvedPath =
2239-
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/tagging";
2248+
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/v20180820/bucket/{Bucket}/tagging";
22402249
resolvedPath = __resolvedPath(resolvedPath, input, "Bucket", () => input.Bucket!, "{Bucket}", false);
22412250
let body: any;
22422251
if (input.Tagging !== undefined) {

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
import static software.amazon.smithy.aws.typescript.codegen.propertyaccess.PropertyAccessor.getFrom;
1919

20+
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Set;
23+
import software.amazon.smithy.aws.traits.ServiceTrait;
2224
import software.amazon.smithy.aws.traits.protocols.RestXmlTrait;
2325
import software.amazon.smithy.codegen.core.SymbolProvider;
2426
import software.amazon.smithy.codegen.core.SymbolReference;
@@ -368,6 +370,21 @@ private void deserializeDocumentBody(
368370
}
369371
}
370372

373+
@Override
374+
public void generateRequestSerializers(GenerationContext context) {
375+
String serviceId = context.getService()
376+
.getTrait(ServiceTrait.class)
377+
.map(ServiceTrait::getSdkId)
378+
.orElse("");
379+
380+
if (serviceId.equals("S3")) {
381+
setContextParamDeduplicationParamControlSet(Collections.singleton("Bucket"));
382+
} else {
383+
setContextParamDeduplicationParamControlSet(Collections.emptySet());
384+
}
385+
super.generateRequestSerializers(context);
386+
}
387+
371388
@Override
372389
public void generateProtocolTests(GenerationContext context) {
373390
AwsProtocolUtils.generateProtocolTests(this, context);

0 commit comments

Comments
 (0)