Skip to content

Commit a8502a7

Browse files
authored
chore(codegen): read Endpoint Discovery Command from trait (#2524)
1 parent 623f80f commit a8502a7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ public List<RuntimeClientPlugin> getClientPlugins() {
6969
RuntimeClientPlugin.builder()
7070
.withConventions(AwsDependency.MIDDLEWARE_ENDPOINT_DISCOVERY.dependency,
7171
"EndpointDiscovery", RuntimeClientPlugin.Convention.HAS_CONFIG)
72-
// ToDo: The Endpoint Discovery Command Name needs to be read from ClientEndpointDiscoveryTrait.
7372
.additionalResolveFunctionParamsSupplier((m, s, o) -> new HashMap<String, Object>() {{
7473
put("endpointDiscoveryCommandCtor",
75-
Symbol.builder().name("DescribeEndpointsCommand").build());
74+
Symbol.builder().name(getClientDiscoveryCommand(s)).build());
7675
}})
7776
.servicePredicate((m, s) -> hasClientEndpointDiscovery(s))
7877
.build(),
@@ -161,4 +160,13 @@ private static boolean isClientDiscoveredEndpointOptional(ServiceShape service,
161160
}
162161
return false;
163162
}
163+
164+
private static String getClientDiscoveryCommand(ServiceShape service) {
165+
if (!hasClientEndpointDiscovery(service)) {
166+
throw new CodegenException(
167+
"EndpointDiscovery command discovery attempt for service without endpoint discovery"
168+
);
169+
}
170+
return service.getTrait(ClientEndpointDiscoveryTrait.class).orElse(null).getOperation().getName() + "Command";
171+
}
164172
}

0 commit comments

Comments
 (0)