Skip to content

Commit 938a73b

Browse files
committed
CRR support for DynamoDB
1 parent f4e75d4 commit 938a73b

File tree

49 files changed

+2018
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2018
-55
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/AddInputShapes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private ShapeModel generateInputShapeModel(Operation operation,
7979
shapeModel.setType(ShapeType.Request.getValue());
8080
shapeModel.setMarshaller(
8181
createInputShapeMarshaller(getServiceModel().getMetadata(), operation));
82+
shapeModel.setEndpointDiscovery(operation.getEndpointDiscovery());
8283

8384
return shapeModel;
8485
}

codegen/src/main/java/software/amazon/awssdk/codegen/AddOperations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public Map<String, OperationModel> constructOperations() {
158158
operationModel.setDocumentation(op.getDocumentation());
159159
operationModel.setIsAuthenticated(isAuthenticated(op));
160160
operationModel.setPaginated(isPaginated(op));
161+
operationModel.setEndpointOperation(op.isEndpointOperation());
162+
operationModel.setEndpointDiscovery(op.getEndpointDiscovery());
161163
operationModel.setEndpointTrait(op.getEndpoint());
162164

163165
Input input = op.getInput();

codegen/src/main/java/software/amazon/awssdk/codegen/AddShapes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ private MemberModel generateMemberModel(String c2jMemberName, Member c2jMemberDe
177177
memberModel.setIdempotencyToken(c2jMemberDefinition.isIdempotencyToken());
178178
memberModel.setEventPayload(c2jMemberDefinition.isEventPayload());
179179
memberModel.setEventHeader(c2jMemberDefinition.isEventHeader());
180+
memberModel.setEndpointDiscoveryId(c2jMemberDefinition.isEndpointDiscoveryId());
180181

181182
// Pass the xmlNameSpace from the member reference
182183
if (c2jMemberDefinition.getXmlNamespace() != null) {

codegen/src/main/java/software/amazon/awssdk/codegen/IntermediateModelBuilder.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ public IntermediateModel build() {
106106
operations.putAll(new AddOperations(this).constructOperations());
107107
authorizers.putAll(new AddCustomAuthorizers(this.service, getNamingStrategy()).constructAuthorizers());
108108

109+
OperationModel endpointOperation = null;
110+
111+
for (OperationModel o : operations.values()) {
112+
if (o.isEndpointOperation()) {
113+
endpointOperation = o;
114+
break;
115+
}
116+
}
117+
109118
for (IntermediateModelShapeProcessor processor : shapeProcessors) {
110119
shapes.putAll(processor.process(Collections.unmodifiableMap(operations),
111120
Collections.unmodifiableMap(shapes)));
@@ -119,7 +128,7 @@ public IntermediateModel build() {
119128

120129
IntermediateModel fullModel = new IntermediateModel(
121130
constructMetadata(service, customConfig), operations, shapes,
122-
customConfig, examples, authorizers, paginators.getPaginators(), namingStrategy);
131+
customConfig, examples, endpointOperation, authorizers, paginators.getPaginators(), namingStrategy);
123132

124133
customization.postprocess(fullModel);
125134

@@ -136,6 +145,7 @@ public IntermediateModel build() {
136145
trimmedShapes,
137146
fullModel.getCustomizationConfig(),
138147
fullModel.getExamples(),
148+
endpointOperation,
139149
fullModel.getCustomAuthorizers(),
140150
fullModel.getPaginators(),
141151
namingStrategy);

codegen/src/main/java/software/amazon/awssdk/codegen/emitters/tasks/AsyncClientGeneratorTasks.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
package software.amazon.awssdk.codegen.emitters.tasks;
1717

1818
import java.io.IOException;
19-
import java.util.Arrays;
19+
import java.util.ArrayList;
2020
import java.util.List;
2121
import software.amazon.awssdk.codegen.emitters.GeneratorTask;
2222
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
2323
import software.amazon.awssdk.codegen.poet.builder.AsyncClientBuilderClass;
2424
import software.amazon.awssdk.codegen.poet.builder.AsyncClientBuilderInterface;
2525
import software.amazon.awssdk.codegen.poet.client.AsyncClientClass;
2626
import software.amazon.awssdk.codegen.poet.client.AsyncClientInterface;
27+
import software.amazon.awssdk.codegen.poet.endpointdiscovery.EndpointDiscoveryAsyncCacheLoaderGenerator;
2728

2829
public class AsyncClientGeneratorTasks extends BaseGeneratorTasks {
2930

@@ -37,10 +38,16 @@ public AsyncClientGeneratorTasks(GeneratorTaskParams dependencies) {
3738
@Override
3839
protected List<GeneratorTask> createTasks() throws Exception {
3940
info("Emitting Async client classes");
40-
return Arrays.asList(createClientClassTask(),
41-
createClientBuilderTask(),
42-
createClientBuilderInterfaceTask(),
43-
createClientInterfaceTask());
41+
List<GeneratorTask> generatorTasks = new ArrayList<>();
42+
generatorTasks.add(createClientClassTask());
43+
generatorTasks.add(createClientBuilderTask());
44+
generatorTasks.add(createClientBuilderInterfaceTask());
45+
generatorTasks.add(createClientInterfaceTask());
46+
if (model.getEndpointOperation().isPresent()) {
47+
generatorTasks.add(createEndpointDiscoveryCacheLoaderTask());
48+
}
49+
50+
return generatorTasks;
4451
}
4552

4653
private GeneratorTask createClientClassTask() throws IOException {
@@ -58,4 +65,8 @@ private GeneratorTask createClientBuilderInterfaceTask() throws IOException {
5865
private GeneratorTask createClientInterfaceTask() throws IOException {
5966
return createPoetGeneratorTask(new AsyncClientInterface(model));
6067
}
68+
69+
private GeneratorTask createEndpointDiscoveryCacheLoaderTask() throws IOException {
70+
return createPoetGeneratorTask(new EndpointDiscoveryAsyncCacheLoaderGenerator(generatorTaskParams));
71+
}
6172
}

codegen/src/main/java/software/amazon/awssdk/codegen/emitters/tasks/SyncClientGeneratorTasks.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import software.amazon.awssdk.codegen.poet.client.ClientSimpleMethodsIntegrationTests;
2626
import software.amazon.awssdk.codegen.poet.client.SyncClientClass;
2727
import software.amazon.awssdk.codegen.poet.client.SyncClientInterface;
28+
import software.amazon.awssdk.codegen.poet.endpointdiscovery.EndpointDiscoveryCacheLoaderGenerator;
2829

2930
public class SyncClientGeneratorTasks extends BaseGeneratorTasks {
3031
private final GeneratorTaskParams generatorTaskParams;
@@ -50,6 +51,9 @@ protected List<GeneratorTask> createTasks() throws Exception {
5051
if (!model.simpleMethodsRequiringTesting().isEmpty()) {
5152
tasks.add(createClientSimpleMethodsTest());
5253
}
54+
if (model.getEndpointOperation().isPresent()) {
55+
tasks.add(createEndpointDiscoveryCacheLoaderTask());
56+
}
5357
return tasks;
5458
}
5559

@@ -72,4 +76,8 @@ private GeneratorTask createClientBuilderInterfaceTask() throws IOException {
7276
private GeneratorTask createClientSimpleMethodsTest() throws IOException {
7377
return createPoetGeneratorTestTask(new ClientSimpleMethodsIntegrationTests(model));
7478
}
79+
80+
private GeneratorTask createEndpointDiscoveryCacheLoaderTask() throws IOException {
81+
return createPoetGeneratorTask(new EndpointDiscoveryCacheLoaderGenerator(generatorTaskParams));
82+
}
7583
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.codegen.model.intermediate;
17+
18+
public class EndpointDiscovery {
19+
20+
private boolean required;
21+
22+
public boolean isRequired() {
23+
return required;
24+
}
25+
26+
public void setRequired(boolean required) {
27+
this.required = required;
28+
}
29+
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/IntermediateModel.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Collections;
2727
import java.util.List;
2828
import java.util.Map;
29+
import java.util.Optional;
2930
import java.util.stream.Collectors;
3031
import software.amazon.awssdk.awscore.AwsResponse;
3132
import software.amazon.awssdk.awscore.AwsResponseMetadata;
@@ -54,6 +55,9 @@ public final class IntermediateModel {
5455

5556
private final Map<String, AuthorizerModel> customAuthorizers;
5657

58+
@JsonIgnore
59+
private final Optional<OperationModel> endpointOperation;
60+
5761
@JsonIgnore
5862
private final Map<String, PaginatorDefinition> paginators;
5963

@@ -68,7 +72,8 @@ public IntermediateModel(
6872
@JsonProperty("customizationConfig") CustomizationConfig customizationConfig,
6973
@JsonProperty("serviceExamples") ServiceExamples examples) {
7074

71-
this(metadata, operations, shapes, customizationConfig, examples, Collections.emptyMap(), Collections.emptyMap(), null);
75+
this(metadata, operations, shapes, customizationConfig, examples, null,
76+
Collections.emptyMap(), Collections.emptyMap(), null);
7277
}
7378

7479
public IntermediateModel(
@@ -77,6 +82,7 @@ public IntermediateModel(
7782
Map<String, ShapeModel> shapes,
7883
CustomizationConfig customizationConfig,
7984
ServiceExamples examples,
85+
OperationModel endpointOperation,
8086
Map<String, AuthorizerModel> customAuthorizers,
8187
Map<String, PaginatorDefinition> paginators,
8288
NamingStrategy namingStrategy) {
@@ -85,6 +91,7 @@ public IntermediateModel(
8591
this.shapes = shapes;
8692
this.customizationConfig = customizationConfig;
8793
this.examples = examples;
94+
this.endpointOperation = Optional.ofNullable(endpointOperation);
8895
this.customAuthorizers = customAuthorizers;
8996
this.paginators = paginators;
9097
this.namingStrategy = namingStrategy;
@@ -205,6 +212,10 @@ public Map<String, AuthorizerModel> getCustomAuthorizers() {
205212
return customAuthorizers;
206213
}
207214

215+
public Optional<OperationModel> getEndpointOperation() {
216+
return endpointOperation;
217+
}
218+
208219
public boolean hasPaginators() {
209220
return paginators.size() > 0;
210221
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/MemberModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public class MemberModel extends DocumentationModel {
8181

8282
private boolean eventHeader;
8383

84+
private boolean endpointDiscoveryId;
85+
8486
public String getName() {
8587
return name;
8688
}
@@ -297,6 +299,15 @@ public void setEventHeader(boolean eventHeader) {
297299
this.eventHeader = eventHeader;
298300
}
299301

302+
303+
public boolean isEndpointDiscoveryId() {
304+
return endpointDiscoveryId;
305+
}
306+
307+
public void setEndpointDiscoveryId(boolean endpointDiscoveryId) {
308+
this.endpointDiscoveryId = endpointDiscoveryId;
309+
}
310+
300311
public ListModel getListModel() {
301312
return listModel;
302313
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/OperationModel.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class OperationModel extends DocumentationModel {
4545

4646
private boolean isPaginated;
4747

48+
private boolean endpointOperation;
49+
50+
private EndpointDiscovery endpointDiscovery;
51+
4852
@JsonIgnore
4953
private ShapeModel inputShape;
5054

@@ -184,6 +188,14 @@ public boolean isStreaming() {
184188
return hasStreamingInput() || hasStreamingOutput();
185189
}
186190

191+
public boolean isEndpointOperation() {
192+
return endpointOperation;
193+
}
194+
195+
public void setEndpointOperation(boolean endpointOperation) {
196+
this.endpointOperation = endpointOperation;
197+
}
198+
187199
public boolean isPaginated() {
188200
return isPaginated;
189201
}
@@ -192,6 +204,14 @@ public void setPaginated(boolean paginated) {
192204
isPaginated = paginated;
193205
}
194206

207+
public EndpointDiscovery getEndpointDiscovery() {
208+
return endpointDiscovery;
209+
}
210+
211+
public void setEndpointDiscovery(EndpointDiscovery endpointDiscovery) {
212+
this.endpointDiscovery = endpointDiscovery;
213+
}
214+
195215
/**
196216
* Returns the endpoint trait that will be used to resolve the endpoint of an API.
197217
*/

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeModel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class ShapeModel extends DocumentationModel implements HasDeprecation {
4646
private boolean wrapper;
4747
private boolean simpleMethod;
4848
private String requestSignerClassFqcn;
49+
private EndpointDiscovery endpointDiscovery;
4950

5051
private List<MemberModel> members;
5152
private List<EnumModel> enums;
@@ -510,6 +511,14 @@ public void setRequestSignerClassFqcn(String authorizerClass) {
510511
this.requestSignerClassFqcn = authorizerClass;
511512
}
512513

514+
public EndpointDiscovery getEndpointDiscovery() {
515+
return endpointDiscovery;
516+
}
517+
518+
public void setEndpointDiscovery(EndpointDiscovery endpointDiscovery) {
519+
this.endpointDiscovery = endpointDiscovery;
520+
}
521+
513522
/**
514523
* @return True if the shape is an 'eventstream' shape. The eventstream shape is the tagged union like
515524
* container that holds individual 'events'.

codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Member.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class Member {
5252
@JsonProperty(value = "eventheader")
5353
private boolean eventHeader;
5454

55+
@JsonProperty(value = "endpointdiscoveryid")
56+
private boolean endpointDiscoveryId;
57+
5558
public String getShape() {
5659
return shape;
5760
}
@@ -171,4 +174,12 @@ public boolean isEventHeader() {
171174
public void setEventHeader(boolean eventHeader) {
172175
this.eventHeader = eventHeader;
173176
}
177+
178+
public boolean isEndpointDiscoveryId() {
179+
return endpointDiscoveryId;
180+
}
181+
182+
public void setEndpointDiscoveryId(boolean endpointDiscoveryId) {
183+
this.endpointDiscoveryId = endpointDiscoveryId;
184+
}
174185
}

codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Operation.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.fasterxml.jackson.annotation.JsonProperty;
1919
import java.util.List;
20+
import software.amazon.awssdk.codegen.model.intermediate.EndpointDiscovery;
2021

2122
public class Operation {
2223

@@ -38,6 +39,12 @@ public class Operation {
3839

3940
private boolean requiresApiKey;
4041

42+
@JsonProperty("endpointdiscovery")
43+
private EndpointDiscovery endpointDiscovery;
44+
45+
@JsonProperty("endpointoperation")
46+
private boolean endpointOperation;
47+
4148
private EndpointTrait endpoint;
4249

4350
@JsonProperty("authtype")
@@ -138,6 +145,22 @@ public void setRequiresApiKey(boolean requiresApiKey) {
138145
this.requiresApiKey = requiresApiKey;
139146
}
140147

148+
public EndpointDiscovery getEndpointDiscovery() {
149+
return endpointDiscovery;
150+
}
151+
152+
public void setEndpointDiscovery(EndpointDiscovery endpointDiscovery) {
153+
this.endpointDiscovery = endpointDiscovery;
154+
}
155+
156+
public boolean isEndpointOperation() {
157+
return endpointOperation;
158+
}
159+
160+
public void setEndpointOperation(boolean endpointOperation) {
161+
this.endpointOperation = endpointOperation;
162+
}
163+
141164
public EndpointTrait getEndpoint() {
142165
return endpoint;
143166
}

0 commit comments

Comments
 (0)