Repository navigation
Implement endpoint bdd resolution #885
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
Open
arandito
wants to merge
1
commit into
develop
Choose a base branch
from
endpoints-bdd
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions
63
codegen-output/aws-json-1-0/src/awsjson10/_private/endpoints.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,63 @@ | ||
| # Code generated by smithy-python-codegen DO NOT EDIT. | ||
|
|
||
| """Endpoint BDD for aws.protocoltests.json10#JsonRpc10.""" | ||
|
|
||
| from smithy_core.endpoints import EndpointBdd | ||
|
|
||
| # fmt: off | ||
| # Tags: ref=0, attr=1, call=2, list=3, map=4, error=5, endpoint=6. | ||
| BDD = EndpointBdd( | ||
| # (name, type, required, default, builtin, client_context) | ||
| parameters=( | ||
| ("Region", "string", False, None, "AWS::Region", False), | ||
| ("UseDualStack", "boolean", True, False, "AWS::UseDualStack", False), | ||
| ("UseFIPS", "boolean", True, False, "AWS::UseFIPS", False), | ||
| ("Endpoint", "string", False, None, "SDK::Endpoint", False), | ||
| ), | ||
| functions=("aws.partition", "booleanEquals", "isSet", "stringEquals"), | ||
| conditions=( | ||
| ((2, "isSet", (0, "Endpoint")), None), # 0: isSet(Endpoint) | ||
| ((2, "isSet", (0, "Region")), None), # 1: isSet(Region) | ||
| ((2, "aws.partition", (0, "Region")), "PartitionResult"), # 2: PartitionResult = aws.partition(Region) | ||
| ((2, "booleanEquals", (0, "UseFIPS"), True), None), # 3: booleanEquals(UseFIPS, true) | ||
| ((2, "booleanEquals", (0, "UseDualStack"), True), None), # 4: booleanEquals(UseDualStack, true) | ||
| ((2, "booleanEquals", (1, (0, "PartitionResult"), "supportsDualStack"), True), None), # 5: booleanEquals(PartitionResult#supportsDualStack, true) | ||
| ((2, "booleanEquals", (1, (0, "PartitionResult"), "supportsFIPS"), True), None), # 6: booleanEquals(PartitionResult#supportsFIPS, true) | ||
| ((2, "stringEquals", (1, (0, "PartitionResult"), "name"), "aws-us-gov"), None), # 7: stringEquals(PartitionResult#name, "aws-us-gov") | ||
| ), | ||
| results=( | ||
| None, # 0: no match | ||
| (5, "Invalid Configuration: FIPS and custom endpoint are not supported"), # 1 | ||
| (5, "Invalid Configuration: Dualstack and custom endpoint are not supported"), # 2 | ||
| (6, (0, "Endpoint"), None, ()), # 3 | ||
| (6, "https://jsonrpc10-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", None, ()), # 4 | ||
| (5, "FIPS and DualStack are enabled, but this partition does not support one or both"), # 5 | ||
| (6, "https://jsonrpc10.{Region}.amazonaws.com", None, ()), # 6 | ||
| (6, "https://jsonrpc10-fips.{Region}.{PartitionResult#dnsSuffix}", None, ()), # 7 | ||
| (5, "FIPS is enabled but this partition does not support FIPS"), # 8 | ||
| (6, "https://jsonrpc10.{Region}.{PartitionResult#dualStackDnsSuffix}", None, ()), # 9 | ||
| (5, "DualStack is enabled but this partition does not support DualStack"), # 10 | ||
| (6, "https://jsonrpc10.{Region}.{PartitionResult#dnsSuffix}", None, ()), # 11 | ||
| (5, "Invalid Configuration: Missing Region"), # 12 | ||
| ), | ||
| root=2, | ||
| # (condition, high, low); 1 and -1 are terminals, a negative reference is a | ||
| # complement edge, and 100_000_000 + k is result k. | ||
| nodes=( | ||
| -1, 1, -1, | ||
| 0, 13, 3, | ||
| 1, 4, 100_000_012, | ||
| 2, 5, 100_000_012, | ||
| 3, 8, 6, | ||
| 4, 7, 100_000_011, | ||
| 5, 100_000_009, 100_000_010, | ||
| 4, 11, 9, | ||
| 6, 10, 100_000_008, | ||
| 7, 100_000_006, 100_000_007, | ||
| 5, 12, 100_000_005, | ||
| 6, 100_000_004, 100_000_005, | ||
| 3, 100_000_001, 14, | ||
| 4, 100_000_002, 100_000_003, | ||
| ), | ||
| ) | ||
| # fmt: on |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,11 @@ | |
| from smithy_aws_core.aio.config import AsyncFileSystem | ||
| from smithy_aws_core.aio.config.aws_config import AsyncAwsConfig, AwsConfigOverrides | ||
| from smithy_aws_core.aio.config.resolvers import EndpointUriResolver | ||
| from smithy_aws_core.aio.endpoints.standard_regional import ( | ||
| AsyncStandardRegionalEndpointsResolver, | ||
| ) | ||
| from smithy_aws_core.aio.protocols import AsyncAwsJson10ClientProtocol | ||
| from smithy_aws_core.config.types import FieldSpec | ||
| from smithy_aws_core.endpoints import AWS_RULES_EXTENSION | ||
| from smithy_aws_core.identity import AWSCredentialsIdentity, AWSIdentityProperties | ||
| from smithy_core.aio.endpoints import AsyncBddEndpointResolver | ||
| from smithy_core.aio.interfaces import AsyncClientProtocol, AsyncEndpointResolver | ||
| from smithy_core.aio.interfaces.auth import AsyncAuthScheme | ||
| from smithy_core.aio.interfaces.identity import AsyncIdentityResolver | ||
|
|
@@ -30,6 +29,7 @@ | |
| from smithy_core.shapes import ShapeID | ||
| from smithy_http.aio.aiohttp import AIOHTTPClient | ||
|
|
||
| from ._private.endpoints import BDD | ||
| from ._private.schemas import JSON_RPC10 | ||
| from .auth import HTTPAuthSchemeResolver | ||
|
|
||
|
|
@@ -136,6 +136,8 @@ class _AsyncJSONRPC10ConfigOverrides(AwsConfigOverrides, total=False): | |
| ) | ||
| auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None | ||
| auth_scheme_resolver: AuthSchemeResolver | None | ||
| use_dualstack_endpoint: bool | None | ||
| use_fips_endpoint: bool | None | ||
|
|
||
|
|
||
| @dataclass(kw_only=True, repr=False, init=False) | ||
|
|
@@ -170,6 +172,12 @@ class AsyncJSONRPC10Config(AsyncAwsConfig): | |
| operation. | ||
| """ | ||
|
|
||
| use_dualstack_endpoint: bool | None = None | ||
| """Whether to use dual-stack.""" | ||
|
|
||
| use_fips_endpoint: bool | None = None | ||
| """Whether to use FIPS-compliant regional endpoint.""" | ||
|
Comment on lines
+175
to
+179
Contributor
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. nit - I think our descriptions can be improved a bit here to be more helpful |
||
|
|
||
| aws_credentials_identity_resolver: ( | ||
| AsyncIdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None | ||
| ) = None | ||
|
|
@@ -200,6 +208,8 @@ class AsyncJSONRPC10Config(AsyncAwsConfig): | |
| """ | ||
|
|
||
| _FIELDS: ClassVar[dict[str, FieldSpec]] = { | ||
| "use_dualstack_endpoint": FieldSpec(default=None), | ||
| "use_fips_endpoint": FieldSpec(default=None), | ||
| "aws_credentials_identity_resolver": FieldSpec(default=None), | ||
| "region": FieldSpec(default=None), | ||
| "aws_access_key_id": FieldSpec(default=None), | ||
|
|
@@ -212,8 +222,8 @@ class AsyncJSONRPC10Config(AsyncAwsConfig): | |
| default=None, resolver=EndpointUriResolver("json_rpc_10") | ||
| ), | ||
| "endpoint_resolver": FieldSpec( | ||
| default_factory=lambda: AsyncStandardRegionalEndpointsResolver( | ||
| endpoint_prefix="jsonrpc10" | ||
| default_factory=lambda: AsyncBddEndpointResolver( | ||
| BDD, extensions=[AWS_RULES_EXTENSION] | ||
| ) | ||
| ), | ||
| "protocol": FieldSpec( | ||
|
|
||
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.
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.
Investigating myself, but asking incase I forget
Why isn't this reflected in the
endpoints.pyfile? Do we do some conversion into a different format?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.
The trait stores
nodesas a base64 string (spec) andEndpointBddGeneratordecodes them to plain ints inendpoints.pyto avoid doing it at runtime. For example,/////wAAAAH/////decodes to-1, 1, -1.