Skip to content

Commit 79c485b

Browse files
committed
fix when region partition customization is applied
1 parent 0f15144 commit 79c485b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ private class AwsFluentClientDocs(private val codegenContext: ClientCodegenConte
174174
*/
175175
private class AwsFluentClientRetryPartition(private val codegenContext: ClientCodegenContext) : FluentClientCustomization() {
176176
override fun section(section: FluentClientSection): Writable {
177-
return when (section) {
178-
is FluentClientSection.BeforeBaseClientPluginSetup ->
177+
return when {
178+
section is FluentClientSection.BeforeBaseClientPluginSetup && usesRegion(codegenContext) -> {
179179
writable {
180180
rustTemplate(
181181
"""
@@ -188,6 +188,7 @@ private class AwsFluentClientRetryPartition(private val codegenContext: ClientCo
188188
"Cow" to RuntimeType.Cow,
189189
)
190190
}
191+
}
191192
else -> emptySection
192193
}
193194
}

aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ class RegionDecorator : ClientCodegenDecorator {
8383
private val envKey = "AWS_REGION".dq()
8484
private val profileKey = "region".dq()
8585

86-
// Services that have an endpoint ruleset that references the SDK::Region built in, or
87-
// that use SigV4, both need a configurable region.
88-
private fun usesRegion(codegenContext: ClientCodegenContext) =
89-
codegenContext.getBuiltIn(AwsBuiltIns.REGION) != null ||
90-
ServiceIndex.of(codegenContext.model)
91-
.getEffectiveAuthSchemes(codegenContext.serviceShape).containsKey(SigV4Trait.ID)
92-
9386
override fun configCustomizations(
9487
codegenContext: ClientCodegenContext,
9588
baseCustomizations: List<ConfigCustomization>,
@@ -223,3 +216,14 @@ class RegionProviderConfig(codegenContext: ClientCodegenContext) : ConfigCustomi
223216
}
224217

225218
fun region(runtimeConfig: RuntimeConfig) = AwsRuntimeType.awsTypes(runtimeConfig).resolve("region")
219+
220+
/**
221+
* Test if region is used and configured for a model (and available on a service client).
222+
*
223+
* Services that have an endpoint ruleset that references the SDK::Region built in, or
224+
* that use SigV4, both need a configurable region.
225+
*/
226+
fun usesRegion(codegenContext: ClientCodegenContext) =
227+
codegenContext.getBuiltIn(AwsBuiltIns.REGION) != null ||
228+
ServiceIndex.of(codegenContext.model)
229+
.getEffectiveAuthSchemes(codegenContext.serviceShape).containsKey(SigV4Trait.ID)

0 commit comments

Comments
 (0)