From 0d31702a8a7f9377ab23d857372134fce5d49611 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Tue, 7 Jan 2025 10:27:57 -0500 Subject: [PATCH 01/12] feat: provide client config property for region provider --- aws-runtime/aws-config/api/aws-config.api | 21 ++++++++++++ .../config/AbstractAwsSdkClientFactory.kt | 3 +- .../runtime/config}/AwsSdkClientConfig.kt | 25 +++++++++++++- .../config/AbstractAwsSdkClientFactoryTest.kt | 4 ++- aws-runtime/aws-core/api/aws-core.api | 18 ---------- .../sdk/kotlin/codegen/AwsKotlinDependency.kt | 5 +++ .../aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt | 13 ++++++-- .../codegen/AwsServiceConfigIntegration.kt | 16 +++++++-- .../codegen/RegionProviderIntegration.kt | 33 +++++++++++++++++++ .../ServiceClientCompanionObjectWriter.kt | 11 +++++++ .../endpoints/BindAwsEndpointBuiltins.kt | 4 +-- ...tlin.codegen.integration.KotlinIntegration | 1 + .../AwsServiceConfigIntegrationTest.kt | 2 +- 13 files changed, 126 insertions(+), 30 deletions(-) rename aws-runtime/{aws-core/common/src/aws/sdk/kotlin/runtime/client => aws-config/common/src/aws/sdk/kotlin/runtime/config}/AwsSdkClientConfig.kt (75%) create mode 100644 codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt diff --git a/aws-runtime/aws-config/api/aws-config.api b/aws-runtime/aws-config/api/aws-config.api index 05589280306..442f8d6f13b 100644 --- a/aws-runtime/aws-config/api/aws-config.api +++ b/aws-runtime/aws-config/api/aws-config.api @@ -222,6 +222,27 @@ public abstract class aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory public static synthetic fun fromEnvironment$default (Laws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } +public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig : aws/smithy/kotlin/runtime/client/SdkClientConfig { + public abstract fun getApplicationId ()Ljava/lang/String; + public abstract fun getRegion ()Ljava/lang/String; + public abstract fun getRegionProvider ()Laws/sdk/kotlin/runtime/region/RegionProvider; + public abstract fun getUseDualStack ()Z + public abstract fun getUseFips ()Z +} + +public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig$Builder { + public abstract fun getApplicationId ()Ljava/lang/String; + public abstract fun getRegion ()Ljava/lang/String; + public abstract fun getRegionProvider ()Laws/sdk/kotlin/runtime/region/RegionProvider; + public abstract fun getUseDualStack ()Ljava/lang/Boolean; + public abstract fun getUseFips ()Ljava/lang/Boolean; + public abstract fun setApplicationId (Ljava/lang/String;)V + public abstract fun setRegion (Ljava/lang/String;)V + public abstract fun setRegionProvider (Laws/sdk/kotlin/runtime/region/RegionProvider;)V + public abstract fun setUseDualStack (Ljava/lang/Boolean;)V + public abstract fun setUseFips (Ljava/lang/Boolean;)V +} + public final class aws/sdk/kotlin/runtime/config/AwsSdkSetting { public static final field INSTANCE Laws/sdk/kotlin/runtime/config/AwsSdkSetting; public final fun getAwsAccessKeyId ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting; diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory.kt index ed5f4b0cd99..2832b08c71c 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory.kt @@ -5,7 +5,6 @@ package aws.sdk.kotlin.runtime.config -import aws.sdk.kotlin.runtime.client.AwsSdkClientConfig import aws.sdk.kotlin.runtime.config.compression.resolveDisableRequestCompression import aws.sdk.kotlin.runtime.config.compression.resolveRequestMinCompressionSizeBytes import aws.sdk.kotlin.runtime.config.endpoints.resolveUseDualStack @@ -74,7 +73,7 @@ public abstract class AbstractAwsSdkClientFactory< block?.let(config::apply) config.logMode = config.logMode ?: ClientSettings.LogMode.resolve(platform = platform) - config.region = config.region ?: resolveRegion(profile = profile) + config.region = config.region ?: config.regionProvider?.getRegion() ?: resolveRegion(profile = profile) config.useFips = config.useFips ?: resolveUseFips(profile = profile) config.useDualStack = config.useDualStack ?: resolveUseDualStack(profile = profile) config.applicationId = config.applicationId ?: resolveUserAgentAppId(platform, profile) diff --git a/aws-runtime/aws-core/common/src/aws/sdk/kotlin/runtime/client/AwsSdkClientConfig.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt similarity index 75% rename from aws-runtime/aws-core/common/src/aws/sdk/kotlin/runtime/client/AwsSdkClientConfig.kt rename to aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt index b8073748e0e..540cc4cfb23 100644 --- a/aws-runtime/aws-core/common/src/aws/sdk/kotlin/runtime/client/AwsSdkClientConfig.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt @@ -3,10 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package aws.sdk.kotlin.runtime.client +package aws.sdk.kotlin.runtime.config import aws.smithy.kotlin.runtime.client.SdkClientConfig +import aws.sdk.kotlin.runtime.region.RegionProvider + /** * Base interface all generated AWS SDK Kotlin clients implement */ @@ -18,6 +20,16 @@ public interface AwsSdkClientConfig : SdkClientConfig { * information */ public val region: String? + /** + * An optional region provider that determines the AWS region for client operations. When specified, this provider + * takes precedence over the default region provider chain, unless a static region is explicitly configured. + * + * Region Resolution Priority: + * 1. Static region (if specified) + * 2. Custom region provider (if configured) + * 3. Default region provider chain + */ + public val regionProvider: RegionProvider? /** * Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests. @@ -54,6 +66,17 @@ public interface AwsSdkClientConfig : SdkClientConfig { */ public var region: String? + /** + * An optional region provider that determines the AWS region for client operations. When specified, this provider + * takes precedence over the default region provider chain, unless a static region is explicitly configured. + * + * Region Resolution Priority: + * 1. Static region (if specified) + * 2. Custom region provider (if configured) + * 3. Default region provider chain + */ + public var regionProvider: RegionProvider? + /** * Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests. * Disabled by default. diff --git a/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt b/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt index b5df492e23f..6568a62ca53 100644 --- a/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt +++ b/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt @@ -5,10 +5,10 @@ package aws.sdk.kotlin.runtime.config -import aws.sdk.kotlin.runtime.client.AwsSdkClientConfig import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig import aws.sdk.kotlin.runtime.config.useragent.resolveUserAgentAppId import aws.sdk.kotlin.runtime.config.utils.mockPlatform +import aws.sdk.kotlin.runtime.region.RegionProvider import aws.smithy.kotlin.runtime.client.* import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy import aws.smithy.kotlin.runtime.util.PlatformProvider @@ -129,6 +129,7 @@ private interface TestClient : SdkClient { override val clientName: String = builder.clientName override val logMode: LogMode = builder.logMode ?: LogMode.Default override val region: String? = builder.region + override var regionProvider: RegionProvider? = builder.regionProvider override var useFips: Boolean = builder.useFips ?: false override var useDualStack: Boolean = builder.useDualStack ?: false override val applicationId: String? = builder.applicationId @@ -141,6 +142,7 @@ private interface TestClient : SdkClient { override var clientName: String = "Test" override var logMode: LogMode? = LogMode.Default override var region: String? = null + override var regionProvider: RegionProvider? = null override var useFips: Boolean? = null override var useDualStack: Boolean? = null override var applicationId: String? = null diff --git a/aws-runtime/aws-core/api/aws-core.api b/aws-runtime/aws-core/api/aws-core.api index 612389b04ac..406106edd66 100644 --- a/aws-runtime/aws-core/api/aws-core.api +++ b/aws-runtime/aws-core/api/aws-core.api @@ -35,21 +35,3 @@ public final class aws/sdk/kotlin/runtime/client/AwsClientOption { public final fun getRegion ()Laws/smithy/kotlin/runtime/collections/AttributeKey; } -public abstract interface class aws/sdk/kotlin/runtime/client/AwsSdkClientConfig : aws/smithy/kotlin/runtime/client/SdkClientConfig { - public abstract fun getApplicationId ()Ljava/lang/String; - public abstract fun getRegion ()Ljava/lang/String; - public abstract fun getUseDualStack ()Z - public abstract fun getUseFips ()Z -} - -public abstract interface class aws/sdk/kotlin/runtime/client/AwsSdkClientConfig$Builder { - public abstract fun getApplicationId ()Ljava/lang/String; - public abstract fun getRegion ()Ljava/lang/String; - public abstract fun getUseDualStack ()Ljava/lang/Boolean; - public abstract fun getUseFips ()Ljava/lang/Boolean; - public abstract fun setApplicationId (Ljava/lang/String;)V - public abstract fun setRegion (Ljava/lang/String;)V - public abstract fun setUseDualStack (Ljava/lang/Boolean;)V - public abstract fun setUseFips (Ljava/lang/Boolean;)V -} - diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt index cfbe2e0b359..3648e7ec140 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt @@ -12,6 +12,10 @@ import software.amazon.smithy.kotlin.codegen.core.isValidVersion // root namespace for the AWS client-runtime const val AWS_CLIENT_RT_ROOT_NS = "aws.sdk.kotlin.runtime" +// groupId and version for kotlin coroutines +const val KOTLINX_COROUTINES_GROUP: String = "org.jetbrains.kotlinx" +const val KOTLINX_COROUTINES_VERSION: String = "1.7.3" + private fun getDefaultRuntimeVersion(): String { // generated as part of the build, see smithy-aws-kotlin-codegen/build.gradle.kts try { @@ -38,6 +42,7 @@ object AwsKotlinDependency { val AWS_CONFIG = KotlinDependency(GradleConfiguration.Api, AWS_CLIENT_RT_ROOT_NS, AWS_CLIENT_RT_GROUP, "aws-config", AWS_CLIENT_RT_VERSION) val AWS_ENDPOINT = KotlinDependency(GradleConfiguration.Api, "$AWS_CLIENT_RT_ROOT_NS.endpoint", AWS_CLIENT_RT_GROUP, "aws-endpoint", AWS_CLIENT_RT_VERSION) val AWS_HTTP = KotlinDependency(GradleConfiguration.Implementation, "$AWS_CLIENT_RT_ROOT_NS.http", AWS_CLIENT_RT_GROUP, "aws-http", AWS_CLIENT_RT_VERSION) + val KOTLINX_COROUTINES = KotlinDependency(GradleConfiguration.Implementation, "kotlinx.coroutines", KOTLINX_COROUTINES_GROUP, "kotlinx-coroutines-core", KOTLINX_COROUTINES_VERSION) } // remap aws-sdk-kotlin dependencies to project notation diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt index b4debfc4bd8..57257234a86 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt @@ -16,10 +16,10 @@ object AwsRuntimeTypes { val AwsErrorMetadata = symbol("AwsErrorMetadata") val AwsServiceException = symbol("AwsServiceException") val ClientException = symbol("ClientException") + } - object Client : RuntimeTypePackage(AwsKotlinDependency.AWS_CORE, "client") { - val AwsSdkClientConfig = symbol("AwsSdkClientConfig") - } + object Coroutines : RuntimeTypePackage(AwsKotlinDependency.KOTLINX_COROUTINES) { + val runBlocking = symbol("runBlocking") } object Endpoint : RuntimeTypePackage(AwsKotlinDependency.AWS_ENDPOINT) { @@ -36,6 +36,8 @@ object AwsRuntimeTypes { object Config : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG) { val AbstractAwsSdkClientFactory = symbol("AbstractAwsSdkClientFactory", "config") + val AwsSdkClientConfig = symbol("AwsSdkClientConfig", "config") + object Endpoints : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG, "config.endpoints") { val AccountIdEndpointMode = symbol("AccountIdEndpointMode") val resolveEndpointUrl = symbol("resolveEndpointUrl") @@ -54,6 +56,11 @@ object AwsRuntimeTypes { val StaticCredentialsProvider = symbol("StaticCredentialsProvider") val manage = symbol("manage", "auth.credentials.internal", isExtension = true) } + + object Region : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG, "region") { + val RegionProvider = symbol("RegionProvider") + val resolveRegion = symbol("resolveRegion") + } } object Http : RuntimeTypePackage(AwsKotlinDependency.AWS_HTTP) { diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt index 044fd39bb71..204ac73a4be 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt @@ -24,20 +24,32 @@ class AwsServiceConfigIntegration : KotlinIntegration { val RegionProp: ConfigProperty = ConfigProperty { name = "region" symbol = KotlinTypes.String.toBuilder().nullable().build() - baseClass = AwsRuntimeTypes.Core.Client.AwsSdkClientConfig + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig useNestedBuilderBaseClass() documentation = """ The AWS region (e.g. `us-west-2`) to make requests to. See about AWS [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more information """.trimIndent() + + propertyType = ConfigPropertyType.Custom( + render = { prop, writer -> + writer.write("override val #1L: #2T? = builder.#1L ?: #3T{ builder.regionProvider?.getRegion() ?: #4T() }", + prop.propertyName, + prop.symbol, + AwsRuntimeTypes.Coroutines.runBlocking, + AwsRuntimeTypes.Config.Region.resolveRegion + ) + } + ) + order = -100 } val UserAgentAppId: ConfigProperty = ConfigProperty { name = "applicationId" symbol = KotlinTypes.String.asNullable() - baseClass = AwsRuntimeTypes.Core.Client.AwsSdkClientConfig + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig useNestedBuilderBaseClass() documentation = """ An optional application specific identifier. diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt new file mode 100644 index 00000000000..4b3464b976b --- /dev/null +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt @@ -0,0 +1,33 @@ +package aws.sdk.kotlin.codegen + +import software.amazon.smithy.kotlin.codegen.core.CodegenContext +import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration +import software.amazon.smithy.kotlin.codegen.model.asNullable +import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty + +/** + * Adds region provider integration to the client config + */ +class RegionProviderIntegration : KotlinIntegration { + companion object { + val RegionProviderProp: ConfigProperty = ConfigProperty { + name = "regionProvider" + symbol = AwsRuntimeTypes.Config.Region.RegionProvider.asNullable() + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig + useNestedBuilderBaseClass() + documentation = """ + An optional region provider that determines the AWS region for client operations. When specified, this provider + takes precedence over the default region provider chain, unless a static region is explicitly configured. + + The region resolution order is: + 1. Static region (if specified) + 2. Custom region provider (if configured) + 3. Default region provider chain + """.trimIndent() + } + } + + override fun additionalServiceConfigProps(ctx: CodegenContext): List = buildList { + add(RegionProviderProp) + } +} \ No newline at end of file diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt index 4f015735231..16f86572222 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt @@ -35,6 +35,7 @@ class ServiceClientCompanionObjectWriter : AppendingSectionWriter { declareSection(FinalizeEnvironmentalConfig) { write("super.#L(builder, sharedConfig, activeProfile)", funName) writeResolveEndpointUrl() +// writeRegionWithRegionProvider() } } } @@ -54,6 +55,16 @@ class ServiceClientCompanionObjectWriter : AppendingSectionWriter { write("#S,", names.sharedConfigKey) } } + +// private fun KotlinWriter.writeRegionWithRegionProvider() { +// withBlock( +// "builder.config.region = builder.config.region ?: builder.config.regionProvider?.getRegion() ?: #T(", +// ")", +// AwsRuntimeTypes.Config.Region.resolveRegion, +// ) { +// write("profile = activeProfile") +// } +// } } internal data class EndpointUrlConfigNames( diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/endpoints/BindAwsEndpointBuiltins.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/endpoints/BindAwsEndpointBuiltins.kt index 5c418be243e..8186804c565 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/endpoints/BindAwsEndpointBuiltins.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/endpoints/BindAwsEndpointBuiltins.kt @@ -38,7 +38,7 @@ class BindAwsEndpointBuiltins : KotlinIntegration { Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests. ` Disabled by default. """.trimIndent() - baseClass = AwsRuntimeTypes.Core.Client.AwsSdkClientConfig + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig useNestedBuilderBaseClass() } @@ -50,7 +50,7 @@ class BindAwsEndpointBuiltins : KotlinIntegration { See [https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoints.html] for more information. ` Disabled by default. """.trimIndent() - baseClass = AwsRuntimeTypes.Core.Client.AwsSdkClientConfig + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig useNestedBuilderBaseClass() } } diff --git a/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration b/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration index 60ccb728f63..723d644e329 100644 --- a/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration +++ b/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration @@ -2,6 +2,7 @@ aws.sdk.kotlin.codegen.AddUserAgentMetadataIntegration aws.sdk.kotlin.codegen.AwsServiceConfigIntegration aws.sdk.kotlin.codegen.GradleGenerator aws.sdk.kotlin.codegen.AwsRetryHeaderIntegration +aws.sdk.kotlin.codegen.RegionProviderIntegration aws.sdk.kotlin.codegen.customization.ReplaceServiceExceptionBase aws.sdk.kotlin.codegen.customization.DefaultMiddleware aws.sdk.kotlin.codegen.customization.AccountIdEndpointBuiltinCustomization diff --git a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt index 9303d312e12..7e60c0963fb 100644 --- a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt +++ b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt @@ -45,7 +45,7 @@ class AwsServiceConfigIntegrationTest { val contents = writer.toString() val expectedProps = """ - override val region: String? = builder.region + override val region: String? = builder.region ?: runBlocking{ builder.regionProvider?.getRegion() ?: resolveRegion() } override val credentialsProvider: CredentialsProvider = builder.credentialsProvider ?: DefaultChainCredentialsProvider(httpClient = httpClient, region = region).manage() """ contents.shouldContainOnlyOnceWithDiff(expectedProps) From acec62e1459d3c4bc02560a9ec3ea46c7df36bd7 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Tue, 7 Jan 2025 10:49:35 -0500 Subject: [PATCH 02/12] lint --- .../aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt | 4 ++-- .../aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt | 7 ++++--- .../aws/sdk/kotlin/codegen/RegionProviderIntegration.kt | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt index 540cc4cfb23..f02575609bd 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt @@ -5,9 +5,8 @@ package aws.sdk.kotlin.runtime.config -import aws.smithy.kotlin.runtime.client.SdkClientConfig - import aws.sdk.kotlin.runtime.region.RegionProvider +import aws.smithy.kotlin.runtime.client.SdkClientConfig /** * Base interface all generated AWS SDK Kotlin clients implement @@ -20,6 +19,7 @@ public interface AwsSdkClientConfig : SdkClientConfig { * information */ public val region: String? + /** * An optional region provider that determines the AWS region for client operations. When specified, this provider * takes precedence over the default region provider chain, unless a static region is explicitly configured. diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt index 204ac73a4be..4254f3e727b 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt @@ -34,13 +34,14 @@ class AwsServiceConfigIntegration : KotlinIntegration { propertyType = ConfigPropertyType.Custom( render = { prop, writer -> - writer.write("override val #1L: #2T? = builder.#1L ?: #3T{ builder.regionProvider?.getRegion() ?: #4T() }", + writer.write( + "override val #1L: #2T? = builder.#1L ?: #3T{ builder.regionProvider?.getRegion() ?: #4T() }", prop.propertyName, prop.symbol, AwsRuntimeTypes.Coroutines.runBlocking, - AwsRuntimeTypes.Config.Region.resolveRegion + AwsRuntimeTypes.Config.Region.resolveRegion, ) - } + }, ) order = -100 diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt index 4b3464b976b..8570caff6a7 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt @@ -30,4 +30,4 @@ class RegionProviderIntegration : KotlinIntegration { override fun additionalServiceConfigProps(ctx: CodegenContext): List = buildList { add(RegionProviderProp) } -} \ No newline at end of file +} From 01507ac3924f598b24df6333cbe8085233aa4f9a Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Tue, 7 Jan 2025 16:17:09 -0500 Subject: [PATCH 03/12] change log --- .changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json diff --git a/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json b/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json new file mode 100644 index 00000000000..5c77cde7dce --- /dev/null +++ b/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json @@ -0,0 +1,8 @@ +{ + "id": "05ac561b-963f-4953-bb4f-1fc19fc1207c", + "type": "feature", + "description": "add regionProvider property to client config", + "issues": [ + "awslabs/aws-sdk-kotlin#1478" + ] +} \ No newline at end of file From ca01936893e4d1672b95eea1c0aa85ad96940624 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Tue, 7 Jan 2025 17:02:47 -0500 Subject: [PATCH 04/12] remove commented code --- .../codegen/ServiceClientCompanionObjectWriter.kt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt index 16f86572222..4f015735231 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt @@ -35,7 +35,6 @@ class ServiceClientCompanionObjectWriter : AppendingSectionWriter { declareSection(FinalizeEnvironmentalConfig) { write("super.#L(builder, sharedConfig, activeProfile)", funName) writeResolveEndpointUrl() -// writeRegionWithRegionProvider() } } } @@ -55,16 +54,6 @@ class ServiceClientCompanionObjectWriter : AppendingSectionWriter { write("#S,", names.sharedConfigKey) } } - -// private fun KotlinWriter.writeRegionWithRegionProvider() { -// withBlock( -// "builder.config.region = builder.config.region ?: builder.config.regionProvider?.getRegion() ?: #T(", -// ")", -// AwsRuntimeTypes.Config.Region.resolveRegion, -// ) { -// write("profile = activeProfile") -// } -// } } internal data class EndpointUrlConfigNames( From a7205063d1794bb5763df0b664d57df48939df51 Mon Sep 17 00:00:00 2001 From: 0marperez Date: Wed, 8 Jan 2025 12:14:58 -0500 Subject: [PATCH 05/12] Trigger CI From 21487ebc4eab40edb588c5d806e1c0b3244244b7 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Wed, 8 Jan 2025 16:01:04 -0500 Subject: [PATCH 06/12] address PR reviews --- .changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json | 2 +- .../main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt | 1 - .../src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt | 4 ---- .../aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt | 4 ++-- tests/codegen/event-stream/build.gradle.kts | 3 +++ 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json b/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json index 5c77cde7dce..9465e61b9fe 100644 --- a/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json +++ b/.changes/05ac561b-963f-4953-bb4f-1fc19fc1207c.json @@ -1,7 +1,7 @@ { "id": "05ac561b-963f-4953-bb4f-1fc19fc1207c", "type": "feature", - "description": "add regionProvider property to client config", + "description": "Add `regionProvider` property to client config", "issues": [ "awslabs/aws-sdk-kotlin#1478" ] diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt index 3648e7ec140..cd69a9674e5 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt @@ -42,7 +42,6 @@ object AwsKotlinDependency { val AWS_CONFIG = KotlinDependency(GradleConfiguration.Api, AWS_CLIENT_RT_ROOT_NS, AWS_CLIENT_RT_GROUP, "aws-config", AWS_CLIENT_RT_VERSION) val AWS_ENDPOINT = KotlinDependency(GradleConfiguration.Api, "$AWS_CLIENT_RT_ROOT_NS.endpoint", AWS_CLIENT_RT_GROUP, "aws-endpoint", AWS_CLIENT_RT_VERSION) val AWS_HTTP = KotlinDependency(GradleConfiguration.Implementation, "$AWS_CLIENT_RT_ROOT_NS.http", AWS_CLIENT_RT_GROUP, "aws-http", AWS_CLIENT_RT_VERSION) - val KOTLINX_COROUTINES = KotlinDependency(GradleConfiguration.Implementation, "kotlinx.coroutines", KOTLINX_COROUTINES_GROUP, "kotlinx-coroutines-core", KOTLINX_COROUTINES_VERSION) } // remap aws-sdk-kotlin dependencies to project notation diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt index 57257234a86..bae07928f9f 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt @@ -18,10 +18,6 @@ object AwsRuntimeTypes { val ClientException = symbol("ClientException") } - object Coroutines : RuntimeTypePackage(AwsKotlinDependency.KOTLINX_COROUTINES) { - val runBlocking = symbol("runBlocking") - } - object Endpoint : RuntimeTypePackage(AwsKotlinDependency.AWS_ENDPOINT) { object Functions : RuntimeTypePackage(AwsKotlinDependency.AWS_ENDPOINT, "functions") { val partitionFn = symbol("partition") diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt index 4254f3e727b..43ee6053e1a 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt @@ -35,10 +35,10 @@ class AwsServiceConfigIntegration : KotlinIntegration { propertyType = ConfigPropertyType.Custom( render = { prop, writer -> writer.write( - "override val #1L: #2T? = builder.#1L ?: #3T{ builder.regionProvider?.getRegion() ?: #4T() }", + "override val #1L: #2T? = builder.#1L ?: #3T { builder.regionProvider?.getRegion() ?: #4T() }", prop.propertyName, prop.symbol, - AwsRuntimeTypes.Coroutines.runBlocking, + KotlinTypes.Coroutines.runBlocking, AwsRuntimeTypes.Config.Region.resolveRegion, ) }, diff --git a/tests/codegen/event-stream/build.gradle.kts b/tests/codegen/event-stream/build.gradle.kts index 837d12b2d3c..4a329769d57 100644 --- a/tests/codegen/event-stream/build.gradle.kts +++ b/tests/codegen/event-stream/build.gradle.kts @@ -94,6 +94,9 @@ tasks.generateSmithyProjections { // ensure the generated tests use the same version of the runtime as the aws aws-runtime val smithyKotlinRuntimeVersion = libs.versions.smithy.kotlin.runtime.version.get() System.setProperty("smithy.kotlin.codegen.clientRuntimeVersion", smithyKotlinRuntimeVersion) + + val smithyKotlinCoroutinesVersion = libs.versions.coroutines.version.get() + System.setProperty("smithy.kotlin.codegen.kotlinCoroutinesVersion", smithyKotlinCoroutinesVersion) } } From 91f08b4aada067e9faedd01373c16a4dfbe1470f Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Wed, 8 Jan 2025 16:05:14 -0500 Subject: [PATCH 07/12] address PR reviews --- .../main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt index cd69a9674e5..cfbe2e0b359 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsKotlinDependency.kt @@ -12,10 +12,6 @@ import software.amazon.smithy.kotlin.codegen.core.isValidVersion // root namespace for the AWS client-runtime const val AWS_CLIENT_RT_ROOT_NS = "aws.sdk.kotlin.runtime" -// groupId and version for kotlin coroutines -const val KOTLINX_COROUTINES_GROUP: String = "org.jetbrains.kotlinx" -const val KOTLINX_COROUTINES_VERSION: String = "1.7.3" - private fun getDefaultRuntimeVersion(): String { // generated as part of the build, see smithy-aws-kotlin-codegen/build.gradle.kts try { From 82dfc9d5b8af81805ad1da10043b36eea3bce9a1 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Wed, 8 Jan 2025 16:21:41 -0500 Subject: [PATCH 08/12] address PR reviews --- .../aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt index 7e60c0963fb..6d77a7272af 100644 --- a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt +++ b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt @@ -45,7 +45,7 @@ class AwsServiceConfigIntegrationTest { val contents = writer.toString() val expectedProps = """ - override val region: String? = builder.region ?: runBlocking{ builder.regionProvider?.getRegion() ?: resolveRegion() } + override val region: String? = builder.region ?: runBlocking { builder.regionProvider?.getRegion() ?: resolveRegion() } override val credentialsProvider: CredentialsProvider = builder.credentialsProvider ?: DefaultChainCredentialsProvider(httpClient = httpClient, region = region).manage() """ contents.shouldContainOnlyOnceWithDiff(expectedProps) From c2eebae93c6b9325b868dc12e88db12bcdfb8e2b Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 10 Jan 2025 13:26:16 -0500 Subject: [PATCH 09/12] address pr reviews --- aws-runtime/aws-config/api/aws-config.api | 26 +++++++-------- .../runtime/config/AwsSdkClientConfig.kt | 2 +- .../region/DefaultRegionProviderChain.kt | 1 + .../region/EnvironmentRegionProvider.kt | 1 + .../runtime/region/ImdsRegionProvider.kt | 1 + .../runtime/region/ProfileRegionProvider.kt | 1 + .../kotlin/runtime/region/RegionProvider.kt | 17 ---------- .../runtime/region/RegionProviderChain.kt | 1 + .../region/AwsRegionProviderChainTest.kt | 1 + .../region/DefaultRegionProviderChainJVM.kt | 1 + .../region/JvmSystemPropRegionProvider.kt | 1 + .../config/AbstractAwsSdkClientFactoryTest.kt | 2 +- .../aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt | 1 - .../codegen/AwsServiceConfigIntegration.kt | 22 +++++++++++-- .../codegen/RegionProviderIntegration.kt | 33 ------------------- ...tlin.codegen.integration.KotlinIntegration | 1 - .../AwsServiceConfigIntegrationTest.kt | 13 +++++++- tests/codegen/event-stream/build.gradle.kts | 3 -- 18 files changed, 53 insertions(+), 75 deletions(-) delete mode 100644 aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProvider.kt delete mode 100644 codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt diff --git a/aws-runtime/aws-config/api/aws-config.api b/aws-runtime/aws-config/api/aws-config.api index 442f8d6f13b..ffc00b119f1 100644 --- a/aws-runtime/aws-config/api/aws-config.api +++ b/aws-runtime/aws-config/api/aws-config.api @@ -225,7 +225,7 @@ public abstract class aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig : aws/smithy/kotlin/runtime/client/SdkClientConfig { public abstract fun getApplicationId ()Ljava/lang/String; public abstract fun getRegion ()Ljava/lang/String; - public abstract fun getRegionProvider ()Laws/sdk/kotlin/runtime/region/RegionProvider; + public abstract fun getRegionProvider ()Laws/smithy/kotlin/runtime/client/region/RegionProvider; public abstract fun getUseDualStack ()Z public abstract fun getUseFips ()Z } @@ -233,12 +233,12 @@ public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig$Builder { public abstract fun getApplicationId ()Ljava/lang/String; public abstract fun getRegion ()Ljava/lang/String; - public abstract fun getRegionProvider ()Laws/sdk/kotlin/runtime/region/RegionProvider; + public abstract fun getRegionProvider ()Laws/smithy/kotlin/runtime/client/region/RegionProvider; public abstract fun getUseDualStack ()Ljava/lang/Boolean; public abstract fun getUseFips ()Ljava/lang/Boolean; public abstract fun setApplicationId (Ljava/lang/String;)V public abstract fun setRegion (Ljava/lang/String;)V - public abstract fun setRegionProvider (Laws/sdk/kotlin/runtime/region/RegionProvider;)V + public abstract fun setRegionProvider (Laws/smithy/kotlin/runtime/client/region/RegionProvider;)V public abstract fun setUseDualStack (Ljava/lang/Boolean;)V public abstract fun setUseFips (Ljava/lang/Boolean;)V } @@ -533,21 +533,21 @@ public final class aws/sdk/kotlin/runtime/config/useragent/ResolveUserAgentKt { public static synthetic fun resolveUserAgentAppId$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } -public final class aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProviderChain, aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable { +public final class aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProviderChain, aws/smithy/kotlin/runtime/client/region/RegionProvider, java/io/Closeable { public fun ()V public fun (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V public synthetic fun (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun close ()V } -public final class aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider { +public final class aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider { public fun ()V public fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;)V public synthetic fun (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable { +public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider, java/io/Closeable { public fun ()V public fun (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;)V public synthetic fun (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -555,14 +555,14 @@ public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/sdk/ko public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public final class aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider { +public final class aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider { public fun ()V public fun (Laws/smithy/kotlin/runtime/util/PropertyProvider;)V public synthetic fun (Laws/smithy/kotlin/runtime/util/PropertyProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider { +public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider { public fun ()V public fun (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V public synthetic fun (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -570,14 +570,10 @@ public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/sdk public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public abstract interface class aws/sdk/kotlin/runtime/region/RegionProvider { - public abstract fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public class aws/sdk/kotlin/runtime/region/RegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProvider { +public class aws/sdk/kotlin/runtime/region/RegionProviderChain : aws/smithy/kotlin/runtime/client/region/RegionProvider { public fun (Ljava/util/List;)V - public fun ([Laws/sdk/kotlin/runtime/region/RegionProvider;)V - protected final fun getProviders ()[Laws/sdk/kotlin/runtime/region/RegionProvider; + public fun ([Laws/smithy/kotlin/runtime/client/region/RegionProvider;)V + protected final fun getProviders ()[Laws/smithy/kotlin/runtime/client/region/RegionProvider; public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun toString ()Ljava/lang/String; } diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt index f02575609bd..dfd717c1e8e 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt @@ -5,8 +5,8 @@ package aws.sdk.kotlin.runtime.config -import aws.sdk.kotlin.runtime.region.RegionProvider import aws.smithy.kotlin.runtime.client.SdkClientConfig +import aws.smithy.kotlin.runtime.client.region.RegionProvider /** * Base interface all generated AWS SDK Kotlin clients implement diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain.kt index 25d59284b6c..5ac84815606 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain.kt @@ -9,6 +9,7 @@ import aws.sdk.kotlin.runtime.config.imds.ImdsClient import aws.sdk.kotlin.runtime.config.imds.InstanceMetadataProvider import aws.sdk.kotlin.runtime.config.profile.AwsProfile import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.io.Closeable import aws.smithy.kotlin.runtime.util.LazyAsyncValue import aws.smithy.kotlin.runtime.util.PlatformProvider diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider.kt index c1058296510..126083ebf4e 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider.kt @@ -6,6 +6,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.AwsSdkSetting +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.util.EnvironmentProvider import aws.smithy.kotlin.runtime.util.PlatformProvider diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ImdsRegionProvider.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ImdsRegionProvider.kt index 6b488006617..9191b9957df 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ImdsRegionProvider.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ImdsRegionProvider.kt @@ -8,6 +8,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.AwsSdkSetting import aws.sdk.kotlin.runtime.config.imds.ImdsClient import aws.sdk.kotlin.runtime.config.imds.InstanceMetadataProvider +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.config.resolve import aws.smithy.kotlin.runtime.io.Closeable import aws.smithy.kotlin.runtime.util.PlatformEnvironProvider diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ProfileRegionProvider.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ProfileRegionProvider.kt index 9e50d845d7b..c1b4491354b 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ProfileRegionProvider.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ProfileRegionProvider.kt @@ -8,6 +8,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.profile.AwsProfile import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig import aws.sdk.kotlin.runtime.config.profile.region +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.util.LazyAsyncValue import aws.smithy.kotlin.runtime.util.PlatformProvider import aws.smithy.kotlin.runtime.util.asyncLazy diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProvider.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProvider.kt deleted file mode 100644 index 63105bdf3c9..00000000000 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProvider.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -package aws.sdk.kotlin.runtime.region - -/** - * Interface for providing AWS region information. Implementations are free to use any strategy for - * providing region information - */ -public interface RegionProvider { - /** - * Return the region name to use. If region information is not available, implementations should return null - */ - public suspend fun getRegion(): String? -} diff --git a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProviderChain.kt b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProviderChain.kt index 4f7c4ce3012..431d8267533 100644 --- a/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProviderChain.kt +++ b/aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/RegionProviderChain.kt @@ -5,6 +5,7 @@ package aws.sdk.kotlin.runtime.region +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.telemetry.logging.logger import aws.smithy.kotlin.runtime.util.asyncLazy import kotlin.coroutines.coroutineContext diff --git a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/region/AwsRegionProviderChainTest.kt b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/region/AwsRegionProviderChainTest.kt index 495e715184f..a1ccc199da0 100644 --- a/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/region/AwsRegionProviderChainTest.kt +++ b/aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/region/AwsRegionProviderChainTest.kt @@ -5,6 +5,7 @@ package aws.sdk.kotlin.runtime.region +import aws.smithy.kotlin.runtime.client.region.RegionProvider import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals diff --git a/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainJVM.kt b/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainJVM.kt index b581deb1d18..aae8855d4ea 100644 --- a/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainJVM.kt +++ b/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainJVM.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.imds.InstanceMetadataProvider import aws.sdk.kotlin.runtime.config.profile.AwsProfile +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.io.Closeable import aws.smithy.kotlin.runtime.util.LazyAsyncValue import aws.smithy.kotlin.runtime.util.PlatformProvider diff --git a/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider.kt b/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider.kt index e2be63a151a..e992035cca5 100644 --- a/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider.kt +++ b/aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider.kt @@ -6,6 +6,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.AwsSdkSetting +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.util.PlatformProvider import aws.smithy.kotlin.runtime.util.PropertyProvider diff --git a/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt b/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt index 6568a62ca53..5cd6e362b0c 100644 --- a/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt +++ b/aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt @@ -8,8 +8,8 @@ package aws.sdk.kotlin.runtime.config import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig import aws.sdk.kotlin.runtime.config.useragent.resolveUserAgentAppId import aws.sdk.kotlin.runtime.config.utils.mockPlatform -import aws.sdk.kotlin.runtime.region.RegionProvider import aws.smithy.kotlin.runtime.client.* +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy import aws.smithy.kotlin.runtime.util.PlatformProvider import aws.smithy.kotlin.runtime.util.asyncLazy diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt index bae07928f9f..5b52661c0cf 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt @@ -54,7 +54,6 @@ object AwsRuntimeTypes { } object Region : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG, "region") { - val RegionProvider = symbol("RegionProvider") val resolveRegion = symbol("resolveRegion") } } diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt index 43ee6053e1a..b2b71dd0c4e 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt @@ -35,10 +35,10 @@ class AwsServiceConfigIntegration : KotlinIntegration { propertyType = ConfigPropertyType.Custom( render = { prop, writer -> writer.write( - "override val #1L: #2T? = builder.#1L ?: #3T { builder.regionProvider?.getRegion() ?: #4T() }", + "override val #1L: #2T? = builder.#1L ?: #3T { builder.regionProvider ?.getRegion() ?: #4T() }", prop.propertyName, prop.symbol, - KotlinTypes.Coroutines.runBlocking, + RuntimeTypes.KotlinxCoroutines.runBlocking, AwsRuntimeTypes.Config.Region.resolveRegion, ) }, @@ -47,6 +47,23 @@ class AwsServiceConfigIntegration : KotlinIntegration { order = -100 } + val RegionProviderProp: ConfigProperty = ConfigProperty { + name = "regionProvider" + symbol = RuntimeTypes.SmithyClient.Region.RegionProvider.asNullable() + baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig + useNestedBuilderBaseClass() + documentation = """ + An optional region provider that determines the AWS region for client operations. When specified, this provider + takes precedence over the default region provider chain, unless a static region is explicitly configured. + The region resolution order is: + 1. Static region (if specified) + 2. Custom region provider (if configured) + 3. Default region provider chain + """.trimIndent() + + order = -100 + } + val UserAgentAppId: ConfigProperty = ConfigProperty { name = "applicationId" symbol = KotlinTypes.String.asNullable() @@ -145,6 +162,7 @@ class AwsServiceConfigIntegration : KotlinIntegration { override fun additionalServiceConfigProps(ctx: CodegenContext): List = buildList { add(RegionProp) + add(RegionProviderProp) if (AwsSignatureVersion4.isSupportedAuthentication(ctx.model, ctx.settings.getService(ctx.model))) { add(CredentialsProviderProp) } diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt deleted file mode 100644 index 8570caff6a7..00000000000 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/RegionProviderIntegration.kt +++ /dev/null @@ -1,33 +0,0 @@ -package aws.sdk.kotlin.codegen - -import software.amazon.smithy.kotlin.codegen.core.CodegenContext -import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration -import software.amazon.smithy.kotlin.codegen.model.asNullable -import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty - -/** - * Adds region provider integration to the client config - */ -class RegionProviderIntegration : KotlinIntegration { - companion object { - val RegionProviderProp: ConfigProperty = ConfigProperty { - name = "regionProvider" - symbol = AwsRuntimeTypes.Config.Region.RegionProvider.asNullable() - baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig - useNestedBuilderBaseClass() - documentation = """ - An optional region provider that determines the AWS region for client operations. When specified, this provider - takes precedence over the default region provider chain, unless a static region is explicitly configured. - - The region resolution order is: - 1. Static region (if specified) - 2. Custom region provider (if configured) - 3. Default region provider chain - """.trimIndent() - } - } - - override fun additionalServiceConfigProps(ctx: CodegenContext): List = buildList { - add(RegionProviderProp) - } -} diff --git a/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration b/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration index 723d644e329..60ccb728f63 100644 --- a/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration +++ b/codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration @@ -2,7 +2,6 @@ aws.sdk.kotlin.codegen.AddUserAgentMetadataIntegration aws.sdk.kotlin.codegen.AwsServiceConfigIntegration aws.sdk.kotlin.codegen.GradleGenerator aws.sdk.kotlin.codegen.AwsRetryHeaderIntegration -aws.sdk.kotlin.codegen.RegionProviderIntegration aws.sdk.kotlin.codegen.customization.ReplaceServiceExceptionBase aws.sdk.kotlin.codegen.customization.DefaultMiddleware aws.sdk.kotlin.codegen.customization.AccountIdEndpointBuiltinCustomization diff --git a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt index 6d77a7272af..107830d978c 100644 --- a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt +++ b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt @@ -45,7 +45,8 @@ class AwsServiceConfigIntegrationTest { val contents = writer.toString() val expectedProps = """ - override val region: String? = builder.region ?: runBlocking { builder.regionProvider?.getRegion() ?: resolveRegion() } + override val region: String? = builder.region ?: runBlocking { builder.regionProvider ?.getRegion() ?: resolveRegion() } + override val regionProvider: RegionProvider? = builder.regionProvider override val credentialsProvider: CredentialsProvider = builder.credentialsProvider ?: DefaultChainCredentialsProvider(httpClient = httpClient, region = region).manage() """ contents.shouldContainOnlyOnceWithDiff(expectedProps) @@ -58,6 +59,16 @@ class AwsServiceConfigIntegrationTest { */ override var region: String? = null + /** + * An optional region provider that determines the AWS region for client operations. When specified, this provider + * takes precedence over the default region provider chain, unless a static region is explicitly configured. + * The region resolution order is: + * 1. Static region (if specified) + * 2. Custom region provider (if configured) + * 3. Default region provider chain + */ + override var regionProvider: RegionProvider? = null + /** * The AWS credentials provider to use for authenticating requests. If not provided a * [aws.sdk.kotlin.runtime.auth.credentials.DefaultChainCredentialsProvider] instance will be used. diff --git a/tests/codegen/event-stream/build.gradle.kts b/tests/codegen/event-stream/build.gradle.kts index 4a329769d57..837d12b2d3c 100644 --- a/tests/codegen/event-stream/build.gradle.kts +++ b/tests/codegen/event-stream/build.gradle.kts @@ -94,9 +94,6 @@ tasks.generateSmithyProjections { // ensure the generated tests use the same version of the runtime as the aws aws-runtime val smithyKotlinRuntimeVersion = libs.versions.smithy.kotlin.runtime.version.get() System.setProperty("smithy.kotlin.codegen.clientRuntimeVersion", smithyKotlinRuntimeVersion) - - val smithyKotlinCoroutinesVersion = libs.versions.coroutines.version.get() - System.setProperty("smithy.kotlin.codegen.kotlinCoroutinesVersion", smithyKotlinCoroutinesVersion) } } From a8a044a0c08fb356db190743cff1d8f4b6b01da6 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 10 Jan 2025 14:12:38 -0500 Subject: [PATCH 10/12] add missing import --- .../kotlin/runtime/region/DefaultRegionProviderChainNative.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/aws-runtime/aws-config/native/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainNative.kt b/aws-runtime/aws-config/native/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainNative.kt index 18ffb383e84..cd29e860991 100644 --- a/aws-runtime/aws-config/native/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainNative.kt +++ b/aws-runtime/aws-config/native/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainNative.kt @@ -7,6 +7,7 @@ package aws.sdk.kotlin.runtime.region import aws.sdk.kotlin.runtime.config.imds.InstanceMetadataProvider import aws.sdk.kotlin.runtime.config.profile.AwsProfile +import aws.smithy.kotlin.runtime.client.region.RegionProvider import aws.smithy.kotlin.runtime.io.Closeable import aws.smithy.kotlin.runtime.util.LazyAsyncValue import aws.smithy.kotlin.runtime.util.PlatformProvider From 761573cc7954ff1cbe1fb94c00f609557697c0b9 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 10 Jan 2025 15:37:47 -0500 Subject: [PATCH 11/12] remove extra space --- .../aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt | 2 +- .../aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt index b2b71dd0c4e..dbf63e2cb86 100644 --- a/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt +++ b/codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt @@ -35,7 +35,7 @@ class AwsServiceConfigIntegration : KotlinIntegration { propertyType = ConfigPropertyType.Custom( render = { prop, writer -> writer.write( - "override val #1L: #2T? = builder.#1L ?: #3T { builder.regionProvider ?.getRegion() ?: #4T() }", + "override val #1L: #2T? = builder.#1L ?: #3T { builder.regionProvider?.getRegion() ?: #4T() }", prop.propertyName, prop.symbol, RuntimeTypes.KotlinxCoroutines.runBlocking, diff --git a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt index 107830d978c..0a7df490cd9 100644 --- a/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt +++ b/codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt @@ -45,7 +45,7 @@ class AwsServiceConfigIntegrationTest { val contents = writer.toString() val expectedProps = """ - override val region: String? = builder.region ?: runBlocking { builder.regionProvider ?.getRegion() ?: resolveRegion() } + override val region: String? = builder.region ?: runBlocking { builder.regionProvider?.getRegion() ?: resolveRegion() } override val regionProvider: RegionProvider? = builder.regionProvider override val credentialsProvider: CredentialsProvider = builder.credentialsProvider ?: DefaultChainCredentialsProvider(httpClient = httpClient, region = region).manage() """ From 01896b69382c9916af921ac23cbc94e1d83df826 Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 10 Jan 2025 18:19:05 -0500 Subject: [PATCH 12/12] update smithy version --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b0713cf239f..81a24b2efbc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ coroutines-version = "1.9.0" atomicfu-version = "0.25.0" # smithy-kotlin codegen and runtime are versioned separately -smithy-kotlin-runtime-version = "1.3.30" +smithy-kotlin-runtime-version = "1.3.33" smithy-kotlin-codegen-version = "0.33.30" # codegen