Skip to content

Commit

Permalink
Add accountIDEndpointMode to context only when defined
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Jan 16, 2025
1 parent b98e583 commit 6118c4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ import software.amazon.smithy.swift.codegen.integration.DefaultHTTPProtocolCusto
import software.amazon.smithy.swift.codegen.integration.HttpProtocolServiceClient
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator
import software.amazon.smithy.swift.codegen.integration.ServiceConfig
import software.amazon.smithy.swift.codegen.model.getTrait
import software.amazon.smithy.swift.codegen.model.isInputEventStream
import software.amazon.smithy.swift.codegen.model.isOutputEventStream

abstract class AWSHTTPProtocolCustomizations : DefaultHTTPProtocolCustomizations() {

override fun renderContextAttributes(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter, serviceShape: ServiceShape, op: OperationShape) {
// FIXME handle indentation properly or do swift formatting after the fact
writer.write(" .withAccountIDEndpointMode(value: config.accountIdEndpointMode)")
val config = AWSServiceConfig(writer, ctx)
if (config.serviceSpecificConfigProperties().any { it.memberName == "accountIdEndpointMode" }) {
writer.write(" .withAccountIDEndpointMode(value: config.accountIdEndpointMode)")
}
writer.write(" .withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: \$S)", "aws.auth#sigv4")
writer.write(" .withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: \$S)", "aws.auth#sigv4a")
writer.write(" .withRegion(value: config.region)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extension GetFooInput {
.withIdentityResolver(value: config.bearerTokenIdentityResolver, schemeID: "smithy.api#httpBearerAuth")
.withFlowType(value: .PRESIGN_REQUEST)
.withExpiration(value: expiration)
.withAccountIDEndpointMode(value: config.accountIdEndpointMode)
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4")
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4a")
.withRegion(value: config.region)
Expand Down Expand Up @@ -107,7 +106,6 @@ extension PostFooInput {
.withIdentityResolver(value: config.bearerTokenIdentityResolver, schemeID: "smithy.api#httpBearerAuth")
.withFlowType(value: .PRESIGN_REQUEST)
.withExpiration(value: expiration)
.withAccountIDEndpointMode(value: config.accountIdEndpointMode)
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4")
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4a")
.withRegion(value: config.region)
Expand Down Expand Up @@ -184,7 +182,6 @@ extension PutFooInput {
.withIdentityResolver(value: config.bearerTokenIdentityResolver, schemeID: "smithy.api#httpBearerAuth")
.withFlowType(value: .PRESIGN_REQUEST)
.withExpiration(value: expiration)
.withAccountIDEndpointMode(value: config.accountIdEndpointMode)
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4")
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4a")
.withRegion(value: config.region)
Expand Down Expand Up @@ -261,7 +258,6 @@ extension PutObjectInput {
.withIdentityResolver(value: config.bearerTokenIdentityResolver, schemeID: "smithy.api#httpBearerAuth")
.withFlowType(value: .PRESIGN_REQUEST)
.withExpiration(value: expiration)
.withAccountIDEndpointMode(value: config.accountIdEndpointMode)
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4")
.withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: "aws.auth#sigv4a")
.withRegion(value: config.region)
Expand Down

0 comments on commit 6118c4a

Please sign in to comment.