File tree Expand file tree Collapse file tree 5 files changed +38
-18
lines changed
aws/core/src/main/java/software/amazon/smithy/python/aws/codegen
core/src/main/java/software/amazon/smithy/python/codegen/generators Expand file tree Collapse file tree 5 files changed +38
-18
lines changed Original file line number Diff line number Diff line change 1010import software .amazon .smithy .codegen .core .Symbol ;
1111import software .amazon .smithy .model .shapes .ShapeId ;
1212import software .amazon .smithy .model .traits .HttpApiKeyAuthTrait ;
13+ import static software .amazon .smithy .python .aws .codegen .AwsConfiguration .REGION ;
1314import software .amazon .smithy .python .codegen .ApplicationProtocol ;
1415import software .amazon .smithy .python .codegen .CodegenUtils ;
1516import software .amazon .smithy .python .codegen .ConfigProperty ;
@@ -30,13 +31,6 @@ public class AwsAuthIntegration implements PythonIntegration {
3031
3132 @ Override
3233 public List <RuntimeClientPlugin > getClientPlugins (GenerationContext context ) {
33- var regionConfig = ConfigProperty .builder ()
34- .name ("region" )
35- .type (Symbol .builder ().name ("str" ).build ())
36- .documentation (" The AWS region to connect to. The configured region is used to "
37- + "determine the service endpoint." )
38- .build ();
39-
4034 return List .of (
4135 RuntimeClientPlugin .builder ()
4236 .servicePredicate ((model , service ) -> service .hasTrait (SigV4Trait .class ))
@@ -65,7 +59,7 @@ public List<RuntimeClientPlugin> getClientPlugins(GenerationContext context) {
6559 // TODO: Initialize with the provider chain?
6660 .nullable (true )
6761 .build ())
68- .addConfigProperty (regionConfig )
62+ .addConfigProperty (REGION )
6963 .authScheme (new Sigv4AuthScheme ())
7064 .build ()
7165 );
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+ package software .amazon .smithy .python .aws .codegen ;
6+
7+ import software .amazon .smithy .codegen .core .Symbol ;
8+ import software .amazon .smithy .python .codegen .ConfigProperty ;
9+ import software .amazon .smithy .utils .SmithyUnstableApi ;
10+
11+ /**
12+ * Common configuration for AWS Clients.
13+ */
14+ @ SmithyUnstableApi
15+ public final class AwsConfiguration {
16+ private AwsConfiguration () {
17+ }
18+
19+ public static final ConfigProperty REGION = ConfigProperty .builder ()
20+ .name ("region" )
21+ .type (Symbol .builder ().name ("str" ).build ())
22+ .documentation (" The AWS region to connect to. The configured region is used to "
23+ + "determine the service endpoint." )
24+ .build ();
25+ }
Original file line number Diff line number Diff line change 1212 */
1313@ SmithyUnstableApi
1414public class AwsPythonDependency {
15+
16+ private AwsPythonDependency () {
17+ }
18+
1519 /**
1620 * The core aws smithy runtime python package.
1721 *
Original file line number Diff line number Diff line change 77import java .util .List ;
88import software .amazon .smithy .aws .traits .ServiceTrait ;
99import software .amazon .smithy .codegen .core .Symbol ;
10+ import static software .amazon .smithy .python .aws .codegen .AwsConfiguration .REGION ;
1011import software .amazon .smithy .python .codegen .CodegenUtils ;
1112import software .amazon .smithy .python .codegen .ConfigProperty ;
1213import software .amazon .smithy .python .codegen .GenerationContext ;
@@ -23,15 +24,9 @@ public class AwsStandardRegionalEndpointsIntegration implements PythonIntegratio
2324 @ Override
2425 public List <RuntimeClientPlugin > getClientPlugins (GenerationContext context ) {
2526 if (context .applicationProtocol ().isHttpProtocol ()) {
26- var region = ConfigProperty .builder ()
27- .name ("region" )
28- .type (Symbol .builder ().name ("str" ).build ())
29- .documentation (" The AWS region to connect to. The configured region is used to "
30- + "determine the service endpoint." )
31- .build ();
3227 return List .of (
3328 RuntimeClientPlugin .builder ()
34- .addConfigProperty (region )
29+ .addConfigProperty (REGION )
3530 .build ());
3631 } else {
3732 return List .of ();
Original file line number Diff line number Diff line change 77import java .util .ArrayList ;
88import java .util .Arrays ;
99import java .util .Collection ;
10+ import java .util .Comparator ;
1011import java .util .LinkedHashMap ;
1112import java .util .List ;
1213import java .util .Locale ;
14+ import java .util .TreeSet ;
1315import software .amazon .smithy .codegen .core .Symbol ;
1416import software .amazon .smithy .model .knowledge .EventStreamIndex ;
1517import software .amazon .smithy .model .knowledge .ServiceIndex ;
@@ -288,9 +290,9 @@ private void writeInterceptorsType(PythonWriter writer) {
288290 private void generateConfig (GenerationContext context , PythonWriter writer ) {
289291 var configSymbol = CodegenUtils .getConfigSymbol (context .settings ());
290292
291- // Initialize the list of config properties with our base properties. Here a new
292- // list is constructed because that base list is immutable.
293- var properties = new ArrayList <> (BASE_PROPERTIES );
293+ // Initialize a set of config properties with our base properties.
294+ var properties = new TreeSet <>( Comparator . comparing ( ConfigProperty :: name ));
295+ properties . addAll (BASE_PROPERTIES );
294296
295297 // Smithy is transport agnostic, so we don't add http-related properties by default.
296298 // Nevertheless, HTTP is the most common use case so we standardize those settings
You can’t perform that action at this time.
0 commit comments