Skip to content

Commit a6bf106

Browse files
authored
Use the endpoint operation for client endpoin tests if exists (#3757)
If the service uses endpoint discovery, default to the service's endpoint operation, otherwise we risk picking an operation that relies on endpoint discovery, in which case the client endpoint tests will be useless because we skip using the Endpoints 2.0 endpoint provider if we have an endpoint from Endpoint Discovery.
1 parent 905088b commit a6bf106

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointRulesClientTestSpec.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ public ClassName className() {
134134
private String findDefaultRequest() {
135135
Map<String, OperationModel> operations = this.model.getOperations();
136136

137+
// If this is an endpoint discovery service, then use the endpoint
138+
// operation since it goes to the service endpoint
139+
Optional<String> endpointOperation = operations.entrySet()
140+
.stream()
141+
.filter(e -> e.getValue().isEndpointOperation())
142+
.map(Map.Entry::getKey)
143+
.findFirst();
144+
145+
if (endpointOperation.isPresent()) {
146+
return endpointOperation.get();
147+
}
148+
137149
// Ideally look for something that we don't need to set any parameters
138150
// on. That means either a request with no members or one that does not
139151
// have any members bound to the URI path

0 commit comments

Comments
 (0)