-
Notifications
You must be signed in to change notification settings - Fork 28
Add AWS QUERY client protocol and codegen support #663
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
Merged
arandito
merged 5 commits into
smithy-lang:feat/add-query-protocol
from
arandito:add-query-protocol
Mar 27, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41f35ed
smithy-aws-core: add support for awsQuery protocol
arandito 65c5ee7
codegen: generate AwsQueryClientProtocol for awsQuery services and ge…
arandito b9a4a2c
smithy-aws-core: update casing for xml traits
arandito 257749b
Address PR feedback
arandito b2f00e4
Fix tests
arandito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...re/src/main/java/software/amazon/smithy/python/aws/codegen/AwsQueryProtocolGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package software.amazon.smithy.python.aws.codegen; | ||
|
|
||
| import java.util.Set; | ||
| import software.amazon.smithy.aws.traits.protocols.AwsQueryTrait; | ||
| import software.amazon.smithy.model.shapes.ShapeId; | ||
| import software.amazon.smithy.python.codegen.ApplicationProtocol; | ||
| import software.amazon.smithy.python.codegen.GenerationContext; | ||
| import software.amazon.smithy.python.codegen.HttpProtocolTestGenerator; | ||
| import software.amazon.smithy.python.codegen.SymbolProperties; | ||
| import software.amazon.smithy.python.codegen.generators.ProtocolGenerator; | ||
| import software.amazon.smithy.python.codegen.writer.PythonWriter; | ||
| import software.amazon.smithy.utils.SmithyInternalApi; | ||
|
|
||
| @SmithyInternalApi | ||
| public final class AwsQueryProtocolGenerator implements ProtocolGenerator { | ||
| private static final Set<String> TESTS_TO_SKIP = Set.of( | ||
| // TODO: support the request compression trait | ||
| // https://smithy.io/2.0/spec/behavior-traits.html#smithy-api-requestcompression-trait | ||
| "SDKAppliedContentEncoding_awsQuery", | ||
| "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery", | ||
|
|
||
| // TODO: support idempotency token autofill | ||
| "QueryProtocolIdempotencyTokenAutoFill", | ||
|
|
||
| // This test asserts nan == nan, which is never true. | ||
| // We should update the generator to make specific assertions for these. | ||
| "AwsQuerySupportsNaNFloatOutputs", | ||
|
|
||
| // TODO: support of the endpoint trait | ||
| "AwsQueryEndpointTraitWithHostLabel", | ||
| "AwsQueryEndpointTrait"); | ||
|
|
||
| @Override | ||
| public ShapeId getProtocol() { | ||
| return AwsQueryTrait.ID; | ||
| } | ||
|
|
||
| @Override | ||
| public ApplicationProtocol getApplicationProtocol(GenerationContext context) { | ||
| return ApplicationProtocol.createDefaultHttpApplicationProtocol(); | ||
| } | ||
|
|
||
| @Override | ||
| public void initializeProtocol(GenerationContext context, PythonWriter writer) { | ||
| writer.addDependency(AwsPythonDependency.SMITHY_AWS_CORE.withOptionalDependencies("xml")); | ||
| writer.addImport("smithy_aws_core.aio.protocols", "AwsQueryClientProtocol"); | ||
| var service = context.settings().service(context.model()); | ||
| var serviceSymbol = context.symbolProvider().toSymbol(service); | ||
| var serviceSchema = serviceSymbol.expectProperty(SymbolProperties.SCHEMA); | ||
| var version = service.getVersion(); | ||
| writer.write("AwsQueryClientProtocol($T, $S)", serviceSchema, version); | ||
| } | ||
|
|
||
| @Override | ||
| public void generateProtocolTests(GenerationContext context) { | ||
| context.writerDelegator() | ||
| .useFileWriter("./tests/test_awsquery_protocol.py", "tests.test_awsquery_protocol", writer -> { | ||
| new HttpProtocolTestGenerator( | ||
| context, | ||
| getProtocol(), | ||
| writer, | ||
| (shape, testCase) -> TESTS_TO_SKIP.contains(testCase.getId())).run(); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...-core/.changes/next-release/smithy-aws-core-feature-ec24e8dbe26b4ee58029f89da5b6526e.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "feature", | ||
| "description": "Add `awsQuery` protocol support for Smithy clients." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/smithy-aws-core/src/smithy_aws_core/_private/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 |
10 changes: 10 additions & 0 deletions
10
packages/smithy-aws-core/src/smithy_aws_core/_private/query/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from .errors import create_aws_query_error | ||
| from .serializers import QueryShapeSerializer | ||
|
|
||
| __all__ = ( | ||
| "QueryShapeSerializer", | ||
| "create_aws_query_error", | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.