Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions codegen-output/aws-json-1-0/src/awsjson10/_private/endpoints.py
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
256 changes: 0 additions & 256 deletions codegen-output/aws-json-1-0/src/awsjson10/_private/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
_JR = "JsonRpc10"
_a = "aws.auth#sigv4"
_a_ = "aws.protocols#awsJson1_0"
_sB = "smithy.rules#endpointBdd"
_aw = "aws.api#service"

CLIENT_OPTIONAL_DEFAULTS: StaticSchema = (18, n0, _COD, 0, (_m,), ((7, {_s: 0}),))
Expand Down Expand Up @@ -862,261 +861,6 @@
{
_a: MappingProxyType({"name": "jsonrpc10"}),
_a_: None,
_sB: MappingProxyType(
{
"version": "1.1",
"parameters": MappingProxyType(
{
"Region": MappingProxyType(
{
"builtIn": "AWS::Region",
"required": False,
"documentation": "The AWS Region. This is a default regional AWS endpointRuleSet.",
"type": "string",
}
),
"UseDualStack": MappingProxyType(
{
"builtIn": "AWS::UseDualStack",
"required": True,
"default": False,
"documentation": "Whether to use dual-stack.",
"type": "boolean",
}
),
"UseFIPS": MappingProxyType(
{
"builtIn": "AWS::UseFIPS",
"required": True,
"default": False,
"documentation": "Whether to use FIPS-compliant regional endpoint.",
"type": "boolean",
}
),
"Endpoint": MappingProxyType(
{
"builtIn": "SDK::Endpoint",
"required": False,
"documentation": "Override the endpoint.",
"type": "string",
}
),
}
),
"conditions": (
MappingProxyType(
{
"fn": "isSet",
"argv": (MappingProxyType({"ref": "Endpoint"}),),
}
),
MappingProxyType(
{"fn": "isSet", "argv": (MappingProxyType({"ref": "Region"}),)}
),
MappingProxyType(
{
"fn": "aws.partition",
"argv": (MappingProxyType({"ref": "Region"}),),
"assign": "PartitionResult",
}
),
MappingProxyType(
{
"fn": "booleanEquals",
"argv": (MappingProxyType({"ref": "UseFIPS"}), True),
}
),
MappingProxyType(
{
"fn": "booleanEquals",
"argv": (MappingProxyType({"ref": "UseDualStack"}), True),
}
),
MappingProxyType(
{
"fn": "booleanEquals",
"argv": (
MappingProxyType(
{
"fn": "getAttr",
"argv": (
MappingProxyType(
{"ref": "PartitionResult"}
),
"supportsDualStack",
),
}
),
True,
),
}
),
MappingProxyType(
{
"fn": "booleanEquals",
"argv": (
MappingProxyType(
{
"fn": "getAttr",
"argv": (
MappingProxyType(
{"ref": "PartitionResult"}
),
"supportsFIPS",
),
}
),
True,
),
}
),
MappingProxyType(
{
"fn": "stringEquals",
"argv": (
MappingProxyType(
{
"fn": "getAttr",
"argv": (
MappingProxyType(
{"ref": "PartitionResult"}
),
"name",
),
}
),
"aws-us-gov",
),
}
),
),
"results": (
MappingProxyType(
{
"conditions": (),
"error": "Invalid Configuration: FIPS and custom endpoint are not supported",
"type": "error",
}
),
MappingProxyType(
{
"conditions": (),
"error": "Invalid Configuration: Dualstack and custom endpoint are not supported",
"type": "error",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": MappingProxyType({"ref": "Endpoint"}),
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": "https://jsonrpc10-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"error": "FIPS and DualStack are enabled, but this partition does not support one or both",
"type": "error",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": "https://jsonrpc10.{Region}.amazonaws.com",
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": "https://jsonrpc10-fips.{Region}.{PartitionResult#dnsSuffix}",
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"error": "FIPS is enabled but this partition does not support FIPS",
"type": "error",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": "https://jsonrpc10.{Region}.{PartitionResult#dualStackDnsSuffix}",
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"error": "DualStack is enabled but this partition does not support DualStack",
"type": "error",
}
),
MappingProxyType(
{
"conditions": (),
"endpoint": MappingProxyType(
{
"url": "https://jsonrpc10.{Region}.{PartitionResult#dnsSuffix}",
"properties": MappingProxyType[str, object]({}),
"headers": MappingProxyType[str, object]({}),
}
),
"type": "endpoint",
}
),
MappingProxyType(
{
"conditions": (),
"error": "Invalid Configuration: Missing Region",
"type": "error",
}
),
),
"root": 2,
"nodeCount": 14,
"nodes": "/////wAAAAH/////AAAAAAAAAA0AAAADAAAAAQAAAAQF9eEMAAAAAgAAAAUF9eEMAAAAAwAAAAgAAAAGAAAABAAAAAcF9eELAAAABQX14QkF9eEKAAAABAAAAAsAAAAJAAAABgAAAAoF9eEIAAAABwX14QYF9eEHAAAABQAAAAwF9eEFAAAABgX14QQF9eEFAAAAAwX14QEAAAAOAAAABAX14QIF9eED",

Copy link
Copy Markdown
Contributor

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.py file? Do we do some conversion into a different format?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trait stores nodes as a base64 string (spec) and EndpointBddGenerator decodes them to plain ints in endpoints.py to avoid doing it at runtime. For example, /////wAAAAH///// decodes to -1, 1, -1.

}
),
_aw: MappingProxyType({"sdkId": "JSON RPC 10"}),
},
)
20 changes: 15 additions & 5 deletions codegen-output/aws-json-1-0/src/awsjson10/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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),
Expand All @@ -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(
Expand Down
Loading
Loading