diff --git a/.changes/next-release/feature-AWSSDKforJavav2-7e045dc.json b/.changes/next-release/feature-AWSSDKforJavav2-7e045dc.json new file mode 100644 index 000000000000..ab97542dae5a --- /dev/null +++ b/.changes/next-release/feature-AWSSDKforJavav2-7e045dc.json @@ -0,0 +1,6 @@ +{ + "type": "feature", + "category": "AWS SDK for Java v2", + "contributor": "", + "description": "Updated Region class generation to use Partitions.json instead of the Endpoints.json and removed the hardcoded global regions." +} diff --git a/codegen-lite-maven-plugin/src/main/java/software/amazon/awssdk/codegen/lite/maven/plugin/RegionGenerationMojo.java b/codegen-lite-maven-plugin/src/main/java/software/amazon/awssdk/codegen/lite/maven/plugin/RegionGenerationMojo.java index e02358f3a67c..10422e931450 100644 --- a/codegen-lite-maven-plugin/src/main/java/software/amazon/awssdk/codegen/lite/maven/plugin/RegionGenerationMojo.java +++ b/codegen-lite-maven-plugin/src/main/java/software/amazon/awssdk/codegen/lite/maven/plugin/RegionGenerationMojo.java @@ -29,6 +29,7 @@ import software.amazon.awssdk.codegen.lite.regions.EndpointTagGenerator; import software.amazon.awssdk.codegen.lite.regions.PartitionMetadataGenerator; import software.amazon.awssdk.codegen.lite.regions.PartitionMetadataProviderGenerator; +import software.amazon.awssdk.codegen.lite.regions.PartitionsRegionsMetadataLoader; import software.amazon.awssdk.codegen.lite.regions.RegionGenerator; import software.amazon.awssdk.codegen.lite.regions.RegionMetadataGenerator; import software.amazon.awssdk.codegen.lite.regions.RegionMetadataLoader; @@ -36,6 +37,7 @@ import software.amazon.awssdk.codegen.lite.regions.ServiceMetadataGenerator; import software.amazon.awssdk.codegen.lite.regions.ServiceMetadataProviderGenerator; import software.amazon.awssdk.codegen.lite.regions.model.Partitions; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionsRegionsMetadata; import software.amazon.awssdk.utils.StringUtils; /** @@ -59,19 +61,24 @@ public class RegionGenerationMojo extends AbstractMojo { "${basedir}/src/main/resources/software/amazon/awssdk/regions/internal/region/endpoints.json") private File endpoints; + @Parameter(property = "partitionsJson", defaultValue = + "${basedir}/../../codegen/src/main/resources/software/amazon/awssdk/codegen/rules/partitions.json.resource") + private File partitionsJson; + @Override public void execute() throws MojoExecutionException { Path baseSourcesDirectory = Paths.get(outputDirectory).resolve("generated-sources").resolve("sdk"); Path testsDirectory = Paths.get(outputDirectory).resolve("generated-test-sources").resolve("sdk-tests"); Partitions partitions = RegionMetadataLoader.build(endpoints); + PartitionsRegionsMetadata regionPartitions = PartitionsRegionsMetadataLoader.build(partitionsJson); generatePartitionMetadataClass(baseSourcesDirectory, partitions); - generateRegionClass(baseSourcesDirectory, partitions); + generateRegionClass(baseSourcesDirectory, regionPartitions); generateServiceMetadata(baseSourcesDirectory, partitions); - generateRegions(baseSourcesDirectory, partitions); + generateRegions(baseSourcesDirectory, regionPartitions); generatePartitionProvider(baseSourcesDirectory, partitions); - generateRegionProvider(baseSourcesDirectory, partitions); + generateRegionProvider(baseSourcesDirectory, regionPartitions); generateServiceProvider(baseSourcesDirectory, partitions); generateEndpointTags(baseSourcesDirectory, partitions); @@ -88,7 +95,7 @@ public void generatePartitionMetadataClass(Path baseSourcesDirectory, Partitions REGION_BASE)).generate()); } - public void generateRegionClass(Path baseSourcesDirectory, Partitions partitions) { + public void generateRegionClass(Path baseSourcesDirectory, PartitionsRegionsMetadata partitions) { Path sourcesDirectory = baseSourcesDirectory.resolve(StringUtils.replace(REGION_BASE, ".", "/")); new CodeGenerator(sourcesDirectory.toString(), new RegionGenerator(partitions, REGION_BASE)).generate(); } @@ -105,7 +112,7 @@ public void generateServiceMetadata(Path baseSourcesDirectory, Partitions partit .generate()); } - public void generateRegions(Path baseSourcesDirectory, Partitions partitions) { + public void generateRegions(Path baseSourcesDirectory, PartitionsRegionsMetadata partitions) { Path sourcesDirectory = baseSourcesDirectory.resolve(StringUtils.replace(REGION_METADATA_BASE, ".", "/")); partitions.getPartitions() .forEach(p -> p.getRegions().forEach((k, v) -> @@ -126,7 +133,7 @@ public void generatePartitionProvider(Path baseSourcesDirectory, Partitions part .generate(); } - public void generateRegionProvider(Path baseSourcesDirectory, Partitions partitions) { + public void generateRegionProvider(Path baseSourcesDirectory, PartitionsRegionsMetadata partitions) { Path sourcesDirectory = baseSourcesDirectory.resolve(StringUtils.replace(REGION_BASE, ".", "/")); new CodeGenerator(sourcesDirectory.toString(), new RegionMetadataProviderGenerator(partitions, REGION_METADATA_BASE, diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/PartitionsRegionsMetadataLoader.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/PartitionsRegionsMetadataLoader.java new file mode 100644 index 000000000000..692ee7758081 --- /dev/null +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/PartitionsRegionsMetadataLoader.java @@ -0,0 +1,47 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.codegen.lite.regions; + +import com.fasterxml.jackson.jr.ob.JSON; +import java.io.File; +import java.io.IOException; +import software.amazon.awssdk.annotations.SdkInternalApi; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionsRegionsMetadata; + +/** + * Loads and parses the partitions.json file into {@link PartitionsRegionsMetadata}. + */ +@SdkInternalApi +public final class PartitionsRegionsMetadataLoader { + + private PartitionsRegionsMetadataLoader() { + } + + public static PartitionsRegionsMetadata build(File path) { + return loadPartitionFromStream(path, path.toString()); + } + + private static PartitionsRegionsMetadata loadPartitionFromStream(File stream, String location) { + + try { + return JSON.std.with(JSON.Feature.USE_IS_GETTERS) + .beanFrom(PartitionsRegionsMetadata.class, stream); + + } catch (IOException | RuntimeException e) { + throw new RuntimeException("Error while loading partitions file from " + location, e); + } + } +} diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerator.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerator.java index fa5467bc847f..27421f2b6b16 100644 --- a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerator.java +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerator.java @@ -38,16 +38,16 @@ import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.codegen.lite.PoetClass; -import software.amazon.awssdk.codegen.lite.regions.model.Partitions; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionsRegionsMetadata; import software.amazon.awssdk.utils.Validate; import software.amazon.awssdk.utils.http.SdkHttpUtils; public class RegionGenerator implements PoetClass { - private final Partitions partitions; + private final PartitionsRegionsMetadata partitions; private final String basePackage; - public RegionGenerator(Partitions partitions, + public RegionGenerator(PartitionsRegionsMetadata partitions, String basePackage) { this.partitions = partitions; this.basePackage = basePackage; @@ -100,21 +100,15 @@ private void regions(TypeSpec.Builder builder) { .add("$T.unmodifiableList($T.asList(", Collections.class, Arrays.class); String regionsCodeBlock = regions.stream().map(r -> { + boolean isGlobal = r.contains("global"); builder.addField(FieldSpec.builder(className(), regionName(r)) .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S)", className(), r) + .initializer(isGlobal ? "$T.of($S, true)" : "$T.of($S)", className(), r) .build()); return regionName(r); }).collect(Collectors.joining(", ")); - addGlobalRegions(builder); - - regionsArray.add(regionsCodeBlock + ", ") - .add("AWS_GLOBAL, ") - .add("AWS_CN_GLOBAL, ") - .add("AWS_US_GOV_GLOBAL, ") - .add("AWS_ISO_GLOBAL, ") - .add("AWS_ISO_B_GLOBAL"); + regionsArray.add(regionsCodeBlock); regionsArray.add("))"); TypeName listOfRegions = ParameterizedTypeName.get(ClassName.get(List.class), className()); @@ -123,29 +117,6 @@ private void regions(TypeSpec.Builder builder) { .initializer(regionsArray.build()).build()); } - private void addGlobalRegions(TypeSpec.Builder builder) { - builder.addField(FieldSpec.builder(className(), "AWS_GLOBAL") - .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S, true)", className(), "aws-global") - .build()) - .addField(FieldSpec.builder(className(), "AWS_CN_GLOBAL") - .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S, true)", className(), "aws-cn-global") - .build()) - .addField(FieldSpec.builder(className(), "AWS_US_GOV_GLOBAL") - .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S, true)", className(), "aws-us-gov-global") - .build()) - .addField(FieldSpec.builder(className(), "AWS_ISO_GLOBAL") - .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S, true)", className(), "aws-iso-global") - .build()) - .addField(FieldSpec.builder(className(), "AWS_ISO_B_GLOBAL") - .addModifiers(PUBLIC, STATIC, FINAL) - .initializer("$T.of($S, true)", className(), "aws-iso-b-global") - .build()); - } - private String regionName(String region) { return region.replace("-", "_").toUpperCase(Locale.US); } diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataGenerator.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataGenerator.java index 92011139d2c6..b71e7c2bb671 100644 --- a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataGenerator.java +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataGenerator.java @@ -32,17 +32,17 @@ import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.codegen.lite.PoetClass; import software.amazon.awssdk.codegen.lite.Utils; -import software.amazon.awssdk.codegen.lite.regions.model.Partition; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionRegionsMetadata; public class RegionMetadataGenerator implements PoetClass { - private final Partition partition; + private final PartitionRegionsMetadata partition; private final String region; private final String regionDescription; private final String basePackage; private final String regionBasePackage; - public RegionMetadataGenerator(Partition partition, + public RegionMetadataGenerator(PartitionRegionsMetadata partition, String region, String regionDescription, String basePackage, @@ -65,9 +65,9 @@ public TypeSpec poetClass() { .addModifiers(FINAL) .addSuperinterface(ClassName.get(regionBasePackage, "RegionMetadata")) .addField(staticFinalField("ID", region)) - .addField(staticFinalField("DOMAIN", partition.getDnsSuffix())) + .addField(staticFinalField("DOMAIN", partition.getOutputs().getDnsSuffix())) .addField(staticFinalField("DESCRIPTION", regionDescription)) - .addField(staticFinalField("PARTITION_ID", partition.getPartition())) + .addField(staticFinalField("PARTITION_ID", partition.getId())) .addMethod(getter("id", "ID")) .addMethod(getter("domain", "DOMAIN")) .addMethod(getter("description", "DESCRIPTION")) diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataProviderGenerator.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataProviderGenerator.java index 0203bbbfb649..fdd16ab73eec 100644 --- a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataProviderGenerator.java +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/RegionMetadataProviderGenerator.java @@ -36,16 +36,16 @@ import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.codegen.lite.PoetClass; import software.amazon.awssdk.codegen.lite.Utils; -import software.amazon.awssdk.codegen.lite.regions.model.Partitions; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionsRegionsMetadata; import software.amazon.awssdk.utils.ImmutableMap; public class RegionMetadataProviderGenerator implements PoetClass { - private final Partitions partitions; + private final PartitionsRegionsMetadata partitions; private final String basePackage; private final String regionBasePackage; - public RegionMetadataProviderGenerator(Partitions partitions, + public RegionMetadataProviderGenerator(PartitionsRegionsMetadata partitions, String basePackage, String regionBasePackage) { this.partitions = partitions; @@ -79,7 +79,7 @@ public ClassName className() { return ClassName.get(regionBasePackage, "GeneratedRegionMetadataProvider"); } - private CodeBlock regions(Partitions partitions) { + private CodeBlock regions(PartitionsRegionsMetadata partitions) { CodeBlock.Builder builder = CodeBlock.builder().add("$T.builder()", ImmutableMap.class); partitions.getPartitions() diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/Partition.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/Partition.java index e225d47bfd82..f8b030f64edb 100644 --- a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/Partition.java +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/Partition.java @@ -67,9 +67,9 @@ public Partition() { public Partition(@JsonProperty(value = "partition") String partition, @JsonProperty(value = "regions") Map - regions, + regions, @JsonProperty(value = "services") Map services) { + Service> services) { this.partition = Validate.paramNotNull(partition, "Partition"); this.regions = regions; this.services = services; @@ -186,4 +186,4 @@ private boolean hasServiceEndpoint(String endpoint) { } return false; } -} +} \ No newline at end of file diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionRegionsMetadata.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionRegionsMetadata.java new file mode 100644 index 000000000000..f780e766f71e --- /dev/null +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionRegionsMetadata.java @@ -0,0 +1,177 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.codegen.lite.regions.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; +import software.amazon.awssdk.annotations.SdkInternalApi; + +/** + * This class models a single partition from partitions.json. + */ +@SdkInternalApi +public final class PartitionRegionsMetadata { + private String id; + private PartitionOutputs outputs; + private String regionRegex; + private Map regions; + + public PartitionRegionsMetadata() { + } + + public PartitionRegionsMetadata(@JsonProperty(value = "id") String id, + @JsonProperty(value = "outputs") PartitionOutputs outputs, + @JsonProperty(value = "regionRegex") String regionRegex, + @JsonProperty(value = "regions") Map regions) { + this.id = id; + this.outputs = outputs; + this.regionRegex = regionRegex; + this.regions = regions; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public PartitionOutputs getOutputs() { + return outputs; + } + + public void setOutputs(PartitionOutputs outputs) { + this.outputs = outputs; + } + + public String getRegionRegex() { + return regionRegex; + } + + public void setRegionRegex(String regionRegex) { + this.regionRegex = regionRegex; + } + + public Map getRegions() { + return regions; + } + + public void setRegions(Map regions) { + this.regions = regions; + } + + /** + * This class models the outputs field of a partition in partitions.json. + */ + @SdkInternalApi + public static final class PartitionOutputs { + private String dnsSuffix; + private String dualStackDnsSuffix; + private String implicitGlobalRegion; + private String name; + private boolean supportsDualStack; + private boolean supportsFIPS; + + public PartitionOutputs() { + } + + public PartitionOutputs(@JsonProperty(value = "dnsSuffix") String dnsSuffix, + @JsonProperty(value = "dualStackDnsSuffix") String dualStackDnsSuffix, + @JsonProperty(value = "implicitGlobalRegion") String implicitGlobalRegion, + @JsonProperty(value = "name") String name, + @JsonProperty(value = "supportsDualStack") boolean supportsDualStack, + @JsonProperty(value = "supportsFIPS") boolean supportsFIPS) { + this.dnsSuffix = dnsSuffix; + this.dualStackDnsSuffix = dualStackDnsSuffix; + this.implicitGlobalRegion = implicitGlobalRegion; + this.name = name; + this.supportsDualStack = supportsDualStack; + this.supportsFIPS = supportsFIPS; + } + + public String getDnsSuffix() { + return dnsSuffix; + } + + public void setDnsSuffix(String dnsSuffix) { + this.dnsSuffix = dnsSuffix; + } + + public String getDualStackDnsSuffix() { + return dualStackDnsSuffix; + } + + public void setDualStackDnsSuffix(String dualStackDnsSuffix) { + this.dualStackDnsSuffix = dualStackDnsSuffix; + } + + public String getImplicitGlobalRegion() { + return implicitGlobalRegion; + } + + public void setImplicitGlobalRegion(String implicitGlobalRegion) { + this.implicitGlobalRegion = implicitGlobalRegion; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isSupportsDualStack() { + return supportsDualStack; + } + + public void setSupportsDualStack(boolean supportsDualStack) { + this.supportsDualStack = supportsDualStack; + } + + public boolean isSupportsFIPS() { + return supportsFIPS; + } + + public void setSupportsFIPS(boolean supportsFIPS) { + this.supportsFIPS = supportsFIPS; + } + } + + /** + * This class models a region in partitions.json. + */ + @SdkInternalApi + public static final class RegionMetadata { + private String description; + + public RegionMetadata() { + } + + public RegionMetadata(@JsonProperty(value = "description") String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + } +} diff --git a/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionsRegionsMetadata.java b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionsRegionsMetadata.java new file mode 100644 index 000000000000..7c5092e41c66 --- /dev/null +++ b/codegen-lite/src/main/java/software/amazon/awssdk/codegen/lite/regions/model/PartitionsRegionsMetadata.java @@ -0,0 +1,55 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.codegen.lite.regions.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import software.amazon.awssdk.annotations.SdkInternalApi; +import software.amazon.awssdk.utils.Validate; + +/** + * This class models the AWS partitions metadata from partitions.json. + */ +@SdkInternalApi +public final class PartitionsRegionsMetadata { + private List partitions; + private String version; + + public PartitionsRegionsMetadata() { + } + + public PartitionsRegionsMetadata(@JsonProperty(value = "partitions") List partitions, + @JsonProperty(value = "version") String version) { + this.partitions = Validate.paramNotNull(partitions, "partitions"); + this.version = Validate.paramNotNull(version, "version"); + } + + public List getPartitions() { + return partitions; + } + + public void setPartitions(List partitions) { + this.partitions = partitions; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/codegen-lite/src/test/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerationTest.java b/codegen-lite/src/test/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerationTest.java index 0240958a17d9..2ace744a0392 100644 --- a/codegen-lite/src/test/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerationTest.java +++ b/codegen-lite/src/test/java/software/amazon/awssdk/codegen/lite/regions/RegionGenerationTest.java @@ -21,35 +21,42 @@ import java.nio.file.Paths; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import software.amazon.awssdk.codegen.lite.regions.model.Partition; import software.amazon.awssdk.codegen.lite.regions.model.Partitions; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionsRegionsMetadata; +import software.amazon.awssdk.codegen.lite.regions.model.PartitionRegionsMetadata; public class RegionGenerationTest { private static final String ENDPOINTS = "/software/amazon/awssdk/codegen/lite/test-endpoints.json"; + private static final String PARTITIONS = "/software/amazon/awssdk/codegen/lite/test-partitions.json.resource"; private static final String SERVICE_METADATA_BASE = "software.amazon.awssdk.regions.servicemetadata"; private static final String REGION_METADATA_BASE = "software.amazon.awssdk.regions.regionmetadata"; private static final String PARTITION_METADATA_BASE = "software.amazon.awssdk.regions.partitionmetadata"; private static final String REGION_BASE = "software.amazon.awssdk.regions"; private File endpoints; + private File partitionsFile; private Partitions partitions; + private PartitionsRegionsMetadata partitionsRegions; + @BeforeEach public void before() throws Exception { this.endpoints = Paths.get(getClass().getResource(ENDPOINTS).toURI()).toFile(); + this.partitionsFile = Paths.get(getClass().getResource(PARTITIONS).toURI()).toFile(); this.partitions = RegionMetadataLoader.build(endpoints); + this.partitionsRegions = PartitionsRegionsMetadataLoader.build(partitionsFile); } @Test public void regionClass() { - RegionGenerator regions = new RegionGenerator(partitions, REGION_BASE); + RegionGenerator regions = new RegionGenerator(partitionsRegions, REGION_BASE); assertThat(regions, generatesTo("regions.java")); } @Test public void regionMetadataClass() { - Partition partition = partitions.getPartitions().get(0); + PartitionRegionsMetadata partition = partitionsRegions.getPartitions().get(0); RegionMetadataGenerator metadataGenerator = new RegionMetadataGenerator(partition, "us-east-1", "US East (N. Virginia)", @@ -61,7 +68,7 @@ public void regionMetadataClass() { @Test public void regionMetadataProviderClass() { - RegionMetadataProviderGenerator providerGenerator = new RegionMetadataProviderGenerator(partitions, + RegionMetadataProviderGenerator providerGenerator = new RegionMetadataProviderGenerator(partitionsRegions, REGION_METADATA_BASE, REGION_BASE); assertThat(providerGenerator, generatesTo("region-metadata-provider.java")); diff --git a/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/region-metadata-provider.java b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/region-metadata-provider.java index 9380df896357..798644de1fef 100644 --- a/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/region-metadata-provider.java +++ b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/region-metadata-provider.java @@ -9,18 +9,37 @@ import software.amazon.awssdk.regions.regionmetadata.ApNortheast2; import software.amazon.awssdk.regions.regionmetadata.ApNortheast3; import software.amazon.awssdk.regions.regionmetadata.ApSouth1; +import software.amazon.awssdk.regions.regionmetadata.ApSouth2; import software.amazon.awssdk.regions.regionmetadata.ApSoutheast1; import software.amazon.awssdk.regions.regionmetadata.ApSoutheast2; +import software.amazon.awssdk.regions.regionmetadata.ApSoutheast3; +import software.amazon.awssdk.regions.regionmetadata.ApSoutheast4; +import software.amazon.awssdk.regions.regionmetadata.ApSoutheast5; +import software.amazon.awssdk.regions.regionmetadata.ApSoutheast7; +import software.amazon.awssdk.regions.regionmetadata.AwsCnGlobal; +import software.amazon.awssdk.regions.regionmetadata.AwsGlobal; +import software.amazon.awssdk.regions.regionmetadata.AwsIsoBGlobal; +import software.amazon.awssdk.regions.regionmetadata.AwsIsoFGlobal; +import software.amazon.awssdk.regions.regionmetadata.AwsIsoGlobal; +import software.amazon.awssdk.regions.regionmetadata.AwsUsGovGlobal; import software.amazon.awssdk.regions.regionmetadata.CaCentral1; +import software.amazon.awssdk.regions.regionmetadata.CaWest1; import software.amazon.awssdk.regions.regionmetadata.CnNorth1; import software.amazon.awssdk.regions.regionmetadata.CnNorthwest1; import software.amazon.awssdk.regions.regionmetadata.EuCentral1; +import software.amazon.awssdk.regions.regionmetadata.EuCentral2; +import software.amazon.awssdk.regions.regionmetadata.EuIsoeWest1; import software.amazon.awssdk.regions.regionmetadata.EuNorth1; import software.amazon.awssdk.regions.regionmetadata.EuSouth1; +import software.amazon.awssdk.regions.regionmetadata.EuSouth2; import software.amazon.awssdk.regions.regionmetadata.EuWest1; import software.amazon.awssdk.regions.regionmetadata.EuWest2; import software.amazon.awssdk.regions.regionmetadata.EuWest3; +import software.amazon.awssdk.regions.regionmetadata.EuscDeEast1; +import software.amazon.awssdk.regions.regionmetadata.IlCentral1; +import software.amazon.awssdk.regions.regionmetadata.MeCentral1; import software.amazon.awssdk.regions.regionmetadata.MeSouth1; +import software.amazon.awssdk.regions.regionmetadata.MxCentral1; import software.amazon.awssdk.regions.regionmetadata.SaEast1; import software.amazon.awssdk.regions.regionmetadata.UsEast1; import software.amazon.awssdk.regions.regionmetadata.UsEast2; @@ -29,6 +48,8 @@ import software.amazon.awssdk.regions.regionmetadata.UsIsoEast1; import software.amazon.awssdk.regions.regionmetadata.UsIsoWest1; import software.amazon.awssdk.regions.regionmetadata.UsIsobEast1; +import software.amazon.awssdk.regions.regionmetadata.UsIsofEast1; +import software.amazon.awssdk.regions.regionmetadata.UsIsofSouth1; import software.amazon.awssdk.regions.regionmetadata.UsWest1; import software.amazon.awssdk.regions.regionmetadata.UsWest2; import software.amazon.awssdk.utils.ImmutableMap; @@ -40,15 +61,26 @@ public final class GeneratedRegionMetadataProvider implements RegionMetadataProv .put(Region.AF_SOUTH_1, new AfSouth1()).put(Region.AP_EAST_1, new ApEast1()) .put(Region.AP_NORTHEAST_1, new ApNortheast1()).put(Region.AP_NORTHEAST_2, new ApNortheast2()) .put(Region.AP_NORTHEAST_3, new ApNortheast3()).put(Region.AP_SOUTH_1, new ApSouth1()) - .put(Region.AP_SOUTHEAST_1, new ApSoutheast1()).put(Region.AP_SOUTHEAST_2, new ApSoutheast2()) - .put(Region.CA_CENTRAL_1, new CaCentral1()).put(Region.EU_CENTRAL_1, new EuCentral1()) - .put(Region.EU_NORTH_1, new EuNorth1()).put(Region.EU_SOUTH_1, new EuSouth1()).put(Region.EU_WEST_1, new EuWest1()) - .put(Region.EU_WEST_2, new EuWest2()).put(Region.EU_WEST_3, new EuWest3()).put(Region.ME_SOUTH_1, new MeSouth1()) + .put(Region.AP_SOUTH_2, new ApSouth2()).put(Region.AP_SOUTHEAST_1, new ApSoutheast1()) + .put(Region.AP_SOUTHEAST_2, new ApSoutheast2()).put(Region.AP_SOUTHEAST_3, new ApSoutheast3()) + .put(Region.AP_SOUTHEAST_4, new ApSoutheast4()).put(Region.AP_SOUTHEAST_5, new ApSoutheast5()) + .put(Region.AP_SOUTHEAST_7, new ApSoutheast7()).put(Region.AWS_GLOBAL, new AwsGlobal()) + .put(Region.CA_CENTRAL_1, new CaCentral1()).put(Region.CA_WEST_1, new CaWest1()) + .put(Region.EU_CENTRAL_1, new EuCentral1()).put(Region.EU_CENTRAL_2, new EuCentral2()) + .put(Region.EU_NORTH_1, new EuNorth1()).put(Region.EU_SOUTH_1, new EuSouth1()).put(Region.EU_SOUTH_2, new EuSouth2()) + .put(Region.EU_WEST_1, new EuWest1()).put(Region.EU_WEST_2, new EuWest2()).put(Region.EU_WEST_3, new EuWest3()) + .put(Region.IL_CENTRAL_1, new IlCentral1()).put(Region.ME_CENTRAL_1, new MeCentral1()) + .put(Region.ME_SOUTH_1, new MeSouth1()).put(Region.MX_CENTRAL_1, new MxCentral1()) .put(Region.SA_EAST_1, new SaEast1()).put(Region.US_EAST_1, new UsEast1()).put(Region.US_EAST_2, new UsEast2()) - .put(Region.US_WEST_1, new UsWest1()).put(Region.US_WEST_2, new UsWest2()).put(Region.CN_NORTH_1, new CnNorth1()) - .put(Region.CN_NORTHWEST_1, new CnNorthwest1()).put(Region.US_GOV_EAST_1, new UsGovEast1()) - .put(Region.US_GOV_WEST_1, new UsGovWest1()).put(Region.US_ISO_EAST_1, new UsIsoEast1()) - .put(Region.US_ISO_WEST_1, new UsIsoWest1()).put(Region.US_ISOB_EAST_1, new UsIsobEast1()).build(); + .put(Region.US_WEST_1, new UsWest1()).put(Region.US_WEST_2, new UsWest2()) + .put(Region.AWS_CN_GLOBAL, new AwsCnGlobal()).put(Region.CN_NORTH_1, new CnNorth1()) + .put(Region.CN_NORTHWEST_1, new CnNorthwest1()).put(Region.AWS_US_GOV_GLOBAL, new AwsUsGovGlobal()) + .put(Region.US_GOV_EAST_1, new UsGovEast1()).put(Region.US_GOV_WEST_1, new UsGovWest1()) + .put(Region.AWS_ISO_GLOBAL, new AwsIsoGlobal()).put(Region.US_ISO_EAST_1, new UsIsoEast1()) + .put(Region.US_ISO_WEST_1, new UsIsoWest1()).put(Region.AWS_ISO_B_GLOBAL, new AwsIsoBGlobal()) + .put(Region.US_ISOB_EAST_1, new UsIsobEast1()).put(Region.EU_ISOE_WEST_1, new EuIsoeWest1()) + .put(Region.AWS_ISO_F_GLOBAL, new AwsIsoFGlobal()).put(Region.US_ISOF_EAST_1, new UsIsofEast1()) + .put(Region.US_ISOF_SOUTH_1, new UsIsofSouth1()).put(Region.EUSC_DE_EAST_1, new EuscDeEast1()).build(); public RegionMetadata regionMetadata(Region region) { return REGION_METADATA.get(region); diff --git a/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/regions.java b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/regions.java index e007c4fbaf79..9935ffd3f4d9 100644 --- a/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/regions.java +++ b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/regions/regions.java @@ -36,17 +36,11 @@ @SdkPublicApi @Generated("software.amazon.awssdk:codegen") public final class Region { - public static final Region AP_SOUTH_1 = Region.of("ap-south-1"); - - public static final Region EU_SOUTH_1 = Region.of("eu-south-1"); - - public static final Region US_GOV_EAST_1 = Region.of("us-gov-east-1"); + public static final Region ME_CENTRAL_1 = Region.of("me-central-1"); - public static final Region CA_CENTRAL_1 = Region.of("ca-central-1"); + public static final Region AWS_CN_GLOBAL = Region.of("aws-cn-global", true); - public static final Region EU_CENTRAL_1 = Region.of("eu-central-1"); - - public static final Region US_ISO_WEST_1 = Region.of("us-iso-west-1"); + public static final Region US_ISOF_SOUTH_1 = Region.of("us-isof-south-1"); public static final Region US_WEST_1 = Region.of("us-west-1"); @@ -54,14 +48,6 @@ public final class Region { public static final Region AF_SOUTH_1 = Region.of("af-south-1"); - public static final Region EU_NORTH_1 = Region.of("eu-north-1"); - - public static final Region EU_WEST_3 = Region.of("eu-west-3"); - - public static final Region EU_WEST_2 = Region.of("eu-west-2"); - - public static final Region EU_WEST_1 = Region.of("eu-west-1"); - public static final Region AP_NORTHEAST_3 = Region.of("ap-northeast-3"); public static final Region AP_NORTHEAST_2 = Region.of("ap-northeast-2"); @@ -72,41 +58,89 @@ public final class Region { public static final Region SA_EAST_1 = Region.of("sa-east-1"); - public static final Region AP_EAST_1 = Region.of("ap-east-1"); - public static final Region CN_NORTH_1 = Region.of("cn-north-1"); - public static final Region US_GOV_WEST_1 = Region.of("us-gov-west-1"); - public static final Region AP_SOUTHEAST_1 = Region.of("ap-southeast-1"); public static final Region AP_SOUTHEAST_2 = Region.of("ap-southeast-2"); - public static final Region US_ISO_EAST_1 = Region.of("us-iso-east-1"); + public static final Region AP_SOUTHEAST_3 = Region.of("ap-southeast-3"); + + public static final Region AP_SOUTHEAST_4 = Region.of("ap-southeast-4"); + + public static final Region AP_SOUTHEAST_5 = Region.of("ap-southeast-5"); public static final Region US_EAST_1 = Region.of("us-east-1"); public static final Region US_EAST_2 = Region.of("us-east-2"); + public static final Region AP_SOUTHEAST_7 = Region.of("ap-southeast-7"); + public static final Region CN_NORTHWEST_1 = Region.of("cn-northwest-1"); - public static final Region US_ISOB_EAST_1 = Region.of("us-isob-east-1"); + public static final Region AP_SOUTH_2 = Region.of("ap-south-2"); + + public static final Region AP_SOUTH_1 = Region.of("ap-south-1"); + + public static final Region EU_SOUTH_1 = Region.of("eu-south-1"); + + public static final Region EU_SOUTH_2 = Region.of("eu-south-2"); + + public static final Region US_GOV_EAST_1 = Region.of("us-gov-east-1"); + + public static final Region IL_CENTRAL_1 = Region.of("il-central-1"); + + public static final Region CA_CENTRAL_1 = Region.of("ca-central-1"); + + public static final Region MX_CENTRAL_1 = Region.of("mx-central-1"); + + public static final Region EU_CENTRAL_1 = Region.of("eu-central-1"); + + public static final Region US_ISO_WEST_1 = Region.of("us-iso-west-1"); + + public static final Region EUSC_DE_EAST_1 = Region.of("eusc-de-east-1"); + + public static final Region EU_CENTRAL_2 = Region.of("eu-central-2"); + + public static final Region EU_ISOE_WEST_1 = Region.of("eu-isoe-west-1"); public static final Region AWS_GLOBAL = Region.of("aws-global", true); - public static final Region AWS_CN_GLOBAL = Region.of("aws-cn-global", true); + public static final Region EU_NORTH_1 = Region.of("eu-north-1"); - public static final Region AWS_US_GOV_GLOBAL = Region.of("aws-us-gov-global", true); + public static final Region EU_WEST_3 = Region.of("eu-west-3"); + + public static final Region EU_WEST_2 = Region.of("eu-west-2"); + + public static final Region EU_WEST_1 = Region.of("eu-west-1"); public static final Region AWS_ISO_GLOBAL = Region.of("aws-iso-global", true); + public static final Region AP_EAST_1 = Region.of("ap-east-1"); + + public static final Region CA_WEST_1 = Region.of("ca-west-1"); + + public static final Region US_GOV_WEST_1 = Region.of("us-gov-west-1"); + + public static final Region US_ISO_EAST_1 = Region.of("us-iso-east-1"); + public static final Region AWS_ISO_B_GLOBAL = Region.of("aws-iso-b-global", true); - private static final List REGIONS = Collections.unmodifiableList(Arrays.asList(AP_SOUTH_1, EU_SOUTH_1, US_GOV_EAST_1, - CA_CENTRAL_1, EU_CENTRAL_1, US_ISO_WEST_1, US_WEST_1, US_WEST_2, AF_SOUTH_1, EU_NORTH_1, EU_WEST_3, EU_WEST_2, - EU_WEST_1, AP_NORTHEAST_3, AP_NORTHEAST_2, AP_NORTHEAST_1, ME_SOUTH_1, SA_EAST_1, AP_EAST_1, CN_NORTH_1, - US_GOV_WEST_1, AP_SOUTHEAST_1, AP_SOUTHEAST_2, US_ISO_EAST_1, US_EAST_1, US_EAST_2, CN_NORTHWEST_1, US_ISOB_EAST_1, - AWS_GLOBAL, AWS_CN_GLOBAL, AWS_US_GOV_GLOBAL, AWS_ISO_GLOBAL, AWS_ISO_B_GLOBAL)); + public static final Region AWS_ISO_F_GLOBAL = Region.of("aws-iso-f-global", true); + + public static final Region AWS_US_GOV_GLOBAL = Region.of("aws-us-gov-global", true); + + public static final Region US_ISOB_EAST_1 = Region.of("us-isob-east-1"); + + public static final Region US_ISOF_EAST_1 = Region.of("us-isof-east-1"); + + private static final List REGIONS = Collections.unmodifiableList(Arrays.asList(ME_CENTRAL_1, AWS_CN_GLOBAL, + US_ISOF_SOUTH_1, US_WEST_1, US_WEST_2, AF_SOUTH_1, AP_NORTHEAST_3, AP_NORTHEAST_2, AP_NORTHEAST_1, ME_SOUTH_1, + SA_EAST_1, CN_NORTH_1, AP_SOUTHEAST_1, AP_SOUTHEAST_2, AP_SOUTHEAST_3, AP_SOUTHEAST_4, AP_SOUTHEAST_5, US_EAST_1, + US_EAST_2, AP_SOUTHEAST_7, CN_NORTHWEST_1, AP_SOUTH_2, AP_SOUTH_1, EU_SOUTH_1, EU_SOUTH_2, US_GOV_EAST_1, + IL_CENTRAL_1, CA_CENTRAL_1, MX_CENTRAL_1, EU_CENTRAL_1, US_ISO_WEST_1, EUSC_DE_EAST_1, EU_CENTRAL_2, EU_ISOE_WEST_1, + AWS_GLOBAL, EU_NORTH_1, EU_WEST_3, EU_WEST_2, EU_WEST_1, AWS_ISO_GLOBAL, AP_EAST_1, CA_WEST_1, US_GOV_WEST_1, + US_ISO_EAST_1, AWS_ISO_B_GLOBAL, AWS_ISO_F_GLOBAL, AWS_US_GOV_GLOBAL, US_ISOB_EAST_1, US_ISOF_EAST_1)); private final boolean isGlobalRegion; diff --git a/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/test-partitions.json.resource b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/test-partitions.json.resource new file mode 100644 index 000000000000..3d7e9530924e --- /dev/null +++ b/codegen-lite/src/test/resources/software/amazon/awssdk/codegen/lite/test-partitions.json.resource @@ -0,0 +1,255 @@ +{ + "partitions" : [ { + "id" : "aws", + "outputs" : { + "dnsSuffix" : "amazonaws.com", + "dualStackDnsSuffix" : "api.aws", + "implicitGlobalRegion" : "us-east-1", + "name" : "aws", + "supportsDualStack" : true, + "supportsFIPS" : true + }, + "regionRegex" : "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$", + "regions" : { + "af-south-1" : { + "description" : "Africa (Cape Town)" + }, + "ap-east-1" : { + "description" : "Asia Pacific (Hong Kong)" + }, + "ap-northeast-1" : { + "description" : "Asia Pacific (Tokyo)" + }, + "ap-northeast-2" : { + "description" : "Asia Pacific (Seoul)" + }, + "ap-northeast-3" : { + "description" : "Asia Pacific (Osaka)" + }, + "ap-south-1" : { + "description" : "Asia Pacific (Mumbai)" + }, + "ap-south-2" : { + "description" : "Asia Pacific (Hyderabad)" + }, + "ap-southeast-1" : { + "description" : "Asia Pacific (Singapore)" + }, + "ap-southeast-2" : { + "description" : "Asia Pacific (Sydney)" + }, + "ap-southeast-3" : { + "description" : "Asia Pacific (Jakarta)" + }, + "ap-southeast-4" : { + "description" : "Asia Pacific (Melbourne)" + }, + "ap-southeast-5" : { + "description" : "Asia Pacific (Malaysia)" + }, + "ap-southeast-7" : { + "description" : "Asia Pacific (Thailand)" + }, + "aws-global" : { + "description" : "AWS Standard global region" + }, + "ca-central-1" : { + "description" : "Canada (Central)" + }, + "ca-west-1" : { + "description" : "Canada West (Calgary)" + }, + "eu-central-1" : { + "description" : "Europe (Frankfurt)" + }, + "eu-central-2" : { + "description" : "Europe (Zurich)" + }, + "eu-north-1" : { + "description" : "Europe (Stockholm)" + }, + "eu-south-1" : { + "description" : "Europe (Milan)" + }, + "eu-south-2" : { + "description" : "Europe (Spain)" + }, + "eu-west-1" : { + "description" : "Europe (Ireland)" + }, + "eu-west-2" : { + "description" : "Europe (London)" + }, + "eu-west-3" : { + "description" : "Europe (Paris)" + }, + "il-central-1" : { + "description" : "Israel (Tel Aviv)" + }, + "me-central-1" : { + "description" : "Middle East (UAE)" + }, + "me-south-1" : { + "description" : "Middle East (Bahrain)" + }, + "mx-central-1" : { + "description" : "Mexico (Central)" + }, + "sa-east-1" : { + "description" : "South America (Sao Paulo)" + }, + "us-east-1" : { + "description" : "US East (N. Virginia)" + }, + "us-east-2" : { + "description" : "US East (Ohio)" + }, + "us-west-1" : { + "description" : "US West (N. California)" + }, + "us-west-2" : { + "description" : "US West (Oregon)" + } + } + }, { + "id" : "aws-cn", + "outputs" : { + "dnsSuffix" : "amazonaws.com.cn", + "dualStackDnsSuffix" : "api.amazonwebservices.com.cn", + "implicitGlobalRegion" : "cn-northwest-1", + "name" : "aws-cn", + "supportsDualStack" : true, + "supportsFIPS" : true + }, + "regionRegex" : "^cn\\-\\w+\\-\\d+$", + "regions" : { + "aws-cn-global" : { + "description" : "AWS China global region" + }, + "cn-north-1" : { + "description" : "China (Beijing)" + }, + "cn-northwest-1" : { + "description" : "China (Ningxia)" + } + } + }, { + "id" : "aws-us-gov", + "outputs" : { + "dnsSuffix" : "amazonaws.com", + "dualStackDnsSuffix" : "api.aws", + "implicitGlobalRegion" : "us-gov-west-1", + "name" : "aws-us-gov", + "supportsDualStack" : true, + "supportsFIPS" : true + }, + "regionRegex" : "^us\\-gov\\-\\w+\\-\\d+$", + "regions" : { + "aws-us-gov-global" : { + "description" : "AWS GovCloud (US) global region" + }, + "us-gov-east-1" : { + "description" : "AWS GovCloud (US-East)" + }, + "us-gov-west-1" : { + "description" : "AWS GovCloud (US-West)" + } + } + }, { + "id" : "aws-iso", + "outputs" : { + "dnsSuffix" : "c2s.ic.gov", + "dualStackDnsSuffix" : "c2s.ic.gov", + "implicitGlobalRegion" : "us-iso-east-1", + "name" : "aws-iso", + "supportsDualStack" : false, + "supportsFIPS" : true + }, + "regionRegex" : "^us\\-iso\\-\\w+\\-\\d+$", + "regions" : { + "aws-iso-global" : { + "description" : "AWS ISO (US) global region" + }, + "us-iso-east-1" : { + "description" : "US ISO East" + }, + "us-iso-west-1" : { + "description" : "US ISO WEST" + } + } + }, { + "id" : "aws-iso-b", + "outputs" : { + "dnsSuffix" : "sc2s.sgov.gov", + "dualStackDnsSuffix" : "sc2s.sgov.gov", + "implicitGlobalRegion" : "us-isob-east-1", + "name" : "aws-iso-b", + "supportsDualStack" : false, + "supportsFIPS" : true + }, + "regionRegex" : "^us\\-isob\\-\\w+\\-\\d+$", + "regions" : { + "aws-iso-b-global" : { + "description" : "AWS ISOB (US) global region" + }, + "us-isob-east-1" : { + "description" : "US ISOB East (Ohio)" + } + } + }, { + "id" : "aws-iso-e", + "outputs" : { + "dnsSuffix" : "cloud.adc-e.uk", + "dualStackDnsSuffix" : "cloud.adc-e.uk", + "implicitGlobalRegion" : "eu-isoe-west-1", + "name" : "aws-iso-e", + "supportsDualStack" : false, + "supportsFIPS" : true + }, + "regionRegex" : "^eu\\-isoe\\-\\w+\\-\\d+$", + "regions" : { + "eu-isoe-west-1" : { + "description" : "EU ISOE West" + } + } + }, { + "id" : "aws-iso-f", + "outputs" : { + "dnsSuffix" : "csp.hci.ic.gov", + "dualStackDnsSuffix" : "csp.hci.ic.gov", + "implicitGlobalRegion" : "us-isof-south-1", + "name" : "aws-iso-f", + "supportsDualStack" : false, + "supportsFIPS" : true + }, + "regionRegex" : "^us\\-isof\\-\\w+\\-\\d+$", + "regions" : { + "aws-iso-f-global" : { + "description" : "AWS ISOF global region" + }, + "us-isof-east-1" : { + "description" : "US ISOF EAST" + }, + "us-isof-south-1" : { + "description" : "US ISOF SOUTH" + } + } + }, { + "id" : "aws-eusc", + "outputs" : { + "dnsSuffix" : "amazonaws.eu", + "dualStackDnsSuffix" : "amazonaws.eu", + "implicitGlobalRegion" : "eusc-de-east-1", + "name" : "aws-eusc", + "supportsDualStack" : false, + "supportsFIPS" : true + }, + "regionRegex" : "^eusc\\-(de)\\-\\w+\\-\\d+$", + "regions" : { + "eusc-de-east-1" : { + "description" : "EU (Germany)" + } + } + } ], + "version" : "1.1" +} \ No newline at end of file diff --git a/core/regions/src/test/java/software/amazon/awssdk/regions/RegionTest.java b/core/regions/src/test/java/software/amazon/awssdk/regions/RegionTest.java index 49f057b746c2..d6d5a94deb97 100644 --- a/core/regions/src/test/java/software/amazon/awssdk/regions/RegionTest.java +++ b/core/regions/src/test/java/software/amazon/awssdk/regions/RegionTest.java @@ -66,4 +66,33 @@ public void idIsUrlEncoded() { Region region = Region.of("http://my-host.com/?"); assertThat(region.id()).isEqualTo("http%3A%2F%2Fmy-host.com%2F%3F"); } + + @Test + public void globalRegionIsRecognized() { + Region globalRegion = Region.of("aws-global"); + assertThat(globalRegion.id()).isEqualTo("aws-global"); + assertSame(Region.AWS_GLOBAL, globalRegion); + } + + @Test + public void multipleGlobalRegionsAreSupported() { + Region awsGlobal = Region.of("aws-global"); + Region s3Global = Region.of("s3-global"); + + assertThat(awsGlobal.id()).isEqualTo("aws-global"); + assertThat(s3Global.id()).isEqualTo("s3-global"); + + assertSame(Region.of("aws-global"), awsGlobal); + assertSame(Region.of("s3-global"), s3Global); + } + + @Test + public void allPartitionGlobalRegionsAreRecognized() { + assertThat(Region.of("aws-global").id()).isEqualTo("aws-global"); + assertThat(Region.of("aws-cn-global").id()).isEqualTo("aws-cn-global"); + assertThat(Region.of("aws-us-gov-global").id()).isEqualTo("aws-us-gov-global"); + assertThat(Region.of("aws-iso-global").id()).isEqualTo("aws-iso-global"); + assertThat(Region.of("aws-iso-b-global").id()).isEqualTo("aws-iso-b-global"); + assertThat(Region.of("aws-iso-f-global").id()).isEqualTo("aws-iso-f-global"); + } }