Skip to content

Commit 538e002

Browse files
committed
fix(client-docdb): remove cross-region copy for non-applicable apis
1 parent e9629e1 commit 538e002

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

clients/client-docdb/commands/CreateDBClusterCommand.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
deserializeAws_queryCreateDBClusterCommand,
55
serializeAws_queryCreateDBClusterCommand,
66
} from "../protocols/Aws_query";
7-
import { getCrossRegionPresignedUrlPlugin } from "@aws-sdk/middleware-sdk-rds";
87
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
98
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
109
import { Command as $Command } from "@aws-sdk/smithy-client";
@@ -61,7 +60,6 @@ export class CreateDBClusterCommand extends $Command<
6160
options?: __HttpHandlerOptions
6261
): Handler<CreateDBClusterCommandInput, CreateDBClusterCommandOutput> {
6362
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
64-
this.middlewareStack.use(getCrossRegionPresignedUrlPlugin(configuration));
6563

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

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,41 @@
1818
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;
1919

2020
import java.util.List;
21+
import java.util.Map;
2122
import java.util.Set;
23+
import java.util.stream.Collectors;
2224
import software.amazon.smithy.aws.traits.ServiceTrait;
2325
import software.amazon.smithy.model.shapes.Shape;
2426
import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
2527
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
26-
import software.amazon.smithy.utils.ListUtils;
28+
import software.amazon.smithy.utils.MapUtils;
2729
import software.amazon.smithy.utils.SetUtils;
2830
import software.amazon.smithy.utils.SmithyInternalApi;
2931

3032
@SmithyInternalApi
3133
public class AddCrossRegionCopyingPlugin implements TypeScriptIntegration {
32-
private static final Set<String> SHARED_PRESIGNED_URL_OPERATIONS = SetUtils.of(
33-
"CopyDBClusterSnapshot",
34-
"CreateDBCluster"
35-
);
36-
private static final Set<String> RDS_PRESIGNED_URL_OPERATIONS = SetUtils.of(
37-
"CopyDBSnapshot",
38-
"CreateDBInstanceReadReplica",
39-
"StartDBInstanceAutomatedBackupsReplication"
34+
private static final Map<String, Set<String>> PRESIGNED_URL_OPERATIONS_MAP = MapUtils.of(
35+
"RDS", SetUtils.of(
36+
"CopyDBClusterSnapshot",
37+
"CreateDBCluster",
38+
"CopyDBSnapshot",
39+
"CreateDBInstanceReadReplica",
40+
"StartDBInstanceAutomatedBackupsReplication"),
41+
"DocDB", SetUtils.of("CopyDBClusterSnapshot"),
42+
"Neptune", SetUtils.of("CopyDBClusterSnapshot", "CreateDBCluster")
4043
);
4144

4245
@Override
4346
public List<RuntimeClientPlugin> getClientPlugins() {
44-
return ListUtils.of(
45-
RuntimeClientPlugin.builder()
46-
.withConventions(AwsDependency.RDS_MIDDLEWARE.dependency, "CrossRegionPresignedUrl",
47-
HAS_MIDDLEWARE)
48-
.operationPredicate((m, s, o) -> RDS_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName(s))
49-
&& testServiceId(s, "RDS"))
50-
.build(),
51-
RuntimeClientPlugin.builder()
52-
.withConventions(AwsDependency.RDS_MIDDLEWARE.dependency, "CrossRegionPresignedUrl",
53-
HAS_MIDDLEWARE)
54-
.operationPredicate((m, s, o) -> SHARED_PRESIGNED_URL_OPERATIONS.contains(o.getId().getName(s))
55-
&& (testServiceId(s, "RDS") || testServiceId(s, "DocDB") || testServiceId(s, "Neptune")))
56-
.build()
57-
);
47+
return PRESIGNED_URL_OPERATIONS_MAP.entrySet().stream().map((entry) -> {
48+
String serviceId = entry.getKey();
49+
Set<String> commands = entry.getValue();
50+
return RuntimeClientPlugin.builder()
51+
.withConventions(AwsDependency.RDS_MIDDLEWARE.dependency, "CrossRegionPresignedUrl", HAS_MIDDLEWARE)
52+
.operationPredicate(
53+
(m, s, o) -> commands.contains(o.getId().getName(s)) && testServiceId(s, serviceId))
54+
.build();
55+
}).collect(Collectors.toList());
5856
}
5957

6058
private static boolean testServiceId(Shape serviceShape, String expectedId) {

0 commit comments

Comments
 (0)