Skip to content

Commit 40b8869

Browse files
authored
Add support for Endpoints 2.0 (#3502)
This release updates internal logic for constructing API endpoints. We have added rule-based endpoint providers. Additionally there are new interfaces for endpoint providers and parameters at the service client level. The SDK provides service-specific `EndpointProvider` interfaces (e.g. `S3EndpointProvider`), that have a single method `resolveEndpoint`. `resolveEndpoint` accepts a set of parameters (also service specific) and computes an endpoint based on those parameters. All clients have a default implementation, but users are free to implement these to customize their endpoint logic.
1 parent a634a01 commit 40b8869

File tree

1,005 files changed

+444322
-2339
lines changed

Some content is hidden

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

1,005 files changed

+444322
-2339
lines changed

.brazil.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"artifactType": "JAR",
4343
"includes": ["target/aws-sdk-java-third-party-jackson-dataformat-cbor-*.jar"]
4444
},
45+
"ruleset-testing-core": {
46+
"packageName": "AwsJavaSdk-Test-RuleSetTestingCore"
47+
},
4548

4649
"archetype-app-quickstart": { "skipImport": true },
4750
"archetype-lambda": { "skipImport": true },
@@ -113,6 +116,10 @@
113116
"software.amazon.awssdk.crt:aws-crt": { "packageName": "Aws-crt-java", "packageVersion": "1.0.x" },
114117
"software.amazon.eventstream:eventstream": { "packageName": "AwsFlowJava", "packageVersion": "1.0" },
115118
"software.amazon.ion:ion-java": { "packageName": "Maven-software-amazon-ion_ion-java", "packageVersion": "1.x" },
116-
"software.amazon:flow": { "packageName": "AwsFlowJava", "packageVersion": "1.0" }
119+
"software.amazon:flow": { "packageName": "AwsFlowJava", "packageVersion": "1.0" },
120+
"org.junit.jupiter:junit-jupiter": { "packageName": "JUnit5", "packageVersion": "5.x" },
121+
"org.mockito:mockito-core": { "packageName": "Mockito", "packageVersion": "3.x" },
122+
"io.reactivex.rxjava3:rxjava": { "packageName": "RxJava", ",packageVersion": "3.x" },
123+
"org.assertj:assertj-core": { "packageName": "AssertJ", ",packageVersion": "3.22.x" }
117124
}
118125
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "feature",
3+
"category": "AWS SDK for Java v2",
4+
"contributor": "",
5+
"description": "This release updates internal logic for constructing API endpoints. \n\nWe have added rule-based endpoint providers. Additionally there are new interfaces for endpoint providers and parameters at the service client level.\n\nThe SDK provides service-specific `EndpointProvider` interfaces (e.g. `S3EndpointProvider`), that have a single method `resolveEndpoint`. `resolveEndpoint` accepts a set of parameters (also service specific) and computes an endpoint based on those parameters. All clients have a default implementation, but users are free to implement these to customize their endpoint logic.\n\nIt is important to know that `EndpointProvider`s and the endpoint override on the client are not mutually exclusive. In all existing cases, the endpoint override is passed as a parameter to the the provider and the provider *may* modify it. For example, the S3 provider may add the bucket name as a prefix to the endpoint override for virtual bucket addressing.\n\nThere may be some behavior changes related to endpoint resolution as as the the endpoint resolution is now standardised across SDKs so this release also bumps the minor version of the SDK to `2.18`.\n\nNotably, there are some changes in S3: when including and endpoint override, the SDK will use virtual bucket addressing as long as the bucket is a valid DNS label. This is different from the previous behavior where this only happens if the endpoint override begins with 's3'.\n\nIn many situations, the exception thrown for validations like including an endpoint override and enabling DualStack has changed to `SdkClientExcpetion` and error messages have changed as well."
6+
}

buildspecs/release-javadoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ phases:
1818
commands:
1919
- python ./scripts/doc_crosslinks/generate_cross_link_data.py --apiDefinitionsBasePath ./services/ --apiDefinitionsRelativeFilePath src/main/resources/codegen-resources/service-2.json --templateFilePath ./scripts/doc_crosslinks/crosslink_redirect.html --outputFilePath ./scripts/crosslink_redirect.html
2020
- mvn install -P quick -T1C
21-
- mvn clean install javadoc:aggregate -B -Ppublic-javadoc -Dcheckstyle.skip -Dspotbugs.skip -DskipTests -Ddoclint=none -pl '!:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:s3-benchmarks,!:module-path-tests,!:test-utils,!:http-client-tests,!:tests-coverage-reporting,!:sdk-native-image-test'
21+
- mvn clean install javadoc:aggregate -B -Ppublic-javadoc -Dcheckstyle.skip -Dspotbugs.skip -DskipTests -Ddoclint=none -pl '!:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:s3-benchmarks,!:module-path-tests,!:test-utils,!:http-client-tests,!:tests-coverage-reporting,!:sdk-native-image-test,!:ruleset-testing-core'
2222
- RELEASE_VERSION=`mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec`
2323
-
2424
- aws s3 sync target/site/apidocs/ $DOC_PATH/$RELEASE_VERSION/

buildspecs/release-to-maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ phases:
4040
awk 'BEGIN { var=ENVIRON["SDK_SIGNING_GPG_KEYNAME"] } { gsub("\\$SDK_SIGNING_GPG_KEYNAME", var, $0); print }' > \
4141
$SETTINGS_XML
4242
43-
mvn clean deploy -B -s $SETTINGS_XML -Ppublishing -DperformRelease -Dspotbugs.skip -DskipTests -Dcheckstyle.skip -Djapicmp.skip -Ddoclint=none -pl !:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:module-path-tests,!:tests-coverage-reporting,!:stability-tests,!:sdk-native-image-test,!:auth-tests,!:s3-benchmarks,!:region-testing -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30
43+
mvn clean deploy -B -s $SETTINGS_XML -Ppublishing -DperformRelease -Dspotbugs.skip -DskipTests -Dcheckstyle.skip -Djapicmp.skip -Ddoclint=none -pl !:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:module-path-tests,!:tests-coverage-reporting,!:stability-tests,!:sdk-native-image-test,!:auth-tests,!:s3-benchmarks,!:region-testing,!:ruleset-testing-core -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30
4444
else
4545
echo "This version was already released."
4646
fi

codegen-maven-plugin/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
<groupId>software.amazon.awssdk</groupId>
5858
<version>${awsjavasdk.version}</version>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.junit.jupiter</groupId>
62+
<artifactId>junit-jupiter</artifactId>
63+
<scope>compile</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.mockito</groupId>
67+
<artifactId>mockito-core</artifactId>
68+
<scope>compile</scope>
69+
</dependency>
6070
<dependency>
6171
<artifactId>maven-plugin-api</artifactId>
6272
<groupId>org.apache.maven</groupId>

codegen-maven-plugin/src/main/java/software/amazon/awssdk/codegen/maven/plugin/GenerationMojo.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import software.amazon.awssdk.codegen.CodeGenerator;
3333
import software.amazon.awssdk.codegen.internal.Utils;
3434
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
35+
import software.amazon.awssdk.codegen.model.rules.endpoints.EndpointTestSuiteModel;
36+
import software.amazon.awssdk.codegen.model.service.EndpointRuleSetModel;
3537
import software.amazon.awssdk.codegen.model.service.Paginators;
3638
import software.amazon.awssdk.codegen.model.service.ServiceModel;
3739
import software.amazon.awssdk.codegen.model.service.Waiters;
@@ -47,6 +49,9 @@ public class GenerationMojo extends AbstractMojo {
4749
private static final String CUSTOMIZATION_CONFIG_FILE = "customization.config";
4850
private static final String WAITERS_FILE = "waiters-2.json";
4951
private static final String PAGINATORS_FILE = "paginators-1.json";
52+
private static final String ENDPOINT_RULE_SET_FILE = "endpoint-rule-set.json";
53+
private static final String ENDPOINT_TESTS_FILE = "endpoint-tests.json";
54+
5055

5156
@Parameter(property = "codeGenResources", defaultValue = "${basedir}/src/main/resources/codegen-resources/")
5257
private File codeGenResources;
@@ -61,11 +66,13 @@ public class GenerationMojo extends AbstractMojo {
6166
private MavenProject project;
6267

6368
private Path sourcesDirectory;
69+
private Path resourcesDirectory;
6470
private Path testsDirectory;
6571

6672
@Override
6773
public void execute() throws MojoExecutionException {
6874
this.sourcesDirectory = Paths.get(outputDirectory).resolve("generated-sources").resolve("sdk");
75+
this.resourcesDirectory = Paths.get(outputDirectory).resolve("generated-resources").resolve("sdk-resources");
6976
this.testsDirectory = Paths.get(outputDirectory).resolve("generated-test-sources").resolve("sdk-tests");
7077

7178
findModelRoots().forEach(p -> {
@@ -76,6 +83,8 @@ public void execute() throws MojoExecutionException {
7683
.serviceModel(loadServiceModel(modelRootPath))
7784
.waitersModel(loadWaiterModel(modelRootPath))
7885
.paginatorsModel(loadPaginatorModel(modelRootPath))
86+
.endpointRuleSetModel(loadEndpointRuleSetModel(modelRootPath))
87+
.endpointTestSuiteModel(loadEndpointTestSuiteModel(modelRootPath))
7988
.build());
8089
});
8190
project.addCompileSourceRoot(sourcesDirectory.toFile().getAbsolutePath());
@@ -105,6 +114,7 @@ private void generateCode(C2jModels models) {
105114
CodeGenerator.builder()
106115
.models(models)
107116
.sourcesDirectory(sourcesDirectory.toFile().getAbsolutePath())
117+
.resourcesDirectory(resourcesDirectory.toFile().getAbsolutePath())
108118
.testsDirectory(testsDirectory.toFile().getAbsolutePath())
109119
.intermediateModelFileNamePrefix(intermediateModelFileNamePrefix(models))
110120
.build()
@@ -134,6 +144,14 @@ private Paginators loadPaginatorModel(Path root) {
134144
return loadOptionalModel(Paginators.class, root.resolve(PAGINATORS_FILE)).orElse(Paginators.none());
135145
}
136146

147+
private EndpointRuleSetModel loadEndpointRuleSetModel(Path root) {
148+
return loadRequiredModel(EndpointRuleSetModel.class, root.resolve(ENDPOINT_RULE_SET_FILE));
149+
}
150+
151+
private EndpointTestSuiteModel loadEndpointTestSuiteModel(Path root) {
152+
return loadRequiredModel(EndpointTestSuiteModel.class, root.resolve(ENDPOINT_TESTS_FILE));
153+
}
154+
137155
/**
138156
* Load required model from the project resources.
139157
*/

codegen/pom.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
<artifactId>metrics-spi</artifactId>
6363
<version>${awsjavasdk.version}</version>
6464
</dependency>
65+
<dependency>
66+
<groupId>software.amazon.awssdk</groupId>
67+
<artifactId>endpoints-spi</artifactId>
68+
<version>${awsjavasdk.version}</version>
69+
</dependency>
6570
<dependency>
6671
<groupId>software.amazon.awssdk</groupId>
6772
<artifactId>regions</artifactId>
@@ -117,6 +122,11 @@
117122
<artifactId>protocol-core</artifactId>
118123
<version>${awsjavasdk.version}</version>
119124
</dependency>
125+
<dependency>
126+
<groupId>software.amazon.awssdk</groupId>
127+
<artifactId>ruleset-testing-core</artifactId>
128+
<version>${awsjavasdk.version}</version>
129+
</dependency>
120130

121131
<dependency>
122132
<artifactId>org.eclipse.jdt.core</artifactId>
@@ -158,7 +168,7 @@
158168
<dependency>
159169
<groupId>org.junit.jupiter</groupId>
160170
<artifactId>junit-jupiter</artifactId>
161-
<scope>test</scope>
171+
<scope>compile</scope>
162172
</dependency>
163173
<dependency>
164174
<groupId>org.junit.vintage</groupId>
@@ -178,7 +188,7 @@
178188
<dependency>
179189
<groupId>org.mockito</groupId>
180190
<artifactId>mockito-core</artifactId>
181-
<scope>test</scope>
191+
<scope>compile</scope>
182192
</dependency>
183193
</dependencies>
184194
</project>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static Metadata constructMetadata(ServiceModel serviceModel,
5858
.withRequestTransformPackageName(namingStrategy.getRequestTransformPackageName(serviceName))
5959
.withPaginatorsPackageName(namingStrategy.getPaginatorsPackageName(serviceName))
6060
.withWaitersPackageName(namingStrategy.getWaitersPackageName(serviceName))
61+
.withEndpointRulesPackageName(namingStrategy.getEndpointRulesPackageName(serviceName))
6162
.withServiceAbbreviation(serviceMetadata.getServiceAbbreviation())
6263
.withServiceFullName(serviceMetadata.getServiceFullName())
6364
.withServiceName(serviceName)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public Map<String, OperationModel> constructOperations() {
165165
operationModel.setEndpointTrait(op.getEndpoint());
166166
operationModel.setHttpChecksumRequired(op.isHttpChecksumRequired());
167167
operationModel.setHttpChecksum(op.getHttpChecksum());
168+
operationModel.setStaticContextParams(op.getStaticContextParams());
168169

169170
Input input = op.getInput();
170171
if (input != null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ private MemberModel generateMemberModel(String c2jMemberName, Member c2jMemberDe
191191
memberModel.setEndpointDiscoveryId(c2jMemberDefinition.isEndpointdiscoveryid());
192192
memberModel.setXmlAttribute(c2jMemberDefinition.isXmlAttribute());
193193
memberModel.setUnionEnumTypeName(namingStrategy.getUnionEnumTypeName(memberModel));
194+
memberModel.setContextParam(c2jMemberDefinition.getContextParam());
194195

195196

196197
// Pass the xmlNameSpace from the member reference

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package software.amazon.awssdk.codegen;
1717

1818
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
19+
import software.amazon.awssdk.codegen.model.rules.endpoints.EndpointTestSuiteModel;
20+
import software.amazon.awssdk.codegen.model.service.EndpointRuleSetModel;
1921
import software.amazon.awssdk.codegen.model.service.Paginators;
2022
import software.amazon.awssdk.codegen.model.service.ServiceModel;
2123
import software.amazon.awssdk.codegen.model.service.Waiters;
@@ -28,15 +30,21 @@ public class C2jModels {
2830

2931
private final ServiceModel serviceModel;
3032
private final Waiters waitersModel;
33+
private final EndpointRuleSetModel endpointRuleSetModel;
34+
private final EndpointTestSuiteModel endpointTestSuiteModel;
3135
private final CustomizationConfig customizationConfig;
3236
private final Paginators paginatorsModel;
3337

3438
private C2jModels(ServiceModel serviceModel,
3539
Waiters waitersModel,
40+
EndpointRuleSetModel endpointRuleSetModel,
41+
EndpointTestSuiteModel endpointTestSuiteModel,
3642
CustomizationConfig customizationConfig,
3743
Paginators paginatorsModel) {
3844
this.serviceModel = serviceModel;
3945
this.waitersModel = waitersModel;
46+
this.endpointRuleSetModel = endpointRuleSetModel;
47+
this.endpointTestSuiteModel = endpointTestSuiteModel;
4048
this.customizationConfig = customizationConfig;
4149
this.paginatorsModel = paginatorsModel;
4250
}
@@ -61,10 +69,20 @@ public Paginators paginatorsModel() {
6169
return paginatorsModel;
6270
}
6371

72+
public EndpointRuleSetModel endpointRuleSetModel() {
73+
return endpointRuleSetModel;
74+
}
75+
76+
public EndpointTestSuiteModel endpointTestSuiteModel() {
77+
return endpointTestSuiteModel;
78+
}
79+
6480
public static class Builder implements SdkBuilder<Builder, C2jModels> {
6581

6682
private ServiceModel serviceModel;
6783
private Waiters waitersModel;
84+
private EndpointRuleSetModel endpointRuleSetModel;
85+
private EndpointTestSuiteModel endpointTestSuiteModel;
6886
private CustomizationConfig customizationConfig;
6987
private Paginators paginatorsModel;
7088

@@ -91,11 +109,22 @@ public Builder paginatorsModel(Paginators paginatorsModel) {
91109
return this;
92110
}
93111

112+
public Builder endpointRuleSetModel(EndpointRuleSetModel endpointRuleSetModel) {
113+
this.endpointRuleSetModel = endpointRuleSetModel;
114+
return this;
115+
}
116+
117+
public Builder endpointTestSuiteModel(EndpointTestSuiteModel endpointTestSuiteModel) {
118+
this.endpointTestSuiteModel = endpointTestSuiteModel;
119+
return this;
120+
}
121+
94122
@Override
95123
public C2jModels build() {
96124
Waiters waiters = waitersModel != null ? waitersModel : Waiters.none();
97125
Paginators paginators = paginatorsModel != null ? paginatorsModel : Paginators.none();
98-
return new C2jModels(serviceModel, waiters, customizationConfig, paginators);
126+
return new C2jModels(serviceModel, waiters, endpointRuleSetModel, endpointTestSuiteModel, customizationConfig,
127+
paginators);
99128
}
100129
}
101130
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class CodeGenerator {
3333

3434
private final C2jModels models;
3535
private final String sourcesDirectory;
36+
private final String resourcesDirectory;
3637
private final String testsDirectory;
3738

3839
/**
@@ -51,6 +52,7 @@ public CodeGenerator(Builder builder) {
5152
this.models = builder.models;
5253
this.sourcesDirectory = builder.sourcesDirectory;
5354
this.testsDirectory = builder.testsDirectory;
55+
this.resourcesDirectory = builder.resourcesDirectory;
5456
this.fileNamePrefix = builder.fileNamePrefix;
5557
}
5658

@@ -124,7 +126,10 @@ private void emitCode(IntermediateModel intermediateModel) {
124126
}
125127

126128
private GeneratorTask createGeneratorTasks(IntermediateModel intermediateModel) {
127-
return new AwsGeneratorTasks(GeneratorTaskParams.create(intermediateModel, sourcesDirectory, testsDirectory));
129+
return new AwsGeneratorTasks(GeneratorTaskParams.create(intermediateModel,
130+
sourcesDirectory,
131+
testsDirectory,
132+
resourcesDirectory));
128133

129134
}
130135

@@ -135,6 +140,7 @@ public static final class Builder {
135140

136141
private C2jModels models;
137142
private String sourcesDirectory;
143+
private String resourcesDirectory;
138144
private String testsDirectory;
139145
private String fileNamePrefix;
140146

@@ -151,6 +157,11 @@ public Builder sourcesDirectory(String sourcesDirectory) {
151157
return this;
152158
}
153159

160+
public Builder resourcesDirectory(String resourcesDirectory) {
161+
this.resourcesDirectory = resourcesDirectory;
162+
return this;
163+
}
164+
154165
public Builder testsDirectory(String smokeTestsDirectory) {
155166
this.testsDirectory = smokeTestsDirectory;
156167
return this;

0 commit comments

Comments
 (0)