Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package aws.sdk.kotlin.codegen.endpoints

object AwsBuiltins {
const val ACCOUNT_ID = "AWS::Auth::AccountId"
const val ACCOUNT_ID_ENDPOINT_MODE = "AWS::Auth::AccountIdEndpointMode"
const val USE_FIPS = "AWS::UseFIPS"
const val USE_DUAL_STACK = "AWS::UseDualStack"
const val S3_ACCELERATE = "AWS::S3::Accelerate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ fun renderBindAwsBuiltins(ctx: ProtocolGenerator.GenerationContext, writer: Kotl
AwsRuntimeTypes.Config.Endpoints.resolveAccountId,
AccountIdEndpointBuiltinCustomization.AccountIdEndpointModeProp.propertyName,
)

AwsBuiltins.ACCOUNT_ID_ENDPOINT_MODE -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment at the top of this function says "In practice, all of these values are sourced from the client config."

Is that still true? Isn't AccountId being sourced exclusively from endpoint rules in your manual test cases?

Copy link
Contributor Author

@0marperez 0marperez Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that still true? Isn't AccountId being sourced exclusively from endpoint rules in your manual test cases?

Account ID isn't being sourced exclusively from endpoint rules. It's sourced from client config as a built in and from the operation context params using JMESPath.

The endpoint rules use both values for different conditions

writer.write(
"#L = config.#L.toString().lowercase()", // Spec specifies these enum values must be lowercase
it.defaultName(),
AccountIdEndpointBuiltinCustomization.AccountIdEndpointModeProp.propertyName,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package aws.sdk.kotlin.codegen.endpoints

import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
import software.amazon.smithy.kotlin.codegen.test.*
import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter
import software.amazon.smithy.rulesengine.language.syntax.parameters.ParameterType
import kotlin.test.Test
import kotlin.test.assertTrue

class BindAwsEndpointBuiltinsTest {
@Test
fun testRenderAccountIdEndpointModeBuiltin() {
val model = "".prependNamespaceAndService().toSmithyModel()

val ctx = model.newTestContext().generationCtx
val writer = KotlinWriter(TestModelDefault.NAMESPACE)
val parameters = listOf(
Parameter
.builder()
.builtIn(AwsBuiltins.ACCOUNT_ID_ENDPOINT_MODE)
.type(ParameterType.STRING)
.name("accountIdEndpointMode")
.build(),
)

renderBindAwsBuiltins(
ctx,
writer,
parameters,
)

assertTrue(
writer
.rawString()
.contains("accountIdEndpointMode = config.accountIdEndpointMode.toString().lowercase()"),
)
}
}
Loading