From c2eebae93c6b9325b868dc12e88db12bcdfb8e2b Mon Sep 17 00:00:00 2001 From: Xinsong Cui Date: Fri, 10 Jan 2025 13:26:16 -0500 Subject: [PATCH] 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) } }