diff --git a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsAuthIntegration.java b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsAuthIntegration.java index 44d5fcbed..707db1930 100644 --- a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsAuthIntegration.java +++ b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsAuthIntegration.java @@ -10,6 +10,7 @@ import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.model.shapes.ShapeId; import software.amazon.smithy.model.traits.HttpApiKeyAuthTrait; +import static software.amazon.smithy.python.aws.codegen.AwsConfiguration.REGION; import software.amazon.smithy.python.codegen.ApplicationProtocol; import software.amazon.smithy.python.codegen.CodegenUtils; import software.amazon.smithy.python.codegen.ConfigProperty; @@ -30,13 +31,6 @@ public class AwsAuthIntegration implements PythonIntegration { @Override public List getClientPlugins(GenerationContext context) { - var regionConfig = ConfigProperty.builder() - .name("region") - .type(Symbol.builder().name("str").build()) - .documentation(" The AWS region to connect to. The configured region is used to " - + "determine the service endpoint.") - .build(); - return List.of( RuntimeClientPlugin.builder() .servicePredicate((model, service) -> service.hasTrait(SigV4Trait.class)) @@ -65,7 +59,7 @@ public List getClientPlugins(GenerationContext context) { // TODO: Initialize with the provider chain? .nullable(true) .build()) - .addConfigProperty(regionConfig) + .addConfigProperty(REGION) .authScheme(new Sigv4AuthScheme()) .build() ); diff --git a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsConfiguration.java b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsConfiguration.java new file mode 100644 index 000000000..7a349772e --- /dev/null +++ b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsConfiguration.java @@ -0,0 +1,25 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +package software.amazon.smithy.python.aws.codegen; + +import software.amazon.smithy.codegen.core.Symbol; +import software.amazon.smithy.python.codegen.ConfigProperty; +import software.amazon.smithy.utils.SmithyUnstableApi; + +/** + * Common configuration for AWS Clients. + */ +@SmithyUnstableApi +public final class AwsConfiguration { + private AwsConfiguration() { + } + + public static final ConfigProperty REGION = ConfigProperty.builder() + .name("region") + .type(Symbol.builder().name("str").build()) + .documentation(" The AWS region to connect to. The configured region is used to " + + "determine the service endpoint.") + .build(); +} diff --git a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsPythonDependency.java b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsPythonDependency.java index b8d0dc2dc..738d66072 100644 --- a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsPythonDependency.java +++ b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsPythonDependency.java @@ -12,6 +12,10 @@ */ @SmithyUnstableApi public class AwsPythonDependency { + + private AwsPythonDependency() { + } + /** * The core aws smithy runtime python package. * diff --git a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsStandardRegionalEndpointsIntegration.java b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsStandardRegionalEndpointsIntegration.java index 7bda7991c..3b5957cbd 100644 --- a/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsStandardRegionalEndpointsIntegration.java +++ b/codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsStandardRegionalEndpointsIntegration.java @@ -7,6 +7,7 @@ import java.util.List; import software.amazon.smithy.aws.traits.ServiceTrait; import software.amazon.smithy.codegen.core.Symbol; +import static software.amazon.smithy.python.aws.codegen.AwsConfiguration.REGION; import software.amazon.smithy.python.codegen.CodegenUtils; import software.amazon.smithy.python.codegen.ConfigProperty; import software.amazon.smithy.python.codegen.GenerationContext; @@ -23,15 +24,9 @@ public class AwsStandardRegionalEndpointsIntegration implements PythonIntegratio @Override public List getClientPlugins(GenerationContext context) { if (context.applicationProtocol().isHttpProtocol()) { - var region = ConfigProperty.builder() - .name("region") - .type(Symbol.builder().name("str").build()) - .documentation(" The AWS region to connect to. The configured region is used to " - + "determine the service endpoint.") - .build(); return List.of( RuntimeClientPlugin.builder() - .addConfigProperty(region) + .addConfigProperty(REGION) .build()); } else { return List.of(); diff --git a/codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java b/codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java index c6874a6d5..c55a3d400 100644 --- a/codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java +++ b/codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java @@ -7,9 +7,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; +import java.util.TreeSet; import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.model.knowledge.EventStreamIndex; import software.amazon.smithy.model.knowledge.ServiceIndex; @@ -288,9 +290,9 @@ private void writeInterceptorsType(PythonWriter writer) { private void generateConfig(GenerationContext context, PythonWriter writer) { var configSymbol = CodegenUtils.getConfigSymbol(context.settings()); - // Initialize the list of config properties with our base properties. Here a new - // list is constructed because that base list is immutable. - var properties = new ArrayList<>(BASE_PROPERTIES); + // Initialize a set of config properties with our base properties. + var properties = new TreeSet<>(Comparator.comparing(ConfigProperty::name)); + properties.addAll(BASE_PROPERTIES); // Smithy is transport agnostic, so we don't add http-related properties by default. // Nevertheless, HTTP is the most common use case so we standardize those settings