diff --git a/codegen-output-py/api-key-auth-client/.smithy-python-manifest.json b/codegen-output-py/api-key-auth-client/.smithy-python-manifest.json deleted file mode 100644 index 4ab6967d4..000000000 --- a/codegen-output-py/api-key-auth-client/.smithy-python-manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "files": { - "README.md": "0575cdb9dbd9d11ba72c347ebd2cfb1a9e68b50208ce144d07c01e46802e1a10", - "pyproject.toml": "94e3cbb02f22fa0b7c2b081fbbb7a797a151ff4e368303e49f69f95f8ae0c96c", - "src/api_key_auth_client/__init__.py": "c9cc2cd353b5b05a7dce3ad05a0e499c8cb368281e2146219dcff4c269e3a1bb", - "src/api_key_auth_client/_private/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "src/api_key_auth_client/_private/endpoints.py": "7d515fe771678e82ddbe07798d6b7e48c25c6c9bec19cec9318deb0bc5064ead", - "src/api_key_auth_client/_private/schemas.py": "64ebd9bc142c33fba620c877d1c1e6f3d258a4875ad38dbf905bcaa2505d471d", - "src/api_key_auth_client/aio/__init__.py": "01574d80de484082fae6de0f710510098e064007fd330bffd9f2e63efc5e75e6", - "src/api_key_auth_client/aio/client.py": "03ff3b33f191c3debf70cd95b37611c6937ecdd21c708ec68a492ca0ca2182fa", - "src/api_key_auth_client/aio/config.py": "5f9cefe2070a5a2a0d69c9fd45c0b2fbff065fdd9e09c4b56fc99db67ec3676d", - "src/api_key_auth_client/client.py": "d5de89636e23b7912a79b21712c5759e8efc98db5501cf05a986996d7471b03b", - "src/api_key_auth_client/config.py": "63a8567780b54a2ffb89e7df6f38b1a2c6d5838fa371f03e32011582ee5ebcff", - "src/api_key_auth_client/models.py": "a05bc9c5dcb44288446bb6ac4a5c0f98cbd1612adb9fb7cbf935e1401617091f", - "src/api_key_auth_client/models.pyi": "8a0650b60d4aa7b90f260cf404e1c67b3014db96f18d837011629eff59725bfb", - "src/api_key_auth_client/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "version": 1 -} diff --git a/codegen-output-py/api-key-auth-client/README.md b/codegen-output-py/api-key-auth-client/README.md deleted file mode 100644 index 7fe7f5b53..000000000 --- a/codegen-output-py/api-key-auth-client/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -## api_key_auth_client Client Package - -Python client for the API key auth fixture diff --git a/codegen-output-py/api-key-auth-client/pyproject.toml b/codegen-output-py/api-key-auth-client/pyproject.toml deleted file mode 100644 index 837fb9337..000000000 --- a/codegen-output-py/api-key-auth-client/pyproject.toml +++ /dev/null @@ -1,37 +0,0 @@ -# Code generated by smithy-python-codegen DO NOT EDIT. - -[project] -name = "api_key_auth_client" -version = "0.0.1" -description = "Python client for the API key auth fixture" -readme = "README.md" -requires-python = ">=3.12" -keywords = ["smithy", "api_key_auth_client"] -license = {text = "Apache-2.0"} -dependencies = [ - "smithy-core~=0.13.0", - "smithy-http[aiohttp,cbor,urllib3]~=0.10.0", -] - -[build-system] -requires = [ - "hatchling", -] -build-backend = "hatchling.build" - -[tool.hatch.build.targets.wheel] -packages = [ - "src/api_key_auth_client", -] - -[tool.pyright] -typeCheckingMode = "strict" - -[tool.ruff] -target-version = "py312" - -[tool.ruff.lint] -ignore = ["F841"] - -[tool.ruff.format] -skip-magic-trailing-comma = true diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/__init__.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/__init__.py deleted file mode 100644 index c9035ee5f..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -from importlib import import_module -from typing import TYPE_CHECKING, Any - -__version__: str = "0.0.1" - -if TYPE_CHECKING: - from .aio.client import AsyncApiKeyService - from .aio.config import AsyncConfig - from .client import ApiKeyService - from .config import Config - -__all__ = ["ApiKeyService", "AsyncApiKeyService", "AsyncConfig", "Config"] - -_EXPORTS = { - "ApiKeyService": ".client", - "Config": ".config", - "AsyncApiKeyService": ".aio.client", - "AsyncConfig": ".aio.config", -} - - -def __getattr__(name: str) -> Any: - if name in _EXPORTS: - return getattr(import_module(_EXPORTS[name], __name__), name) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/endpoints.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/endpoints.py deleted file mode 100644 index ad3066783..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/endpoints.py +++ /dev/null @@ -1,27 +0,0 @@ -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_attribute) - parameters=( - ("endpoint", "string", False, None, "SDK::Endpoint", None), - ), - functions=("isSet",), - conditions=( - ((2, "isSet", (0, "endpoint")), None), # 0: isSet(endpoint) - ), - results=( - None, # 0: no match - (6, (0, "endpoint"), None, ()), # 1 - (5, "(default endpointRuleSet) endpoint is not set - you must configure an endpoint."), # 2 - ), - 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, 100_000_001, 100_000_002, - ), -) -# fmt: on diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/schemas.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/schemas.py deleted file mode 100644 index 791b44a6a..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/schemas.py +++ /dev/null @@ -1,105 +0,0 @@ -from smithy_core._schema_compact import StaticOperationSchema, StaticSchema - -n0 = "example.apikey" -_s0 = "GetThingInput" -_s1 = "smithy.synthetic#originalShapeId" -_s2 = "example.apikey#GetThingInput" -_s3 = "smithy.api#input" -_s4 = "name" -_s5 = "GetThingOutput" -_s6 = "example.apikey#GetThingOutput" -_s7 = "smithy.api#output" -_s8 = "value" -_s9 = "HealthInput" -_s10 = "smithy.api#Unit" -_s11 = "HealthOutput" -_s12 = "PingInput" -_s13 = "PingOutput" -_s14 = "GetThing" -_s15 = "Health" -_s16 = "Ping" -_s17 = "ApiKeyService" -_s18 = "smithy.protocols#rpcv2Cbor" - -GET_THING_INPUT: StaticSchema = ( - 18, - n0, - _s0, - {_s1: _s2, _s3: None}, - (_s4,), - ((3, 0),), -) - -GET_THING_OUTPUT: StaticSchema = ( - 18, - n0, - _s5, - {_s1: _s6, _s7: None}, - (_s8,), - ((3, 0),), -) - -HEALTH_INPUT: StaticSchema = ( - 18, - n0, - _s9, - {_s1: _s10, _s3: None}, -) - -HEALTH_OUTPUT: StaticSchema = ( - 18, - n0, - _s11, - {_s1: _s10, _s7: None}, -) - -PING_INPUT: StaticSchema = ( - 18, - n0, - _s12, - {_s1: _s10, _s3: None}, -) - -PING_OUTPUT: StaticSchema = ( - 18, - n0, - _s13, - {_s1: _s10, _s7: None}, -) - -GET_THING: StaticOperationSchema = ( - 23, - n0, - _s14, - 0, - GET_THING_INPUT, - GET_THING_OUTPUT, - (), -) - -HEALTH: StaticOperationSchema = ( - 23, - n0, - _s15, - 0, - HEALTH_INPUT, - HEALTH_OUTPUT, - (), -) - -PING: StaticOperationSchema = ( - 23, - n0, - _s16, - 0, - PING_INPUT, - PING_OUTPUT, - (), -) - -API_KEY_SERVICE: StaticSchema = ( - 21, - n0, - _s17, - {_s18: None}, -) diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/__init__.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/__init__.py deleted file mode 100644 index 61152f98d..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from importlib import import_module -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from .client import AsyncApiKeyService - from .config import AsyncConfig - -__all__ = ["AsyncApiKeyService", "AsyncConfig"] - -_EXPORTS = { - "AsyncApiKeyService": ".client", - "AsyncConfig": ".config", -} - - -def __getattr__(name: str) -> Any: - if name in _EXPORTS: - return getattr(import_module(_EXPORTS[name], __name__), name) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/client.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/client.py deleted file mode 100644 index 4dafdcad6..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/client.py +++ /dev/null @@ -1,120 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.aio.client import AsyncClient -from smithy_http.plugins import user_agent_plugin - -from api_key_auth_client import models -from api_key_auth_client.aio.config import AsyncConfig, Plugin - - -class AsyncApiKeyService(AsyncClient[AsyncConfig]): - "A service that authenticates with an API key." - - _client_plugins = (user_agent_plugin,) - - @overload - async def get_thing( - self, - request: models.GetThingInput | models.GetThingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.GetThingOutput: ... - - @overload - async def get_thing( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.GetThingInputDict], - ) -> models.GetThingOutput: - """ - Uses the service's API key auth. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def get_thing( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.GetThingOutput: - return await self._invoke( - self._select_input(models.GET_THING, args, kwargs), - models.GET_THING, - [], - plugins, - ) - - @overload - async def health( - self, - request: models.HealthInput | models.HealthInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.HealthOutput: ... - - @overload - async def health( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.HealthInputDict], - ) -> models.HealthOutput: - """ - Needs no auth. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def health( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.HealthOutput: - return await self._invoke( - self._select_input(models.HEALTH, args, kwargs), - models.HEALTH, - [], - plugins, - ) - - @overload - async def ping( - self, - request: models.PingInput | models.PingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PingOutput: ... - - @overload - async def ping( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PingInputDict], - ) -> models.PingOutput: - """ - Sends the API key when it has one. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def ping( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PingOutput: - return await self._invoke( - self._select_input(models.PING, args, kwargs), - models.PING, - [], - plugins, - ) - - def _new_config(self) -> AsyncConfig: - return AsyncConfig() diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/config.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/config.py deleted file mode 100644 index 4ea9e2359..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/aio/config.py +++ /dev/null @@ -1,122 +0,0 @@ -from collections.abc import Callable -from dataclasses import dataclass -from typing import Any, cast - -from smithy_core.aio.interfaces import AsyncClientTransport, AsyncEndpointResolver -from smithy_core.aio.interfaces.auth import AsyncAuthScheme -from smithy_core.aio.interfaces.identity import AsyncIdentityResolver -from smithy_core.auth import DefaultAuthResolver -from smithy_core.endpoints import BddEndpointResolver -from smithy_core.interceptors import Interceptor -from smithy_core.interfaces import ( - ClientProtocol, - EndpointResolver, - ProtocolConstructor, - ProtocolSettings, - URI, -) -from smithy_core.interfaces.auth import AuthSchemeResolver -from smithy_core.interfaces.retries import RetryStrategy -from smithy_core.retries import RetryStrategyOptions -from smithy_core.shapes import ShapeID -from smithy_core.traits import APIKeyLocation -from smithy_http.aio.aiohttp import AIOHTTPClient -from smithy_http.aio.auth.apikey import AsyncAPIKeyAuthScheme -from smithy_http.aio.identity.apikey import AsyncAPIKeyIdentityResolver -from smithy_http.aio.protocols import AsyncRpcV2CborClientProtocol -from smithy_http.identity import APIKeyIdentity, APIKeyIdentityProperties - -from api_key_auth_client._private.endpoints import BDD -from api_key_auth_client._private.schemas import API_KEY_SERVICE - -_PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.apikey", - service_target="ApiKeyService", - version="2026-11-17", - service_schema=API_KEY_SERVICE, -) - - -@dataclass(init=False) -class AsyncConfig: - "Configuration for AsyncApiKeyService." - - api_key: str | None - "The API key to send along with requests." - - api_key_identity_resolver: ( - AsyncIdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None - ) - "Resolves the API key." - - auth_scheme_resolver: AuthSchemeResolver - "Determines the auth scheme for each operation." - - auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] - "Auth schemes by auth scheme ID." - - endpoint_resolver: EndpointResolver | AsyncEndpointResolver - "Resolves the endpoint of each operation." - - endpoint_uri: str | URI | None - "The endpoint URI, read by the endpoint rules as ``SDK::Endpoint``." - - interceptors: list[Interceptor[Any, Any, Any, Any]] - "Hooks called during the execution of a request." - - protocol: ClientProtocol[Any, Any] - "Serializes requests and deserializes responses." - - retry_strategy: RetryStrategy | RetryStrategyOptions | None - "The retry strategy, or options to create one." - - transport: AsyncClientTransport[Any, Any] - "Sends requests, such as an HTTP client." - - def __init__( - self, - *, - api_key: str | None = None, - api_key_identity_resolver: AsyncIdentityResolver[ - APIKeyIdentity, APIKeyIdentityProperties - ] - | None = None, - auth_scheme_resolver: AuthSchemeResolver | None = None, - auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None = None, - endpoint_resolver: EndpointResolver | AsyncEndpointResolver | None = None, - endpoint_uri: str | URI | None = None, - interceptors: list[Interceptor[Any, Any, Any, Any]] | None = None, - protocol: ClientProtocol[Any, Any] - | ProtocolConstructor[ClientProtocol[Any, Any]] - | None = None, - retry_strategy: RetryStrategy | RetryStrategyOptions | None = None, - transport: AsyncClientTransport[Any, Any] | None = None, - ) -> None: - self.api_key = api_key - self.api_key_identity_resolver = ( - api_key_identity_resolver or AsyncAPIKeyIdentityResolver() - ) - self.auth_scheme_resolver = auth_scheme_resolver or DefaultAuthResolver() - self.auth_schemes = auth_schemes or { - ShapeID("smithy.api#httpApiKeyAuth"): AsyncAPIKeyAuthScheme( - name="Authorization", location=APIKeyLocation.HEADER, scheme="ApiKey" - ), - } - self.endpoint_resolver = endpoint_resolver or BddEndpointResolver(BDD) - self.endpoint_uri = endpoint_uri - self.interceptors = interceptors or [] - if isinstance(protocol, type): - protocol = protocol(_PROTOCOL_SETTINGS) - self.protocol = cast( - ClientProtocol[Any, Any], protocol - ) or AsyncRpcV2CborClientProtocol(_PROTOCOL_SETTINGS) - self.retry_strategy = retry_strategy - self.transport = transport or AIOHTTPClient() - - def set_auth_scheme(self, scheme: AsyncAuthScheme[Any, Any, Any, Any]) -> None: - "Set an auth scheme under its scheme ID." - self.auth_schemes[scheme.scheme_id] = scheme - - -type Plugin = Callable[[AsyncConfig], None] -"A callable that customizes the client configuration." diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/client.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/client.py deleted file mode 100644 index 1cc76139a..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/client.py +++ /dev/null @@ -1,120 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.client import Client -from smithy_http.plugins import user_agent_plugin - -from api_key_auth_client import models -from api_key_auth_client.config import Config, Plugin - - -class ApiKeyService(Client[Config]): - "A service that authenticates with an API key." - - _client_plugins = (user_agent_plugin,) - - @overload - def get_thing( - self, - request: models.GetThingInput | models.GetThingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.GetThingOutput: ... - - @overload - def get_thing( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.GetThingInputDict], - ) -> models.GetThingOutput: - """ - Uses the service's API key auth. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def get_thing( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.GetThingOutput: - return self._invoke( - self._select_input(models.GET_THING, args, kwargs), - models.GET_THING, - [], - plugins, - ) - - @overload - def health( - self, - request: models.HealthInput | models.HealthInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.HealthOutput: ... - - @overload - def health( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.HealthInputDict], - ) -> models.HealthOutput: - """ - Needs no auth. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def health( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.HealthOutput: - return self._invoke( - self._select_input(models.HEALTH, args, kwargs), - models.HEALTH, - [], - plugins, - ) - - @overload - def ping( - self, - request: models.PingInput | models.PingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PingOutput: ... - - @overload - def ping( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PingInputDict], - ) -> models.PingOutput: - """ - Sends the API key when it has one. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def ping( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PingOutput: - return self._invoke( - self._select_input(models.PING, args, kwargs), - models.PING, - [], - plugins, - ) - - def _new_config(self) -> Config: - return Config() diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/config.py b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/config.py deleted file mode 100644 index 74922ff65..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/config.py +++ /dev/null @@ -1,121 +0,0 @@ -from collections.abc import Callable -from dataclasses import dataclass -from typing import Any, cast - -from smithy_core.auth import DefaultAuthResolver -from smithy_core.endpoints import BddEndpointResolver -from smithy_core.interceptors import Interceptor -from smithy_core.interfaces import ( - ClientProtocol, - ClientTransport, - EndpointResolver, - ProtocolConstructor, - ProtocolSettings, - URI, -) -from smithy_core.interfaces.auth import AuthScheme, AuthSchemeResolver -from smithy_core.interfaces.identity import IdentityResolver -from smithy_core.interfaces.retries import RetryStrategy -from smithy_core.retries import RetryStrategyOptions -from smithy_core.shapes import ShapeID -from smithy_core.traits import APIKeyLocation -from smithy_http.auth.apikey import APIKeyAuthScheme -from smithy_http.identity import APIKeyIdentity, APIKeyIdentityProperties -from smithy_http.identity.apikey import APIKeyIdentityResolver -from smithy_http.protocols import RpcV2CborClientProtocol -from smithy_http.urllib3 import Urllib3HTTPClient - -from api_key_auth_client._private.endpoints import BDD -from api_key_auth_client._private.schemas import API_KEY_SERVICE - -_PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.apikey", - service_target="ApiKeyService", - version="2026-11-17", - service_schema=API_KEY_SERVICE, -) - - -@dataclass(init=False) -class Config: - "Configuration for ApiKeyService." - - api_key: str | None - "The API key to send along with requests." - - api_key_identity_resolver: ( - IdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None - ) - "Resolves the API key." - - auth_scheme_resolver: AuthSchemeResolver - "Determines the auth scheme for each operation." - - auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] - "Auth schemes by auth scheme ID." - - endpoint_resolver: EndpointResolver - "Resolves the endpoint of each operation." - - endpoint_uri: str | URI | None - "The endpoint URI, read by the endpoint rules as ``SDK::Endpoint``." - - interceptors: list[Interceptor[Any, Any, Any, Any]] - "Hooks called during the execution of a request." - - protocol: ClientProtocol[Any, Any] - "Serializes requests and deserializes responses." - - retry_strategy: RetryStrategy | RetryStrategyOptions | None - "The retry strategy, or options to create one." - - transport: ClientTransport[Any, Any] - "Sends requests, such as an HTTP client." - - def __init__( - self, - *, - api_key: str | None = None, - api_key_identity_resolver: IdentityResolver[ - APIKeyIdentity, APIKeyIdentityProperties - ] - | None = None, - auth_scheme_resolver: AuthSchemeResolver | None = None, - auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None, - endpoint_resolver: EndpointResolver | None = None, - endpoint_uri: str | URI | None = None, - interceptors: list[Interceptor[Any, Any, Any, Any]] | None = None, - protocol: ClientProtocol[Any, Any] - | ProtocolConstructor[ClientProtocol[Any, Any]] - | None = None, - retry_strategy: RetryStrategy | RetryStrategyOptions | None = None, - transport: ClientTransport[Any, Any] | None = None, - ) -> None: - self.api_key = api_key - self.api_key_identity_resolver = ( - api_key_identity_resolver or APIKeyIdentityResolver() - ) - self.auth_scheme_resolver = auth_scheme_resolver or DefaultAuthResolver() - self.auth_schemes = auth_schemes or { - ShapeID("smithy.api#httpApiKeyAuth"): APIKeyAuthScheme( - name="Authorization", location=APIKeyLocation.HEADER, scheme="ApiKey" - ), - } - self.endpoint_resolver = endpoint_resolver or BddEndpointResolver(BDD) - self.endpoint_uri = endpoint_uri - self.interceptors = interceptors or [] - if isinstance(protocol, type): - protocol = protocol(_PROTOCOL_SETTINGS) - self.protocol = cast( - ClientProtocol[Any, Any], protocol - ) or RpcV2CborClientProtocol(_PROTOCOL_SETTINGS) - self.retry_strategy = retry_strategy - self.transport = transport or Urllib3HTTPClient() - - def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None: - "Set an auth scheme under its scheme ID." - self.auth_schemes[scheme.scheme_id] = scheme - - -type Plugin = Callable[[Config], None] -"A callable that customizes the client configuration." diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.pyi b/codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.pyi deleted file mode 100644 index 78bb20062..000000000 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.pyi +++ /dev/null @@ -1,104 +0,0 @@ -from dataclasses import dataclass -from typing import Self, TypedDict - -from smithy_core.deserializers import ShapeDeserializer -from smithy_core.exceptions import ModeledError -from smithy_core.response import ResponseMetadata -from smithy_core.schemas import APIOperation -from smithy_core.serializers import ShapeSerializer - -__all__ = [ - "GET_THING", - "HEALTH", - "PING", - "GetThingInput", - "GetThingOutput", - "HealthInput", - "HealthOutput", - "PingInput", - "PingOutput", - "ServiceError", -] - -class _SerdeShape: - def serialize(self, serializer: ShapeSerializer) -> None: ... - def serialize_members(self, serializer: ShapeSerializer) -> None: ... - @classmethod - def deserialize(cls, deserializer: ShapeDeserializer) -> Self: ... - -class ServiceError(ModeledError): - """ - Base error for all errors in the service. - - Some exceptions do not extend from this class, including synthetic, - implicit, and shared exception types. - """ - -@dataclass(kw_only=True) -class GetThingInput(_SerdeShape): - "Dataclass for GetThingInput structure." - - name: str | None = ... - -class GetThingInputDict(TypedDict, total=False): - "Dictionary form of `GetThingInput`." - - name: str | None - -@dataclass(kw_only=True) -class GetThingOutput(_SerdeShape): - "Dataclass for GetThingOutput structure." - - value: str | None = ... - response_metadata: ResponseMetadata = ... - """ - Metadata about the response that produced this output. - - Use this to recover the request identifiers a service's support team - needs in order to investigate a call. Members of the metadata are - individually optional. - """ - -@dataclass(kw_only=True) -class HealthInput(_SerdeShape): - "Dataclass for HealthInput structure." - -class HealthInputDict(TypedDict, total=False): - "Dictionary form of `HealthInput`." - -@dataclass(kw_only=True) -class HealthOutput(_SerdeShape): - "Dataclass for HealthOutput structure." - - response_metadata: ResponseMetadata = ... - """ - Metadata about the response that produced this output. - - Use this to recover the request identifiers a service's support team - needs in order to investigate a call. Members of the metadata are - individually optional. - """ - -@dataclass(kw_only=True) -class PingInput(_SerdeShape): - "Dataclass for PingInput structure." - -class PingInputDict(TypedDict, total=False): - "Dictionary form of `PingInput`." - -@dataclass(kw_only=True) -class PingOutput(_SerdeShape): - "Dataclass for PingOutput structure." - - response_metadata: ResponseMetadata = ... - """ - Metadata about the response that produced this output. - - Use this to recover the request identifiers a service's support team - needs in order to investigate a call. Members of the metadata are - individually optional. - """ - -GET_THING: APIOperation[GetThingInput, GetThingOutput] -HEALTH: APIOperation[HealthInput, HealthOutput] -PING: APIOperation[PingInput, PingOutput] diff --git a/codegen-output-py/aws-config-client/.smithy-python-manifest.json b/codegen-output-py/aws-config-client/.smithy-python-manifest.json deleted file mode 100644 index 0c11ee822..000000000 --- a/codegen-output-py/aws-config-client/.smithy-python-manifest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "files": { - "README.md": "fd9e871f95d184d149ce23c2a4cd0eb77dffebac24d83f19fd0333b38329f665", - "pyproject.toml": "2d25ffb28e4599769791f7453a05fd7665cd5544850add05903dd701516253ab", - "src/aws_config_client/__init__.py": "316c15daeb5ec5c2087ab41af28a36fa149a117ec0f145ed4f0f836bae84cfe6", - "src/aws_config_client/_private/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "src/aws_config_client/_private/endpoints.py": "7b7fc7e93046c5849dadc9002eccd8a71dca2f0e194a2dbd1158ecca174f6d85", - "src/aws_config_client/_private/schemas.py": "c215a5e2bceb78db677a60e607358cd9e58ca68f379df23c7c2771733b6ee5b7", - "src/aws_config_client/aio/__init__.py": "0a179e5a12e1d0aa9e7d4307ac0c0c00526cebb5145cc9b0b35e69d41aaada67", - "src/aws_config_client/aio/client.py": "e0939941df6eef91aca4b5b33fbd84b9cf68b4bc903d786d96e1678e47abb796", - "src/aws_config_client/aio/config.py": "d17750691ea420996bb2ddfbb5f09d5bd8397346b0c0ceb7ea5bf6b14185bd10", - "src/aws_config_client/aio/user_agent.py": "36d50d3e1ef1b524f6c137eb377b7d7a6905e069b5f784074017664a3c65852e", - "src/aws_config_client/client.py": "6bff2d04a812609e3d12fc36a06fb80f4fb94686328b40ca88ba71694509f9e5", - "src/aws_config_client/config.py": "f652b5f8975bab09486a0d862d6c5c5d2df9b20816798f13c9e7f987d965e4c9", - "src/aws_config_client/models.py": "63766a511b14b4fdb2dba4a5db834016aa14001cde495a4960ac0ab6f4f601b0", - "src/aws_config_client/models.pyi": "a378f899f5dd91d9353081c0d312306b411c3e926b26ace7cdb46908f2af2b70", - "src/aws_config_client/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "src/aws_config_client/user_agent.py": "d07f98802cecab19abca8bde1853ff9d8fa8ce9ef471abf73b7b4d56abad7a36" - }, - "version": 1 -} diff --git a/codegen-output-py/aws-config-client/README.md b/codegen-output-py/aws-config-client/README.md deleted file mode 100644 index 1d8cdf0a0..000000000 --- a/codegen-output-py/aws-config-client/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -## aws_config_client Client Package - -Python client for the AWS config fixture diff --git a/codegen-output-py/aws-config-client/pyproject.toml b/codegen-output-py/aws-config-client/pyproject.toml deleted file mode 100644 index 228725111..000000000 --- a/codegen-output-py/aws-config-client/pyproject.toml +++ /dev/null @@ -1,38 +0,0 @@ -# Code generated by smithy-python-codegen DO NOT EDIT. - -[project] -name = "aws_config_client" -version = "0.0.1" -description = "Python client for the AWS config fixture" -readme = "README.md" -requires-python = ">=3.12" -keywords = ["smithy", "aws_config_client"] -license = {text = "Apache-2.0"} -dependencies = [ - "smithy-aws-core~=0.16.0", - "smithy-core~=0.13.0", - "smithy-http[aiohttp,cbor,urllib3]~=0.10.0", -] - -[build-system] -requires = [ - "hatchling", -] -build-backend = "hatchling.build" - -[tool.hatch.build.targets.wheel] -packages = [ - "src/aws_config_client", -] - -[tool.pyright] -typeCheckingMode = "strict" - -[tool.ruff] -target-version = "py312" - -[tool.ruff.lint] -ignore = ["F841"] - -[tool.ruff.format] -skip-magic-trailing-comma = true diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/__init__.py b/codegen-output-py/aws-config-client/src/aws_config_client/__init__.py deleted file mode 100644 index 1886830e7..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/__init__.py +++ /dev/null @@ -1,30 +0,0 @@ -from importlib import import_module -from typing import TYPE_CHECKING, Any - -__version__: str = "0.0.1" - -if TYPE_CHECKING: - from .aio.client import AsyncWeatherStationClient - from .aio.config import AsyncWeatherStationConfig - from .client import WeatherStationClient - from .config import WeatherStationConfig - -__all__ = [ - "AsyncWeatherStationClient", - "AsyncWeatherStationConfig", - "WeatherStationClient", - "WeatherStationConfig", -] - -_EXPORTS = { - "WeatherStationClient": ".client", - "WeatherStationConfig": ".config", - "AsyncWeatherStationClient": ".aio.client", - "AsyncWeatherStationConfig": ".aio.config", -} - - -def __getattr__(name: str) -> Any: - if name in _EXPORTS: - return getattr(import_module(_EXPORTS[name], __name__), name) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/_private/__init__.py b/codegen-output-py/aws-config-client/src/aws_config_client/_private/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/_private/endpoints.py b/codegen-output-py/aws-config-client/src/aws_config_client/_private/endpoints.py deleted file mode 100644 index 973ba8ee5..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/_private/endpoints.py +++ /dev/null @@ -1,27 +0,0 @@ -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_attribute) - parameters=( - ("Endpoint", "string", False, None, "SDK::Endpoint", None), - ), - functions=("isSet",), - conditions=( - ((2, "isSet", (0, "Endpoint")), None), # 0: isSet(Endpoint) - ), - results=( - None, # 0: no match - (6, (0, "Endpoint"), None, ()), # 1 - (5, "Endpoint is not set"), # 2 - ), - 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, 100_000_001, 100_000_002, - ), -) -# fmt: on diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/_private/schemas.py b/codegen-output-py/aws-config-client/src/aws_config_client/_private/schemas.py deleted file mode 100644 index 711777f98..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/_private/schemas.py +++ /dev/null @@ -1,53 +0,0 @@ -from types import MappingProxyType - -from smithy_core._schema_compact import StaticOperationSchema, StaticSchema - -n0 = "example.awsconfig" -_s0 = "GetForecastInput" -_s1 = "smithy.synthetic#originalShapeId" -_s2 = "example.awsconfig#GetForecastInput" -_s3 = "smithy.api#input" -_s4 = "city" -_s5 = "GetForecastOutput" -_s6 = "example.awsconfig#GetForecastOutput" -_s7 = "smithy.api#output" -_s8 = "summary" -_s9 = "GetForecast" -_s10 = "WeatherStation" -_s11 = "aws.api#service" -_s12 = "smithy.protocols#rpcv2Cbor" - -GET_FORECAST_INPUT: StaticSchema = ( - 18, - n0, - _s0, - {_s1: _s2, _s3: None}, - (_s4,), - ((3, 0),), -) - -GET_FORECAST_OUTPUT: StaticSchema = ( - 18, - n0, - _s5, - {_s1: _s6, _s7: None}, - (_s8,), - ((3, 0),), -) - -GET_FORECAST: StaticOperationSchema = ( - 23, - n0, - _s9, - 0, - GET_FORECAST_INPUT, - GET_FORECAST_OUTPUT, - (), -) - -WEATHER_STATION: StaticSchema = ( - 21, - n0, - _s10, - {_s11: MappingProxyType({"sdkId": "Weather Station"}), _s12: None}, -) diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/aio/__init__.py b/codegen-output-py/aws-config-client/src/aws_config_client/aio/__init__.py deleted file mode 100644 index c70a641a6..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/aio/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from importlib import import_module -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from .client import AsyncWeatherStationClient - from .config import AsyncWeatherStationConfig - -__all__ = ["AsyncWeatherStationClient", "AsyncWeatherStationConfig"] - -_EXPORTS = { - "AsyncWeatherStationClient": ".client", - "AsyncWeatherStationConfig": ".config", -} - - -def __getattr__(name: str) -> Any: - if name in _EXPORTS: - return getattr(import_module(_EXPORTS[name], __name__), name) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/aio/client.py b/codegen-output-py/aws-config-client/src/aws_config_client/aio/client.py deleted file mode 100644 index ace077e17..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/aio/client.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.aio.client import AsyncClient -from smithy_http.plugins import user_agent_plugin - -from aws_config_client import models -from aws_config_client.aio.config import AsyncWeatherStationConfig, Plugin -from aws_config_client.aio.user_agent import aws_user_agent_plugin - - -class AsyncWeatherStationClient(AsyncClient[AsyncWeatherStationConfig]): - "An AWS service that reads its config from the environment and profiles." - - _client_plugins = (aws_user_agent_plugin, user_agent_plugin) - - @overload - async def get_forecast( - self, - request: models.GetForecastInput | models.GetForecastInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.GetForecastOutput: ... - - @overload - async def get_forecast( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.GetForecastInputDict], - ) -> models.GetForecastOutput: - """ - Gets the forecast for a city. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def get_forecast( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.GetForecastOutput: - return await self._invoke( - self._select_input(models.GET_FORECAST, args, kwargs), - models.GET_FORECAST, - [], - plugins, - ) - - async def _new_config(self) -> AsyncWeatherStationConfig: - return await AsyncWeatherStationConfig.resolve() diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/client.py b/codegen-output-py/aws-config-client/src/aws_config_client/client.py deleted file mode 100644 index 713796674..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/client.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.client import Client -from smithy_http.plugins import user_agent_plugin - -from aws_config_client import models -from aws_config_client.config import Plugin, WeatherStationConfig -from aws_config_client.user_agent import aws_user_agent_plugin - - -class WeatherStationClient(Client[WeatherStationConfig]): - "An AWS service that reads its config from the environment and profiles." - - _client_plugins = (aws_user_agent_plugin, user_agent_plugin) - - @overload - def get_forecast( - self, - request: models.GetForecastInput | models.GetForecastInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.GetForecastOutput: ... - - @overload - def get_forecast( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.GetForecastInputDict], - ) -> models.GetForecastOutput: - """ - Gets the forecast for a city. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def get_forecast( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.GetForecastOutput: - return self._invoke( - self._select_input(models.GET_FORECAST, args, kwargs), - models.GET_FORECAST, - [], - plugins, - ) - - def _new_config(self) -> WeatherStationConfig: - return WeatherStationConfig.resolve() diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/models.py b/codegen-output-py/aws-config-client/src/aws_config_client/models.py deleted file mode 100644 index c620e949e..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/models.py +++ /dev/null @@ -1,61 +0,0 @@ -from smithy_core._dynamic_models import ModelRegistry -from smithy_core.exceptions import ModeledError - -from ._private import schemas - - -class ServiceError(ModeledError): - """ - Base error for all errors in the service. - - Some exceptions do not extend from this class, including synthetic, - implicit, and shared exception types. - """ - - -_MODEL_INDEX = { - "GetForecastInput": "GET_FORECAST_INPUT", - "GetForecastOutput": "GET_FORECAST_OUTPUT", -} - -_RENAMES: dict[str, str] = {} - -_TARGET_NAMES: dict[str, str] = {} - -_OPERATIONS: dict[str, tuple[tuple[str, ...], tuple[str, ...]]] = { - "GET_FORECAST": ( - (), - ("smithy.api#noAuth",), - ), -} - -_MODEL_NAMES = tuple(_MODEL_INDEX) -__all__ = ("ServiceError", *_MODEL_NAMES, *_OPERATIONS) # pyright: ignore[reportUnsupportedDunderAll] - - -_registry = ModelRegistry( - schemas, - renames=_RENAMES, - index=_MODEL_INDEX, - target_names=_TARGET_NAMES, - shape_names=frozenset( - { - "GetForecastInput", - "GetForecastOutput", - } - ), - service_error="ServiceError", -) -del schemas, ModelRegistry, ModeledError - - -def __getattr__(name: str): - if (data := _OPERATIONS.get(name)) is not None: - return globals().setdefault(name, _registry.build_operation(name, *data)) - value = _registry.build(name) - globals()[name] = value - return value - - -def __dir__() -> list[str]: - return sorted({*globals(), *__all__}) diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/models.pyi b/codegen-output-py/aws-config-client/src/aws_config_client/models.pyi deleted file mode 100644 index a06ebc7da..000000000 --- a/codegen-output-py/aws-config-client/src/aws_config_client/models.pyi +++ /dev/null @@ -1,56 +0,0 @@ -from dataclasses import dataclass -from typing import Self, TypedDict - -from smithy_core.deserializers import ShapeDeserializer -from smithy_core.exceptions import ModeledError -from smithy_core.response import ResponseMetadata -from smithy_core.schemas import APIOperation -from smithy_core.serializers import ShapeSerializer - -__all__ = [ - "GET_FORECAST", - "GetForecastInput", - "GetForecastOutput", - "ServiceError", -] - -class _SerdeShape: - def serialize(self, serializer: ShapeSerializer) -> None: ... - def serialize_members(self, serializer: ShapeSerializer) -> None: ... - @classmethod - def deserialize(cls, deserializer: ShapeDeserializer) -> Self: ... - -class ServiceError(ModeledError): - """ - Base error for all errors in the service. - - Some exceptions do not extend from this class, including synthetic, - implicit, and shared exception types. - """ - -@dataclass(kw_only=True) -class GetForecastInput(_SerdeShape): - "Dataclass for GetForecastInput structure." - - city: str | None = ... - -class GetForecastInputDict(TypedDict, total=False): - "Dictionary form of `GetForecastInput`." - - city: str | None - -@dataclass(kw_only=True) -class GetForecastOutput(_SerdeShape): - "Dataclass for GetForecastOutput structure." - - summary: str | None = ... - response_metadata: ResponseMetadata = ... - """ - Metadata about the response that produced this output. - - Use this to recover the request identifiers a service's support team - needs in order to investigate a call. Members of the metadata are - individually optional. - """ - -GET_FORECAST: APIOperation[GetForecastInput, GetForecastOutput] diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/py.typed b/codegen-output-py/aws-config-client/src/aws_config_client/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/codegen-output-py/endpoint-rules-client/.smithy-python-manifest.json b/codegen-output-py/endpoint-rules-client/.smithy-python-manifest.json deleted file mode 100644 index 9be605dfe..000000000 --- a/codegen-output-py/endpoint-rules-client/.smithy-python-manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "files": { - "README.md": "21b6af5d2c11ca92be799a611365291e00be66fee36e0e94876c35ff323358ec", - "pyproject.toml": "0d9158aab01dd1a034aa2bca0a69aa2d247433509c1ebd153b837c95ae79606b", - "src/endpoint_rules_client/__init__.py": "f85901beed783e493475b1ccde6669b030eafa7a9b98f796d9a62e3d584e5286", - "src/endpoint_rules_client/_private/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "src/endpoint_rules_client/_private/endpoints.py": "f5bec5c0c17f9ec3fab86ea81c1472b1771118e6064f52cbb58cf85d89e09b20", - "src/endpoint_rules_client/_private/schemas.py": "804820a7542d2b6df7be9a0e146c17d81ea02eec9e145c056f859e8f6a2c5871", - "src/endpoint_rules_client/aio/__init__.py": "9d803a788ce4051a5e037f67248d7cb3c278781e1bd8380e8a35a67cca039e13", - "src/endpoint_rules_client/aio/client.py": "b2b375ec339945500d429023176de2aae003eaf2255df15fa9e317af6834d2ca", - "src/endpoint_rules_client/aio/config.py": "dc2b548541bdec4ccf2757638c7fed7a7cb07d432193a87e465274a8f187e557", - "src/endpoint_rules_client/client.py": "33e88867c1dcbac308a159a5974db2c7ddcbfebca1728aa789a6ec49b7e30623", - "src/endpoint_rules_client/config.py": "ec161b5e6c5bc00f5f55d3b4f9a41dc52967e6b80240b58ce3dcc0426a00a129", - "src/endpoint_rules_client/models.py": "74fd08f8085335f26b9aa7c46696666700a0e71235a3ae666a40139c19a8eb18", - "src/endpoint_rules_client/models.pyi": "87c615ea467d648b79ca9bdb0eef29006463720de95f71303a39d908cfc4a277", - "src/endpoint_rules_client/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "tests/test_endpoints.py": "f24e7dc5f6052b3f5d2e6b55e77c00f4265579619e453d996056da72fbd2014a" - }, - "version": 1 -} diff --git a/codegen-output-py/endpoint-rules-client/README.md b/codegen-output-py/endpoint-rules-client/README.md deleted file mode 100644 index 602cdb0a6..000000000 --- a/codegen-output-py/endpoint-rules-client/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -## endpoint_rules_client Client Package - -Python client for the endpoint rules fixture diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/__init__.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/__init__.py deleted file mode 100644 index ae4cf8845..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -from importlib import import_module -from typing import TYPE_CHECKING, Any - -__version__: str = "0.0.1" - -if TYPE_CHECKING: - from .aio.client import AsyncEndpointService - from .aio.config import AsyncConfig - from .client import EndpointService - from .config import Config - -__all__ = ["AsyncConfig", "AsyncEndpointService", "Config", "EndpointService"] - -_EXPORTS = { - "EndpointService": ".client", - "Config": ".config", - "AsyncEndpointService": ".aio.client", - "AsyncConfig": ".aio.config", -} - - -def __getattr__(name: str) -> Any: - if name in _EXPORTS: - return getattr(import_module(_EXPORTS[name], __name__), name) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/__init__.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/schemas.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/schemas.py deleted file mode 100644 index 10b959240..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/schemas.py +++ /dev/null @@ -1,108 +0,0 @@ -from types import MappingProxyType - -from smithy_core._schema_compact import StaticOperationSchema, StaticSchema - -n0 = "example.endpoints" -_s0 = "PluginNames" -_s1 = "member" -_s2 = "ThingTag" -_s3 = "key" -_s4 = "value" -_s5 = "PutThingInput" -_s6 = "smithy.synthetic#originalShapeId" -_s7 = "example.endpoints#PutThingInput" -_s8 = "smithy.api#input" -_s9 = "name" -_s10 = "smithy.rules#contextParam" -_s11 = "smithy.api#required" -_s12 = "tag" -_s13 = "plugins" -_s14 = "PingInput" -_s15 = "smithy.api#Unit" -_s16 = "PingOutput" -_s17 = "smithy.api#output" -_s18 = "PutThingOutput" -_s19 = "Ping" -_s20 = "smithy.rules#staticContextParams" -_s21 = "PutThing" -_s22 = "EndpointService" -_s23 = "smithy.protocols#rpcv2Cbor" - -PLUGIN_NAMES: StaticSchema = ( - 16, - n0, - _s0, - 0, - (_s1,), - ((3, 0),), -) - -THING_TAG: StaticSchema = ( - 18, - n0, - _s2, - 0, - (_s3, _s4), - ((3, 0), (3, 0)), -) - -PUT_THING_INPUT: StaticSchema = ( - 18, - n0, - _s5, - {_s6: _s7, _s8: None}, - (_s9, _s12, _s13), - ( - (3, {_s10: MappingProxyType({"name": "Name"}), _s11: None}), - (THING_TAG, 0), - (PLUGIN_NAMES, 0), - ), -) - -PING_INPUT: StaticSchema = ( - 18, - n0, - _s14, - {_s6: _s15, _s8: None}, -) - -PING_OUTPUT: StaticSchema = ( - 18, - n0, - _s16, - {_s6: _s15, _s17: None}, -) - -PUT_THING_OUTPUT: StaticSchema = ( - 18, - n0, - _s18, - {_s6: _s15, _s17: None}, -) - -PING: StaticOperationSchema = ( - 23, - n0, - _s19, - {_s20: MappingProxyType({"Kind": MappingProxyType({"value": "ping"})})}, - PING_INPUT, - PING_OUTPUT, - (), -) - -PUT_THING: StaticOperationSchema = ( - 23, - n0, - _s21, - {_s20: MappingProxyType({"Kind": MappingProxyType({"value": "put"})})}, - PUT_THING_INPUT, - PUT_THING_OUTPUT, - (), -) - -ENDPOINT_SERVICE: StaticSchema = ( - 21, - n0, - _s22, - {_s23: None}, -) diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/client.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/client.py deleted file mode 100644 index 37e97b008..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/client.py +++ /dev/null @@ -1,86 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.aio.client import AsyncClient -from smithy_http.plugins import user_agent_plugin - -from endpoint_rules_client import models -from endpoint_rules_client.aio.config import AsyncConfig, Plugin - - -class AsyncEndpointService(AsyncClient[AsyncConfig]): - "A service whose endpoint rules read config, input, and operation values." - - _client_plugins = (user_agent_plugin,) - - @overload - async def ping( - self, - request: models.PingInput | models.PingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PingOutput: ... - - @overload - async def ping( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PingInputDict], - ) -> models.PingOutput: - """ - Invokes the Ping operation. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def ping( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PingOutput: - return await self._invoke( - self._select_input(models.PING, args, kwargs), - models.PING, - [], - plugins, - ) - - @overload - async def put_thing( - self, - request: models.PutThingInput | models.PutThingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PutThingOutput: ... - - @overload - async def put_thing( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PutThingInputDict], - ) -> models.PutThingOutput: - """ - Invokes the PutThing operation. - - :param plugins: Callables that change the configuration for this call - only. - """ - - async def put_thing( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PutThingOutput: - return await self._invoke( - self._select_input(models.PUT_THING, args, kwargs), - models.PUT_THING, - [], - plugins, - ) - - def _new_config(self) -> AsyncConfig: - return AsyncConfig() diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/config.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/config.py deleted file mode 100644 index 4b72802e0..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/config.py +++ /dev/null @@ -1,102 +0,0 @@ -from collections.abc import Callable -from dataclasses import dataclass -from typing import Any, cast - -from smithy_core.aio.interfaces import AsyncClientTransport, AsyncEndpointResolver -from smithy_core.aio.interfaces.auth import AsyncAuthScheme -from smithy_core.auth import DefaultAuthResolver -from smithy_core.endpoints import BddEndpointResolver -from smithy_core.interceptors import Interceptor -from smithy_core.interfaces import ( - ClientProtocol, - EndpointResolver, - ProtocolConstructor, - ProtocolSettings, - URI, -) -from smithy_core.interfaces.auth import AuthSchemeResolver -from smithy_core.interfaces.retries import RetryStrategy -from smithy_core.retries import RetryStrategyOptions -from smithy_core.shapes import ShapeID -from smithy_http.aio.aiohttp import AIOHTTPClient -from smithy_http.aio.protocols import AsyncRpcV2CborClientProtocol - -from endpoint_rules_client._private.endpoints import BDD -from endpoint_rules_client._private.schemas import ENDPOINT_SERVICE - -_PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.endpoints", - service_target="EndpointService", - version="2026-11-20", - service_schema=ENDPOINT_SERVICE, -) - - -@dataclass(init=False) -class AsyncConfig: - "Configuration for AsyncEndpointService." - - auth_scheme_resolver: AuthSchemeResolver - "Determines the auth scheme for each operation." - - auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] - "Auth schemes by auth scheme ID." - - endpoint_resolver: EndpointResolver | AsyncEndpointResolver - "Resolves the endpoint of each operation." - - endpoint_uri: str | URI | None - "The endpoint URI, read by the endpoint rules as ``SDK::Endpoint``." - - interceptors: list[Interceptor[Any, Any, Any, Any]] - "Hooks called during the execution of a request." - - protocol: ClientProtocol[Any, Any] - "Serializes requests and deserializes responses." - - retry_strategy: RetryStrategy | RetryStrategyOptions | None - "The retry strategy, or options to create one." - - transport: AsyncClientTransport[Any, Any] - "Sends requests, such as an HTTP client." - - stage: str | None - "The deployment stage." - - force_path_style: bool | None - "Forces path-style addressing." - - def __init__( - self, - *, - auth_scheme_resolver: AuthSchemeResolver | None = None, - auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None = None, - endpoint_resolver: EndpointResolver | AsyncEndpointResolver | None = None, - endpoint_uri: str | URI | None = None, - interceptors: list[Interceptor[Any, Any, Any, Any]] | None = None, - protocol: ClientProtocol[Any, Any] - | ProtocolConstructor[ClientProtocol[Any, Any]] - | None = None, - retry_strategy: RetryStrategy | RetryStrategyOptions | None = None, - transport: AsyncClientTransport[Any, Any] | None = None, - stage: str | None = None, - force_path_style: bool | None = None, - ) -> None: - self.auth_scheme_resolver = auth_scheme_resolver or DefaultAuthResolver() - self.auth_schemes = auth_schemes or {} - self.endpoint_resolver = endpoint_resolver or BddEndpointResolver(BDD) - self.endpoint_uri = endpoint_uri - self.interceptors = interceptors or [] - if isinstance(protocol, type): - protocol = protocol(_PROTOCOL_SETTINGS) - self.protocol = cast( - ClientProtocol[Any, Any], protocol - ) or AsyncRpcV2CborClientProtocol(_PROTOCOL_SETTINGS) - self.retry_strategy = retry_strategy - self.transport = transport or AIOHTTPClient() - self.stage = stage - self.force_path_style = force_path_style - - -type Plugin = Callable[[AsyncConfig], None] -"A callable that customizes the client configuration." diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/client.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/client.py deleted file mode 100644 index 99267d6c1..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/client.py +++ /dev/null @@ -1,86 +0,0 @@ -from __future__ import annotations - -from typing import Unpack, overload - -from smithy_core.client import Client -from smithy_http.plugins import user_agent_plugin - -from endpoint_rules_client import models -from endpoint_rules_client.config import Config, Plugin - - -class EndpointService(Client[Config]): - "A service whose endpoint rules read config, input, and operation values." - - _client_plugins = (user_agent_plugin,) - - @overload - def ping( - self, - request: models.PingInput | models.PingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PingOutput: ... - - @overload - def ping( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PingInputDict], - ) -> models.PingOutput: - """ - Invokes the Ping operation. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def ping( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PingOutput: - return self._invoke( - self._select_input(models.PING, args, kwargs), - models.PING, - [], - plugins, - ) - - @overload - def put_thing( - self, - request: models.PutThingInput | models.PutThingInputDict, - /, - *, - plugins: list[Plugin] | None = None, - ) -> models.PutThingOutput: ... - - @overload - def put_thing( - self, - /, - *, - plugins: list[Plugin] | None = None, - **kwargs: Unpack[models.PutThingInputDict], - ) -> models.PutThingOutput: - """ - Invokes the PutThing operation. - - :param plugins: Callables that change the configuration for this call - only. - """ - - def put_thing( - self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object - ) -> models.PutThingOutput: - return self._invoke( - self._select_input(models.PUT_THING, args, kwargs), - models.PUT_THING, - [], - plugins, - ) - - def _new_config(self) -> Config: - return Config() diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/config.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/config.py deleted file mode 100644 index a8706e2b2..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/config.py +++ /dev/null @@ -1,101 +0,0 @@ -from collections.abc import Callable -from dataclasses import dataclass -from typing import Any, cast - -from smithy_core.auth import DefaultAuthResolver -from smithy_core.endpoints import BddEndpointResolver -from smithy_core.interceptors import Interceptor -from smithy_core.interfaces import ( - ClientProtocol, - ClientTransport, - EndpointResolver, - ProtocolConstructor, - ProtocolSettings, - URI, -) -from smithy_core.interfaces.auth import AuthScheme, AuthSchemeResolver -from smithy_core.interfaces.retries import RetryStrategy -from smithy_core.retries import RetryStrategyOptions -from smithy_core.shapes import ShapeID -from smithy_http.protocols import RpcV2CborClientProtocol -from smithy_http.urllib3 import Urllib3HTTPClient - -from endpoint_rules_client._private.endpoints import BDD -from endpoint_rules_client._private.schemas import ENDPOINT_SERVICE - -_PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.endpoints", - service_target="EndpointService", - version="2026-11-20", - service_schema=ENDPOINT_SERVICE, -) - - -@dataclass(init=False) -class Config: - "Configuration for EndpointService." - - auth_scheme_resolver: AuthSchemeResolver - "Determines the auth scheme for each operation." - - auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] - "Auth schemes by auth scheme ID." - - endpoint_resolver: EndpointResolver - "Resolves the endpoint of each operation." - - endpoint_uri: str | URI | None - "The endpoint URI, read by the endpoint rules as ``SDK::Endpoint``." - - interceptors: list[Interceptor[Any, Any, Any, Any]] - "Hooks called during the execution of a request." - - protocol: ClientProtocol[Any, Any] - "Serializes requests and deserializes responses." - - retry_strategy: RetryStrategy | RetryStrategyOptions | None - "The retry strategy, or options to create one." - - transport: ClientTransport[Any, Any] - "Sends requests, such as an HTTP client." - - stage: str | None - "The deployment stage." - - force_path_style: bool | None - "Forces path-style addressing." - - def __init__( - self, - *, - auth_scheme_resolver: AuthSchemeResolver | None = None, - auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None, - endpoint_resolver: EndpointResolver | None = None, - endpoint_uri: str | URI | None = None, - interceptors: list[Interceptor[Any, Any, Any, Any]] | None = None, - protocol: ClientProtocol[Any, Any] - | ProtocolConstructor[ClientProtocol[Any, Any]] - | None = None, - retry_strategy: RetryStrategy | RetryStrategyOptions | None = None, - transport: ClientTransport[Any, Any] | None = None, - stage: str | None = None, - force_path_style: bool | None = None, - ) -> None: - self.auth_scheme_resolver = auth_scheme_resolver or DefaultAuthResolver() - self.auth_schemes = auth_schemes or {} - self.endpoint_resolver = endpoint_resolver or BddEndpointResolver(BDD) - self.endpoint_uri = endpoint_uri - self.interceptors = interceptors or [] - if isinstance(protocol, type): - protocol = protocol(_PROTOCOL_SETTINGS) - self.protocol = cast( - ClientProtocol[Any, Any], protocol - ) or RpcV2CborClientProtocol(_PROTOCOL_SETTINGS) - self.retry_strategy = retry_strategy - self.transport = transport or Urllib3HTTPClient() - self.stage = stage - self.force_path_style = force_path_style - - -type Plugin = Callable[[Config], None] -"A callable that customizes the client configuration." diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.py b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.py deleted file mode 100644 index 65b2b9cda..000000000 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.py +++ /dev/null @@ -1,71 +0,0 @@ -from smithy_core._dynamic_models import ModelRegistry -from smithy_core.exceptions import ModeledError - -from ._private import schemas - - -class ServiceError(ModeledError): - """ - Base error for all errors in the service. - - Some exceptions do not extend from this class, including synthetic, - implicit, and shared exception types. - """ - - -_MODEL_INDEX = { - "PutThingInput": "PUT_THING_INPUT", - "ThingTag": "THING_TAG", - "PingInput": "PING_INPUT", - "PingOutput": "PING_OUTPUT", - "PutThingOutput": "PUT_THING_OUTPUT", -} - -_RENAMES: dict[str, str] = {} - -_TARGET_NAMES: dict[str, str] = {} - -_OPERATIONS: dict[str, tuple[tuple[str, ...], tuple[str, ...]]] = { - "PING": ( - (), - ("smithy.api#noAuth",), - ), - "PUT_THING": ( - (), - ("smithy.api#noAuth",), - ), -} - -_MODEL_NAMES = tuple(_MODEL_INDEX) -__all__ = ("ServiceError", *_MODEL_NAMES, *_OPERATIONS) # pyright: ignore[reportUnsupportedDunderAll] - - -_registry = ModelRegistry( - schemas, - renames=_RENAMES, - index=_MODEL_INDEX, - target_names=_TARGET_NAMES, - shape_names=frozenset( - { - "PingInput", - "PingOutput", - "PutThingInput", - "PutThingOutput", - "ThingTag", - } - ), - service_error="ServiceError", -) -del schemas, ModelRegistry, ModeledError - - -def __getattr__(name: str): - if (data := _OPERATIONS.get(name)) is not None: - return globals().setdefault(name, _registry.build_operation(name, *data)) - value = _registry.build(name) - globals()[name] = value - return value - - -def __dir__() -> list[str]: - return sorted({*globals(), *__all__}) diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/py.typed b/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/codegen-output-py/features-client/.smithy-python-manifest.json b/codegen-output-py/features-client/.smithy-python-manifest.json new file mode 100644 index 000000000..1eef86129 --- /dev/null +++ b/codegen-output-py/features-client/.smithy-python-manifest.json @@ -0,0 +1,22 @@ +{ + "files": { + "README.md": "2806a5e5abe658301cad30030818d656fc9095fd3e510bc14744e2c053766c38", + "pyproject.toml": "3bf9e8ba4f2d5620cb43a34b5a05445485d96bbc71b79d568cfe10e92d3deef6", + "src/features_client/__init__.py": "32592f5725712e19c306d0c817040e64c67203ae420e3fac2a05301915b742aa", + "src/features_client/_private/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "src/features_client/_private/endpoints.py": "f5bec5c0c17f9ec3fab86ea81c1472b1771118e6064f52cbb58cf85d89e09b20", + "src/features_client/_private/schemas.py": "7b2007610a0ec1e352198c77230810edaa6a2ec41cc4d3034b58fd36b278b613", + "src/features_client/aio/__init__.py": "2d6c204a7bbceeed5b175fe0df922722d341068027b29287cfdcbb9cb29403af", + "src/features_client/aio/client.py": "910b8914637d5e09218664a96792ca6727c941a52d4e678ba4c31fdbc81e360e", + "src/features_client/aio/config.py": "c341294cd16f4940fceb60c8513e29b5b81636a8ba4b999951e09c23efa9e093", + "src/features_client/aio/user_agent.py": "05cbb5932a96cb83d55ece172f9b9b5b8aeb625782140647e177d5d5cbd18dd5", + "src/features_client/client.py": "fb0acd7beabe576c39ba2f1f1067366d5ba63635ad66f4849280c546fe3d059d", + "src/features_client/config.py": "9ac6470542449161d0aa85f94eec11623e79cf5fbc5db6749b8ce462940e8fdb", + "src/features_client/models.py": "b326674510de3a4f6dd77a4d172cf4dfce08a6ed24f01fa162e99c31dfa13567", + "src/features_client/models.pyi": "26858d43ae4e5d88d0ef0db95bd332d12de4784e8b8bf9b0a0a71d54cec5b93a", + "src/features_client/py.typed": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "src/features_client/user_agent.py": "6d7e1477fa0123330b26d750070dcb49afe76bd14baa8bbe4b66a3d28e7ad75f", + "tests/test_endpoints.py": "dd98319dec82644ab5f58d0793e0c2dcf877f358b60b96dcb26f2367c8c37f21" + }, + "version": 1 +} diff --git a/codegen-output-py/features-client/README.md b/codegen-output-py/features-client/README.md new file mode 100644 index 000000000..4d5b07230 --- /dev/null +++ b/codegen-output-py/features-client/README.md @@ -0,0 +1,5 @@ + + +## features_client Client Package + +Python client for the client features fixture diff --git a/codegen-output-py/endpoint-rules-client/pyproject.toml b/codegen-output-py/features-client/pyproject.toml similarity index 78% rename from codegen-output-py/endpoint-rules-client/pyproject.toml rename to codegen-output-py/features-client/pyproject.toml index 93dcc1f92..ddf01f809 100644 --- a/codegen-output-py/endpoint-rules-client/pyproject.toml +++ b/codegen-output-py/features-client/pyproject.toml @@ -1,14 +1,15 @@ # Code generated by smithy-python-codegen DO NOT EDIT. [project] -name = "endpoint_rules_client" +name = "features_client" version = "0.0.1" -description = "Python client for the endpoint rules fixture" +description = "Python client for the client features fixture" readme = "README.md" requires-python = ">=3.12" -keywords = ["smithy", "endpoint_rules_client"] +keywords = ["smithy", "features_client"] license = {text = "Apache-2.0"} dependencies = [ + "smithy-aws-core~=0.16.0", "smithy-core~=0.13.0", "smithy-http[aiohttp,cbor,urllib3]~=0.10.0", ] @@ -28,7 +29,7 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = [ - "src/endpoint_rules_client", + "src/features_client", ] [tool.pyright] diff --git a/codegen-output-py/features-client/src/features_client/__init__.py b/codegen-output-py/features-client/src/features_client/__init__.py new file mode 100644 index 000000000..1e343c972 --- /dev/null +++ b/codegen-output-py/features-client/src/features_client/__init__.py @@ -0,0 +1,30 @@ +from importlib import import_module +from typing import TYPE_CHECKING, Any + +__version__: str = "0.0.1" + +if TYPE_CHECKING: + from .aio.client import AsyncFieldNotesClient + from .aio.config import AsyncFieldNotesConfig + from .client import FieldNotesClient + from .config import FieldNotesConfig + +__all__ = [ + "AsyncFieldNotesClient", + "AsyncFieldNotesConfig", + "FieldNotesClient", + "FieldNotesConfig", +] + +_EXPORTS = { + "FieldNotesClient": ".client", + "FieldNotesConfig": ".config", + "AsyncFieldNotesClient": ".aio.client", + "AsyncFieldNotesConfig": ".aio.config", +} + + +def __getattr__(name: str) -> Any: + if name in _EXPORTS: + return getattr(import_module(_EXPORTS[name], __name__), name) + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/__init__.py b/codegen-output-py/features-client/src/features_client/_private/__init__.py similarity index 100% rename from codegen-output-py/api-key-auth-client/src/api_key_auth_client/_private/__init__.py rename to codegen-output-py/features-client/src/features_client/_private/__init__.py diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/endpoints.py b/codegen-output-py/features-client/src/features_client/_private/endpoints.py similarity index 100% rename from codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/_private/endpoints.py rename to codegen-output-py/features-client/src/features_client/_private/endpoints.py diff --git a/codegen-output-py/features-client/src/features_client/_private/schemas.py b/codegen-output-py/features-client/src/features_client/_private/schemas.py new file mode 100644 index 000000000..fa3c54098 --- /dev/null +++ b/codegen-output-py/features-client/src/features_client/_private/schemas.py @@ -0,0 +1,204 @@ +from types import MappingProxyType + +from smithy_core._schema_compact import StaticOperationSchema, StaticSchema + +n0 = "example.features" +_s0 = "GetThingInput" +_s1 = "smithy.synthetic#originalShapeId" +_s2 = "example.features#GetThingInput" +_s3 = "smithy.api#input" +_s4 = "name" +_s5 = "GetThingOutput" +_s6 = "example.features#GetThingOutput" +_s7 = "smithy.api#output" +_s8 = "value" +_s9 = "PluginNames" +_s10 = "member" +_s11 = "PutNoteInput" +_s12 = "example.features#PutNoteInput" +_s13 = "text" +_s14 = "PutNoteOutput" +_s15 = "example.features#PutNoteOutput" +_s16 = "id" +_s17 = "ThingTag" +_s18 = "key" +_s19 = "PutThingInput" +_s20 = "example.features#PutThingInput" +_s21 = "smithy.rules#contextParam" +_s22 = "smithy.api#required" +_s23 = "tag" +_s24 = "plugins" +_s25 = "EchoInput" +_s26 = "smithy.api#Unit" +_s27 = "EchoOutput" +_s28 = "PingInput" +_s29 = "PingOutput" +_s30 = "PutThingOutput" +_s31 = "Echo" +_s32 = "GetThing" +_s33 = "Ping" +_s34 = "smithy.rules#staticContextParams" +_s35 = "PutNote" +_s36 = "PutThing" +_s37 = "FieldNotes" +_s38 = "aws.api#service" +_s39 = "smithy.protocols#rpcv2Cbor" + +GET_THING_INPUT: StaticSchema = ( + 18, + n0, + _s0, + {_s1: _s2, _s3: None}, + (_s4,), + ((3, 0),), +) + +GET_THING_OUTPUT: StaticSchema = ( + 18, + n0, + _s5, + {_s1: _s6, _s7: None}, + (_s8,), + ((3, 0),), +) + +PLUGIN_NAMES: StaticSchema = ( + 16, + n0, + _s9, + 0, + (_s10,), + ((3, 0),), +) + +PUT_NOTE_INPUT: StaticSchema = ( + 18, + n0, + _s11, + {_s1: _s12, _s3: None}, + (_s13,), + ((3, 0),), +) + +PUT_NOTE_OUTPUT: StaticSchema = ( + 18, + n0, + _s14, + {_s1: _s15, _s7: None}, + (_s16,), + ((3, 0),), +) + +THING_TAG: StaticSchema = ( + 18, + n0, + _s17, + 0, + (_s18, _s8), + ((3, 0), (3, 0)), +) + +PUT_THING_INPUT: StaticSchema = ( + 18, + n0, + _s19, + {_s1: _s20, _s3: None}, + (_s4, _s23, _s24), + ( + (3, {_s21: MappingProxyType({"name": "Name"}), _s22: None}), + (THING_TAG, 0), + (PLUGIN_NAMES, 0), + ), +) + +ECHO_INPUT: StaticSchema = ( + 18, + n0, + _s25, + {_s1: _s26, _s3: None}, +) + +ECHO_OUTPUT: StaticSchema = ( + 18, + n0, + _s27, + {_s1: _s26, _s7: None}, +) + +PING_INPUT: StaticSchema = ( + 18, + n0, + _s28, + {_s1: _s26, _s3: None}, +) + +PING_OUTPUT: StaticSchema = ( + 18, + n0, + _s29, + {_s1: _s26, _s7: None}, +) + +PUT_THING_OUTPUT: StaticSchema = ( + 18, + n0, + _s30, + {_s1: _s26, _s7: None}, +) + +ECHO: StaticOperationSchema = ( + 23, + n0, + _s31, + 0, + ECHO_INPUT, + ECHO_OUTPUT, + (), +) + +GET_THING: StaticOperationSchema = ( + 23, + n0, + _s32, + 0, + GET_THING_INPUT, + GET_THING_OUTPUT, + (), +) + +PING: StaticOperationSchema = ( + 23, + n0, + _s33, + {_s34: MappingProxyType({"Kind": MappingProxyType({"value": "ping"})})}, + PING_INPUT, + PING_OUTPUT, + (), +) + +PUT_NOTE: StaticOperationSchema = ( + 23, + n0, + _s35, + 0, + PUT_NOTE_INPUT, + PUT_NOTE_OUTPUT, + (), +) + +PUT_THING: StaticOperationSchema = ( + 23, + n0, + _s36, + {_s34: MappingProxyType({"Kind": MappingProxyType({"value": "put"})})}, + PUT_THING_INPUT, + PUT_THING_OUTPUT, + (), +) + +FIELD_NOTES: StaticSchema = ( + 21, + n0, + _s37, + {_s38: MappingProxyType({"sdkId": "Field Notes"}), _s39: None}, +) diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/__init__.py b/codegen-output-py/features-client/src/features_client/aio/__init__.py similarity index 57% rename from codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/__init__.py rename to codegen-output-py/features-client/src/features_client/aio/__init__.py index 7dee4fc86..43527de6d 100644 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/aio/__init__.py +++ b/codegen-output-py/features-client/src/features_client/aio/__init__.py @@ -2,14 +2,14 @@ from typing import TYPE_CHECKING, Any if TYPE_CHECKING: - from .client import AsyncEndpointService - from .config import AsyncConfig + from .client import AsyncFieldNotesClient + from .config import AsyncFieldNotesConfig -__all__ = ["AsyncConfig", "AsyncEndpointService"] +__all__ = ["AsyncFieldNotesClient", "AsyncFieldNotesConfig"] _EXPORTS = { - "AsyncEndpointService": ".client", - "AsyncConfig": ".config", + "AsyncFieldNotesClient": ".client", + "AsyncFieldNotesConfig": ".config", } diff --git a/codegen-output-py/features-client/src/features_client/aio/client.py b/codegen-output-py/features-client/src/features_client/aio/client.py new file mode 100644 index 000000000..bd9bcffaf --- /dev/null +++ b/codegen-output-py/features-client/src/features_client/aio/client.py @@ -0,0 +1,216 @@ +from __future__ import annotations + +from typing import Unpack, cast, overload + +from smithy_aws_core.aio.identity.chain import AsyncIdentityChain +from smithy_aws_core.config.types import ConfigSource +from smithy_aws_core.identity.components import AWSCredentialsIdentity +from smithy_core.aio.client import AsyncClient +from smithy_http.aio.interfaces import AsyncHTTPClient +from smithy_http.plugins import user_agent_plugin + +from features_client import models +from features_client.aio.config import AsyncFieldNotesConfig, Plugin +from features_client.aio.user_agent import aws_user_agent_plugin + + +class AsyncFieldNotesClient(AsyncClient[AsyncFieldNotesConfig]): + """ + An AWS service that uses every client feature the generator supports. + + Its endpoint rules read config, input, and operation values. Its + operations + use SigV4, API key auth, optional auth, and no auth. + """ + + _client_plugins = (aws_user_agent_plugin, user_agent_plugin) + + @overload + async def echo( + self, + request: models.EchoInput | models.EchoInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.EchoOutput: ... + + @overload + async def echo( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.EchoInputDict], + ) -> models.EchoOutput: + """ + Uses API key auth, but sends no key when it has none. + + :param plugins: Callables that change the configuration for this call + only. + """ + + async def echo( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.EchoOutput: + return await self._invoke( + self._select_input(models.ECHO, args, kwargs), + models.ECHO, + [], + plugins, + ) + + @overload + async def get_thing( + self, + request: models.GetThingInput | models.GetThingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.GetThingOutput: ... + + @overload + async def get_thing( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.GetThingInputDict], + ) -> models.GetThingOutput: + """ + Uses API key auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + async def get_thing( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.GetThingOutput: + return await self._invoke( + self._select_input(models.GET_THING, args, kwargs), + models.GET_THING, + [], + plugins, + ) + + @overload + async def ping( + self, + request: models.PingInput | models.PingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PingOutput: ... + + @overload + async def ping( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PingInputDict], + ) -> models.PingOutput: + """ + Needs no auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + async def ping( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PingOutput: + return await self._invoke( + self._select_input(models.PING, args, kwargs), + models.PING, + [], + plugins, + ) + + @overload + async def put_note( + self, + request: models.PutNoteInput | models.PutNoteInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PutNoteOutput: ... + + @overload + async def put_note( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PutNoteInputDict], + ) -> models.PutNoteOutput: + """ + Saves a note, signed with SigV4. + + :param plugins: Callables that change the configuration for this call + only. + """ + + async def put_note( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PutNoteOutput: + return await self._invoke( + self._select_input(models.PUT_NOTE, args, kwargs), + models.PUT_NOTE, + [], + plugins, + ) + + @overload + async def put_thing( + self, + request: models.PutThingInput | models.PutThingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PutThingOutput: ... + + @overload + async def put_thing( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PutThingInputDict], + ) -> models.PutThingOutput: + """ + Needs no auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + async def put_thing( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PutThingOutput: + return await self._invoke( + self._select_input(models.PUT_THING, args, kwargs), + models.PUT_THING, + [], + plugins, + ) + + async def _new_config(self) -> AsyncFieldNotesConfig: + return await AsyncFieldNotesConfig.resolve() + + async def _post_setup(self, config: AsyncFieldNotesConfig) -> None: + if config.aws_credentials_identity_resolver is None: + config_context = config.resolution_context() + config_file = None + profile_name = None + if config_context is not None: + config_file = await config_context.parsed_profiles() + if config_context.profile_source is ConfigSource.OVERRIDE: + profile_name = config_context.profile_name + config.aws_credentials_identity_resolver = await AsyncIdentityChain.create( + AWSCredentialsIdentity, + config_file=config_file, + profile_name=profile_name, + region_override=config.region, + http_client=cast(AsyncHTTPClient | None, config.transport), + ) diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/aio/config.py b/codegen-output-py/features-client/src/features_client/aio/config.py similarity index 56% rename from codegen-output-py/aws-config-client/src/aws_config_client/aio/config.py rename to codegen-output-py/features-client/src/features_client/aio/config.py index 4347c321d..dc1060b2d 100644 --- a/codegen-output-py/aws-config-client/src/aws_config_client/aio/config.py +++ b/codegen-output-py/features-client/src/features_client/aio/config.py @@ -2,6 +2,7 @@ from dataclasses import dataclass, field from typing import Any, ClassVar, Self, Unpack +from smithy_aws_core.aio.auth.sigv4 import AsyncSigV4AuthScheme from smithy_aws_core.aio.config.aws_config import ( AsyncAwsConfig, AsyncAwsConfigOverrides, @@ -11,6 +12,7 @@ from smithy_aws_core.config.types import FieldSpec from smithy_core.aio.interfaces import AsyncEndpointResolver from smithy_core.aio.interfaces.auth import AsyncAuthScheme +from smithy_core.aio.interfaces.identity import AsyncIdentityResolver from smithy_core.auth import DefaultAuthResolver from smithy_core.endpoints import BddEndpointResolver from smithy_core.interceptors import Interceptor @@ -22,22 +24,26 @@ ) from smithy_core.interfaces.auth import AuthSchemeResolver from smithy_core.shapes import ShapeID +from smithy_core.traits import APIKeyLocation from smithy_http.aio.aiohttp import AIOHTTPClient +from smithy_http.aio.auth.apikey import AsyncAPIKeyAuthScheme +from smithy_http.aio.identity.apikey import AsyncAPIKeyIdentityResolver from smithy_http.aio.protocols import AsyncRpcV2CborClientProtocol +from smithy_http.identity import APIKeyIdentity, APIKeyIdentityProperties -from aws_config_client._private.endpoints import BDD -from aws_config_client._private.schemas import WEATHER_STATION +from features_client._private.endpoints import BDD +from features_client._private.schemas import FIELD_NOTES _PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.awsconfig", - service_target="WeatherStation", - version="2026-11-19", - service_schema=WEATHER_STATION, + namespace="example.features", + service_target="FieldNotes", + version="2026-11-20", + service_schema=FIELD_NOTES, ) -class _AsyncWeatherStationConfigOverrides(AsyncAwsConfigOverrides, total=False): - "Explicit field values AsyncWeatherStationConfig.resolve accepts." +class _AsyncFieldNotesConfigOverrides(AsyncAwsConfigOverrides, total=False): + "Explicit field values AsyncFieldNotesConfig.resolve accepts." endpoint_resolver: EndpointResolver | AsyncEndpointResolver | None protocol: ( @@ -45,11 +51,17 @@ class _AsyncWeatherStationConfigOverrides(AsyncAwsConfigOverrides, total=False): ) auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None auth_scheme_resolver: AuthSchemeResolver | None + api_key: str | None + api_key_identity_resolver: ( + AsyncIdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None + ) + stage: str | None + force_path_style: bool | None @dataclass(kw_only=True, repr=False, init=False) -class AsyncWeatherStationConfig(AsyncAwsConfig): - "Configuration for AsyncWeatherStationClient." +class AsyncFieldNotesConfig(AsyncAwsConfig): + "Configuration for AsyncFieldNotesClient." interceptors: list[Interceptor[Any, Any, Any, Any]] = field( default_factory=list[Interceptor[Any, Any, Any, Any]] @@ -68,10 +80,24 @@ class AsyncWeatherStationConfig(AsyncAwsConfig): auth_scheme_resolver: AuthSchemeResolver | None = None "Determines the auth scheme for each operation." + api_key: str | None = None + "The API key to send along with requests." + + api_key_identity_resolver: ( + AsyncIdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None + ) = None + "Resolves the API key." + + stage: str | None = None + "The deployment stage." + + force_path_style: bool | None = None + "Forces path-style addressing." + _FIELDS: ClassVar[dict[str, FieldSpec]] = { **AsyncAwsConfig._FIELDS, "endpoint_uri": FieldSpec( - default=None, resolver=EndpointUriResolver("weather_station").program + default=None, resolver=EndpointUriResolver("field_notes").program ), "endpoint_resolver": FieldSpec( default_factory=lambda: BddEndpointResolver(BDD) @@ -80,11 +106,32 @@ class AsyncWeatherStationConfig(AsyncAwsConfig): default_factory=lambda: AsyncRpcV2CborClientProtocol(_PROTOCOL_SETTINGS), converter=lambda p: p(_PROTOCOL_SETTINGS) if isinstance(p, type) else p, ), - "auth_schemes": FieldSpec(default_factory=dict), + "auth_schemes": FieldSpec( + default_factory=lambda: { + ShapeID("aws.auth#sigv4"): AsyncSigV4AuthScheme(service="fieldnotes"), + ShapeID("smithy.api#httpApiKeyAuth"): AsyncAPIKeyAuthScheme( + name="Authorization", + location=APIKeyLocation.HEADER, + scheme="ApiKey", + ), + } + ), "auth_scheme_resolver": FieldSpec(default_factory=DefaultAuthResolver), + "api_key": FieldSpec(default=None), + "api_key_identity_resolver": FieldSpec( + default_factory=lambda: AsyncAPIKeyIdentityResolver() + ), + "stage": FieldSpec(default=None), + "force_path_style": FieldSpec(default=None), "transport": FieldSpec(default_factory=lambda: AIOHTTPClient()), } + def set_auth_scheme(self, scheme: AsyncAuthScheme[Any, Any, Any, Any]) -> None: + "Set an auth scheme under its scheme ID." + auth_schemes = dict(self.auth_schemes or {}) + auth_schemes[scheme.scheme_id] = scheme + self.auth_schemes = auth_schemes + @classmethod async def resolve( # pyright: ignore[reportIncompatibleMethodOverride] cls, @@ -93,7 +140,7 @@ async def resolve( # pyright: ignore[reportIncompatibleMethodOverride] fs: AsyncFileSystem | None = None, config_file_path: str | None = None, credentials_file_path: str | None = None, - **overrides: Unpack[_AsyncWeatherStationConfigOverrides], + **overrides: Unpack[_AsyncFieldNotesConfigOverrides], ) -> Self: "Resolve the config from overrides, the environment, and config files." return await cls._resolve( @@ -105,5 +152,5 @@ async def resolve( # pyright: ignore[reportIncompatibleMethodOverride] ) -type Plugin = Callable[[AsyncWeatherStationConfig], None] +type Plugin = Callable[[AsyncFieldNotesConfig], None] "A callable that customizes the client configuration." diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/user_agent.py b/codegen-output-py/features-client/src/features_client/aio/user_agent.py similarity index 61% rename from codegen-output-py/aws-config-client/src/aws_config_client/user_agent.py rename to codegen-output-py/features-client/src/features_client/aio/user_agent.py index 14c9fb3f4..e5b253b4e 100644 --- a/codegen-output-py/aws-config-client/src/aws_config_client/user_agent.py +++ b/codegen-output-py/features-client/src/features_client/aio/user_agent.py @@ -1,16 +1,16 @@ from smithy_aws_core.interceptors.user_agent import UserAgentInterceptor -from aws_config_client import __version__ -from aws_config_client.config import WeatherStationConfig +from features_client import __version__ +from features_client.aio.config import AsyncFieldNotesConfig -def aws_user_agent_plugin(config: WeatherStationConfig) -> None: +def aws_user_agent_plugin(config: AsyncFieldNotesConfig) -> None: "Send the AWS user agent with every request." config.interceptors.append( UserAgentInterceptor( ua_suffix=config.user_agent_extra, ua_app_id=config.sdk_ua_app_id, sdk_version=__version__, - service_id="Weather_Station", + service_id="Field_Notes", ) ) diff --git a/codegen-output-py/features-client/src/features_client/client.py b/codegen-output-py/features-client/src/features_client/client.py new file mode 100644 index 000000000..568a91cc1 --- /dev/null +++ b/codegen-output-py/features-client/src/features_client/client.py @@ -0,0 +1,216 @@ +from __future__ import annotations + +from typing import Unpack, cast, overload + +from smithy_aws_core.config.types import ConfigSource +from smithy_aws_core.identity.chain.resolver import IdentityChain +from smithy_aws_core.identity.components import AWSCredentialsIdentity +from smithy_core.client import Client +from smithy_http.interfaces import HTTPClient +from smithy_http.plugins import user_agent_plugin + +from features_client import models +from features_client.config import FieldNotesConfig, Plugin +from features_client.user_agent import aws_user_agent_plugin + + +class FieldNotesClient(Client[FieldNotesConfig]): + """ + An AWS service that uses every client feature the generator supports. + + Its endpoint rules read config, input, and operation values. Its + operations + use SigV4, API key auth, optional auth, and no auth. + """ + + _client_plugins = (aws_user_agent_plugin, user_agent_plugin) + + @overload + def echo( + self, + request: models.EchoInput | models.EchoInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.EchoOutput: ... + + @overload + def echo( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.EchoInputDict], + ) -> models.EchoOutput: + """ + Uses API key auth, but sends no key when it has none. + + :param plugins: Callables that change the configuration for this call + only. + """ + + def echo( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.EchoOutput: + return self._invoke( + self._select_input(models.ECHO, args, kwargs), + models.ECHO, + [], + plugins, + ) + + @overload + def get_thing( + self, + request: models.GetThingInput | models.GetThingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.GetThingOutput: ... + + @overload + def get_thing( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.GetThingInputDict], + ) -> models.GetThingOutput: + """ + Uses API key auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + def get_thing( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.GetThingOutput: + return self._invoke( + self._select_input(models.GET_THING, args, kwargs), + models.GET_THING, + [], + plugins, + ) + + @overload + def ping( + self, + request: models.PingInput | models.PingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PingOutput: ... + + @overload + def ping( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PingInputDict], + ) -> models.PingOutput: + """ + Needs no auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + def ping( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PingOutput: + return self._invoke( + self._select_input(models.PING, args, kwargs), + models.PING, + [], + plugins, + ) + + @overload + def put_note( + self, + request: models.PutNoteInput | models.PutNoteInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PutNoteOutput: ... + + @overload + def put_note( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PutNoteInputDict], + ) -> models.PutNoteOutput: + """ + Saves a note, signed with SigV4. + + :param plugins: Callables that change the configuration for this call + only. + """ + + def put_note( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PutNoteOutput: + return self._invoke( + self._select_input(models.PUT_NOTE, args, kwargs), + models.PUT_NOTE, + [], + plugins, + ) + + @overload + def put_thing( + self, + request: models.PutThingInput | models.PutThingInputDict, + /, + *, + plugins: list[Plugin] | None = None, + ) -> models.PutThingOutput: ... + + @overload + def put_thing( + self, + /, + *, + plugins: list[Plugin] | None = None, + **kwargs: Unpack[models.PutThingInputDict], + ) -> models.PutThingOutput: + """ + Needs no auth. + + :param plugins: Callables that change the configuration for this call + only. + """ + + def put_thing( + self, /, *args: object, plugins: list[Plugin] | None = None, **kwargs: object + ) -> models.PutThingOutput: + return self._invoke( + self._select_input(models.PUT_THING, args, kwargs), + models.PUT_THING, + [], + plugins, + ) + + def _new_config(self) -> FieldNotesConfig: + return FieldNotesConfig.resolve() + + def _post_setup(self, config: FieldNotesConfig) -> None: + if config.aws_credentials_identity_resolver is None: + config_context = config.resolution_context() + config_file = None + profile_name = None + if config_context is not None: + config_file = config_context.parsed_profiles() + if config_context.profile_source is ConfigSource.OVERRIDE: + profile_name = config_context.profile_name + config.aws_credentials_identity_resolver = IdentityChain.create( + AWSCredentialsIdentity, + config_file=config_file, + profile_name=profile_name, + region_override=config.region, + http_client=cast(HTTPClient | None, config.transport), + ) diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/config.py b/codegen-output-py/features-client/src/features_client/config.py similarity index 56% rename from codegen-output-py/aws-config-client/src/aws_config_client/config.py rename to codegen-output-py/features-client/src/features_client/config.py index a389c5ea8..91612c864 100644 --- a/codegen-output-py/aws-config-client/src/aws_config_client/config.py +++ b/codegen-output-py/features-client/src/features_client/config.py @@ -2,6 +2,7 @@ from dataclasses import dataclass, field from typing import Any, ClassVar, Self, Unpack +from smithy_aws_core.auth.sigv4 import SigV4AuthScheme from smithy_aws_core.config.aws_config import AwsConfig, AwsConfigOverrides from smithy_aws_core.config.filesystem import FileSystem from smithy_aws_core.config.resolvers import EndpointUriResolver @@ -16,23 +17,28 @@ ProtocolSettings, ) from smithy_core.interfaces.auth import AuthScheme, AuthSchemeResolver +from smithy_core.interfaces.identity import IdentityResolver from smithy_core.shapes import ShapeID +from smithy_core.traits import APIKeyLocation +from smithy_http.auth.apikey import APIKeyAuthScheme +from smithy_http.identity import APIKeyIdentity, APIKeyIdentityProperties +from smithy_http.identity.apikey import APIKeyIdentityResolver from smithy_http.protocols import RpcV2CborClientProtocol from smithy_http.urllib3 import Urllib3HTTPClient -from aws_config_client._private.endpoints import BDD -from aws_config_client._private.schemas import WEATHER_STATION +from features_client._private.endpoints import BDD +from features_client._private.schemas import FIELD_NOTES _PROTOCOL_SETTINGS = ProtocolSettings( - namespace="example.awsconfig", - service_target="WeatherStation", - version="2026-11-19", - service_schema=WEATHER_STATION, + namespace="example.features", + service_target="FieldNotes", + version="2026-11-20", + service_schema=FIELD_NOTES, ) -class _WeatherStationConfigOverrides(AwsConfigOverrides, total=False): - "Explicit field values WeatherStationConfig.resolve accepts." +class _FieldNotesConfigOverrides(AwsConfigOverrides, total=False): + "Explicit field values FieldNotesConfig.resolve accepts." endpoint_resolver: EndpointResolver | None protocol: ( @@ -40,11 +46,17 @@ class _WeatherStationConfigOverrides(AwsConfigOverrides, total=False): ) auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None auth_scheme_resolver: AuthSchemeResolver | None + api_key: str | None + api_key_identity_resolver: ( + IdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None + ) + stage: str | None + force_path_style: bool | None @dataclass(kw_only=True, repr=False, init=False) -class WeatherStationConfig(AwsConfig): - "Configuration for WeatherStationClient." +class FieldNotesConfig(AwsConfig): + "Configuration for FieldNotesClient." interceptors: list[Interceptor[Any, Any, Any, Any]] = field( default_factory=list[Interceptor[Any, Any, Any, Any]] @@ -63,10 +75,24 @@ class WeatherStationConfig(AwsConfig): auth_scheme_resolver: AuthSchemeResolver | None = None "Determines the auth scheme for each operation." + api_key: str | None = None + "The API key to send along with requests." + + api_key_identity_resolver: ( + IdentityResolver[APIKeyIdentity, APIKeyIdentityProperties] | None + ) = None + "Resolves the API key." + + stage: str | None = None + "The deployment stage." + + force_path_style: bool | None = None + "Forces path-style addressing." + _FIELDS: ClassVar[dict[str, FieldSpec]] = { **AwsConfig._FIELDS, "endpoint_uri": FieldSpec( - default=None, resolver=EndpointUriResolver("weather_station").program + default=None, resolver=EndpointUriResolver("field_notes").program ), "endpoint_resolver": FieldSpec( default_factory=lambda: BddEndpointResolver(BDD) @@ -75,11 +101,32 @@ class WeatherStationConfig(AwsConfig): default_factory=lambda: RpcV2CborClientProtocol(_PROTOCOL_SETTINGS), converter=lambda p: p(_PROTOCOL_SETTINGS) if isinstance(p, type) else p, ), - "auth_schemes": FieldSpec(default_factory=dict), + "auth_schemes": FieldSpec( + default_factory=lambda: { + ShapeID("aws.auth#sigv4"): SigV4AuthScheme(service="fieldnotes"), + ShapeID("smithy.api#httpApiKeyAuth"): APIKeyAuthScheme( + name="Authorization", + location=APIKeyLocation.HEADER, + scheme="ApiKey", + ), + } + ), "auth_scheme_resolver": FieldSpec(default_factory=DefaultAuthResolver), + "api_key": FieldSpec(default=None), + "api_key_identity_resolver": FieldSpec( + default_factory=lambda: APIKeyIdentityResolver() + ), + "stage": FieldSpec(default=None), + "force_path_style": FieldSpec(default=None), "transport": FieldSpec(default_factory=lambda: Urllib3HTTPClient()), } + def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None: + "Set an auth scheme under its scheme ID." + auth_schemes = dict(self.auth_schemes or {}) + auth_schemes[scheme.scheme_id] = scheme + self.auth_schemes = auth_schemes + @classmethod def resolve( # pyright: ignore[reportIncompatibleMethodOverride] cls, @@ -88,7 +135,7 @@ def resolve( # pyright: ignore[reportIncompatibleMethodOverride] fs: FileSystem | None = None, config_file_path: str | None = None, credentials_file_path: str | None = None, - **overrides: Unpack[_WeatherStationConfigOverrides], + **overrides: Unpack[_FieldNotesConfigOverrides], ) -> Self: "Resolve the config from overrides, the environment, and config files." return cls._resolve( @@ -100,5 +147,5 @@ def resolve( # pyright: ignore[reportIncompatibleMethodOverride] ) -type Plugin = Callable[[WeatherStationConfig], None] +type Plugin = Callable[[FieldNotesConfig], None] "A callable that customizes the client configuration." diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.py b/codegen-output-py/features-client/src/features_client/models.py similarity index 73% rename from codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.py rename to codegen-output-py/features-client/src/features_client/models.py index 5140b3314..a7c3ffed3 100644 --- a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/models.py +++ b/codegen-output-py/features-client/src/features_client/models.py @@ -16,10 +16,15 @@ class ServiceError(ModeledError): _MODEL_INDEX = { "GetThingInput": "GET_THING_INPUT", "GetThingOutput": "GET_THING_OUTPUT", - "HealthInput": "HEALTH_INPUT", - "HealthOutput": "HEALTH_OUTPUT", + "PutNoteInput": "PUT_NOTE_INPUT", + "PutNoteOutput": "PUT_NOTE_OUTPUT", + "PutThingInput": "PUT_THING_INPUT", + "ThingTag": "THING_TAG", + "EchoInput": "ECHO_INPUT", + "EchoOutput": "ECHO_OUTPUT", "PingInput": "PING_INPUT", "PingOutput": "PING_OUTPUT", + "PutThingOutput": "PUT_THING_OUTPUT", } _RENAMES: dict[str, str] = {} @@ -27,17 +32,25 @@ class ServiceError(ModeledError): _TARGET_NAMES: dict[str, str] = {} _OPERATIONS: dict[str, tuple[tuple[str, ...], tuple[str, ...]]] = { + "ECHO": ( + (), + ("smithy.api#httpApiKeyAuth", "smithy.api#noAuth"), + ), "GET_THING": ( (), ("smithy.api#httpApiKeyAuth",), ), - "HEALTH": ( + "PING": ( (), ("smithy.api#noAuth",), ), - "PING": ( + "PUT_NOTE": ( (), - ("smithy.api#httpApiKeyAuth", "smithy.api#noAuth"), + ("aws.auth#sigv4", "smithy.api#httpApiKeyAuth"), + ), + "PUT_THING": ( + (), + ("smithy.api#noAuth",), ), } @@ -52,12 +65,17 @@ class ServiceError(ModeledError): target_names=_TARGET_NAMES, shape_names=frozenset( { + "EchoInput", + "EchoOutput", "GetThingInput", "GetThingOutput", - "HealthInput", - "HealthOutput", "PingInput", "PingOutput", + "PutNoteInput", + "PutNoteOutput", + "PutThingInput", + "PutThingOutput", + "ThingTag", } ), service_error="ServiceError", diff --git a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.pyi b/codegen-output-py/features-client/src/features_client/models.pyi similarity index 55% rename from codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.pyi rename to codegen-output-py/features-client/src/features_client/models.pyi index d8fc0c837..845560dd7 100644 --- a/codegen-output-py/endpoint-rules-client/src/endpoint_rules_client/models.pyi +++ b/codegen-output-py/features-client/src/features_client/models.pyi @@ -9,10 +9,19 @@ from smithy_core.schemas import APIOperation from smithy_core.serializers import ShapeSerializer __all__ = [ + "ECHO", + "GET_THING", "PING", + "PUT_NOTE", "PUT_THING", + "EchoInput", + "EchoOutput", + "GetThingInput", + "GetThingOutput", "PingInput", "PingOutput", + "PutNoteInput", + "PutNoteOutput", "PutThingInput", "PutThingOutput", "ServiceError", @@ -33,6 +42,56 @@ class ServiceError(ModeledError): implicit, and shared exception types. """ +@dataclass(kw_only=True) +class GetThingInput(_SerdeShape): + "Dataclass for GetThingInput structure." + + name: str | None = ... + +class GetThingInputDict(TypedDict, total=False): + "Dictionary form of `GetThingInput`." + + name: str | None + +@dataclass(kw_only=True) +class GetThingOutput(_SerdeShape): + "Dataclass for GetThingOutput structure." + + value: str | None = ... + response_metadata: ResponseMetadata = ... + """ + Metadata about the response that produced this output. + + Use this to recover the request identifiers a service's support team + needs in order to investigate a call. Members of the metadata are + individually optional. + """ + +@dataclass(kw_only=True) +class PutNoteInput(_SerdeShape): + "Dataclass for PutNoteInput structure." + + text: str | None = ... + +class PutNoteInputDict(TypedDict, total=False): + "Dictionary form of `PutNoteInput`." + + text: str | None + +@dataclass(kw_only=True) +class PutNoteOutput(_SerdeShape): + "Dataclass for PutNoteOutput structure." + + id: str | None = ... + response_metadata: ResponseMetadata = ... + """ + Metadata about the response that produced this output. + + Use this to recover the request identifiers a service's support team + needs in order to investigate a call. Members of the metadata are + individually optional. + """ + @dataclass(kw_only=True) class PutThingInput(_SerdeShape): "Dataclass for PutThingInput structure." @@ -61,6 +120,26 @@ class ThingTagDict(TypedDict, total=False): key: str | None value: str | None +@dataclass(kw_only=True) +class EchoInput(_SerdeShape): + "Dataclass for EchoInput structure." + +class EchoInputDict(TypedDict, total=False): + "Dictionary form of `EchoInput`." + +@dataclass(kw_only=True) +class EchoOutput(_SerdeShape): + "Dataclass for EchoOutput structure." + + response_metadata: ResponseMetadata = ... + """ + Metadata about the response that produced this output. + + Use this to recover the request identifiers a service's support team + needs in order to investigate a call. Members of the metadata are + individually optional. + """ + @dataclass(kw_only=True) class PingInput(_SerdeShape): "Dataclass for PingInput structure." @@ -94,5 +173,8 @@ class PutThingOutput(_SerdeShape): individually optional. """ +ECHO: APIOperation[EchoInput, EchoOutput] +GET_THING: APIOperation[GetThingInput, GetThingOutput] PING: APIOperation[PingInput, PingOutput] +PUT_NOTE: APIOperation[PutNoteInput, PutNoteOutput] PUT_THING: APIOperation[PutThingInput, PutThingOutput] diff --git a/codegen-output-py/api-key-auth-client/src/api_key_auth_client/py.typed b/codegen-output-py/features-client/src/features_client/py.typed similarity index 100% rename from codegen-output-py/api-key-auth-client/src/api_key_auth_client/py.typed rename to codegen-output-py/features-client/src/features_client/py.typed diff --git a/codegen-output-py/aws-config-client/src/aws_config_client/aio/user_agent.py b/codegen-output-py/features-client/src/features_client/user_agent.py similarity index 60% rename from codegen-output-py/aws-config-client/src/aws_config_client/aio/user_agent.py rename to codegen-output-py/features-client/src/features_client/user_agent.py index ec484d1b4..b6b586822 100644 --- a/codegen-output-py/aws-config-client/src/aws_config_client/aio/user_agent.py +++ b/codegen-output-py/features-client/src/features_client/user_agent.py @@ -1,16 +1,16 @@ from smithy_aws_core.interceptors.user_agent import UserAgentInterceptor -from aws_config_client import __version__ -from aws_config_client.aio.config import AsyncWeatherStationConfig +from features_client import __version__ +from features_client.config import FieldNotesConfig -def aws_user_agent_plugin(config: AsyncWeatherStationConfig) -> None: +def aws_user_agent_plugin(config: FieldNotesConfig) -> None: "Send the AWS user agent with every request." config.interceptors.append( UserAgentInterceptor( ua_suffix=config.user_agent_extra, ua_app_id=config.sdk_ua_app_id, sdk_version=__version__, - service_id="Weather_Station", + service_id="Field_Notes", ) ) diff --git a/codegen-output-py/endpoint-rules-client/tests/test_endpoints.py b/codegen-output-py/features-client/tests/test_endpoints.py similarity index 82% rename from codegen-output-py/endpoint-rules-client/tests/test_endpoints.py rename to codegen-output-py/features-client/tests/test_endpoints.py index ed05beb20..9ebbb3540 100644 --- a/codegen-output-py/endpoint-rules-client/tests/test_endpoints.py +++ b/codegen-output-py/features-client/tests/test_endpoints.py @@ -1,8 +1,8 @@ from collections.abc import Awaitable, Callable, Mapping from typing import Any, Concatenate -from endpoint_rules_client.aio.client import AsyncEndpointService -from endpoint_rules_client.aio.config import AsyncConfig +from features_client.aio.client import AsyncFieldNotesClient +from features_client.aio.config import AsyncFieldNotesConfig from pytest import mark, param from smithy_core.aio.utils import close_async from smithy_core.endpoints import BddEndpointResolver @@ -11,13 +11,23 @@ from smithy_test import check_rules_case from smithy_test.aio import check_client_case_async -# Endpoint tests from the endpointTests trait of example.endpoints#EndpointService. +# Endpoint tests from the endpointTests trait of example.features#FieldNotes. pytestmark = mark.asyncio -async def _config(**fields: Any) -> AsyncConfig: - return AsyncConfig(**fields, retry_strategy=SimpleRetryStrategy(max_attempts=1)) +_TEST_CONFIG: dict[str, Any] = { + "region": "us-east-1", + "aws_access_key_id": "AKIDTEST", + "aws_secret_access_key": "secret", +} +"Config fields every test sets. A case's own fields replace them." + + +async def _config(**fields: Any) -> AsyncFieldNotesConfig: + return await AsyncFieldNotesConfig.resolve( + **(_TEST_CONFIG | fields), retry_strategy=SimpleRetryStrategy(max_attempts=1) + ) # Every rules test shares one resolver, so its caches see changing parameters. @@ -42,8 +52,8 @@ async def _endpoint_resolver() -> BddEndpointResolver: async def _client( config: Mapping[str, Any], capture: Interceptor[Any, Any, Any, Any] -) -> AsyncEndpointService: - return AsyncEndpointService(config=await _config(**config, interceptors=[capture])) +) -> AsyncFieldNotesClient: + return AsyncFieldNotesClient(config=await _config(**config, interceptors=[capture])) RULES_CASES = [ @@ -113,7 +123,7 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> CLIENT_CASES = [ param( {"stage": "beta"}, - AsyncEndpointService.ping, + AsyncFieldNotesClient.ping, {}, { "endpoint": { @@ -125,7 +135,7 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> ), param( {"stage": "beta"}, - AsyncEndpointService.put_thing, + AsyncFieldNotesClient.put_thing, {"name": "thing", "tag": {"key": "k", "value": "v"}, "plugins_": ["p"]}, { "endpoint": { @@ -137,7 +147,7 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> ), param( {"stage": "beta"}, - AsyncEndpointService.put_thing, + AsyncFieldNotesClient.put_thing, {"name": "not a label"}, { "endpoint": { @@ -149,21 +159,21 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> ), param( {"force_path_style": True}, - AsyncEndpointService.ping, + AsyncFieldNotesClient.ping, {}, {"endpoint": {"url": "https://path.example.com"}}, id="Path style from config", ), param( {"endpoint_uri": "https://custom.example.com", "stage": "beta"}, - AsyncEndpointService.ping, + AsyncFieldNotesClient.ping, {}, {"endpoint": {"url": "https://custom.example.com"}}, id="Custom endpoint", ), param( {}, - AsyncEndpointService.ping, + AsyncFieldNotesClient.ping, {}, {"endpoint": {"url": "https://us-west-2.example.com"}}, id="Region from the built-in", @@ -171,7 +181,7 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> ), param( {}, - AsyncEndpointService.ping, + AsyncFieldNotesClient.ping, {}, {"error": "No stage"}, id="Missing stage", @@ -182,7 +192,7 @@ async def test_endpoint_rules(params: dict[str, Any], expect: dict[str, Any]) -> @mark.parametrize(("config", "operation", "input", "expect"), CLIENT_CASES) async def test_endpoint_client( config: dict[str, Any], - operation: Callable[Concatenate[AsyncEndpointService, ...], Awaitable[Any]], + operation: Callable[Concatenate[AsyncFieldNotesClient, ...], Awaitable[Any]], input: dict[str, Any], expect: dict[str, Any], ) -> None: diff --git a/designs/codegen/client.md b/designs/codegen/client.md index 84aedbe0c..797aa0dfe 100644 --- a/designs/codegen/client.md +++ b/designs/codegen/client.md @@ -162,7 +162,10 @@ two shapes with the same name. Effective auth scheme IDs follow Smithy's `NO_AUTH_AWARE` mode. Service schemes are ordered by shape ID unless an `auth` trait on the operation, or else the service, orders them. `smithy.api#noAuth` is appended when no scheme applies or -the operation has `optionalAuth`. +the operation has `optionalAuth`. A service trait is an auth scheme when its +definition has `authDefinition`. The prelude HTTP auth traits, `aws.auth#sigv4`, +and `aws.auth#sigv4a` count without a definition, since JSON ASTs usually leave +those definitions out. ## Protocols @@ -255,6 +258,11 @@ default, a client parameter that is not a client context parameter, and a blob, timestamp, big decimal, or document value. An input that names an operation the service lacks, or a member its input lacks, fails generation. +Every test sets `_TEST_CONFIG`, the config fields integrations supply through +`endpoint_test_config`, and a case's own fields replace them. The AWS config +integration sets a region and static credentials, so tests never reach the +credentials chain. + The module marks its tests with `pytest.mark.asyncio`. The package's `test` dependency group adds `pytest`, `pytest-asyncio`, and `smithy-test`. @@ -292,9 +300,12 @@ defaults to no change: | Hook | Changes | | --- | --- | | `client_names` | The client and config class names | +| `auth_schemes` | Auth schemes added to the core ones | | `config_fields` | Config fields a client context field must not take | | `write_config` | The config class, written in place of the core one | | `new_config` | The callable that creates a default config | +| `write_client_methods` | Extra client methods, such as `_post_setup` | +| `endpoint_test_config` | Config fields every generated endpoint test sets | | `client_plugins` | Plugins every client applies, before the core ones | | `write_files` | Extra modules | @@ -328,6 +339,20 @@ config: The generated package depends on `smithy-aws-core`. A client context field may not take an `AwsConfig` field name. +`AwsSigV4Integration` matches a service with both `aws.api#service` and +`aws.auth#sigv4`, and follows the Java generator: + +* Both configs default `auth_schemes` to `SigV4AuthScheme` or + `AsyncSigV4AuthScheme` for the trait's signing name. `AwsConfig` already + declares the credential fields and `aws_credentials_identity_resolver`. +* A client's `_post_setup` sets the default AWS credentials chain when the + config has no credentials resolver. The chain reads the config's profile, + region, and transport. +* A service with `aws.auth#sigv4` but not `aws.api#service` fails generation, + because SigV4 needs the AWS config. + +S3 signing properties come later with S3 support. + ## Clients and Configuration Service classes are thin subclasses of `Client[Config]` and @@ -386,13 +411,13 @@ runtime metadata. It covers `self`, `plugins`, defaults, and idempotency tokens. ## Supported Features The generator supports non-streaming RPCv2 CBOR and RPCv2 JSON operations that -are unsigned or use API key auth, and whose endpoint rules use the standard -library. Models that require other auth schemes or event or data streams fail -generation with a diagnostic naming the operation and feature. +are unsigned or use API key auth or SigV4, and whose endpoint rules use the +standard library. Models that require other auth schemes or event or data +streams fail generation with a diagnostic naming the operation and feature. Authentication and endpoint extension points are provider-neutral. AWS config -resolution and the AWS user agent are AWS integrations. SigV4, AWS endpoint -functions, and AWS protocols are not supported yet. +resolution, the AWS user agent, and SigV4 are AWS integrations. AWS endpoint +functions and AWS protocols are not supported yet. ## Validation @@ -403,24 +428,27 @@ decoded CBOR payload, response models, and error types. An endpoint test resolves a host from a client context field, an input context parameter, and a static context parameter. -Lowering tests port the Java generator's tests. The `endpoint-rules-client` -snapshot is generated from a fixture whose endpoint rules read client context -fields, `SDK::Endpoint`, an input context parameter, and static context -parameters. `models/endpoint-rules.smithy` is its source, and -`models/endpoint-rules.json` is that model assembled by Smithy with its ruleset -compiled by `CompileBdd`. The snapshot tests run the snapshot's generated -endpoint tests. - -The `api-key-auth-client` snapshot comes from `models/api-key-auth.smithy`, -assembled by Smithy into `models/api-key-auth.json`. Its operations use the -service's API key auth, `@auth([])`, and `@optionalAuth`. Tests check which -requests carry the key and that a missing key fails the call. - -The `aws-config-client` snapshot comes from `models/aws-config.smithy`, -assembled by Smithy into `models/aws-config.json` with its ruleset compiled by -`CompileBdd`. Its tests resolve the endpoint from `AWS_ENDPOINT_URL_` -and from a profile, check the AWS user agent, and check that unknown fields and -direct construction fail. +Lowering tests port the Java generator's tests. + +The `features-client` snapshot covers every client feature in one AWS service. +`models/features.smithy` is its source, and `models/features.json` is that +model assembled by Smithy with its ruleset compiled by `CompileBdd`: + +| Feature | Fixture | +| --- | --- | +| Endpoint rules | Client context fields, `SDK::Endpoint`, an input context parameter, and static context parameters | +| Endpoint tests | Rules and client cases, run by the snapshot tests | +| SigV4 | The service's default auth | +| API key auth | Operations with `@auth([httpApiKeyAuth])`, one also `@optionalAuth` | +| No auth | Operations with `@auth([])` | +| AWS config | `aws.api#service`, with the SDK ID `Field Notes` | + +Its tests check which requests carry the API key and that a missing key fails +the call. They resolve the endpoint from `AWS_ENDPOINT_URL_` and from a +profile, check the AWS user agent, check that unknown fields and direct +construction fail, and check SigV4 signing with configured credentials and with +credentials from the default chain. The core config is covered by the +`rpcv2-cbor-client` and `rpcv2-json-client` snapshots and by unit tests. Client snapshots sit alongside the types snapshots and cover the provider-neutral RPCv2 CBOR and RPCv2 JSON projections. Checks cover deterministic diff --git a/packages/smithy-python/.changes/next-release/smithy-python-feature-7db2e12e18fb4803bec204c1f72c290a.json b/packages/smithy-python/.changes/next-release/smithy-python-feature-7db2e12e18fb4803bec204c1f72c290a.json new file mode 100644 index 000000000..6faf6e876 --- /dev/null +++ b/packages/smithy-python/.changes/next-release/smithy-python-feature-7db2e12e18fb4803bec204c1f72c290a.json @@ -0,0 +1,4 @@ +{ + "type": "feature", + "description": "Generate SigV4 auth for AWS clients. Configs default to the SigV4 auth scheme for the service's signing name, and clients fall back to the default AWS credentials chain. Treat aws.auth#sigv4 as an auth scheme even when the AST omits its definition. Generated endpoint tests take shared config fields from integrations." +} diff --git a/packages/smithy-python/src/smithy_python/_client_emitter.py b/packages/smithy-python/src/smithy_python/_client_emitter.py index 046d89f1b..1c20ce97b 100644 --- a/packages/smithy-python/src/smithy_python/_client_emitter.py +++ b/packages/smithy-python/src/smithy_python/_client_emitter.py @@ -22,15 +22,18 @@ from .writer import PythonWriter -def check_supported(plan: ClientPlan) -> None: +def check_supported( + plan: ClientPlan, integrations: Sequence[ClientIntegration] = () +) -> None: """Reject models that need features generated clients do not support yet. + :param integrations: The integrations that match the service. :raises CodegenError: Naming the first unsupported operation and feature. """ service = plan.selection.service assert service is not None # noqa: S101 - ClientPlan requires a service supported = {_NO_AUTH} | { - scheme.scheme_id for scheme in _auth.supported_schemes(service) + scheme.scheme_id for scheme in _auth_schemes(service, integrations) } for operation, exports in zip(plan.operations, plan.models.operations, strict=True): shape = operation.operation @@ -65,7 +68,7 @@ def plan_endpoints( reserved = set(_CONFIG_FIELDS) reserved.update( field.name - for scheme in _auth.supported_schemes(service) + for scheme in _auth_schemes(service, integrations) for field in scheme.fields ) for integration in integrations: @@ -116,7 +119,7 @@ def write_client( mode=mode, endpoints=endpoints, bdd=TypeReference("BDD", endpoints_module), - auth_schemes=_auth.supported_schemes(service), + auth_schemes=_auth_schemes(service, integrations), protocol_settings="_PROTOCOL_SETTINGS", ), integrations, @@ -143,6 +146,11 @@ def write_client( TypeReference(aio.client, f"{import_name}.aio.client"), aio_config, _new_config(aio, aio_config, integrations), + { + name: value + for integration in integrations + for name, value in integration.endpoint_test_config(service).items() + }, ) aio_init = context.files.python_module( f"src/{directory}/aio/__init__.py", f"{import_name}.aio" @@ -209,6 +217,15 @@ def _generic(reference: TypeReference, *arguments: TypeReference) -> TypeReferen ) +def _auth_schemes( + service: _model.ServiceShape, integrations: Sequence[ClientIntegration] +) -> tuple[_auth.AuthContribution, ...]: + contributions = dict(_auth.DEFAULT_AUTH_SCHEMES) + for integration in integrations: + contributions.update(integration.auth_schemes(service)) + return _auth.supported_schemes(service, contributions) + + def _new_config( mode: ClientMode, config: TypeReference, @@ -216,7 +233,8 @@ def _new_config( ) -> tuple[str | TypeReference, ...]: parts: tuple[str | TypeReference, ...] = (config,) for integration in integrations: - parts = integration.new_config(mode, config) + if (changed := integration.new_config(mode, config)) is not None: + parts = changed return parts @@ -571,6 +589,8 @@ def _write_client( writer.line(define, "_new_config(self) -> ", config, ":") with writer.indent(): writer.line("return ", *create, "()") + for integration in integrations: + integration.write_client_methods(writer, plan, mode, config) def _write_operation( diff --git a/packages/smithy-python/src/smithy_python/_endpoint_tests.py b/packages/smithy-python/src/smithy_python/_endpoint_tests.py index 510cfcd6e..ed69217bd 100644 --- a/packages/smithy-python/src/smithy_python/_endpoint_tests.py +++ b/packages/smithy-python/src/smithy_python/_endpoint_tests.py @@ -36,6 +36,7 @@ def write_endpoint_tests( client: TypeReference, config: TypeReference, new_config: tuple[str | TypeReference, ...] | None = None, + test_config: Mapping[str, str] | None = None, ) -> None: """Register ``tests/test_endpoints.py`` when the service has endpoint tests. @@ -43,6 +44,8 @@ def write_endpoint_tests( :param config: The async config class. :param new_config: The callable that creates an async config from keyword fields. Defaults to the config class. + :param test_config: Config fields every test sets, as Python literals by + field name. A case's own fields replace them. :raises CodegenError: If a case names an operation the service doesn't contain, expects neither an endpoint nor an error, or gives an operation an input member it doesn't have. @@ -68,6 +71,7 @@ def write_endpoint_tests( client, config, new_config or (config,), + test_config or {}, ).write(service, tuple(_object(case, "test case") for case in cases)) @@ -142,9 +146,11 @@ def __init__( client: TypeReference, config: TypeReference, new_config: tuple[str | TypeReference, ...], + test_config: Mapping[str, str], ) -> None: self._writer = writer self._new_config = new_config + self._test_config = test_config self._plan = plan self._client = client self._config = config @@ -176,12 +182,24 @@ def _write_factories(self) -> None: any_ = _ANY w.line() w.line() + w.line("_TEST_CONFIG: dict[str, ", any_, "] = {") + with w.indent(): + for name, value in self._test_config.items(): + w.line(_endpoints.literal(name), ": ", value, ",") + w.line("}") + w.line( + _endpoints.literal( + "Config fields every test sets. A case's own fields replace them." + ) + ) + w.line() + w.line() w.line("async def _config(**fields: ", any_, ") -> ", self._config, ":") with w.indent(): w.line( "return ", *self._new_config, - "(**fields, retry_strategy=", + "(**(_TEST_CONFIG | fields), retry_strategy=", _RETRY, "(max_attempts=1))", ) diff --git a/packages/smithy-python/src/smithy_python/aws/__init__.py b/packages/smithy-python/src/smithy_python/aws/__init__.py index a6962672b..08237e447 100644 --- a/packages/smithy-python/src/smithy_python/aws/__init__.py +++ b/packages/smithy-python/src/smithy_python/aws/__init__.py @@ -4,7 +4,8 @@ A service with the ``aws.api#service`` trait gets clients named for its SDK ID and configs that resolve from the environment and shared config files. Its clients also -send the AWS user agent. +send the AWS user agent. A service with the ``aws.auth#sigv4`` trait also gets SigV4 +auth and the default AWS credentials chain. """ from __future__ import annotations @@ -13,8 +14,14 @@ from ._config import AwsConfigIntegration from ._dependencies import SMITHY_AWS_CORE +from ._sigv4 import AwsSigV4Integration -__all__ = ["AWS_INTEGRATIONS", "SMITHY_AWS_CORE", "AwsConfigIntegration"] +__all__ = [ + "AWS_INTEGRATIONS", + "SMITHY_AWS_CORE", + "AwsConfigIntegration", + "AwsSigV4Integration", +] -AWS_INTEGRATIONS: Final = (AwsConfigIntegration(),) +AWS_INTEGRATIONS: Final = (AwsConfigIntegration(), AwsSigV4Integration()) """The integrations AWS services get, in order.""" diff --git a/packages/smithy-python/src/smithy_python/aws/_config.py b/packages/smithy-python/src/smithy_python/aws/_config.py index 188592344..a11737941 100644 --- a/packages/smithy-python/src/smithy_python/aws/_config.py +++ b/packages/smithy-python/src/smithy_python/aws/_config.py @@ -56,7 +56,19 @@ def write_config(self, writer: PythonWriter, config: ConfigPlan) -> bool: _write_config(writer, config) return True - def new_config(self, mode: ClientMode, config: TypeReference) -> tuple[Part, ...]: + def endpoint_test_config(self, service: _model.ServiceShape) -> Mapping[str, str]: + del service + # AwsConfig requires a region. Static credentials keep the tests from + # reaching the credentials chain. + return { + "region": _quote("us-east-1"), + "aws_access_key_id": _quote("AKIDTEST"), + "aws_secret_access_key": _quote("secret"), + } + + def new_config( + self, mode: ClientMode, config: TypeReference + ) -> tuple[Part, ...] | None: return ("await ", config, ".resolve") if mode.is_async else (config, ".resolve") def client_plugins( diff --git a/packages/smithy-python/src/smithy_python/aws/_sigv4.py b/packages/smithy-python/src/smithy_python/aws/_sigv4.py new file mode 100644 index 000000000..d2792d4ac --- /dev/null +++ b/packages/smithy-python/src/smithy_python/aws/_sigv4.py @@ -0,0 +1,148 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""SigV4 auth and the default AWS credentials chain.""" + +from __future__ import annotations + +from collections.abc import Callable, Mapping +from typing import TYPE_CHECKING, Final + +from .. import exceptions as _exceptions +from .. import model as _model +from .. import models as _models +from .._auth import AuthContribution +from ..dependencies import SMITHY_HTTP +from ..integrations import ClientIntegration, ClientMode +from ..symbols import TypeReference +from ._dependencies import SMITHY_AWS_CORE + +if TYPE_CHECKING: + from ..clients import ClientPlan + from ..integrations import Part + from ..writer import PythonWriter + +__all__ = ["SIGV4", "AwsSigV4Integration"] + + +class AwsSigV4Integration(ClientIntegration): + """SigV4 auth for AWS services with the ``aws.auth#sigv4`` trait. + + Configs default ``auth_schemes`` to the SigV4 scheme for the trait's signing + name. The credential fields come from ``AwsConfig``. A client whose config has + no credentials resolver sets the default AWS credentials chain in + ``_post_setup``, built from the config's profile and region. + """ + + def matches(self, service: _model.ServiceShape) -> bool: + return service.has_trait(_SERVICE) and service.has_trait(SIGV4.scheme_id) + + def auth_schemes( + self, service: _model.ServiceShape + ) -> Mapping[_model.ShapeId, AuthContribution]: + del service + return {SIGV4.scheme_id: SIGV4} + + def write_client_methods( + self, + writer: PythonWriter, + plan: ClientPlan, + mode: ClientMode, + config: TypeReference, + ) -> None: + del plan + sync = not mode.is_async + wait = "" if sync else "await " + chain = ( + _aws("IdentityChain", "identity.chain.resolver") + if sync + else _aws("AsyncIdentityChain", "aio.identity.chain") + ) + http_client = ( + _http("HTTPClient", "interfaces") + if sync + else _http("AsyncHTTPClient", "aio.interfaces") + ) + writer.line() + writer.line( + "def " if sync else "async def ", + "_post_setup(self, config: ", + config, + ") -> None:", + ) + with writer.indent(): + writer.line("if config.aws_credentials_identity_resolver is None:") + with writer.indent(): + writer.line("config_context = config.resolution_context()") + writer.line("config_file = None") + writer.line("profile_name = None") + writer.line("if config_context is not None:") + with writer.indent(): + writer.line( + "config_file = ", wait, "config_context.parsed_profiles()" + ) + writer.line( + "if config_context.profile_source is ", + _CONFIG_SOURCE, + ".OVERRIDE:", + ) + with writer.indent(): + writer.line("profile_name = config_context.profile_name") + writer.line( + "config.aws_credentials_identity_resolver = ", + wait, + chain, + ".create(", + ) + with writer.indent(): + writer.line(_CREDENTIALS_IDENTITY, ",") + writer.line("config_file=config_file,") + writer.line("profile_name=profile_name,") + writer.line("region_override=config.region,") + writer.line( + "http_client=", + _CAST, + "(", + http_client, + " | None, config.transport),", + ) + writer.line(")") + + +def _aws(name: str, module: str) -> TypeReference: + return TypeReference( + name, f"smithy_aws_core.{module}", dependencies=(SMITHY_AWS_CORE,) + ) + + +def _http(name: str, module: str) -> TypeReference: + return TypeReference(name, f"smithy_http.{module}", dependencies=(SMITHY_HTTP,)) + + +def _signing_name(trait: _model.Node) -> str: + name = trait.get("name") if isinstance(trait, Mapping) else None + if not isinstance(name, str) or not name: + raise _exceptions.CodegenError("Invalid aws.auth#sigv4 trait: needs a name") + return name + + +def _scheme(reference: TypeReference) -> Callable[[_model.Node], tuple[Part, ...]]: + def build(trait: _model.Node) -> tuple[Part, ...]: + quoted = _models._quote(_signing_name(trait)) # pyright: ignore[reportPrivateUsage] + return (reference, f"(service={quoted})") + + return build + + +_SERVICE: Final = _model.ShapeId("aws.api", "service") +_CAST: Final = TypeReference("cast", "typing") +_CONFIG_SOURCE: Final = _aws("ConfigSource", "config.types") +_CREDENTIALS_IDENTITY: Final = _aws("AWSCredentialsIdentity", "identity.components") + +SIGV4: Final = AuthContribution( + scheme_id=_model.ShapeId("aws.auth", "sigv4"), + scheme=_scheme(_aws("SigV4AuthScheme", "auth.sigv4")), + async_scheme=_scheme(_aws("AsyncSigV4AuthScheme", "aio.auth.sigv4")), + # AwsConfig declares the credential fields and the credentials resolver. + fields=(), +) +"""SigV4 auth, from the ``aws.auth#sigv4`` trait.""" diff --git a/packages/smithy-python/src/smithy_python/clients.py b/packages/smithy-python/src/smithy_python/clients.py index 3a5a5d691..99cc1f8d0 100644 --- a/packages/smithy-python/src/smithy_python/clients.py +++ b/packages/smithy-python/src/smithy_python/clients.py @@ -66,7 +66,7 @@ def generate( for integration in self._integrations if integration.matches(service) ) - _client_emitter.check_supported(plan) + _client_emitter.check_supported(plan, integrations) endpoints = _client_emitter.plan_endpoints(plan, integrations) _schemas.SchemaGenerator().generate(context) _models.ModelGenerator().generate(context) @@ -276,10 +276,22 @@ def normalize_client_model( _AUTH_DEFINITION = _model.ShapeId("smithy.api", "authDefinition") _OPTIONAL_AUTH = _model.ShapeId("smithy.api", "optionalAuth") _NO_AUTH = _model.ShapeId("smithy.api", "noAuth") -# The embedded prelude omits trait definitions, so its auth traits are listed. -_PRELUDE_AUTH_SCHEMES = frozenset( - _model.ShapeId("smithy.api", name) - for name in ("httpApiKeyAuth", "httpBasicAuth", "httpBearerAuth", "httpDigestAuth") +# The embedded prelude omits trait definitions, and JSON ASTs usually leave out the +# definitions of the AWS auth traits, so those auth traits are listed. +_KNOWN_AUTH_SCHEMES = frozenset( + ( + *( + _model.ShapeId("smithy.api", name) + for name in ( + "httpApiKeyAuth", + "httpBasicAuth", + "httpBearerAuth", + "httpDigestAuth", + ) + ), + _model.ShapeId("aws.auth", "sigv4"), + _model.ShapeId("aws.auth", "sigv4a"), + ) ) @@ -298,7 +310,7 @@ def _effective_auth_schemes( ( trait_id for trait_id in service.traits - if trait_id in _PRELUDE_AUTH_SCHEMES + if trait_id in _KNOWN_AUTH_SCHEMES or ( (definition := model.find_shape(trait_id)) is not None and definition.has_trait(_AUTH_DEFINITION) diff --git a/packages/smithy-python/src/smithy_python/integrations.py b/packages/smithy-python/src/smithy_python/integrations.py index ea0254e1a..be27c1ef7 100644 --- a/packages/smithy-python/src/smithy_python/integrations.py +++ b/packages/smithy-python/src/smithy_python/integrations.py @@ -10,7 +10,7 @@ from __future__ import annotations -from collections.abc import Collection +from collections.abc import Collection, Mapping from dataclasses import dataclass from typing import TYPE_CHECKING @@ -94,6 +94,16 @@ def client_names( del service return names + def auth_schemes( + self, service: _model.ServiceShape + ) -> Mapping[_model.ShapeId, _auth.AuthContribution]: + """Auth schemes the integration supports, by auth trait ID. + + They join the core auth schemes for the services the integration matches. + """ + del service + return {} + def config_fields(self, service: _model.ServiceShape) -> Collection[str]: """Config fields the integration declares, which a client context parameter's field must not take.""" @@ -108,14 +118,39 @@ def write_config(self, writer: PythonWriter, config: ConfigPlan) -> bool: del writer, config return False - def new_config(self, mode: ClientMode, config: TypeReference) -> tuple[Part, ...]: + def new_config( + self, mode: ClientMode, config: TypeReference + ) -> tuple[Part, ...] | None: """The callable that creates a default config, called with keyword fields. A client calls it with no arguments when it has no config. An async mode - may begin the parts with ``"await "``. + may begin the parts with ``"await "``. None leaves the callable as the + config class or an earlier integration set it. + """ + del mode, config + return None + + def endpoint_test_config(self, service: _model.ServiceShape) -> Mapping[str, str]: + """Config fields every generated endpoint test sets, as Python literals. + + A config that resolves from the environment, for example, may need a + region and credentials. A test case's own fields replace these. + """ + del service + return {} + + def write_client_methods( + self, + writer: PythonWriter, + plan: ClientPlan, + mode: ClientMode, + config: TypeReference, + ) -> None: + """Write extra methods at the end of the mode's client class. + + :param config: The mode's config class. """ - del mode - return (config,) + del writer, plan, mode, config def client_plugins( self, plan: ClientPlan, mode: ClientMode, package: str diff --git a/packages/smithy-python/tests/unit/test_client_generation.py b/packages/smithy-python/tests/unit/test_client_generation.py index ea8ce15cf..a26c5e37e 100644 --- a/packages/smithy-python/tests/unit/test_client_generation.py +++ b/packages/smithy-python/tests/unit/test_client_generation.py @@ -712,3 +712,43 @@ def test_aws_clients_with_dashed_package_names_import( assert package.AsyncGreeterClient._client_plugins[0].__module__ == ( "aws_greeter_dashed.aio.user_agent" ) + + +def _add_sigv4(shapes: dict[str, Any]) -> None: + traits = shapes["example#Greeter"]["traits"] + traits["aws.api#service"] = {"sdkId": "Greeter"} + traits["aws.auth#sigv4"] = {"name": "greeter"} + + +def test_sigv4_services_sign_with_the_signing_name(tmp_path: Path) -> None: + shapes = _shapes() + _add_sigv4(shapes) + _aws_generate(tmp_path, "greeter_sigv4", shapes) + source = tmp_path / "src/greeter_sigv4" + config = (source / "aio/config.py").read_text() + assert 'ShapeID("aws.auth#sigv4"): AsyncSigV4AuthScheme(service="greeter")' in ( + config + ) + client = (source / "aio/client.py").read_text() + assert "async def _post_setup(self, config: AsyncGreeterConfig) -> None:" in client + assert "await AsyncIdentityChain.create(" in client + assert "return await AsyncGreeterConfig.resolve()" in client + models = (source / "models.py").read_text() + assert '("aws.auth#sigv4",)' in models + + +def test_sigv4_needs_the_aws_integrations(tmp_path: Path) -> None: + # Without its definition in the AST, sigv4 is still an auth scheme, so a + # client that can't sign it isn't generated as unsigned. + shapes = _shapes() + _add_sigv4(shapes) + with pytest.raises(CodegenError, match=r"requires auth \(aws\.auth#sigv4\)"): + _generate(tmp_path, "greeter_unsigned", shapes) + + +def test_sigv4_trait_needs_a_signing_name(tmp_path: Path) -> None: + shapes = _shapes() + _add_sigv4(shapes) + shapes["example#Greeter"]["traits"]["aws.auth#sigv4"] = {} + with pytest.raises(CodegenError, match="needs a name"): + _aws_generate(tmp_path, "greeter_no_signing_name", shapes) diff --git a/scripts/api-snapshot/api-rex.json b/scripts/api-snapshot/api-rex.json index aba525c51..36c86e043 100644 --- a/scripts/api-snapshot/api-rex.json +++ b/scripts/api-snapshot/api-rex.json @@ -1330,6 +1330,7 @@ }, "smithy_python.aws": { "AwsConfigIntegration": "rex-class", + "AwsSigV4Integration": "rex-class", "SMITHY_AWS_CORE": "rex-Dependency" }, "smithy_python.cli": { diff --git a/scripts/codegen-output-py/client-projections.json b/scripts/codegen-output-py/client-projections.json index ce2d31581..79f84f065 100644 --- a/scripts/codegen-output-py/client-projections.json +++ b/scripts/codegen-output-py/client-projections.json @@ -1,23 +1,9 @@ { - "api-key-auth-client": { - "description": "Python client for the API key auth fixture", - "model": "models/api-key-auth.json", - "package": "api_key_auth_client", - "service": "example.apikey#ApiKeyService", - "version": "0.0.1" - }, - "aws-config-client": { - "description": "Python client for the AWS config fixture", - "model": "models/aws-config.json", - "package": "aws_config_client", - "service": "example.awsconfig#WeatherStation", - "version": "0.0.1" - }, - "endpoint-rules-client": { - "description": "Python client for the endpoint rules fixture", - "model": "models/endpoint-rules.json", - "package": "endpoint_rules_client", - "service": "example.endpoints#EndpointService", + "features-client": { + "description": "Python client for the client features fixture", + "model": "models/features.json", + "package": "features_client", + "service": "example.features#FieldNotes", "version": "0.0.1" }, "rpcv2-cbor-client": { diff --git a/scripts/codegen-output-py/models/api-key-auth.json b/scripts/codegen-output-py/models/api-key-auth.json deleted file mode 100644 index acaa66b09..000000000 --- a/scripts/codegen-output-py/models/api-key-auth.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "smithy": "2.0", - "shapes": { - "example.apikey#ApiKeyService": { - "type": "service", - "version": "2026-11-17", - "operations": [ - { - "target": "example.apikey#GetThing" - }, - { - "target": "example.apikey#Health" - }, - { - "target": "example.apikey#Ping" - } - ], - "traits": { - "smithy.api#documentation": "A service that authenticates with an API key.", - "smithy.api#httpApiKeyAuth": { - "name": "Authorization", - "in": "header", - "scheme": "ApiKey" - }, - "smithy.protocols#rpcv2Cbor": {} - } - }, - "example.apikey#GetThing": { - "type": "operation", - "input": { - "target": "example.apikey#GetThingInput" - }, - "output": { - "target": "example.apikey#GetThingOutput" - }, - "traits": { - "smithy.api#documentation": "Uses the service's API key auth." - } - }, - "example.apikey#GetThingInput": { - "type": "structure", - "members": { - "name": { - "target": "smithy.api#String" - } - }, - "traits": { - "smithy.api#input": {} - } - }, - "example.apikey#GetThingOutput": { - "type": "structure", - "members": { - "value": { - "target": "smithy.api#String" - } - }, - "traits": { - "smithy.api#output": {} - } - }, - "example.apikey#Health": { - "type": "operation", - "input": { - "target": "smithy.api#Unit" - }, - "output": { - "target": "smithy.api#Unit" - }, - "traits": { - "smithy.api#auth": [], - "smithy.api#documentation": "Needs no auth." - } - }, - "example.apikey#Ping": { - "type": "operation", - "input": { - "target": "smithy.api#Unit" - }, - "output": { - "target": "smithy.api#Unit" - }, - "traits": { - "smithy.api#documentation": "Sends the API key when it has one.", - "smithy.api#optionalAuth": {} - } - } - } -} diff --git a/scripts/codegen-output-py/models/api-key-auth.smithy b/scripts/codegen-output-py/models/api-key-auth.smithy deleted file mode 100644 index 55d50cdaf..000000000 --- a/scripts/codegen-output-py/models/api-key-auth.smithy +++ /dev/null @@ -1,31 +0,0 @@ -$version: "2.0" - -namespace example.apikey - -use smithy.protocols#rpcv2Cbor - -/// A service that authenticates with an API key. -@rpcv2Cbor -@httpApiKeyAuth(name: "Authorization", in: "header", scheme: "ApiKey") -service ApiKeyService { - version: "2026-11-17" - operations: [GetThing, Health, Ping] -} - -/// Uses the service's API key auth. -operation GetThing { - input := { - name: String - } - output := { - value: String - } -} - -/// Needs no auth. -@auth([]) -operation Health {} - -/// Sends the API key when it has one. -@optionalAuth -operation Ping {} diff --git a/scripts/codegen-output-py/models/aws-config.json b/scripts/codegen-output-py/models/aws-config.json deleted file mode 100644 index d87bc62a6..000000000 --- a/scripts/codegen-output-py/models/aws-config.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "smithy": "2.0", - "shapes": { - "example.awsconfig#GetForecast": { - "type": "operation", - "input": { - "target": "example.awsconfig#GetForecastInput" - }, - "output": { - "target": "example.awsconfig#GetForecastOutput" - }, - "traits": { - "smithy.api#documentation": "Gets the forecast for a city." - } - }, - "example.awsconfig#GetForecastInput": { - "type": "structure", - "members": { - "city": { - "target": "smithy.api#String" - } - }, - "traits": { - "smithy.api#input": {} - } - }, - "example.awsconfig#GetForecastOutput": { - "type": "structure", - "members": { - "summary": { - "target": "smithy.api#String" - } - }, - "traits": { - "smithy.api#output": {} - } - }, - "example.awsconfig#WeatherStation": { - "type": "service", - "version": "2026-11-19", - "operations": [ - { - "target": "example.awsconfig#GetForecast" - } - ], - "traits": { - "aws.api#service": { - "sdkId": "Weather Station" - }, - "smithy.api#documentation": "An AWS service that reads its config from the environment and profiles.", - "smithy.protocols#rpcv2Cbor": {}, - "smithy.rules#endpointBdd": { - "version": "1.1", - "parameters": { - "Endpoint": { - "builtIn": "SDK::Endpoint", - "required": false, - "documentation": "A custom endpoint.", - "type": "string" - } - }, - "conditions": [ - { - "fn": "isSet", - "argv": [ - { - "ref": "Endpoint" - } - ] - } - ], - "results": [ - { - "conditions": [], - "endpoint": { - "url": { - "ref": "Endpoint" - }, - "properties": {}, - "headers": {} - }, - "type": "endpoint" - }, - { - "conditions": [], - "error": "Endpoint is not set", - "type": "error" - } - ], - "root": 2, - "nodeCount": 2, - "nodes": "/////wAAAAH/////AAAAAAX14QEF9eEC" - }, - "smithy.rules#endpointRuleSet": { - "version": "1.0", - "parameters": { - "Endpoint": { - "type": "string", - "builtIn": "SDK::Endpoint", - "documentation": "A custom endpoint." - } - }, - "rules": [ - { - "conditions": [ - { - "fn": "isSet", - "argv": [ - { - "ref": "Endpoint" - } - ] - } - ], - "endpoint": { - "url": { - "ref": "Endpoint" - } - }, - "type": "endpoint" - }, - { - "conditions": [], - "error": "Endpoint is not set", - "type": "error" - } - ] - } - } - } - } -} diff --git a/scripts/codegen-output-py/models/aws-config.smithy b/scripts/codegen-output-py/models/aws-config.smithy deleted file mode 100644 index 198840642..000000000 --- a/scripts/codegen-output-py/models/aws-config.smithy +++ /dev/null @@ -1,39 +0,0 @@ -$version: "2.0" - -namespace example.awsconfig - -use aws.api#service -use smithy.protocols#rpcv2Cbor -use smithy.rules#endpointRuleSet - -/// An AWS service that reads its config from the environment and profiles. -@service(sdkId: "Weather Station") -@rpcv2Cbor -@endpointRuleSet({ - version: "1.0" - parameters: { - Endpoint: { type: "string", builtIn: "SDK::Endpoint", documentation: "A custom endpoint." } - } - rules: [ - { - conditions: [{ fn: "isSet", argv: [{ ref: "Endpoint" }] }] - endpoint: { url: { ref: "Endpoint" } } - type: "endpoint" - } - { conditions: [], error: "Endpoint is not set", type: "error" } - ] -}) -service WeatherStation { - version: "2026-11-19" - operations: [GetForecast] -} - -/// Gets the forecast for a city. -operation GetForecast { - input := { - city: String - } - output := { - summary: String - } -} diff --git a/scripts/codegen-output-py/models/endpoint-rules.json b/scripts/codegen-output-py/models/features.json similarity index 84% rename from scripts/codegen-output-py/models/endpoint-rules.json rename to scripts/codegen-output-py/models/features.json index bd33c5612..798b6823e 100644 --- a/scripts/codegen-output-py/models/endpoint-rules.json +++ b/scripts/codegen-output-py/models/features.json @@ -1,19 +1,55 @@ { "smithy": "2.0", "shapes": { - "example.endpoints#EndpointService": { + "example.features#Echo": { + "type": "operation", + "input": { + "target": "smithy.api#Unit" + }, + "output": { + "target": "smithy.api#Unit" + }, + "traits": { + "smithy.api#auth": [ + "smithy.api#httpApiKeyAuth" + ], + "smithy.api#documentation": "Uses API key auth, but sends no key when it has none.", + "smithy.api#optionalAuth": {} + } + }, + "example.features#FieldNotes": { "type": "service", "version": "2026-11-20", "operations": [ { - "target": "example.endpoints#Ping" + "target": "example.features#Echo" + }, + { + "target": "example.features#GetThing" + }, + { + "target": "example.features#Ping" }, { - "target": "example.endpoints#PutThing" + "target": "example.features#PutNote" + }, + { + "target": "example.features#PutThing" } ], "traits": { - "smithy.api#documentation": "A service whose endpoint rules read config, input, and operation values.", + "aws.api#service": { + "sdkId": "Field Notes" + }, + "aws.auth#sigv4": { + "name": "fieldnotes" + }, + "smithy.api#documentation": "An AWS service that uses every client feature the generator supports.\n\nIts endpoint rules read config, input, and operation values. Its operations\nuse SigV4, API key auth, optional auth, and no auth.", + "smithy.api#httpApiKeyAuth": { + "name": "Authorization", + "in": "header", + "scheme": "ApiKey" + }, "smithy.protocols#rpcv2Cbor": {}, "smithy.rules#clientContextParams": { "Stage": { @@ -525,7 +561,44 @@ } } }, - "example.endpoints#Ping": { + "example.features#GetThing": { + "type": "operation", + "input": { + "target": "example.features#GetThingInput" + }, + "output": { + "target": "example.features#GetThingOutput" + }, + "traits": { + "smithy.api#auth": [ + "smithy.api#httpApiKeyAuth" + ], + "smithy.api#documentation": "Uses API key auth." + } + }, + "example.features#GetThingInput": { + "type": "structure", + "members": { + "name": { + "target": "smithy.api#String" + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "example.features#GetThingOutput": { + "type": "structure", + "members": { + "value": { + "target": "smithy.api#String" + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "example.features#Ping": { "type": "operation", "input": { "target": "smithy.api#Unit" @@ -534,6 +607,8 @@ "target": "smithy.api#Unit" }, "traits": { + "smithy.api#auth": [], + "smithy.api#documentation": "Needs no auth.", "smithy.rules#staticContextParams": { "Kind": { "value": "ping" @@ -541,21 +616,57 @@ } } }, - "example.endpoints#PluginNames": { + "example.features#PluginNames": { "type": "list", "member": { "target": "smithy.api#String" } }, - "example.endpoints#PutThing": { + "example.features#PutNote": { + "type": "operation", + "input": { + "target": "example.features#PutNoteInput" + }, + "output": { + "target": "example.features#PutNoteOutput" + }, + "traits": { + "smithy.api#documentation": "Saves a note, signed with SigV4." + } + }, + "example.features#PutNoteInput": { + "type": "structure", + "members": { + "text": { + "target": "smithy.api#String" + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "example.features#PutNoteOutput": { + "type": "structure", + "members": { + "id": { + "target": "smithy.api#String" + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "example.features#PutThing": { "type": "operation", "input": { - "target": "example.endpoints#PutThingInput" + "target": "example.features#PutThingInput" }, "output": { "target": "smithy.api#Unit" }, "traits": { + "smithy.api#auth": [], + "smithy.api#documentation": "Needs no auth.", "smithy.rules#staticContextParams": { "Kind": { "value": "put" @@ -563,7 +674,7 @@ } } }, - "example.endpoints#PutThingInput": { + "example.features#PutThingInput": { "type": "structure", "members": { "name": { @@ -576,17 +687,17 @@ } }, "tag": { - "target": "example.endpoints#ThingTag" + "target": "example.features#ThingTag" }, "plugins": { - "target": "example.endpoints#PluginNames" + "target": "example.features#PluginNames" } }, "traits": { "smithy.api#input": {} } }, - "example.endpoints#ThingTag": { + "example.features#ThingTag": { "type": "structure", "members": { "key": { diff --git a/scripts/codegen-output-py/models/endpoint-rules.smithy b/scripts/codegen-output-py/models/features.smithy similarity index 86% rename from scripts/codegen-output-py/models/endpoint-rules.smithy rename to scripts/codegen-output-py/models/features.smithy index d902eeb76..14d5b06d5 100644 --- a/scripts/codegen-output-py/models/endpoint-rules.smithy +++ b/scripts/codegen-output-py/models/features.smithy @@ -1,7 +1,9 @@ $version: "2.0" -namespace example.endpoints +namespace example.features +use aws.api#service +use aws.auth#sigv4 use smithy.protocols#rpcv2Cbor use smithy.rules#clientContextParams use smithy.rules#contextParam @@ -9,8 +11,14 @@ use smithy.rules#endpointRuleSet use smithy.rules#endpointTests use smithy.rules#staticContextParams -/// A service whose endpoint rules read config, input, and operation values. +/// An AWS service that uses every client feature the generator supports. +/// +/// Its endpoint rules read config, input, and operation values. Its operations +/// use SigV4, API key auth, optional auth, and no auth. +@service(sdkId: "Field Notes") +@sigv4(name: "fieldnotes") @rpcv2Cbor +@httpApiKeyAuth(name: "Authorization", in: "header", scheme: "ApiKey") @clientContextParams( Stage: { type: "string", documentation: "The deployment stage." } ForcePathStyle: { type: "boolean", documentation: "Forces path-style addressing." } @@ -159,14 +167,44 @@ use smithy.rules#staticContextParams } ] }) -service EndpointService { +service FieldNotes { version: "2026-11-20" - operations: [Ping, PutThing] + operations: [Echo, GetThing, Ping, PutNote, PutThing] } +/// Uses API key auth, but sends no key when it has none. +@auth([httpApiKeyAuth]) +@optionalAuth +operation Echo {} + +/// Uses API key auth. +@auth([httpApiKeyAuth]) +operation GetThing { + input := { + name: String + } + output := { + value: String + } +} + +/// Needs no auth. +@auth([]) @staticContextParams(Kind: { value: "ping" }) operation Ping {} +/// Saves a note, signed with SigV4. +operation PutNote { + input := { + text: String + } + output := { + id: String + } +} + +/// Needs no auth. +@auth([]) @staticContextParams(Kind: { value: "put" }) operation PutThing { input := { diff --git a/scripts/codegen-output-py/pyrightconfig.json b/scripts/codegen-output-py/pyrightconfig.json index 2edc0da59..7691bd305 100644 --- a/scripts/codegen-output-py/pyrightconfig.json +++ b/scripts/codegen-output-py/pyrightconfig.json @@ -8,13 +8,11 @@ "tests/_typecheck.py" ], "extraPaths": [ - "../../codegen-output-py/api-key-auth-client/src", - "../../codegen-output-py/aws-config-client/src", "../../codegen-output-py/aws-json-1-0/src", "../../codegen-output-py/aws-json-1-1/src", "../../codegen-output-py/aws-query/src", "../../codegen-output-py/ec2-query/src", - "../../codegen-output-py/endpoint-rules-client/src", + "../../codegen-output-py/features-client/src", "../../codegen-output-py/my-handwritten-json-model/src", "../../codegen-output-py/my-handwritten-model/src", "../../codegen-output-py/non-query-compatible-rpcv2-cbor/src", diff --git a/scripts/codegen-output-py/tests/test_client_snapshots.py b/scripts/codegen-output-py/tests/test_client_snapshots.py index 5a265edeb..aa2aeb0cd 100644 --- a/scripts/codegen-output-py/tests/test_client_snapshots.py +++ b/scripts/codegen-output-py/tests/test_client_snapshots.py @@ -139,8 +139,23 @@ def test_snapshot_client_round_trips_through_the_runtime( assert loads(body) == {"stringValue": "in", "integerValue": 3} -def test_generated_endpoint_tests_pass() -> None: - projection = _ROOT / "codegen-output-py/endpoint-rules-client" +@pytest.fixture +def aws_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> pytest.MonkeyPatch: + """An environment with only a region, credentials, and empty config files.""" + for name in list(os.environ): + if name.startswith("AWS_"): + monkeypatch.delenv(name) + monkeypatch.setenv("AWS_CONFIG_FILE", str(tmp_path / "config")) + monkeypatch.setenv("AWS_SHARED_CREDENTIALS_FILE", str(tmp_path / "credentials")) + # The base AWS config requires a region, and SigV4 requires credentials. + monkeypatch.setenv("AWS_REGION", "us-west-2") + monkeypatch.setenv("AWS_ACCESS_KEY_ID", "AKIDFROMENV") + monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret") + return monkeypatch + + +def test_generated_endpoint_tests_pass(aws_env: pytest.MonkeyPatch) -> None: + projection = _ROOT / "codegen-output-py/features-client" result = subprocess.run( [ sys.executable, @@ -164,9 +179,9 @@ def test_generated_endpoint_tests_pass() -> None: @pytest.fixture(scope="module") -def api_key_package() -> Iterator[ModuleType]: - source = _ROOT / "codegen-output-py/api-key-auth-client/src" - name = _PROJECTIONS["api-key-auth-client"]["package"] +def features() -> Iterator[ModuleType]: + source = _ROOT / "codegen-output-py/features-client/src" + name = _PROJECTIONS["features-client"]["package"] sys.path.insert(0, str(source)) try: yield importlib.import_module(name) @@ -177,114 +192,75 @@ def api_key_package() -> Iterator[ModuleType]: del sys.modules[module] -def _api_key_client(package: ModuleType, aio: bool, **config: Any) -> Any: - transport = (_AsyncTransport if aio else _Transport)(b"\xa0") - client = (package.AsyncApiKeyService if aio else package.ApiKeyService)( - (package.AsyncConfig if aio else package.Config)( - endpoint_uri="https://example.com", - transport=transport, - retry_strategy=SimpleRetryStrategy(max_attempts=1), - **config, - ) +def _client(package: ModuleType, aio: bool, **overrides: Any) -> Any: + # CBOR {"id": "n1"}. + transport = (_AsyncTransport if aio else _Transport)(b"\xa1\x62id\x62n1") + config_class = package.AsyncFieldNotesConfig if aio else package.FieldNotesConfig + config = config_class.resolve( + transport=transport, + retry_strategy=SimpleRetryStrategy(max_attempts=1), + **overrides, ) - return client, transport + if aio: + config = asyncio.run(config) + client = package.AsyncFieldNotesClient if aio else package.FieldNotesClient + return client(config), transport def _call(aio: bool, call: Any) -> Any: return asyncio.run(call) if aio else call +_ENDPOINT = "https://notes.example.com" + + @pytest.mark.parametrize("aio", [False, True]) def test_api_key_auth_signs_by_operation( - api_key_package: ModuleType, aio: bool + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch ) -> None: - client, transport = _api_key_client(api_key_package, aio, api_key="secret") + client, transport = _client(features, aio, endpoint_uri=_ENDPOINT, api_key="key") _call(aio, client.get_thing(name="a")) + _call(aio, client.echo()) _call(aio, client.ping()) - _call(aio, client.health()) - get_thing, ping, health = transport.requests - assert get_thing.fields["Authorization"].values == ["ApiKey secret"] - assert ping.fields["Authorization"].values == ["ApiKey secret"] + get_thing, echo, ping = transport.requests + assert get_thing.fields["Authorization"].values == ["ApiKey key"] + # @optionalAuth signs with the first supported scheme. + assert echo.fields["Authorization"].values == ["ApiKey key"] # @auth([]) leaves only noAuth, so the request is unsigned. - assert "Authorization" not in health.fields + assert "Authorization" not in ping.fields @pytest.mark.parametrize("aio", [False, True]) -def test_api_key_auth_requires_a_key(api_key_package: ModuleType, aio: bool) -> None: - client, transport = _api_key_client(api_key_package, aio) +def test_api_key_auth_requires_a_key( + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch +) -> None: + client, transport = _client(features, aio, endpoint_uri=_ENDPOINT) with pytest.raises(SmithyIdentityError, match="api_key was not set"): _call(aio, client.get_thing(name="a")) - _call(aio, client.health()) + _call(aio, client.ping()) assert len(transport.requests) == 1 -@pytest.fixture -def aws_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> pytest.MonkeyPatch: - """An environment with no AWS settings and empty shared config files.""" - for name in list(os.environ): - if name.startswith("AWS_"): - monkeypatch.delenv(name) - monkeypatch.setenv("AWS_CONFIG_FILE", str(tmp_path / "config")) - monkeypatch.setenv("AWS_SHARED_CREDENTIALS_FILE", str(tmp_path / "credentials")) - # The base AWS config requires a region. - monkeypatch.setenv("AWS_REGION", "us-west-2") - return monkeypatch - - -@pytest.fixture(scope="module") -def aws_package() -> Iterator[ModuleType]: - source = _ROOT / "codegen-output-py/aws-config-client/src" - name = _PROJECTIONS["aws-config-client"]["package"] - sys.path.insert(0, str(source)) - try: - yield importlib.import_module(name) - finally: - sys.path.remove(str(source)) - for module in tuple(sys.modules): - if module == name or module.startswith(name + "."): - del sys.modules[module] - - -def _aws_client(package: ModuleType, aio: bool, **overrides: Any) -> Any: - transport = (_AsyncTransport if aio else _Transport)(b"\xa1\x67summary\x63sun") - config_class = ( - package.AsyncWeatherStationConfig if aio else package.WeatherStationConfig - ) - config = config_class.resolve( - transport=transport, - retry_strategy=SimpleRetryStrategy(max_attempts=1), - **overrides, - ) - if aio: - config = asyncio.run(config) - client = package.AsyncWeatherStationClient if aio else package.WeatherStationClient - return client(config), transport - - @pytest.mark.parametrize("aio", [False, True]) def test_aws_config_resolves_the_endpoint_from_the_environment( - aws_package: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch ) -> None: - aws_env.setenv("AWS_ENDPOINT_URL_WEATHER_STATION", "https://weather.example.com") - client, transport = _aws_client(aws_package, aio, sdk_ua_app_id="forecaster") - output = _call(aio, client.get_forecast(city="Lisbon")) - assert output.summary == "sun" + aws_env.setenv("AWS_ENDPOINT_URL_FIELD_NOTES", _ENDPOINT) + client, transport = _client(features, aio, sdk_ua_app_id="jotter") + output = _call(aio, client.put_note(text="hi")) + assert output.id == "n1" (request,) = transport.requests - assert request.destination.host == "weather.example.com" + assert request.destination.host == "notes.example.com" user_agent = request.fields["User-Agent"].as_string() - assert "api/Weather_Station#0.0.1" in user_agent - assert "app/forecaster" in user_agent + assert "api/Field_Notes#0.0.1" in user_agent + assert "app/jotter" in user_agent @pytest.mark.parametrize("aio", [False, True]) def test_aws_config_rejects_unknown_fields( - aws_package: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch ) -> None: - config_class = ( - aws_package.AsyncWeatherStationConfig - if aio - else aws_package.WeatherStationConfig - ) + config_class = features.AsyncFieldNotesConfig if aio else features.FieldNotesConfig with pytest.raises(Exception, match="nope"): _call(aio, config_class.resolve(nope=1)) with pytest.raises(ConfigError, match="cannot be constructed directly"): @@ -292,7 +268,7 @@ def test_aws_config_rejects_unknown_fields( def test_aws_client_resolves_its_own_config( - aws_package: ModuleType, aws_env: pytest.MonkeyPatch + features: ModuleType, aws_env: pytest.MonkeyPatch ) -> None: (Path(os.environ["AWS_CONFIG_FILE"])).write_text( "[default]\nendpoint_url = https://profile.example.com\n" @@ -302,7 +278,36 @@ def test_aws_client_resolves_its_own_config( def use_transport(config: Any) -> None: config.transport = transport - client = aws_package.WeatherStationClient(plugins=[use_transport]) - client.get_forecast(city="Lisbon") + client = features.FieldNotesClient(plugins=[use_transport]) + client.put_note(text="hi") (request,) = transport.requests assert request.destination.host == "profile.example.com" + + +@pytest.mark.parametrize("aio", [False, True]) +def test_sigv4_signs_with_configured_credentials( + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch +) -> None: + client, transport = _client( + features, + aio, + endpoint_uri=_ENDPOINT, + aws_access_key_id="AKIDEXAMPLE", + aws_secret_access_key="secret", + ) + _call(aio, client.put_note(text="hi")) + (request,) = transport.requests + authorization = request.fields["Authorization"].as_string() + assert authorization.startswith("AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/") + assert "/us-west-2/fieldnotes/aws4_request" in authorization + + +@pytest.mark.parametrize("aio", [False, True]) +def test_sigv4_clients_default_to_the_credentials_chain( + features: ModuleType, aio: bool, aws_env: pytest.MonkeyPatch +) -> None: + client, transport = _client(features, aio, endpoint_uri=_ENDPOINT) + _call(aio, client.put_note(text="hi")) + (request,) = transport.requests + authorization = request.fields["Authorization"].as_string() + assert "Credential=AKIDFROMENV/" in authorization diff --git a/scripts/verifications/import-cost.json b/scripts/verifications/import-cost.json index fc8cf3def..ef63cd343 100644 --- a/scripts/verifications/import-cost.json +++ b/scripts/verifications/import-cost.json @@ -16,7 +16,7 @@ "smithy_json": 21, "smithy_json (all public modules)": 21, "smithy_python": 1, - "smithy_python (all public modules)": 31, + "smithy_python (all public modules)": 32, "smithy_test": 44, "smithy_test (all public modules)": 60, "smithy_xml": 20,