-
Notifications
You must be signed in to change notification settings - Fork 94
feat: Schema-based AWSJSON protocol #2131
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
base: epic/sbs
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,11 +80,13 @@ final class QueryCompatibleTests: XCTestCase { | |
| do { | ||
| _ = try await mockClient.getQueueUrl(input: .init(queueName: "non-existent-queue")) | ||
| XCTFail("Expected QueueDoesNotExist error") | ||
| } catch let error as AWSServiceError { | ||
| } catch let error as QueueDoesNotExist { | ||
| // TC2: Verify error code falls back to __type field | ||
| XCTAssertNotNil(error.errorCode, "Error code should not be nil") | ||
| XCTAssertEqual(error.errorCode, "QueueDoesNotExist", | ||
| "Error code should be parsed from __type field when header is missing") | ||
| // TODO: Establish why errorCode should be different depending on how the | ||
| // error was matched (this exposes implementation) | ||
| // XCTAssertEqual(error.errorCode, "QueueDoesNotExist", | ||
| // "Error code should be parsed from __type field when header is missing") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer checking this code value because we model error code as static for a modeled error type, and passing TC1 & TC2 requires passing different error codes for the same type |
||
| } | ||
| } | ||
|
|
||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,6 @@ import class ClientRuntime.OrchestratorTelemetry | |
| import class ClientRuntime.SdkHttpClient | ||
| import class Smithy.Context | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This & the next several files contain generated changes. |
||
| import class Smithy.ContextBuilder | ||
| import class SmithyHTTPAPI.HTTPRequest | ||
| import class SmithyHTTPAPI.HTTPResponse | ||
| @_spi(SmithyReadWrite) import class SmithyJSON.Writer | ||
| import enum AWSClientRuntime.AWSClockSkewProvider | ||
| import enum AWSClientRuntime.AWSRetryErrorInfoProvider | ||
| import enum AWSClientRuntime.AWSRetryMode | ||
|
|
@@ -37,30 +34,29 @@ import protocol ClientRuntime.DefaultHttpClientConfiguration | |
| import protocol ClientRuntime.HttpInterceptorProvider | ||
| import protocol ClientRuntime.IdempotencyTokenGenerator | ||
| import protocol ClientRuntime.InterceptorProvider | ||
| import protocol ClientRuntime.Plugin | ||
| import protocol ClientRuntime.TelemetryProvider | ||
| import protocol Smithy.LogAgent | ||
| import protocol SmithyHTTPAPI.HTTPClient | ||
| import protocol SmithyHTTPAuthAPI.AuthSchemeResolver | ||
| @_spi(AWSCredentialIdentityResolver) import protocol SmithyIdentity.AWSCredentialIdentityResolver | ||
| import protocol SmithyIdentity.BearerTokenIdentityResolver | ||
| @_spi(SmithyReadWrite) import protocol SmithyReadWrite.SmithyWriter | ||
| @_spi(AWSEndpointResolverMiddleware) import struct AWSClientRuntime.AWSEndpointResolverMiddleware | ||
| import struct AWSClientRuntime.AmzSdkInvocationIdMiddleware | ||
| import struct AWSClientRuntime.UserAgentMiddleware | ||
| import struct AWSSDKHTTPAuth.SigV4AuthScheme | ||
| import struct ClientRuntime.AuthSchemeMiddleware | ||
| @_spi(SmithyReadWrite) import struct ClientRuntime.BodyMiddleware | ||
| import struct ClientRuntime.ContentLengthMiddleware | ||
| import struct ClientRuntime.ContentTypeMiddleware | ||
| @_spi(SmithyReadWrite) import struct ClientRuntime.DeserializeMiddleware | ||
| import struct ClientRuntime.LoggerMiddleware | ||
| import struct ClientRuntime.MutateHeadersMiddleware | ||
| import struct ClientRuntime.SendableHttpInterceptorProviderBox | ||
| import struct ClientRuntime.SendableInterceptorProviderBox | ||
| import struct ClientRuntime.SignerMiddleware | ||
| import struct ClientRuntime.URLHostMiddleware | ||
| import struct ClientRuntime.URLPathMiddleware | ||
| import struct Smithy.Attributes | ||
| import struct SmithyAWSJSON.HTTPClientProtocol | ||
| import struct SmithyAWSJSON.Plugin | ||
| import struct SmithyIdentity.BearerTokenIdentity | ||
| @_spi(StaticAWSCredentialIdentityResolver) import struct SmithyIdentity.StaticAWSCredentialIdentityResolver | ||
| @_spi(StaticBearerTokenIdentityResolver) import struct SmithyIdentity.StaticBearerTokenIdentityResolver | ||
|
|
@@ -631,6 +627,12 @@ extension CognitoIdentityClient { | |
| /// - `ResourceNotFoundException` : Thrown when the requested resource (for example, a dataset or record) does not exist. | ||
| /// - `TooManyRequestsException` : Thrown when a request is throttled. | ||
| public func getCredentialsForIdentity(input: GetCredentialsForIdentityInput) async throws -> GetCredentialsForIdentityOutput { | ||
| var config = config | ||
| let plugins: [any ClientRuntime.Plugin] = [SmithyAWSJSON.Plugin()] | ||
| for plugin in plugins { | ||
| try await plugin.configureClient(clientConfiguration: &config) | ||
| } | ||
| let operation = CognitoIdentityClient.getCredentialsForIdentityOperation | ||
| let context = Smithy.ContextBuilder() | ||
| .withMethod(value: .post) | ||
| .withServiceName(value: serviceName) | ||
|
|
@@ -641,18 +643,18 @@ extension CognitoIdentityClient { | |
| .withRegion(value: config.region) | ||
| .withRequestChecksumCalculation(value: config.requestChecksumCalculation) | ||
| .withResponseChecksumValidation(value: config.responseChecksumValidation) | ||
| .withOperationProperties(value: operation) | ||
| .build() | ||
| let builder = ClientRuntime.OrchestratorBuilder<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, SmithyHTTPAPI.HTTPRequest, SmithyHTTPAPI.HTTPResponse>() | ||
| let clientProtocol = SmithyAWSJSON.HTTPClientProtocol(version: .v1_1) | ||
| let builder = ClientRuntime.OrchestratorBuilder(operation, clientProtocol) | ||
| config.interceptorProviders.forEach { provider in | ||
| builder.interceptors.add(provider.create()) | ||
| } | ||
| config.httpInterceptorProviders.forEach { provider in | ||
| builder.interceptors.add(provider.create()) | ||
| } | ||
| builder.interceptors.add(ClientRuntime.URLPathMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>(GetCredentialsForIdentityInput.urlPathProvider(_:))) | ||
| builder.interceptors.add(ClientRuntime.URLHostMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>()) | ||
| builder.interceptors.add(ClientRuntime.ContentLengthMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>()) | ||
| builder.deserialize(ClientRuntime.DeserializeMiddleware<GetCredentialsForIdentityOutput>(GetCredentialsForIdentityOutput.httpOutput(from:), GetCredentialsForIdentityOutputError.httpError(from:))) | ||
| builder.interceptors.add(ClientRuntime.LoggerMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>(clientLogMode: config.clientLogMode)) | ||
| builder.clockSkewProvider(AWSClientRuntime.AWSClockSkewProvider.provider()) | ||
| builder.retryStrategy(SmithyRetries.DefaultRetryStrategy(options: config.retryStrategyOptions)) | ||
|
|
@@ -664,7 +666,6 @@ extension CognitoIdentityClient { | |
| } | ||
| builder.applyEndpoint(AWSClientRuntime.AWSEndpointResolverMiddleware<GetCredentialsForIdentityOutput, EndpointParams>(paramsBlock: endpointParamsBlock, resolverBlock: { [config] in try config.endpointResolver.resolve(params: $0) })) | ||
| builder.interceptors.add(ClientRuntime.MutateHeadersMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>(overrides: ["X-Amz-Target": "AWSCognitoIdentityService.GetCredentialsForIdentity"])) | ||
| builder.serialize(ClientRuntime.BodyMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, SmithyJSON.Writer>(rootNodeInfo: "", inputWritingClosure: GetCredentialsForIdentityInput.write(value:to:))) | ||
| builder.interceptors.add(ClientRuntime.ContentTypeMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>(contentType: "application/x-amz-json-1.1")) | ||
| builder.selectAuthScheme(ClientRuntime.AuthSchemeMiddleware<GetCredentialsForIdentityOutput>()) | ||
| builder.interceptors.add(AWSClientRuntime.AmzSdkInvocationIdMiddleware<GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput>()) | ||
|
|
@@ -705,6 +706,12 @@ extension CognitoIdentityClient { | |
| /// - `ResourceNotFoundException` : Thrown when the requested resource (for example, a dataset or record) does not exist. | ||
| /// - `TooManyRequestsException` : Thrown when a request is throttled. | ||
| public func getId(input: GetIdInput) async throws -> GetIdOutput { | ||
| var config = config | ||
| let plugins: [any ClientRuntime.Plugin] = [SmithyAWSJSON.Plugin()] | ||
| for plugin in plugins { | ||
| try await plugin.configureClient(clientConfiguration: &config) | ||
| } | ||
| let operation = CognitoIdentityClient.getIdOperation | ||
| let context = Smithy.ContextBuilder() | ||
| .withMethod(value: .post) | ||
| .withServiceName(value: serviceName) | ||
|
|
@@ -715,18 +722,18 @@ extension CognitoIdentityClient { | |
| .withRegion(value: config.region) | ||
| .withRequestChecksumCalculation(value: config.requestChecksumCalculation) | ||
| .withResponseChecksumValidation(value: config.responseChecksumValidation) | ||
| .withOperationProperties(value: operation) | ||
| .build() | ||
| let builder = ClientRuntime.OrchestratorBuilder<GetIdInput, GetIdOutput, SmithyHTTPAPI.HTTPRequest, SmithyHTTPAPI.HTTPResponse>() | ||
| let clientProtocol = SmithyAWSJSON.HTTPClientProtocol(version: .v1_1) | ||
| let builder = ClientRuntime.OrchestratorBuilder(operation, clientProtocol) | ||
| config.interceptorProviders.forEach { provider in | ||
| builder.interceptors.add(provider.create()) | ||
| } | ||
| config.httpInterceptorProviders.forEach { provider in | ||
| builder.interceptors.add(provider.create()) | ||
| } | ||
| builder.interceptors.add(ClientRuntime.URLPathMiddleware<GetIdInput, GetIdOutput>(GetIdInput.urlPathProvider(_:))) | ||
| builder.interceptors.add(ClientRuntime.URLHostMiddleware<GetIdInput, GetIdOutput>()) | ||
| builder.interceptors.add(ClientRuntime.ContentLengthMiddleware<GetIdInput, GetIdOutput>()) | ||
| builder.deserialize(ClientRuntime.DeserializeMiddleware<GetIdOutput>(GetIdOutput.httpOutput(from:), GetIdOutputError.httpError(from:))) | ||
| builder.interceptors.add(ClientRuntime.LoggerMiddleware<GetIdInput, GetIdOutput>(clientLogMode: config.clientLogMode)) | ||
| builder.clockSkewProvider(AWSClientRuntime.AWSClockSkewProvider.provider()) | ||
| builder.retryStrategy(SmithyRetries.DefaultRetryStrategy(options: config.retryStrategyOptions)) | ||
|
|
@@ -738,7 +745,6 @@ extension CognitoIdentityClient { | |
| } | ||
| builder.applyEndpoint(AWSClientRuntime.AWSEndpointResolverMiddleware<GetIdOutput, EndpointParams>(paramsBlock: endpointParamsBlock, resolverBlock: { [config] in try config.endpointResolver.resolve(params: $0) })) | ||
| builder.interceptors.add(ClientRuntime.MutateHeadersMiddleware<GetIdInput, GetIdOutput>(overrides: ["X-Amz-Target": "AWSCognitoIdentityService.GetId"])) | ||
| builder.serialize(ClientRuntime.BodyMiddleware<GetIdInput, GetIdOutput, SmithyJSON.Writer>(rootNodeInfo: "", inputWritingClosure: GetIdInput.write(value:to:))) | ||
| builder.interceptors.add(ClientRuntime.ContentTypeMiddleware<GetIdInput, GetIdOutput>(contentType: "application/x-amz-json-1.1")) | ||
| builder.selectAuthScheme(ClientRuntime.AuthSchemeMiddleware<GetIdOutput>()) | ||
| builder.interceptors.add(AWSClientRuntime.AmzSdkInvocationIdMiddleware<GetIdInput, GetIdOutput>()) | ||
|
|
||
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.
We were not checking for this modeled error type before (we would have failed if we did, because an unknown error was being thrown.)