Skip to content

Commit c07dc9c

Browse files
committed
Route applicationId through to internal clients
1 parent 4f784be commit c07dc9c

File tree

7 files changed

+33
-0
lines changed

7 files changed

+33
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig
265265
public abstract fun setUseFips (Ljava/lang/Boolean;)V
266266
}
267267

268+
public final class aws/sdk/kotlin/runtime/config/AwsSdkClientOption {
269+
public static final field INSTANCE Laws/sdk/kotlin/runtime/config/AwsSdkClientOption;
270+
public final fun getApplicationId ()Laws/smithy/kotlin/runtime/collections/AttributeKey;
271+
}
272+
268273
public final class aws/sdk/kotlin/runtime/config/AwsSdkSetting {
269274
public static final field INSTANCE Laws/sdk/kotlin/runtime/config/AwsSdkSetting;
270275
public final fun getAwsAccessKeyId ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package aws.sdk.kotlin.runtime.auth.credentials
88
import aws.sdk.kotlin.runtime.auth.credentials.internal.credentials
99
import aws.sdk.kotlin.runtime.auth.credentials.internal.sso.SsoClient
1010
import aws.sdk.kotlin.runtime.auth.credentials.internal.sso.getRoleCredentials
11+
import aws.sdk.kotlin.runtime.config.AwsSdkClientOption
1112
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.AwsBusinessMetric
1213
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.withBusinessMetric
1314
import aws.smithy.kotlin.runtime.auth.awscredentials.*
@@ -102,6 +103,7 @@ public class SsoCredentialsProvider public constructor(
102103
httpClient = this@SsoCredentialsProvider.httpClient
103104
telemetryProvider = telemetry
104105
logMode = attributes.getOrNull(SdkClientOption.LogMode)
106+
applicationId = attributes.getOrNull(AwsSdkClientOption.ApplicationId)
105107
// FIXME - create an anonymous credential provider to explicitly avoid default chain creation (technically the transform should remove need for sigv4 cred provider since it's all anon auth)
106108
}
107109

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/StsAssumeRoleCredentialsProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.assumeRole
1212
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.PolicyDescriptorType
1313
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.RegionDisabledException
1414
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.Tag
15+
import aws.sdk.kotlin.runtime.config.AwsSdkClientOption
1516
import aws.sdk.kotlin.runtime.config.AwsSdkSetting
1617
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.AwsBusinessMetric
1718
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.withBusinessMetric
@@ -106,6 +107,7 @@ public class StsAssumeRoleCredentialsProvider(
106107
httpClient = provider.httpClient
107108
telemetryProvider = telemetry
108109
logMode = attributes.getOrNull(SdkClientOption.LogMode)
110+
applicationId = attributes.getOrNull(AwsSdkClientOption.ApplicationId)
109111
}
110112

111113
val resp = try {

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import aws.sdk.kotlin.runtime.auth.credentials.internal.credentials
1010
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.StsClient
1111
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.assumeRoleWithWebIdentity
1212
import aws.sdk.kotlin.runtime.auth.credentials.internal.sts.model.PolicyDescriptorType
13+
import aws.sdk.kotlin.runtime.config.AwsSdkClientOption
1314
import aws.sdk.kotlin.runtime.config.AwsSdkSetting
1415
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.AwsBusinessMetric
1516
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.withBusinessMetric
@@ -122,6 +123,7 @@ public class StsWebIdentityCredentialsProvider(
122123
// NOTE: credentials provider not needed for this operation
123124
telemetryProvider = telemetry
124125
logMode = attributes.getOrNull(SdkClientOption.LogMode)
126+
applicationId = attributes.getOrNull(AwsSdkClientOption.ApplicationId)
125127
}
126128

127129
val resp = try {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package aws.sdk.kotlin.runtime.config
7+
8+
import aws.smithy.kotlin.runtime.collections.AttributeKey
9+
10+
// AWS-specific version of smithy-kotlin's SdkClientOption
11+
public object AwsSdkClientOption {
12+
public val ApplicationId: AttributeKey<String> = AttributeKey("aws.sdk.kotlin#ApplicationId")
13+
}

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ object AwsRuntimeTypes {
3838
val AbstractAwsSdkClientFactory = symbol("AbstractAwsSdkClientFactory", "config")
3939

4040
val AwsSdkClientConfig = symbol("AwsSdkClientConfig", "config")
41+
val AwsSdkClientOption = symbol("AwsSdkClientOption", "config")
4142

4243
object Endpoints : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG, "config.endpoints") {
4344
val AccountIdEndpointMode = symbol("AccountIdEndpointMode")

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
package aws.sdk.kotlin.codegen
66

77
import software.amazon.smithy.kotlin.codegen.core.*
8+
import software.amazon.smithy.kotlin.codegen.integration.AppendingSectionWriter
89
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
910
import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
1011
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
1112
import software.amazon.smithy.kotlin.codegen.model.asNullable
1213
import software.amazon.smithy.kotlin.codegen.model.knowledge.AwsSignatureVersion4
1314
import software.amazon.smithy.kotlin.codegen.model.nullable
1415
import software.amazon.smithy.kotlin.codegen.rendering.*
16+
import software.amazon.smithy.kotlin.codegen.rendering.protocol.HttpProtocolClientGenerator
1517
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
1618
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
1719
import software.amazon.smithy.kotlin.codegen.rendering.util.RuntimeConfigProperty
@@ -173,6 +175,12 @@ class AwsServiceConfigIntegration : KotlinIntegration {
173175
writer.getContextValue(ServiceClientGenerator.Sections.CompanionObject.ServiceSymbol),
174176
)
175177
},
178+
SectionWriterBinding(
179+
HttpProtocolClientGenerator.MergeServiceDefaults,
180+
AppendingSectionWriter { writer ->
181+
writer.write("ctx.#T(#T.ApplicationId, config.#L)", RuntimeTypes.Core.Collections.putIfAbsentNotNull, AwsRuntimeTypes.Config.AwsSdkClientOption, UserAgentAppId.propertyName)
182+
},
183+
),
176184
)
177185

178186
override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> = buildList {

0 commit comments

Comments
 (0)