Skip to content

Commit

Permalink
fix(client-s3): disable bucket endpoint pluggin for WriteGetObjectRes…
Browse files Browse the repository at this point in the history
…ponseCommand
  • Loading branch information
AllanZhengYP committed Feb 21, 2022
1 parent 1e3faa1 commit 53f46a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
@@ -1,4 +1,3 @@
import { getBucketEndpointPlugin } from "@aws-sdk/middleware-bucket-endpoint";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
Expand Down Expand Up @@ -93,7 +92,6 @@ export class WriteGetObjectResponseCommand extends $Command<
options?: __HttpHandlerOptions
): Handler<WriteGetObjectResponseCommandInput, WriteGetObjectResponseCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(getBucketEndpointPlugin(configuration));

const stack = clientStack.concat(this.middlewareStack);

Expand Down
3 changes: 3 additions & 0 deletions codegen/.vscode/settings.json
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
Expand Up @@ -55,7 +55,9 @@
public final class AddS3Config implements TypeScriptIntegration {
private static final Logger LOGGER = Logger.getLogger(AddS3Config.class.getName());

private static final Set<String> SSEC_OPERATIONS = SetUtils.of("SSECustomerKey", "CopySourceSSECustomerKey");
private static final Set<String> SSEC_INPUT_KEYS = SetUtils.of("SSECustomerKey", "CopySourceSSECustomerKey");

private static final Set<String> BUCKET_ENDPOINT_INPUT_KEYS = SetUtils.of("Bucket");

private static final Set<String> NON_BUCKET_ENDPOINT_OPERATIONS = SetUtils.of(
"CreateBucket",
Expand Down Expand Up @@ -178,14 +180,13 @@ && testServiceId(s))
.build(),
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.SSEC_MIDDLEWARE.dependency, "Ssec", HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, SSEC_OPERATIONS)
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, SSEC_INPUT_KEYS)
&& testServiceId(s))
.build(),
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.LOCATION_CONSTRAINT.dependency, "LocationConstraint",
HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("CreateBucket")
&& testServiceId(s))
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("CreateBucket") && testServiceId(s))
.build(),
/**
* BUCKET_ENDPOINT_MIDDLEWARE needs two separate plugins. The first resolves the config in the client.
Expand All @@ -200,7 +201,8 @@ && testServiceId(s))
.withConventions(AwsDependency.BUCKET_ENDPOINT_MIDDLEWARE.dependency, "BucketEndpoint",
HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> !NON_BUCKET_ENDPOINT_OPERATIONS.contains(o.getId().getName(s))
&& testServiceId(s))
&& testServiceId(s)
&& testInputContainsMember(m, o, BUCKET_ENDPOINT_INPUT_KEYS))
.build()
);
}
Expand Down

0 comments on commit 53f46a0

Please sign in to comment.