Skip to content

Commit 094809f

Browse files
authored
refactor(rt): make region providers public (#1123)
1 parent c3194fc commit 094809f

File tree

9 files changed

+60
-8
lines changed

9 files changed

+60
-8
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "3c7d640f-a734-4b7a-9939-1f3cb67f8cbb",
3+
"type": "feature",
4+
"description": "Make region providers public and allow profile name override",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1002",
7+
"awslabs/aws-sdk-kotlin#1003"
8+
]
9+
}

aws-runtime/aws-config/api/aws-config.api

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,43 @@ public final class aws/sdk/kotlin/runtime/config/retries/ResolveRetryStrategyKt
327327
public final class aws/sdk/kotlin/runtime/config/useragent/ResolveUserAgentKt {
328328
}
329329

330+
public final class aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProviderChain, aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable {
331+
public fun <init> ()V
332+
public fun <init> (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V
333+
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
334+
public fun close ()V
335+
}
336+
337+
public final class aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
338+
public fun <init> ()V
339+
public fun <init> (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;)V
340+
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
341+
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
342+
}
343+
344+
public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable {
345+
public fun <init> ()V
346+
public fun <init> (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;)V
347+
public synthetic fun <init> (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
348+
public fun close ()V
349+
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
350+
}
351+
352+
public final class aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
353+
public fun <init> ()V
354+
public fun <init> (Laws/smithy/kotlin/runtime/util/PropertyProvider;)V
355+
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/PropertyProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
356+
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
357+
}
358+
359+
public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
360+
public fun <init> ()V
361+
public fun <init> (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V
362+
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
363+
public fun <init> (Ljava/lang/String;)V
364+
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
365+
}
366+
330367
public abstract interface class aws/sdk/kotlin/runtime/region/RegionProvider {
331368
public abstract fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
332369
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import aws.smithy.kotlin.runtime.util.asyncLazy
2121
* 3. Check the AWS config files/profile for region information
2222
* 4. If running on EC2, check the EC2 metadata service for region
2323
*/
24-
internal expect class DefaultRegionProviderChain constructor(
24+
public expect class DefaultRegionProviderChain constructor(
2525
platformProvider: PlatformProvider = PlatformProvider.System,
2626
imdsClient: Lazy<InstanceMetadataProvider> = lazy { ImdsClient() },
2727
profile: LazyAsyncValue<AwsProfile> = asyncLazy { loadAwsSharedConfig(platformProvider).activeProfile },

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import aws.smithy.kotlin.runtime.util.PlatformProvider
1313
* [RegionProvider] that checks `AWS_REGION` region environment variable
1414
* @param environ the environment mapping to lookup keys in (defaults to the system environment)
1515
*/
16-
internal class EnvironmentRegionProvider(
16+
public class EnvironmentRegionProvider(
1717
private val environ: EnvironmentProvider = PlatformProvider.System,
1818
) : RegionProvider {
1919
override suspend fun getRegion(): String? = environ.getenv(AwsSdkSetting.AwsRegion.envVar)

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ImdsRegionProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private const val REGION_PATH: String = "/latest/meta-data/placement/region"
2222
* @param client the IMDS client to use to resolve region information with
2323
* @param platformProvider the [PlatformEnvironProvider] instance
2424
*/
25-
internal class ImdsRegionProvider(
25+
public class ImdsRegionProvider(
2626
private val client: Lazy<InstanceMetadataProvider> = lazy { ImdsClient() },
2727
private val platformProvider: PlatformEnvironProvider = PlatformProvider.System,
2828
) : RegionProvider, Closeable {

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/region/ProfileRegionProvider.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ import aws.smithy.kotlin.runtime.util.asyncLazy
1515
/**
1616
* [RegionProvider] that sources region information from the active profile
1717
*/
18-
internal class ProfileRegionProvider(
18+
public class ProfileRegionProvider(
1919
private val profile: LazyAsyncValue<AwsProfile> = asyncLazy { loadAwsSharedConfig(PlatformProvider.System).activeProfile },
2020
) : RegionProvider {
21+
22+
/**
23+
* Create a new [ProfileRegionProvider] that sources region from the given [profileName]
24+
*/
25+
public constructor(profileName: String) : this(asyncLazy { loadAwsSharedConfig(PlatformProvider.System, profileName).activeProfile })
2126
override suspend fun getRegion(): String? = profile.get().region
2227
}

aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainJVM.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import aws.smithy.kotlin.runtime.io.Closeable
1111
import aws.smithy.kotlin.runtime.util.LazyAsyncValue
1212
import aws.smithy.kotlin.runtime.util.PlatformProvider
1313

14-
internal actual class DefaultRegionProviderChain actual constructor(
14+
public actual class DefaultRegionProviderChain actual constructor(
1515
platformProvider: PlatformProvider,
1616
imdsClient: Lazy<InstanceMetadataProvider>,
1717
profile: LazyAsyncValue<AwsProfile>,

aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
package aws.sdk.kotlin.runtime.region
77

88
import aws.sdk.kotlin.runtime.config.AwsSdkSetting
9+
import aws.smithy.kotlin.runtime.util.PlatformProvider
910
import aws.smithy.kotlin.runtime.util.PropertyProvider
1011

1112
/**
1213
* [RegionProvider] that checks `aws.region` system property
1314
*/
14-
internal class JvmSystemPropRegionProvider(
15-
private val propertyProvider: PropertyProvider,
15+
public class JvmSystemPropRegionProvider(
16+
private val propertyProvider: PropertyProvider = PlatformProvider.System,
1617
) : RegionProvider {
1718
override suspend fun getRegion(): String? = propertyProvider.getProperty(AwsSdkSetting.AwsRegion.sysProp)
1819
}

aws-runtime/aws-config/native/src/aws/sdk/kotlin/runtime/region/DefaultRegionProviderChainNative.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import aws.smithy.kotlin.runtime.io.Closeable
1111
import aws.smithy.kotlin.runtime.util.LazyAsyncValue
1212
import aws.smithy.kotlin.runtime.util.PlatformProvider
1313

14-
internal actual class DefaultRegionProviderChain actual constructor(
14+
public actual class DefaultRegionProviderChain actual constructor(
1515
platformProvider: PlatformProvider,
1616
imdsClient: Lazy<InstanceMetadataProvider>,
1717
profile: LazyAsyncValue<AwsProfile>,

0 commit comments

Comments
 (0)