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

0 commit comments

Comments
 (0)