-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Move RPCv2CBOR generation to smithy-swift #900
Conversation
public typealias RuntimeConfigType | ||
= DefaultSDKRuntimeConfiguration<DefaultRetryStrategy, DefaultRetryErrorInfoProvider> | ||
|
||
open class ClientConfigDefaultsProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously only AWSClientConfigDefaultsProvider existed. This separates out code that was not AWS specific to allow for supporting protocol generation in the future.
endpointResolverBlock: @escaping (Params) throws -> Endpoint, | ||
endpointParams: Params, | ||
paramsBlock: @escaping (Context) throws -> Params, | ||
resolverBlock: @escaping (Params) throws -> Endpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This updates EndpointResolverMiddleware.swift in smithy-swift to include type updates made to the same class in AWSClientRuntime
import class SmithyHTTPAPI.HTTPResponse | ||
@_spi(SmithyReadWrite) import class SmithyCBOR.Reader | ||
|
||
public struct RpcV2CborError: BaseError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift
|
||
import SmithyHTTPAPI | ||
|
||
public struct CborValidateResponseHeaderMiddleware<Input, Output> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift
/** | ||
* Generates code for EndpointResolver tests. | ||
*/ | ||
class EndpointTestGenerator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift as it is used by protocol generators
import software.amazon.smithy.swift.codegen.SwiftWriter | ||
import software.amazon.smithy.swift.codegen.middleware.OperationMiddleware | ||
|
||
class SmithyHttpProtocolClientGeneratorFactory : HttpProtocolClientGeneratorFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created to support protocol generators in smithy swift
const val AUTH_SCHEME_RESOLVER = "authSchemeResolver" | ||
const val ENDPOINT_PARAMS = "endpointParams" | ||
|
||
class SmithyServiceConfig(writer: SwiftWriter, val ctx: ProtocolGenerator.GenerationContext) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created to support SmithyHttpProtocolClientGeneratorFactory which is used in Protocol generators
import software.amazon.smithy.swift.codegen.middleware.MiddlewareRenderable | ||
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes | ||
|
||
class MutateHeadersMiddleware( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift
* Generates EndpointResolverMiddleware interception code. | ||
* Including creation of EndpointParams instance and pass it as middleware param along with EndpointResolver | ||
*/ | ||
open class OperationEndpointResolverMiddleware( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift. aws-sdk-swift now has AWSOperationEndpointResolverMiddleware which adds AWS specific logic related to account-id based & general endpoint resolution
} | ||
} | ||
|
||
open fun handleBuiltInParam(param: Parameter, writer: SwiftWriter): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to support overriding in AWSOperationEndpointResolverMiddleware
} | ||
} | ||
|
||
open fun handleClientContextParam(param: Parameter, writer: SwiftWriter): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to support overriding in AWSOperationEndpointResolverMiddleware
import software.amazon.smithy.swift.codegen.integration.ServiceConfig | ||
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes | ||
|
||
class RpcV2CborCustomizations : DefaultHTTPProtocolCustomizations() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved from aws-sdk-swift
import software.amazon.smithy.swift.codegen.model.targetOrSelf | ||
import software.amazon.smithy.swift.codegen.testModuleName | ||
|
||
class RpcV2CborProtocolGenerator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from aws-sdk-swift and directly inherits HTTPBindingProtocolGenerator rather than AWSHTTPBindingProtocolGenerator. This class adds in logic from AWSHTTPBindingProtocolGenerator directly into the protocol generator.
import software.amazon.smithy.swift.codegen.model.shapes | ||
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes | ||
|
||
class CborValidateResponseHeaderIntegration : SwiftIntegration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved from aws-sdk-swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments; 1 for changing method signature & 1 that's up to you
...otlin/software/amazon/smithy/swift/codegen/protocols/rpcv2cbor/RpcV2CborProtocolGenerator.kt
Outdated
Show resolved
Hide resolved
...e/amazon/smithy/swift/codegen/integration/middlewares/OperationEndpointResolverMiddleware.kt
Outdated
Show resolved
Hide resolved
).generateProtocolTests() + renderEndpointsTests(ctx) | ||
} | ||
|
||
fun renderEndpointsTests(ctx: ProtocolGenerator.GenerationContext): Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code unique to CBOR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope that's in AWSHTTPBindingProtocolGenerator as well that's here for parody: https://github.com/awslabs/aws-sdk-swift/blob/ea415dea03c6c6c8603ba7cd6637c6a52290802d/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSHTTPBindingProtocolGenerator.kt#L60
Issue #
SWIFT-2276
Description of changes
Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.