|
16 | 16 | package software.amazon.smithy.aws.typescript.codegen;
|
17 | 17 |
|
18 | 18 | import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isAwsService;
|
| 19 | +import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isEndpointsV2Service; |
19 | 20 | import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isSigV4Service;
|
20 | 21 | import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_CONFIG;
|
21 | 22 | import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;
|
@@ -46,82 +47,89 @@ public List<RuntimeClientPlugin> getClientPlugins() {
|
46 | 47 | // Note that order is significant because configurations might
|
47 | 48 | // rely on previously resolved values.
|
48 | 49 | return ListUtils.of(
|
49 |
| - RuntimeClientPlugin.builder() |
50 |
| - .withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Region", HAS_CONFIG) |
51 |
| - .servicePredicate((m, s) -> isAwsService(s) || isSigV4Service(s)) |
52 |
| - .build(), |
53 |
| - // Only one of Endpoints or CustomEndpoints should be used |
54 |
| - RuntimeClientPlugin.builder() |
55 |
| - .withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Endpoints", HAS_CONFIG) |
56 |
| - .servicePredicate((m, s) -> isAwsService(s)) |
57 |
| - .build(), |
58 |
| - RuntimeClientPlugin.builder() |
59 |
| - .withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "CustomEndpoints", HAS_CONFIG) |
60 |
| - .servicePredicate((m, s) -> !isAwsService(s)) |
61 |
| - .build(), |
62 |
| - RuntimeClientPlugin.builder() |
63 |
| - .withConventions(TypeScriptDependency.MIDDLEWARE_RETRY.dependency, "Retry") |
64 |
| - .build(), |
65 |
| - RuntimeClientPlugin.builder() |
66 |
| - .withConventions(TypeScriptDependency.MIDDLEWARE_CONTENT_LENGTH.dependency, "ContentLength", |
67 |
| - HAS_MIDDLEWARE) |
68 |
| - .build(), |
69 |
| - RuntimeClientPlugin.builder() |
70 |
| - .withConventions(AwsDependency.ACCEPT_HEADER.dependency, "AcceptHeader", |
71 |
| - HAS_MIDDLEWARE) |
72 |
| - .servicePredicate((m, s) -> testServiceId(s, "API Gateway")) |
73 |
| - .build(), |
74 |
| - RuntimeClientPlugin.builder() |
75 |
| - .withConventions(AwsDependency.GLACIER_MIDDLEWARE.dependency, |
76 |
| - "Glacier", HAS_MIDDLEWARE) |
77 |
| - .servicePredicate((m, s) -> testServiceId(s, "Glacier")) |
78 |
| - .build(), |
79 |
| - RuntimeClientPlugin.builder() |
80 |
| - .withConventions(AwsDependency.EC2_MIDDLEWARE.dependency, |
81 |
| - "CopySnapshotPresignedUrl", HAS_MIDDLEWARE) |
82 |
| - .operationPredicate((m, s, o) -> o.getId().getName(s).equals("CopySnapshot") |
83 |
| - && testServiceId(s, "EC2")) |
84 |
| - .build(), |
85 |
| - RuntimeClientPlugin.builder() |
86 |
| - .withConventions(AwsDependency.MACHINELEARNING_MIDDLEWARE.dependency, "PredictEndpoint", |
87 |
| - HAS_MIDDLEWARE) |
88 |
| - .operationPredicate((m, s, o) -> o.getId().getName(s).equals("Predict") |
89 |
| - && testServiceId(s, "Machine Learning")) |
90 |
| - .build(), |
91 |
| - RuntimeClientPlugin.builder() |
92 |
| - .withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency, |
93 |
| - "ChangeResourceRecordSets", HAS_MIDDLEWARE) |
94 |
| - .operationPredicate((m, s, o) -> o.getId().getName(s).equals("ChangeResourceRecordSets") |
95 |
| - && testServiceId(s, "Route 53")) |
96 |
| - .build(), |
97 |
| - RuntimeClientPlugin.builder() |
98 |
| - .withConventions(AwsDependency.ROUTE53_MIDDLEWARE.dependency, "IdNormalizer", |
99 |
| - HAS_MIDDLEWARE) |
100 |
| - .operationPredicate((m, s, o) -> testInputContainsMember(m, o, ROUTE_53_ID_MEMBERS) |
101 |
| - && testServiceId(s, "Route 53")) |
102 |
| - .build(), |
103 |
| - RuntimeClientPlugin.builder() |
104 |
| - .withConventions(AwsDependency.MIDDLEWARE_HOST_HEADER.dependency, "HostHeader") |
105 |
| - .build(), |
106 |
| - RuntimeClientPlugin.builder() |
107 |
| - .withConventions(AwsDependency.MIDDLEWARE_LOGGER.dependency, "Logger", HAS_MIDDLEWARE) |
108 |
| - .build(), |
109 |
| - RuntimeClientPlugin.builder() |
110 |
| - .withConventions(AwsDependency.RECURSION_DETECTION_MIDDLEWARE.dependency, |
111 |
| - "RecursionDetection", HAS_MIDDLEWARE) |
112 |
| - .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() |
113 | 121 | );
|
114 | 122 | }
|
115 | 123 |
|
116 | 124 | private static boolean testInputContainsMember(
|
117 |
| - Model model, |
118 |
| - OperationShape operationShape, |
119 |
| - Set<String> expectedMemberNames |
| 125 | + Model model, |
| 126 | + OperationShape operationShape, |
| 127 | + Set<String> expectedMemberNames |
120 | 128 | ) {
|
121 | 129 | OperationIndex operationIndex = OperationIndex.of(model);
|
122 | 130 | return operationIndex.getInput(operationShape)
|
123 |
| - .filter(input -> input.getMemberNames().stream().anyMatch(expectedMemberNames::contains)) |
124 |
| - .isPresent(); |
| 131 | + .filter(input -> input.getMemberNames().stream().anyMatch(expectedMemberNames::contains)) |
| 132 | + .isPresent(); |
125 | 133 | }
|
126 | 134 |
|
127 | 135 | private static boolean testServiceId(Shape serviceShape, String expectedId) {
|
|
0 commit comments