Skip to content

Commit

Permalink
fix(client-s3-control): restrict Bucket param dedupe to S3 only (#4132)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Nov 1, 2022
1 parent 33f5ef6 commit 80634b7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
33 changes: 21 additions & 12 deletions clients/client-s3-control/src/protocols/Aws_restXml.ts
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = '<?xml version="1.0" encoding="UTF-8"?>';
Expand Down Expand Up @@ -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) {
Expand Down
Expand Up @@ -17,8 +17,10 @@

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;
Expand Down Expand Up @@ -368,6 +370,21 @@ 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);
Expand Down

0 comments on commit 80634b7

Please sign in to comment.