Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client-s3-control): restrict Bucket param dedupe to S3 only #4132

Merged
merged 4 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions clients/client-s3-control/src/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

kuhe marked this conversation as resolved.
Show resolved Hide resolved
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 +371,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")) {
kuhe marked this conversation as resolved.
Show resolved Hide resolved
setContextParamDeduplicationParamControlSet(Collections.singleton("Bucket"));
} else {
setContextParamDeduplicationParamControlSet(Collections.emptySet());
}
super.generateRequestSerializers(context);
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
Expand Down