Skip to content

Commit 8c5abe8

Browse files
committed
feat(endpoint): codegen formatting
1 parent 8aa8b04 commit 8c5abe8

File tree

2 files changed

+84
-83
lines changed

2 files changed

+84
-83
lines changed

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

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -47,86 +47,89 @@ public List<RuntimeClientPlugin> getClientPlugins() {
4747
// Note that order is significant because configurations might
4848
// rely on previously resolved values.
4949
return ListUtils.of(
50-
RuntimeClientPlugin.builder()
51-
.withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Region", HAS_CONFIG)
52-
.servicePredicate((m, s) -> isAwsService(s) || isSigV4Service(s))
53-
.build(),
54-
// Only one of Endpoints or CustomEndpoints should be used
55-
RuntimeClientPlugin.builder()
56-
.withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Endpoints", HAS_CONFIG)
57-
.servicePredicate((m, s) -> isAwsService(s) && !isEndpointsV2Service(s))
58-
.build(),
59-
RuntimeClientPlugin.builder()
60-
.withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "CustomEndpoints", HAS_CONFIG)
61-
.servicePredicate((m, s) -> !isAwsService(s) && !isEndpointsV2Service(s))
62-
.build(),
63-
RuntimeClientPlugin.builder()
64-
.withConventions(TypeScriptDependency.MIDDLEWARE_ENDPOINTS_V2.dependency, "Endpoint", HAS_CONFIG)
65-
.servicePredicate((m, s) -> isAwsService(s) && isEndpointsV2Service(s))
66-
.build(),
67-
RuntimeClientPlugin.builder()
68-
.withConventions(TypeScriptDependency.MIDDLEWARE_RETRY.dependency, "Retry")
69-
.build(),
70-
RuntimeClientPlugin.builder()
71-
.withConventions(TypeScriptDependency.MIDDLEWARE_CONTENT_LENGTH.dependency, "ContentLength",
72-
HAS_MIDDLEWARE)
73-
.build(),
74-
RuntimeClientPlugin.builder()
75-
.withConventions(AwsDependency.ACCEPT_HEADER.dependency, "AcceptHeader",
76-
HAS_MIDDLEWARE)
77-
.servicePredicate((m, s) -> testServiceId(s, "API Gateway"))
78-
.build(),
79-
RuntimeClientPlugin.builder()
80-
.withConventions(AwsDependency.GLACIER_MIDDLEWARE.dependency,
81-
"Glacier", HAS_MIDDLEWARE)
82-
.servicePredicate((m, s) -> testServiceId(s, "Glacier"))
83-
.build(),
84-
RuntimeClientPlugin.builder()
85-
.withConventions(AwsDependency.EC2_MIDDLEWARE.dependency,
86-
"CopySnapshotPresignedUrl", HAS_MIDDLEWARE)
87-
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("CopySnapshot")
88-
&& testServiceId(s, "EC2"))
89-
.build(),
90-
RuntimeClientPlugin.builder()
91-
.withConventions(AwsDependency.MACHINELEARNING_MIDDLEWARE.dependency, "PredictEndpoint",
92-
HAS_MIDDLEWARE)
93-
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("Predict")
94-
&& testServiceId(s, "Machine Learning"))
95-
.build(),
96-
RuntimeClientPlugin.builder()
97-
.withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency,
98-
"ChangeResourceRecordSets", HAS_MIDDLEWARE)
99-
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("ChangeResourceRecordSets")
100-
&& testServiceId(s, "Route 53"))
101-
.build(),
102-
RuntimeClientPlugin.builder()
103-
.withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency, "IdNormalizer",
104-
HAS_MIDDLEWARE)
105-
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, ROUTE_53_ID_MEMBERS)
106-
&& testServiceId(s, "Route 53"))
107-
.build(),
108-
RuntimeClientPlugin.builder()
109-
.withConventions(AwsDependency.MIDDLEWARE_HOST_HEADER.dependency, "HostHeader")
110-
.build(),
111-
RuntimeClientPlugin.builder()
112-
.withConventions(AwsDependency.MIDDLEWARE_LOGGER.dependency, "Logger", HAS_MIDDLEWARE)
113-
.build(),
114-
RuntimeClientPlugin.builder()
115-
.withConventions(AwsDependency.RECURSION_DETECTION_MIDDLEWARE.dependency,
116-
"RecursionDetection", HAS_MIDDLEWARE)
117-
.build()
50+
RuntimeClientPlugin.builder()
51+
.withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Region", HAS_CONFIG)
52+
.servicePredicate((m, s) -> isAwsService(s) || isSigV4Service(s))
53+
.build(),
54+
// Only one of Endpoints or CustomEndpoints should be used
55+
RuntimeClientPlugin.builder()
56+
.withConventions(
57+
TypeScriptDependency.CONFIG_RESOLVER.dependency, "Endpoints", HAS_CONFIG)
58+
.servicePredicate((m, s) -> isAwsService(s) && !isEndpointsV2Service(s))
59+
.build(),
60+
RuntimeClientPlugin.builder()
61+
.withConventions(
62+
TypeScriptDependency.CONFIG_RESOLVER.dependency, "CustomEndpoints", HAS_CONFIG)
63+
.servicePredicate((m, s) -> !isAwsService(s) && !isEndpointsV2Service(s))
64+
.build(),
65+
RuntimeClientPlugin.builder()
66+
.withConventions(
67+
TypeScriptDependency.MIDDLEWARE_ENDPOINTS_V2.dependency, "Endpoint", HAS_CONFIG)
68+
.servicePredicate((m, s) -> isAwsService(s) && isEndpointsV2Service(s))
69+
.build(),
70+
RuntimeClientPlugin.builder()
71+
.withConventions(TypeScriptDependency.MIDDLEWARE_RETRY.dependency, "Retry")
72+
.build(),
73+
RuntimeClientPlugin.builder()
74+
.withConventions(TypeScriptDependency.MIDDLEWARE_CONTENT_LENGTH.dependency, "ContentLength",
75+
HAS_MIDDLEWARE)
76+
.build(),
77+
RuntimeClientPlugin.builder()
78+
.withConventions(AwsDependency.ACCEPT_HEADER.dependency, "AcceptHeader",
79+
HAS_MIDDLEWARE)
80+
.servicePredicate((m, s) -> testServiceId(s, "API Gateway"))
81+
.build(),
82+
RuntimeClientPlugin.builder()
83+
.withConventions(AwsDependency.GLACIER_MIDDLEWARE.dependency,
84+
"Glacier", HAS_MIDDLEWARE)
85+
.servicePredicate((m, s) -> testServiceId(s, "Glacier"))
86+
.build(),
87+
RuntimeClientPlugin.builder()
88+
.withConventions(AwsDependency.EC2_MIDDLEWARE.dependency,
89+
"CopySnapshotPresignedUrl", HAS_MIDDLEWARE)
90+
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("CopySnapshot")
91+
&& testServiceId(s, "EC2"))
92+
.build(),
93+
RuntimeClientPlugin.builder()
94+
.withConventions(AwsDependency.MACHINELEARNING_MIDDLEWARE.dependency, "PredictEndpoint",
95+
HAS_MIDDLEWARE)
96+
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("Predict")
97+
&& testServiceId(s, "Machine Learning"))
98+
.build(),
99+
RuntimeClientPlugin.builder()
100+
.withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency,
101+
"ChangeResourceRecordSets", HAS_MIDDLEWARE)
102+
.operationPredicate((m, s, o) -> o.getId().getName(s).equals("ChangeResourceRecordSets")
103+
&& testServiceId(s, "Route 53"))
104+
.build(),
105+
RuntimeClientPlugin.builder()
106+
.withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency, "IdNormalizer",
107+
HAS_MIDDLEWARE)
108+
.operationPredicate((m, s, o) -> testInputContainsMember(m, o, ROUTE_53_ID_MEMBERS)
109+
&& testServiceId(s, "Route 53"))
110+
.build(),
111+
RuntimeClientPlugin.builder()
112+
.withConventions(AwsDependency.MIDDLEWARE_HOST_HEADER.dependency, "HostHeader")
113+
.build(),
114+
RuntimeClientPlugin.builder()
115+
.withConventions(AwsDependency.MIDDLEWARE_LOGGER.dependency, "Logger", HAS_MIDDLEWARE)
116+
.build(),
117+
RuntimeClientPlugin.builder()
118+
.withConventions(AwsDependency.RECURSION_DETECTION_MIDDLEWARE.dependency,
119+
"RecursionDetection", HAS_MIDDLEWARE)
120+
.build()
118121
);
119122
}
120123

121124
private static boolean testInputContainsMember(
122-
Model model,
123-
OperationShape operationShape,
124-
Set<String> expectedMemberNames
125+
Model model,
126+
OperationShape operationShape,
127+
Set<String> expectedMemberNames
125128
) {
126129
OperationIndex operationIndex = OperationIndex.of(model);
127130
return operationIndex.getInput(operationShape)
128-
.filter(input -> input.getMemberNames().stream().anyMatch(expectedMemberNames::contains))
129-
.isPresent();
131+
.filter(input -> input.getMemberNames().stream().anyMatch(expectedMemberNames::contains))
132+
.isPresent();
130133
}
131134

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

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.Map;
2525
import java.util.function.BiConsumer;
2626
import java.util.function.Consumer;
27-
28-
import com.sun.tools.javac.util.List;
2927
import software.amazon.smithy.codegen.core.SymbolProvider;
3028
import software.amazon.smithy.model.Model;
3129
import software.amazon.smithy.model.shapes.ServiceShape;
@@ -80,17 +78,17 @@ public void addConfigInterfaceFields(
8078
add("ClientResolvedEndpointParameters");
8179
add("resolveClientEndpointParameters");
8280
add("EndpointParameters");
83-
}}.forEach(name -> {
84-
writer.addImport(
85-
name,
86-
null,
87-
Paths.get(".", CodegenUtils.SOURCE_FOLDER, "endpoint/EndpointParameters").toString()
88-
);
89-
});
81+
}}.forEach(name -> writer.addImport(
82+
name,
83+
null,
84+
Paths.get(".", CodegenUtils.SOURCE_FOLDER, "endpoint/EndpointParameters").toString()
85+
));
9086

9187
writer.addImport("EndpointV2", "__EndpointV2", TypeScriptDependency.AWS_SDK_TYPES.packageName);
9288
} else {
93-
writer.addImport("RegionInfoProvider", "RegionInfoProvider", TypeScriptDependency.AWS_SDK_TYPES.packageName);
89+
writer.addImport(
90+
"RegionInfoProvider", null, TypeScriptDependency.AWS_SDK_TYPES.packageName
91+
);
9492
writer.writeDocs("Fetch related hostname, signing name or signing region with given region.\n"
9593
+ "@internal");
9694
writer.write("regionInfoProvider?: RegionInfoProvider;\n");

0 commit comments

Comments
 (0)