From 78a4f377272559061477e36df2f1e5c32f6cdcc3 Mon Sep 17 00:00:00 2001 From: Andrew Foss Date: Wed, 8 May 2024 21:34:23 -0700 Subject: [PATCH] chore: refactor endpoints resolver to extend from smithy-swift --- .../Endpoints/AWSEndpoint.swift | 18 -- .../AWSEndpointsRequestContext.swift | 26 --- .../AWSEndpointsResolvedEndpoint.swift | 54 ------ .../AWSEndpointsResolvedEndpointType.swift | 19 -- .../Endpoints/AWSEndpointsRuleEngine.swift | 20 -- ...ion.swift => AWSPartitionDefinition.swift} | 2 +- .../Endpoints/AuthSchemeResolver.swift | 2 + .../Endpoints/EndpointError.swift | 13 -- .../Signing/AWSSigningAlgorithm.swift | 28 --- .../Signing/AWSSigningConfig.swift | 1 + .../AWSClientConfigurationIntegration.kt | 3 +- .../swift/codegen/AWSClientRuntimeTypes.kt | 8 +- .../AWSHttpBindingProtocolGenerator.kt | 2 +- .../codegen/AWSHttpProtocolCustomizations.kt | 9 +- .../aws/swift/codegen/AWSServiceConfig.kt | 50 +---- .../swift/codegen/EndpointParamsGenerator.kt | 101 ---------- .../codegen/EndpointResolverGenerator.kt | 106 ----------- .../swift/codegen/EndpointTestGenerator.kt | 5 +- .../config/AWSEndpointClientConfiguration.kt | 33 ---- ...re.kt => AWSEndpointResolverMiddleware.kt} | 39 +--- .../OperationEndpointResolverMiddleware.kt | 179 ------------------ .../swift/codegen/plugins/EndpointPlugin.kt | 8 +- ...perationEndpointResolverMiddlewareTests.kt | 12 +- .../smithy/aws/swift/codegen/TestUtils.kt | 4 +- .../AWSRestJson1ProtocolGeneratorTests.kt | 20 +- 25 files changed, 50 insertions(+), 712 deletions(-) delete mode 100644 Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRequestContext.swift delete mode 100644 Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpoint.swift delete mode 100644 Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpointType.swift delete mode 100644 Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRuleEngine.swift rename Sources/Core/AWSClientRuntime/Endpoints/{PartitionDefinition.swift => AWSPartitionDefinition.swift} (99%) delete mode 100644 Sources/Core/AWSClientRuntime/Endpoints/EndpointError.swift delete mode 100644 Sources/Core/AWSClientRuntime/Signing/AWSSigningAlgorithm.swift delete mode 100644 codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt delete mode 100644 codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointResolverGenerator.kt delete mode 100644 codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/config/AWSEndpointClientConfiguration.kt rename codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/{EndpointResolverMiddleware.kt => AWSEndpointResolverMiddleware.kt} (74%) delete mode 100644 codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpoint.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpoint.swift index c03c392efc7..ac031bb6874 100644 --- a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpoint.swift +++ b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpoint.swift @@ -56,21 +56,3 @@ public struct AWSEndpoint: Equatable { return try candidate.resolveEndpoint(region: region) } } - -/// Keys used to access auth scheme container and auth scheme properties -private enum AuthSchemeKeys { - static let authSchemes = "authSchemes" -} - -extension Endpoint { - /// Returns list of auth schemes - /// This is an internal API and subject to change without notice - /// - Returns: list of auth schemes if present - public func authSchemes() -> [[String: Any]]? { - guard let schemes = properties[AuthSchemeKeys.authSchemes] as? [[String: Any]] else { - return nil - } - - return schemes - } -} diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRequestContext.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRequestContext.swift deleted file mode 100644 index 85d5410ffdd..00000000000 --- a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRequestContext.swift +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0. - -import AwsCommonRuntimeKit - -/// Wrapper for CRTAWSEndpointsRequestContext -public class AWSEndpointsRequestContext { - - let crtContext: AwsCommonRuntimeKit.EndpointsRequestContext - - public init() throws { - self.crtContext = try AwsCommonRuntimeKit.EndpointsRequestContext() - } - - public func add(name: String, value: String?) throws { - try crtContext.add(name: name, value: value) - } - - public func add(name: String, value: Bool?) throws { - try crtContext.add(name: name, value: value) - } - - public func toCRT() -> AwsCommonRuntimeKit.EndpointsRequestContext { - crtContext - } -} diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpoint.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpoint.swift deleted file mode 100644 index bd59307cfd6..00000000000 --- a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpoint.swift +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0. - -import AwsCommonRuntimeKit - -/// Wrapper for CRTAWSEndpointResolvedEndpoint -public class AWSEndpointsResolvedEndpoint { - - let crtResolvedEndpoint: AwsCommonRuntimeKit.ResolvedEndpoint - - init(crtResolvedEndpoint: AwsCommonRuntimeKit.ResolvedEndpoint) { - self.crtResolvedEndpoint = crtResolvedEndpoint - } - - public func getType() -> AWSEndpointsResolvedEndpointType { - AWSEndpointsResolvedEndpointType(crtType: crtResolvedEndpoint) - } - - public func getError() -> String? { - switch crtResolvedEndpoint { - case .endpoint: - return nil - case let .error(message): - return message - } - } - - public func getURL() -> String? { - switch crtResolvedEndpoint { - case let .endpoint(url, _, _): - return url - case .error: - return nil - } - } - - public func getProperties() -> [String: AnyHashable]? { - switch crtResolvedEndpoint { - case let .endpoint(_, _, properties): - return properties - case .error: - return nil - } - } - - public func getHeaders() -> [String: [String]]? { - switch crtResolvedEndpoint { - case let .endpoint(_, headers, _): - return headers - case .error: - return nil - } - } -} diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpointType.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpointType.swift deleted file mode 100644 index 8ba4951c8d5..00000000000 --- a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsResolvedEndpointType.swift +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2. - -import AwsCommonRuntimeKit - -/// Wrapper for CRTAWSEndpointsResolvedEndpointType -public enum AWSEndpointsResolvedEndpointType { - case error - case endpoint - - init(crtType: AwsCommonRuntimeKit.ResolvedEndpoint) { - switch crtType { - case .error: - self = .error - case .endpoint: - self = .endpoint - } - } -} diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRuleEngine.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRuleEngine.swift deleted file mode 100644 index 9da381279fa..00000000000 --- a/Sources/Core/AWSClientRuntime/Endpoints/AWSEndpointsRuleEngine.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0. - -import AwsCommonRuntimeKit - -/// Wrapper for CRTAWSEndpointsRuleEngine -public class AWSEndpointsRuleEngine { - - let crtEngine: AwsCommonRuntimeKit.EndpointsRuleEngine - - public init(partitions: String = partitionJSON, ruleSet: String) throws { - Utils.setupCRT() // ensures CRT is set up before calling the CRT endpoint rules engine - crtEngine = try AwsCommonRuntimeKit.EndpointsRuleEngine(partitions: partitions, ruleSet: ruleSet) - } - - public func resolve(context: AWSEndpointsRequestContext) throws -> AWSEndpointsResolvedEndpoint? { - let crtResolvedEndpoint = try crtEngine.resolve(context: context.toCRT()) - return AWSEndpointsResolvedEndpoint(crtResolvedEndpoint: crtResolvedEndpoint) - } -} diff --git a/Sources/Core/AWSClientRuntime/Endpoints/PartitionDefinition.swift b/Sources/Core/AWSClientRuntime/Endpoints/AWSPartitionDefinition.swift similarity index 99% rename from Sources/Core/AWSClientRuntime/Endpoints/PartitionDefinition.swift rename to Sources/Core/AWSClientRuntime/Endpoints/AWSPartitionDefinition.swift index 4cb37e2d81d..7b0bae79c0e 100644 --- a/Sources/Core/AWSClientRuntime/Endpoints/PartitionDefinition.swift +++ b/Sources/Core/AWSClientRuntime/Endpoints/AWSPartitionDefinition.swift @@ -10,7 +10,7 @@ import Foundation // Partition definitions are embedded as a static resource in this project, for now. // When Trebuchet integration is performed, partitions should be obtained from Trebuchet for every // build instead of being loaded from a static definition. -public let partitionJSON = """ +public let awsPartitionJSON = """ { "version": "1.1", "partitions": [ diff --git a/Sources/Core/AWSClientRuntime/Endpoints/AuthSchemeResolver.swift b/Sources/Core/AWSClientRuntime/Endpoints/AuthSchemeResolver.swift index 8fbbf24ec46..d9b430e851f 100644 --- a/Sources/Core/AWSClientRuntime/Endpoints/AuthSchemeResolver.swift +++ b/Sources/Core/AWSClientRuntime/Endpoints/AuthSchemeResolver.swift @@ -5,6 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // +import ClientRuntime + /// Supported authentication schemes public enum AuthScheme: Equatable { case sigV4(SigV4Parameters) diff --git a/Sources/Core/AWSClientRuntime/Endpoints/EndpointError.swift b/Sources/Core/AWSClientRuntime/Endpoints/EndpointError.swift deleted file mode 100644 index 4988180ab4f..00000000000 --- a/Sources/Core/AWSClientRuntime/Endpoints/EndpointError.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// - -public enum EndpointError: Error { - case hostnameIsNil(String) - case partitionsEmpty(String) - case unresolved(String?) - case authScheme(String?) -} diff --git a/Sources/Core/AWSClientRuntime/Signing/AWSSigningAlgorithm.swift b/Sources/Core/AWSClientRuntime/Signing/AWSSigningAlgorithm.swift deleted file mode 100644 index 2999d0fe89b..00000000000 --- a/Sources/Core/AWSClientRuntime/Signing/AWSSigningAlgorithm.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// -import AwsCommonRuntimeKit - -/// Type of signing algorithm -/// String raw value used for serialization and deserialization -public enum AWSSigningAlgorithm: String { - /// Signature Version 4 - case sigv4 - /// Signature Version 4 Asymmetric - case sigv4a -} - -extension AWSSigningAlgorithm { - - /// Convert self to CRT SigningAlgorithmType - /// - Returns: SigningAlgorithmType - func toCRTType() -> SigningAlgorithmType { - switch self { - case .sigv4: return .signingV4 - case .sigv4a: return .signingV4Asymmetric - } - } -} diff --git a/Sources/Core/AWSClientRuntime/Signing/AWSSigningConfig.swift b/Sources/Core/AWSClientRuntime/Signing/AWSSigningConfig.swift index e9905d173c1..9f2127ddcc2 100644 --- a/Sources/Core/AWSClientRuntime/Signing/AWSSigningConfig.swift +++ b/Sources/Core/AWSClientRuntime/Signing/AWSSigningConfig.swift @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // +import ClientRuntime import AwsCommonRuntimeKit import Foundation diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientConfigurationIntegration.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientConfigurationIntegration.kt index 2a48527593f..4ab58aadd65 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientConfigurationIntegration.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientConfigurationIntegration.kt @@ -6,7 +6,6 @@ package software.amazon.smithy.aws.swift.codegen import software.amazon.smithy.aws.swift.codegen.config.AWSDefaultClientConfiguration -import software.amazon.smithy.aws.swift.codegen.config.AWSEndpointClientConfiguration import software.amazon.smithy.aws.swift.codegen.config.AWSRegionClientConfiguration import software.amazon.smithy.aws.swift.codegen.plugins.AuthSchemePlugin import software.amazon.smithy.aws.swift.codegen.plugins.DefaultAWSAuthSchemePlugin @@ -20,7 +19,7 @@ import software.amazon.smithy.swift.codegen.integration.plugins.DefaultAWSClient class AWSClientConfigurationIntegration : SwiftIntegration { override fun clientConfigurations(ctx: ProtocolGenerator.GenerationContext): List { - return listOf(AWSDefaultClientConfiguration(), AWSRegionClientConfiguration(), AWSEndpointClientConfiguration(ctx)) + return listOf(AWSDefaultClientConfiguration(), AWSRegionClientConfiguration()) } override fun plugins(serviceConfig: ServiceConfig): List { diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientRuntimeTypes.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientRuntimeTypes.kt index 7b9b21e03e4..3ab309bf471 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientRuntimeTypes.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSClientRuntimeTypes.kt @@ -37,7 +37,7 @@ object AWSClientRuntimeTypes { val FrameworkMetadata = runtimeSymbol("FrameworkMetadata") val AWSCredentialIdentityResolver = runtimeSymbol("AWSCredentialIdentityResolver") val AWSClientConfiguration = runtimeSymbol("AWSClientConfiguration") - val AWSEndpoint = runtimeSymbol("AWSEndpoint") + val Partition = runtimeSymbol("Partition") val ServiceEndpointMetadata = runtimeSymbol("ServiceEndpointMetadata") val CredentialScope = runtimeSymbol("CredentialScope") @@ -45,12 +45,10 @@ object AWSClientRuntimeTypes { val AWSServiceError = runtimeSymbol("AWSServiceError") val RegionResolver = runtimeSymbol("RegionResolver") val Sha256TreeHashMiddleware = runtimeSymbol("Sha256TreeHashMiddleware") - val AWSEndpointsRuleEngine = runtimeSymbol("AWSEndpointsRuleEngine") - val AWSEndpointsRequestContext = runtimeSymbol("AWSEndpointsRequestContext") - val AuthSchemeResolver = runtimeSymbol("AuthSchemeResolver") - val DefaultAuthSchemeResolver = runtimeSymbol("DefaultAuthSchemeResolver") + val AWSEndpoints = runtimeSymbol("AWSEndpoints") val AWSRetryErrorInfoProvider = runtimeSymbol("AWSRetryErrorInfoProvider") val AWSRetryMode = runtimeSymbol("AWSRetryMode") + val AWSPartitionDefinition = runtimeSymbol("awsPartitionJSON") } object CRT { diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpBindingProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpBindingProtocolGenerator.kt index e4cc79ee98c..89fa4b70c7b 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpBindingProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpBindingProtocolGenerator.kt @@ -6,7 +6,6 @@ package software.amazon.smithy.aws.swift.codegen import software.amazon.smithy.aws.swift.codegen.message.MessageMarshallableGenerator import software.amazon.smithy.aws.swift.codegen.message.MessageUnmarshallableGenerator -import software.amazon.smithy.aws.swift.codegen.middleware.OperationEndpointResolverMiddleware import software.amazon.smithy.aws.swift.codegen.middleware.UserAgentMiddleware import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.MemberShape @@ -19,6 +18,7 @@ import software.amazon.smithy.rulesengine.language.EndpointRuleSet import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait import software.amazon.smithy.rulesengine.traits.EndpointTestsTrait import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.endpoint.OperationEndpointResolverMiddleware import software.amazon.smithy.swift.codegen.integration.HttpBindingProtocolGenerator import software.amazon.smithy.swift.codegen.integration.HttpProtocolTestGenerator import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestErrorGenerator diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpProtocolCustomizations.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpProtocolCustomizations.kt index 6aae12eec14..1c90c1b945b 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpProtocolCustomizations.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHttpProtocolCustomizations.kt @@ -6,6 +6,7 @@ package software.amazon.smithy.aws.swift.codegen import software.amazon.smithy.aws.swift.codegen.customization.RulesBasedAuthSchemeResolverGenerator +import software.amazon.smithy.aws.swift.codegen.middleware.AWSEndpointResolverMiddleware import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.swift.codegen.AuthSchemeResolverGenerator @@ -21,7 +22,6 @@ import software.amazon.smithy.swift.codegen.model.isOutputEventStream abstract class AWSHttpProtocolCustomizations : DefaultHttpProtocolCustomizations() { override fun renderContextAttributes(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter, serviceShape: ServiceShape, op: OperationShape) { - val endpointPrefix = ctx.service.endpointPrefix // get endpoint prefix from smithy trait // FIXME handle indentation properly or do swift formatting after the fact writer.write(" .withIdentityResolver(value: config.awsCredentialIdentityResolver, schemeID: \$S)", "aws.auth#sigv4") @@ -45,12 +45,15 @@ abstract class AWSHttpProtocolCustomizations : DefaultHttpProtocolCustomizations } override fun renderInternals(ctx: ProtocolGenerator.GenerationContext) { - super.renderInternals(ctx) + AuthSchemeResolverGenerator().render(ctx) // Generate rules-based auth scheme resolver for services that depend on endpoint resolver for auth scheme resolution if (AuthSchemeResolverGenerator.usesRulesBasedAuthResolver(ctx)) { RulesBasedAuthSchemeResolverGenerator().render(ctx) } - EndpointResolverGenerator().render(ctx) + EndpointResolverGenerator( + { writer, input, output, outputError -> AWSEndpointResolverMiddleware(writer, input, output, outputError) }, + AWSClientRuntimeTypes.Core.AWSPartitionDefinition + ).render(ctx) } override fun getClientProperties(): List { diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSServiceConfig.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSServiceConfig.kt index 2cca706a389..9d057ef2814 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSServiceConfig.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSServiceConfig.kt @@ -5,57 +5,9 @@ package software.amazon.smithy.aws.swift.codegen -import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.model.shapes.ShapeType -import software.amazon.smithy.rulesengine.traits.ClientContextParamsTrait -import software.amazon.smithy.swift.codegen.SwiftTypes import software.amazon.smithy.swift.codegen.SwiftWriter -import software.amazon.smithy.swift.codegen.integration.ConfigField import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.ServiceConfig -import software.amazon.smithy.swift.codegen.model.buildSymbol -import software.amazon.smithy.swift.codegen.model.getTrait -import software.amazon.smithy.swift.codegen.utils.clientName -import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase - -const val ENDPOINT_RESOLVER = "endpointResolver" -const val AUTH_SCHEME_RESOLVER = "authSchemeResolver" -const val ENDPOINT_PARAMS = "endpointParams" class AWSServiceConfig(writer: SwiftWriter, val ctx: ProtocolGenerator.GenerationContext) : - ServiceConfig(writer, ctx.symbolProvider.toSymbol(ctx.service).name, ctx.service.sdkId) { - - override fun serviceSpecificConfigProperties(): List { - var configs = mutableListOf() - - // service specific EndpointResolver - configs.add(ConfigField(ENDPOINT_RESOLVER, AWSServiceTypes.EndpointResolver, "\$N", "Endpoint resolver")) - // service specific AuthSchemeResolver - configs.add(ConfigField(AUTH_SCHEME_RESOLVER, buildSymbol { this.name = serviceName.clientName() + "AuthSchemeResolver" }, "\$N")) - - val clientContextParams = ctx.service.getTrait() - clientContextParams?.parameters?.forEach { - configs.add(ConfigField(it.key.toLowerCamelCase(), it.value.type.toSwiftType(), "\$T")) - } - return configs.sortedBy { it.memberName } - } -} - -fun ShapeType.toSwiftType(): Symbol { - return when (this) { - ShapeType.STRING -> SwiftTypes.String - ShapeType.BOOLEAN -> SwiftTypes.Bool - else -> throw IllegalArgumentException("Unsupported shape type: $this") - } -} - -object AWSServiceTypes { - val EndpointResolver = symbol("EndpointResolver") - val EndpointParams = symbol("EndpointParams") - val EndpointResolverMiddleware = symbol("EndpointResolverMiddleware") - val DefaultEndpointResolver = symbol("DefaultEndpointResolver") - - private fun symbol(name: String): Symbol = buildSymbol { - this.name = name - } -} + ServiceConfig(writer, ctx.symbolProvider.toSymbol(ctx.service).name, ctx.settings.sdkId) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt deleted file mode 100644 index 50c8d15d9fe..00000000000 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointParamsGenerator.kt +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. - */ - -package software.amazon.smithy.aws.swift.codegen - -import software.amazon.smithy.codegen.core.CodegenException -import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.rulesengine.language.EndpointRuleSet -import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter -import software.amazon.smithy.rulesengine.language.syntax.parameters.ParameterType -import software.amazon.smithy.swift.codegen.AuthSchemeResolverGenerator -import software.amazon.smithy.swift.codegen.SwiftTypes -import software.amazon.smithy.swift.codegen.SwiftWriter -import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator -import software.amazon.smithy.swift.codegen.model.boxed -import software.amazon.smithy.swift.codegen.model.defaultValue -import software.amazon.smithy.swift.codegen.utils.clientName -import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase - -/** - * Generates EndpointParams struct for the service - */ -class EndpointParamsGenerator(private val endpointRules: EndpointRuleSet?) { - fun render(writer: SwiftWriter, ctx: ProtocolGenerator.GenerationContext? = null) { - writer.openBlock("public struct EndpointParams {", "}") { - endpointRules?.parameters?.toList()?.sortedBy { it.name.toString() }?.let { sortedParameters -> - renderMembers(writer, sortedParameters) - writer.write("") - renderInit(writer, sortedParameters) - // Convert auth scheme params to endpoint params for rules-based auth scheme resolvers - if (ctx != null && AuthSchemeResolverGenerator.usesRulesBasedAuthResolver(ctx)) { - renderConversionInit(writer, sortedParameters, ctx) - } - } - } - } - - private fun renderInit(writer: SwiftWriter, parameters: List) { - writer.openBlock("public init(", ")") { - for ((index, param) in parameters.withIndex()) { - val memberName = param.name.toString().toLowerCamelCase() - val memberSymbol = param.toSymbol() - val terminator = if (index != parameters.lastIndex) "," else "" - writer.write("$memberName: \$D$terminator", memberSymbol) - } - } - - writer.openBlock("{", "}") { - parameters.forEach { - val memberName = it.name.toString().toLowerCamelCase() - writer.write("self.\$1L = \$1L", memberName) - } - } - } - - private fun renderMembers(writer: SwiftWriter, parameters: List) { - parameters.forEach { param -> - val memberName = param.name.toString().toLowerCamelCase() - val memberSymbol = param.toSymbol() - val optional = if (param.isRequired) "" else "?" - param.documentation.orElse(null)?.let { writer.write("/// $it") } - writer.write("public let \$L: \$L$optional", memberName, memberSymbol) - } - } - - private fun renderConversionInit( - writer: SwiftWriter, - parameters: List, - ctx: ProtocolGenerator.GenerationContext - ) { - writer.apply { - val paramsType = ctx.service.sdkId.clientName() + "AuthSchemeResolverParameters" - openBlock("public init (authSchemeParams: \$L) {", "}", paramsType) { - parameters.forEach { - val memberName = it.name.toString().toLowerCamelCase() - writer.write("self.\$1L = authSchemeParams.\$1L", memberName) - } - } - } - } -} - -fun Parameter.toSymbol(): Symbol { - val swiftType = when (type) { - ParameterType.STRING -> SwiftTypes.String - ParameterType.BOOLEAN -> SwiftTypes.Bool - else -> throw CodegenException("Unsupported parameter type: $type") - } - var builder = Symbol.builder().name(swiftType.fullName) - if (!isRequired) { - builder = builder.boxed() - } - - default.ifPresent { defaultValue -> - builder.defaultValue(defaultValue.toString()) - } - - return builder.build() -} diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointResolverGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointResolverGenerator.kt deleted file mode 100644 index efcb864a043..00000000000 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointResolverGenerator.kt +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. - */ - -package software.amazon.smithy.aws.swift.codegen - -import software.amazon.smithy.aws.swift.codegen.middleware.EndpointResolverMiddleware -import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.model.node.Node -import software.amazon.smithy.rulesengine.language.EndpointRuleSet -import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait -import software.amazon.smithy.swift.codegen.ClientRuntimeTypes -import software.amazon.smithy.swift.codegen.MiddlewareGenerator -import software.amazon.smithy.swift.codegen.SwiftDependency -import software.amazon.smithy.swift.codegen.SwiftWriter -import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator -import software.amazon.smithy.swift.codegen.model.getTrait -import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase - -/** - * Generates a per/service endpoint resolver (internal to the generated SDK) - */ -class EndpointResolverGenerator() { - fun render(ctx: ProtocolGenerator.GenerationContext) { - val rootNamespace = ctx.settings.moduleName - - val ruleSetNode = ctx.service.getTrait()?.ruleSet - val ruleSet = if (ruleSetNode != null) EndpointRuleSet.fromNode(ruleSetNode) else null - - ctx.delegator.useFileWriter("./$rootNamespace/EndpointResolver.swift") { - val endpointParamsGenerator = EndpointParamsGenerator(ruleSet) - endpointParamsGenerator.render(it, ctx) - } - - ctx.delegator.useFileWriter("./$rootNamespace/EndpointResolver.swift") { - renderResolverProtocol(it) - it.write("") - renderResolver(it, ruleSet) - val inputSymbol = Symbol.builder().name("SdkHttpRequestBuilder").build() - val outputSymbol = Symbol.builder().name("OperationStackOutput").build() - val outputErrorSymbol = Symbol.builder().name("OperationStackError").build() - val middleware = EndpointResolverMiddleware(it, inputSymbol, outputSymbol, outputErrorSymbol) - it.addImport(SwiftDependency.CLIENT_RUNTIME.target) - it.write("") - MiddlewareGenerator(it, middleware).generate() - } - } - - private fun renderResolverProtocol(writer: SwiftWriter) { - writer.openBlock("public protocol \$L {", "}", AWSServiceTypes.EndpointResolver) { - writer.write("func resolve(params: EndpointParams) throws -> \$L", ClientRuntimeTypes.Core.Endpoint) - } - } - - private fun renderResolver(writer: SwiftWriter, endpointRules: EndpointRuleSet?) { - writer.openBlock("public struct \$L: \$L {", "}", AWSServiceTypes.DefaultEndpointResolver, AWSServiceTypes.EndpointResolver) { - writer.write("") - endpointRules?.let { - writer.write("private let engine: \$L", AWSClientRuntimeTypes.Core.AWSEndpointsRuleEngine) - writer.write("private let ruleSet = \$S", Node.printJson(endpointRules.toNode())) - } - writer.write("") - writer.openBlock("public init() throws {", "}") { - endpointRules?.let { - writer.write("engine = try \$L(ruleSet: ruleSet)", AWSClientRuntimeTypes.Core.AWSEndpointsRuleEngine) - } - } - writer.write("") - writer.openBlock( - "public func resolve(params: EndpointParams) throws -> \$L {", "}", ClientRuntimeTypes.Core.Endpoint - ) { - endpointRules?.let { - writer.write("let context = try \$L()", AWSClientRuntimeTypes.Core.AWSEndpointsRequestContext) - endpointRules.parameters?.toList()?.sortedBy { it.name.toString() }?.let { sortedParameters -> - sortedParameters.forEach { param -> - val memberName = param.name.toString().toLowerCamelCase() - val paramName = param.name.toString() - writer.write("try context.add(name: \$S, value: params.\$L)", paramName, memberName) - } - writer.write("") - } - writer.openBlock("guard let crtResolvedEndpoint = try engine.resolve(context: context) else {", "}") { - writer.write("throw EndpointError.unresolved(\"Failed to resolved endpoint\")") - }.write("") - - writer.openBlock("if crtResolvedEndpoint.getType() == .error {", "}") { - writer.write("let error = crtResolvedEndpoint.getError()") - writer.write("throw EndpointError.unresolved(error)") - }.write("") - - writer.openBlock("guard let url = crtResolvedEndpoint.getURL() else {", "}") { - writer.write("assertionFailure(\"This must be a bug in either CRT or the rule engine, if the endpoint is not an error, it must have a url\")") - writer.write("throw EndpointError.unresolved(\"Failed to resolved endpoint\")") - }.write("") - - writer.write("let headers = crtResolvedEndpoint.getHeaders() ?? [:]") - writer.write("let properties = crtResolvedEndpoint.getProperties() ?? [:]") - writer.write("return try Endpoint(urlString: url, headers: Headers(headers), properties: properties)") - } ?: run { - writer.write("fatalError(\"EndpointResolver not implemented\")") - } - } - } - } -} diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt index 9fc62a6d094..9e3171ed8c9 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/EndpointTestGenerator.kt @@ -20,6 +20,7 @@ import software.amazon.smithy.swift.codegen.ClientRuntimeTypes import software.amazon.smithy.swift.codegen.SwiftDependency import software.amazon.smithy.swift.codegen.SwiftWriter import software.amazon.smithy.swift.codegen.XCTestTypes +import software.amazon.smithy.swift.codegen.endpoint.EndpointSymbols import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase @@ -57,7 +58,7 @@ class EndpointTestGenerator( endpointTest.testCases.forEach { testCase -> writer.write("/// \$L", testCase.documentation) writer.openBlock("func testResolve${++count}() throws {", "}") { - writer.openBlock("let endpointParams = \$L(", ")", AWSServiceTypes.EndpointParams) { + writer.openBlock("let endpointParams = \$L(", ")", EndpointSymbols.EndpointParams) { val applicableParams = testCase.params.members.filter { endpointParamsMembers.contains(it.key.value) } .toSortedMap(compareBy { it.value }).map { (key, value) -> @@ -74,7 +75,7 @@ class EndpointTestGenerator( } } } - writer.write("let resolver = try \$L()", AWSServiceTypes.DefaultEndpointResolver).write("") + writer.write("let resolver = try \$L()", EndpointSymbols.DefaultEndpointResolver).write("") testCase.expect.error.ifPresent { error -> writer.openBlock( diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/config/AWSEndpointClientConfiguration.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/config/AWSEndpointClientConfiguration.kt deleted file mode 100644 index bab3209dace..00000000000 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/config/AWSEndpointClientConfiguration.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. - */ - -package software.amazon.smithy.aws.swift.codegen.config - -import software.amazon.smithy.aws.swift.codegen.AWSServiceTypes -import software.amazon.smithy.aws.swift.codegen.ENDPOINT_RESOLVER -import software.amazon.smithy.aws.swift.codegen.toSwiftType -import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.rulesengine.traits.ClientContextParamsTrait -import software.amazon.smithy.swift.codegen.config.ClientConfiguration -import software.amazon.smithy.swift.codegen.config.ConfigProperty -import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator -import software.amazon.smithy.swift.codegen.model.getTrait -import software.amazon.smithy.swift.codegen.model.toOptional -import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase - -class AWSEndpointClientConfiguration(val ctx: ProtocolGenerator.GenerationContext) : ClientConfiguration { - override val swiftProtocolName: Symbol? - get() = null - - override fun getProperties(ctx: ProtocolGenerator.GenerationContext): Set { - val properties: MutableSet = mutableSetOf() - val clientContextParams = ctx.service.getTrait() - clientContextParams?.parameters?.forEach { - properties.add(ConfigProperty(it.key.toLowerCamelCase(), it.value.type.toSwiftType().toOptional())) - } - properties.add(ConfigProperty(ENDPOINT_RESOLVER, AWSServiceTypes.EndpointResolver, "DefaultEndpointResolver()", true)) - return properties - } -} diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/AWSEndpointResolverMiddleware.kt similarity index 74% rename from codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt rename to codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/AWSEndpointResolverMiddleware.kt index 50fbe95d991..be0f9129a1f 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/EndpointResolverMiddleware.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/AWSEndpointResolverMiddleware.kt @@ -5,53 +5,26 @@ package software.amazon.smithy.aws.swift.codegen.middleware -import software.amazon.smithy.aws.swift.codegen.AUTH_SCHEME_RESOLVER -import software.amazon.smithy.aws.swift.codegen.AWSClientRuntimeTypes -import software.amazon.smithy.aws.swift.codegen.AWSServiceTypes import software.amazon.smithy.aws.swift.codegen.AWSSwiftDependency -import software.amazon.smithy.aws.swift.codegen.ENDPOINT_PARAMS -import software.amazon.smithy.aws.swift.codegen.ENDPOINT_RESOLVER import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.swift.codegen.Middleware import software.amazon.smithy.swift.codegen.SwiftDependency import software.amazon.smithy.swift.codegen.SwiftWriter -import software.amazon.smithy.swift.codegen.integration.steps.OperationBuildStep +import software.amazon.smithy.swift.codegen.endpoint.EndpointResolverMiddleware /** * Generates endpoint middleware for the service. */ -class EndpointResolverMiddleware( +class AWSEndpointResolverMiddleware( private val writer: SwiftWriter, inputSymbol: Symbol, outputSymbol: Symbol, outputErrorSymbol: Symbol -) : Middleware(writer, inputSymbol, OperationBuildStep(outputSymbol, outputErrorSymbol)) { +) : EndpointResolverMiddleware(writer, inputSymbol, outputSymbol, outputErrorSymbol) { override val id: String = "EndpointResolverMiddleware" override val typeName = "EndpointResolverMiddleware<$outputSymbol>" - override val properties: MutableMap = mutableMapOf( - ENDPOINT_RESOLVER to AWSServiceTypes.EndpointResolver, - ENDPOINT_PARAMS to AWSServiceTypes.EndpointParams, - AUTH_SCHEME_RESOLVER to AWSClientRuntimeTypes.Core.AuthSchemeResolver - ) - - override fun generateInit() { - writer.openBlock( - "public init($ENDPOINT_RESOLVER: \$N, $ENDPOINT_PARAMS: \$N, $AUTH_SCHEME_RESOLVER: \$N = \$N()) {", - "}", - AWSServiceTypes.EndpointResolver, - AWSServiceTypes.EndpointParams, - AWSClientRuntimeTypes.Core.AuthSchemeResolver, - AWSClientRuntimeTypes.Core.DefaultAuthSchemeResolver - ) { - writer.write("self.\$L = \$L", ENDPOINT_RESOLVER, ENDPOINT_RESOLVER) - writer.write("self.\$L = \$L", ENDPOINT_PARAMS, ENDPOINT_PARAMS) - writer.write("self.\$L = \$L", AUTH_SCHEME_RESOLVER, AUTH_SCHEME_RESOLVER) - } - } - override fun renderExtensions() { writer.write( """ @@ -69,7 +42,7 @@ class EndpointResolverMiddleware( var signingRegion: String? = nil var signingAlgorithm: String? = nil if let authSchemes = endpoint.authSchemes() { - let schemes = try authSchemes.map { try AuthScheme(from: ${'$'}${'$'}0) } + let schemes = try authSchemes.map { try EndpointAuthScheme(from: ${'$'}${'$'}0) } let authScheme = try authSchemeResolver.resolve(authSchemes: schemes) signingAlgorithm = authScheme.name switch authScheme { @@ -138,8 +111,4 @@ class EndpointResolverMiddleware( """.trimIndent() ) } - - override fun renderReturn() { - writer.write("return try await next.handle(context: context, input: updatedRequest.toBuilder())") - } } diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt deleted file mode 100644 index c1bd67316cb..00000000000 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/middleware/OperationEndpointResolverMiddleware.kt +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. - */ - -package software.amazon.smithy.aws.swift.codegen.middleware - -import software.amazon.smithy.aws.swift.codegen.AWSServiceTypes -import software.amazon.smithy.codegen.core.Symbol -import software.amazon.smithy.model.shapes.MemberShape -import software.amazon.smithy.model.shapes.OperationShape -import software.amazon.smithy.rulesengine.language.EndpointRuleSet -import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter -import software.amazon.smithy.rulesengine.language.syntax.parameters.ParameterType -import software.amazon.smithy.rulesengine.traits.ClientContextParamDefinition -import software.amazon.smithy.rulesengine.traits.ClientContextParamsTrait -import software.amazon.smithy.rulesengine.traits.ContextParamTrait -import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait -import software.amazon.smithy.rulesengine.traits.StaticContextParamDefinition -import software.amazon.smithy.rulesengine.traits.StaticContextParamsTrait -import software.amazon.smithy.swift.codegen.AuthSchemeResolverGenerator -import software.amazon.smithy.swift.codegen.SwiftWriter -import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator -import software.amazon.smithy.swift.codegen.integration.middlewares.handlers.MiddlewareShapeUtils -import software.amazon.smithy.swift.codegen.middleware.MiddlewarePosition -import software.amazon.smithy.swift.codegen.middleware.MiddlewareRenderable -import software.amazon.smithy.swift.codegen.middleware.MiddlewareStep -import software.amazon.smithy.swift.codegen.model.getTrait -import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase - -/** - * Generates EndpointResolverMiddleware interception code. - * Including creation of EndpointParams instance and pass it as middleware param along with EndpointResolver - */ -class OperationEndpointResolverMiddleware( - val ctx: ProtocolGenerator.GenerationContext, -) : MiddlewareRenderable { - - override val name = "EndpointResolverMiddleware" - - override val middlewareStep = MiddlewareStep.BUILDSTEP - - override val position = MiddlewarePosition.BEFORE - - override fun render(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter, op: OperationShape, operationStackName: String) { - renderEndpointParams(ctx, writer, op) - - // Write code that saves endpoint params to middleware context for use in auth scheme middleware when using rules-based auth scheme resolvers - if (AuthSchemeResolverGenerator.usesRulesBasedAuthResolver(ctx)) { - writer.write("context.attributes.set(key: AttributeKey(name: \"EndpointParams\"), value: endpointParams)") - } - - super.renderSpecific(ctx, writer, op, operationStackName, "applyEndpoint") - } - - override fun renderMiddlewareInit( - ctx: ProtocolGenerator.GenerationContext, - writer: SwiftWriter, - op: OperationShape - ) { - val output = MiddlewareShapeUtils.outputSymbol(ctx.symbolProvider, ctx.model, op) - writer.write( - "\$N<\$N>(endpointResolver: config.endpointResolver, endpointParams: endpointParams)", - AWSServiceTypes.EndpointResolverMiddleware, - output - ) - } - - private fun renderEndpointParams(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter, op: OperationShape) { - val outputError = MiddlewareShapeUtils.outputErrorSymbol(op) - val params = mutableListOf() - ctx.service.getTrait()?.ruleSet?.let { node -> - val ruleSet = EndpointRuleSet.fromNode(node) - val staticContextParams = op.getTrait()?.parameters ?: emptyMap() - val clientContextParams = ctx.service.getTrait()?.parameters ?: emptyMap() - val parameters = ruleSet.parameters.toList() - parameters.toList() - .sortedBy { it.name.toString() } - .forEach { param -> - val memberName = param.name.toString().toLowerCamelCase() - val contextParam = ctx.model.expectShape(op.inputShape).members() - .firstOrNull { it.getTrait()?.name == param.name.toString() } - val value = resolveParameterValue( - param, - staticContextParams[param.name.toString()], - contextParam, - clientContextParams[param.name.toString()], - writer, - outputError - ) - value?.let { - params.add("$memberName: $it") - } - } - } - - writer.write("let endpointParams = EndpointParams(${params.joinToString(separator = ", ")})") - } - - /** - * Resolve the parameter value based on the following order - * 1. staticContextParams: direct value from the static context params - * 2. contextParam: value from the input shape - * 3. clientContextParams: value from the client config - * 4. Built-In Bindings: value from the client config - * 5. Built-in binding default values: default value from the built-in binding - */ - private fun resolveParameterValue( - param: Parameter, - staticContextParam: StaticContextParamDefinition?, - contextParam: MemberShape?, - clientContextParam: ClientContextParamDefinition?, - writer: SwiftWriter, - outputError: Symbol - ): String? { - return when { - staticContextParam != null -> { - return when (param.type) { - ParameterType.STRING -> { - "\"${staticContextParam.value}\"" - } - - ParameterType.BOOLEAN -> { - staticContextParam.value.toString() - } - } - } - contextParam != null -> { - return "input.${contextParam.memberName.toLowerCamelCase()}" - } - clientContextParam != null -> { - when { - param.default.isPresent -> { - "config.${param.name.toString().toLowerCamelCase()} ?? ${param.defaultValueLiteral}" - } - else -> { - return "config.${param.name.toString().toLowerCamelCase()}" - } - } - } - param.isBuiltIn -> { - return when { - param.isRequired -> { - when { - param.default.isPresent -> { - "config.${param.name.toString().toLowerCamelCase()} ?? ${param.defaultValueLiteral}" - } - else -> { - // if the parameter is required, we must unwrap the optional value - writer.openBlock("guard let ${param.name.toString().toLowerCamelCase()} = config.${param.name.toString().toLowerCamelCase()} else {", "}") { - writer.write("throw SdkError<\$N>.client(ClientError.unknownError((\"Missing required parameter: \$L\")))", outputError, param.name.toString()) - } - param.name.toString().toLowerCamelCase() - } - } - } - param.default.isPresent -> { - "config.${param.name.toString().toLowerCamelCase()} ?? ${param.defaultValueLiteral}" - } - else -> { - "config.${param.name.toString().toLowerCamelCase()}" - } - } - } - else -> { - // we can't resolve this param, skip it - return null - } - } - } -} - -private val Parameter.defaultValueLiteral: String - get() { - return when (type) { - ParameterType.BOOLEAN -> default.get().toString() - ParameterType.STRING -> "\"${default.get()}\"" - } - } diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/plugins/EndpointPlugin.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/plugins/EndpointPlugin.kt index 537e6c2d453..c72a98f373a 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/plugins/EndpointPlugin.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/plugins/EndpointPlugin.kt @@ -1,8 +1,8 @@ package software.amazon.smithy.aws.swift.codegen.plugins -import software.amazon.smithy.aws.swift.codegen.AWSServiceTypes import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.endpoint.EndpointSymbols import software.amazon.smithy.swift.codegen.integration.Plugin import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.ServiceConfig @@ -20,12 +20,12 @@ class EndpointPlugin(private val serviceConfig: ServiceConfig) : Plugin { override fun render(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter) { writer.openBlock("public class $pluginName: Plugin {", "}") { - writer.write("private var endpointResolver: \$L", AWSServiceTypes.EndpointResolver) - writer.openBlock("public init(endpointResolver: \$L) {", "}", AWSServiceTypes.EndpointResolver) { + writer.write("private var endpointResolver: \$L", EndpointSymbols.EndpointResolver) + writer.openBlock("public init(endpointResolver: \$L) {", "}", EndpointSymbols.EndpointResolver) { writer.write("self.endpointResolver = endpointResolver") } writer.openBlock("public convenience init() throws {", "}") { - writer.write("self.init(endpointResolver: try \$L())", AWSServiceTypes.DefaultEndpointResolver) + writer.write("self.init(endpointResolver: try \$L())", EndpointSymbols.DefaultEndpointResolver) } writer.openBlock("public func configureClient(clientConfiguration: ClientRuntime.ClientConfiguration) throws {", "}") { writer.openBlock("if let config = clientConfiguration as? ${serviceConfig.typeName} {", "}") { diff --git a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/OperationEndpointResolverMiddlewareTests.kt b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/OperationEndpointResolverMiddlewareTests.kt index 09321a31f9a..0dba20bfcdc 100644 --- a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/OperationEndpointResolverMiddlewareTests.kt +++ b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/OperationEndpointResolverMiddlewareTests.kt @@ -7,9 +7,9 @@ package software.amazon.smithy.aws.swift.codegen import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test -import software.amazon.smithy.aws.swift.codegen.middleware.OperationEndpointResolverMiddleware import software.amazon.smithy.aws.traits.protocols.RestJson1Trait import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.endpoint.OperationEndpointResolverMiddleware import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator class OperationEndpointResolverMiddlewareTests { @@ -34,5 +34,13 @@ operationStack.buildStep.intercept(position: .before, middleware: EndpointResolv fun setupGenerationContext(smithyFile: String, serviceShapeId: String): ProtocolGenerator.GenerationContext { val context = TestUtils.executeDirectedCodegen(smithyFile, serviceShapeId, RestJson1Trait.ID) - return ProtocolGenerator.GenerationContext(context.ctx.settings, context.ctx.model, context.ctx.service, context.ctx.symbolProvider, listOf(), RestJson1Trait.ID, context.ctx.delegator) + return ProtocolGenerator.GenerationContext( + context.ctx.settings, + context.ctx.model, + context.ctx.service, + context.ctx.symbolProvider, + listOf(), + RestJson1Trait.ID, + context.ctx.delegator + ) } diff --git a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/TestUtils.kt b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/TestUtils.kt index 0ff8d4c2143..1c3e573770a 100644 --- a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/TestUtils.kt +++ b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/TestUtils.kt @@ -6,6 +6,7 @@ package software.amazon.smithy.aws.swift.codegen import org.junit.jupiter.api.Assertions +import software.amazon.smithy.aws.traits.ServiceTrait import software.amazon.smithy.build.MockManifest import software.amazon.smithy.build.PluginContext import software.amazon.smithy.codegen.core.SymbolProvider @@ -19,6 +20,7 @@ import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration +import software.amazon.smithy.swift.codegen.model.expectTrait import java.net.URL data class TestContext( @@ -38,7 +40,7 @@ class TestUtils { var model = createModelFromSmithy(modelFile) val service = model.getShape(ShapeId.from(serviceShapeIdWithNamespace)).get().asServiceShape().get() - val settings = buildDefaultSwiftSettingsObjectNode(serviceShapeIdWithNamespace, service.sdkId) + val settings = buildDefaultSwiftSettingsObjectNode(serviceShapeIdWithNamespace, service.expectTrait().sdkId) val swiftSettings = SwiftSettings.from(model, settings) val integrations = mutableListOf() diff --git a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/awsrestjson/AWSRestJson1ProtocolGeneratorTests.kt b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/awsrestjson/AWSRestJson1ProtocolGeneratorTests.kt index ff88398ef3b..945362f08b7 100644 --- a/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/awsrestjson/AWSRestJson1ProtocolGeneratorTests.kt +++ b/codegen/smithy-aws-swift-codegen/src/test/kotlin/software/amazon/smithy/aws/swift/codegen/awsrestjson/AWSRestJson1ProtocolGeneratorTests.kt @@ -131,8 +131,6 @@ class RestJsonProtocolGeneratorTests { public var signingRegion: Swift.String? - public var endpointResolver: EndpointResolver - public var telemetryProvider: ClientRuntime.TelemetryProvider public var retryStrategyOptions: ClientRuntime.RetryStrategyOptions @@ -151,9 +149,11 @@ class RestJsonProtocolGeneratorTests { public var authSchemeResolver: ClientRuntime.AuthSchemeResolver + public var endpointResolver: EndpointResolver + internal let logger: ClientRuntime.LogAgent - private init(_ useFIPS: Swift.Bool?, _ useDualStack: Swift.Bool?, _ appID: Swift.String?, _ awsCredentialIdentityResolver: any AWSClientRuntime.AWSCredentialIdentityResolver, _ awsRetryMode: AWSClientRuntime.AWSRetryMode, _ region: Swift.String?, _ signingRegion: Swift.String?, _ endpointResolver: EndpointResolver, _ telemetryProvider: ClientRuntime.TelemetryProvider, _ retryStrategyOptions: ClientRuntime.RetryStrategyOptions, _ clientLogMode: ClientRuntime.ClientLogMode, _ endpoint: Swift.String?, _ idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator, _ httpClientEngine: ClientRuntime.HTTPClient, _ httpClientConfiguration: ClientRuntime.HttpClientConfiguration, _ authSchemes: [ClientRuntime.AuthScheme]?, _ authSchemeResolver: ClientRuntime.AuthSchemeResolver) { + private init(_ useFIPS: Swift.Bool?, _ useDualStack: Swift.Bool?, _ appID: Swift.String?, _ awsCredentialIdentityResolver: any AWSClientRuntime.AWSCredentialIdentityResolver, _ awsRetryMode: AWSClientRuntime.AWSRetryMode, _ region: Swift.String?, _ signingRegion: Swift.String?, _ telemetryProvider: ClientRuntime.TelemetryProvider, _ retryStrategyOptions: ClientRuntime.RetryStrategyOptions, _ clientLogMode: ClientRuntime.ClientLogMode, _ endpoint: Swift.String?, _ idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator, _ httpClientEngine: ClientRuntime.HTTPClient, _ httpClientConfiguration: ClientRuntime.HttpClientConfiguration, _ authSchemes: [ClientRuntime.AuthScheme]?, _ authSchemeResolver: ClientRuntime.AuthSchemeResolver, _ endpointResolver: EndpointResolver) { self.useFIPS = useFIPS self.useDualStack = useDualStack self.appID = appID @@ -161,7 +161,6 @@ class RestJsonProtocolGeneratorTests { self.awsRetryMode = awsRetryMode self.region = region self.signingRegion = signingRegion - self.endpointResolver = endpointResolver self.telemetryProvider = telemetryProvider self.retryStrategyOptions = retryStrategyOptions self.clientLogMode = clientLogMode @@ -171,23 +170,24 @@ class RestJsonProtocolGeneratorTests { self.httpClientConfiguration = httpClientConfiguration self.authSchemes = authSchemes self.authSchemeResolver = authSchemeResolver + self.endpointResolver = endpointResolver self.logger = telemetryProvider.loggerProvider.getLogger(name: ExampleClient.clientName) } - public convenience init(useFIPS: Swift.Bool? = nil, useDualStack: Swift.Bool? = nil, appID: Swift.String? = nil, awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)? = nil, awsRetryMode: AWSClientRuntime.AWSRetryMode? = nil, region: Swift.String? = nil, signingRegion: Swift.String? = nil, endpointResolver: EndpointResolver? = nil, telemetryProvider: ClientRuntime.TelemetryProvider? = nil, retryStrategyOptions: ClientRuntime.RetryStrategyOptions? = nil, clientLogMode: ClientRuntime.ClientLogMode? = nil, endpoint: Swift.String? = nil, idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator? = nil, httpClientEngine: ClientRuntime.HTTPClient? = nil, httpClientConfiguration: ClientRuntime.HttpClientConfiguration? = nil, authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ClientRuntime.AuthSchemeResolver? = nil) throws { - self.init(useFIPS, useDualStack, try appID ?? AWSClientConfigDefaultsProvider.appID(), try awsCredentialIdentityResolver ?? AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(awsCredentialIdentityResolver), try awsRetryMode ?? AWSClientConfigDefaultsProvider.retryMode(), region, signingRegion, try endpointResolver ?? DefaultEndpointResolver(), telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, try retryStrategyOptions ?? AWSClientConfigDefaultsProvider.retryStrategyOptions(), clientLogMode ?? AWSClientConfigDefaultsProvider.clientLogMode, endpoint, idempotencyTokenGenerator ?? AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, httpClientEngine ?? AWSClientConfigDefaultsProvider.httpClientEngine, httpClientConfiguration ?? AWSClientConfigDefaultsProvider.httpClientConfiguration, authSchemes ?? [SigV4AuthScheme()], authSchemeResolver ?? DefaultExampleAuthSchemeResolver()) + public convenience init(useFIPS: Swift.Bool? = nil, useDualStack: Swift.Bool? = nil, appID: Swift.String? = nil, awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)? = nil, awsRetryMode: AWSClientRuntime.AWSRetryMode? = nil, region: Swift.String? = nil, signingRegion: Swift.String? = nil, telemetryProvider: ClientRuntime.TelemetryProvider? = nil, retryStrategyOptions: ClientRuntime.RetryStrategyOptions? = nil, clientLogMode: ClientRuntime.ClientLogMode? = nil, endpoint: Swift.String? = nil, idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator? = nil, httpClientEngine: ClientRuntime.HTTPClient? = nil, httpClientConfiguration: ClientRuntime.HttpClientConfiguration? = nil, authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ClientRuntime.AuthSchemeResolver? = nil, endpointResolver: EndpointResolver? = nil) throws { + self.init(useFIPS, useDualStack, try appID ?? AWSClientConfigDefaultsProvider.appID(), try awsCredentialIdentityResolver ?? AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(awsCredentialIdentityResolver), try awsRetryMode ?? AWSClientConfigDefaultsProvider.retryMode(), region, signingRegion, telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, try retryStrategyOptions ?? AWSClientConfigDefaultsProvider.retryStrategyOptions(), clientLogMode ?? AWSClientConfigDefaultsProvider.clientLogMode, endpoint, idempotencyTokenGenerator ?? AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, httpClientEngine ?? AWSClientConfigDefaultsProvider.httpClientEngine, httpClientConfiguration ?? AWSClientConfigDefaultsProvider.httpClientConfiguration, authSchemes ?? [SigV4AuthScheme()], authSchemeResolver ?? DefaultExampleAuthSchemeResolver(), try endpointResolver ?? DefaultEndpointResolver()) } - public convenience init(useFIPS: Swift.Bool? = nil, useDualStack: Swift.Bool? = nil, appID: Swift.String? = nil, awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)? = nil, awsRetryMode: AWSClientRuntime.AWSRetryMode? = nil, region: Swift.String? = nil, signingRegion: Swift.String? = nil, endpointResolver: EndpointResolver? = nil, telemetryProvider: ClientRuntime.TelemetryProvider? = nil, retryStrategyOptions: ClientRuntime.RetryStrategyOptions? = nil, clientLogMode: ClientRuntime.ClientLogMode? = nil, endpoint: Swift.String? = nil, idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator? = nil, httpClientEngine: ClientRuntime.HTTPClient? = nil, httpClientConfiguration: ClientRuntime.HttpClientConfiguration? = nil, authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ClientRuntime.AuthSchemeResolver? = nil) async throws { - self.init(useFIPS, useDualStack, try appID ?? AWSClientConfigDefaultsProvider.appID(), try awsCredentialIdentityResolver ?? AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(awsCredentialIdentityResolver), try awsRetryMode ?? AWSClientConfigDefaultsProvider.retryMode(), try await AWSClientConfigDefaultsProvider.region(region), try await AWSClientConfigDefaultsProvider.region(region), try endpointResolver ?? DefaultEndpointResolver(), telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, try retryStrategyOptions ?? AWSClientConfigDefaultsProvider.retryStrategyOptions(), clientLogMode ?? AWSClientConfigDefaultsProvider.clientLogMode, endpoint, idempotencyTokenGenerator ?? AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, httpClientEngine ?? AWSClientConfigDefaultsProvider.httpClientEngine, httpClientConfiguration ?? AWSClientConfigDefaultsProvider.httpClientConfiguration, authSchemes ?? [SigV4AuthScheme()], authSchemeResolver ?? DefaultExampleAuthSchemeResolver()) + public convenience init(useFIPS: Swift.Bool? = nil, useDualStack: Swift.Bool? = nil, appID: Swift.String? = nil, awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)? = nil, awsRetryMode: AWSClientRuntime.AWSRetryMode? = nil, region: Swift.String? = nil, signingRegion: Swift.String? = nil, telemetryProvider: ClientRuntime.TelemetryProvider? = nil, retryStrategyOptions: ClientRuntime.RetryStrategyOptions? = nil, clientLogMode: ClientRuntime.ClientLogMode? = nil, endpoint: Swift.String? = nil, idempotencyTokenGenerator: ClientRuntime.IdempotencyTokenGenerator? = nil, httpClientEngine: ClientRuntime.HTTPClient? = nil, httpClientConfiguration: ClientRuntime.HttpClientConfiguration? = nil, authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ClientRuntime.AuthSchemeResolver? = nil, endpointResolver: EndpointResolver? = nil) async throws { + self.init(useFIPS, useDualStack, try appID ?? AWSClientConfigDefaultsProvider.appID(), try awsCredentialIdentityResolver ?? AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(awsCredentialIdentityResolver), try awsRetryMode ?? AWSClientConfigDefaultsProvider.retryMode(), try await AWSClientConfigDefaultsProvider.region(region), try await AWSClientConfigDefaultsProvider.region(region), telemetryProvider ?? ClientRuntime.DefaultTelemetry.provider, try retryStrategyOptions ?? AWSClientConfigDefaultsProvider.retryStrategyOptions(), clientLogMode ?? AWSClientConfigDefaultsProvider.clientLogMode, endpoint, idempotencyTokenGenerator ?? AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, httpClientEngine ?? AWSClientConfigDefaultsProvider.httpClientEngine, httpClientConfiguration ?? AWSClientConfigDefaultsProvider.httpClientConfiguration, authSchemes ?? [SigV4AuthScheme()], authSchemeResolver ?? DefaultExampleAuthSchemeResolver(), try endpointResolver ?? DefaultEndpointResolver()) } public convenience required init() async throws { - try await self.init(useFIPS: nil, useDualStack: nil, appID: nil, awsCredentialIdentityResolver: nil, awsRetryMode: nil, region: nil, signingRegion: nil, endpointResolver: nil, telemetryProvider: nil, retryStrategyOptions: nil, clientLogMode: nil, endpoint: nil, idempotencyTokenGenerator: nil, httpClientEngine: nil, httpClientConfiguration: nil, authSchemes: nil, authSchemeResolver: nil) + try await self.init(useFIPS: nil, useDualStack: nil, appID: nil, awsCredentialIdentityResolver: nil, awsRetryMode: nil, region: nil, signingRegion: nil, telemetryProvider: nil, retryStrategyOptions: nil, clientLogMode: nil, endpoint: nil, idempotencyTokenGenerator: nil, httpClientEngine: nil, httpClientConfiguration: nil, authSchemes: nil, authSchemeResolver: nil, endpointResolver: nil) } public convenience init(region: String) throws { - self.init(nil, nil, try AWSClientConfigDefaultsProvider.appID(), try AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(), try AWSClientConfigDefaultsProvider.retryMode(), region, region, try DefaultEndpointResolver(), ClientRuntime.DefaultTelemetry.provider, try AWSClientConfigDefaultsProvider.retryStrategyOptions(), AWSClientConfigDefaultsProvider.clientLogMode, nil, AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, AWSClientConfigDefaultsProvider.httpClientEngine, AWSClientConfigDefaultsProvider.httpClientConfiguration, [SigV4AuthScheme()], DefaultExampleAuthSchemeResolver()) + self.init(nil, nil, try AWSClientConfigDefaultsProvider.appID(), try AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(), try AWSClientConfigDefaultsProvider.retryMode(), region, region, ClientRuntime.DefaultTelemetry.provider, try AWSClientConfigDefaultsProvider.retryStrategyOptions(), AWSClientConfigDefaultsProvider.clientLogMode, nil, AWSClientConfigDefaultsProvider.idempotencyTokenGenerator, AWSClientConfigDefaultsProvider.httpClientEngine, AWSClientConfigDefaultsProvider.httpClientConfiguration, [SigV4AuthScheme()], DefaultExampleAuthSchemeResolver(), try DefaultEndpointResolver()) } public var partitionID: String? {