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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"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
}
5 changes: 5 additions & 0 deletions codegen-output-py/aws-config-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Code generated by smithy-python-codegen DO NOT EDIT. -->

## aws_config_client Client Package

Python client for the AWS config fixture
38 changes: 38 additions & 0 deletions codegen-output-py/aws-config-client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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
Original file line number Diff line number Diff line change
@@ -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 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}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Any, ClassVar, Self, Unpack

from smithy_aws_core.aio.config.aws_config import (
AsyncAwsConfig,
AsyncAwsConfigOverrides,
)
from smithy_aws_core.aio.config.filesystem import AsyncFileSystem
from smithy_aws_core.config.resolvers import EndpointUriResolver
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.auth import DefaultAuthResolver
from smithy_core.endpoints import BddEndpointResolver
from smithy_core.interceptors import Interceptor
from smithy_core.interfaces import (
ClientProtocol,
EndpointResolver,
ProtocolConstructor,
ProtocolSettings,
)
from smithy_core.interfaces.auth import AuthSchemeResolver
from smithy_core.shapes import ShapeID
from smithy_http.aio.aiohttp import AIOHTTPClient
from smithy_http.aio.protocols import AsyncRpcV2CborClientProtocol

from aws_config_client._private.endpoints import BDD
from aws_config_client._private.schemas import WEATHER_STATION

_PROTOCOL_SETTINGS = ProtocolSettings(
namespace="example.awsconfig",
service_target="WeatherStation",
version="2026-11-19",
service_schema=WEATHER_STATION,
)


class _AsyncWeatherStationConfigOverrides(AsyncAwsConfigOverrides, total=False):
"Explicit field values AsyncWeatherStationConfig.resolve accepts."

endpoint_resolver: EndpointResolver | AsyncEndpointResolver | None
protocol: (
ClientProtocol[Any, Any] | ProtocolConstructor[ClientProtocol[Any, Any]] | None
)
auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None
auth_scheme_resolver: AuthSchemeResolver | None


@dataclass(kw_only=True, repr=False, init=False)
class AsyncWeatherStationConfig(AsyncAwsConfig):
"Configuration for AsyncWeatherStationClient."

interceptors: list[Interceptor[Any, Any, Any, Any]] = field(
default_factory=list[Interceptor[Any, Any, Any, Any]]
)
"Hooks called during the execution of a request."

endpoint_resolver: EndpointResolver | AsyncEndpointResolver | None = None
"Resolves the endpoint of each operation."

protocol: ClientProtocol[Any, Any] | None = None
"Serializes requests and deserializes responses."

auth_schemes: dict[ShapeID, AsyncAuthScheme[Any, Any, Any, Any]] | None = None
"Auth schemes by auth scheme ID."

auth_scheme_resolver: AuthSchemeResolver | None = None
"Determines the auth scheme for each operation."

_FIELDS: ClassVar[dict[str, FieldSpec]] = {
**AsyncAwsConfig._FIELDS,
"endpoint_uri": FieldSpec(
default=None, resolver=EndpointUriResolver("weather_station").program
),
"endpoint_resolver": FieldSpec(
default_factory=lambda: BddEndpointResolver(BDD)
),
"protocol": FieldSpec(
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_scheme_resolver": FieldSpec(default_factory=DefaultAuthResolver),
"transport": FieldSpec(default_factory=lambda: AIOHTTPClient()),
}

@classmethod
async def resolve( # pyright: ignore[reportIncompatibleMethodOverride]
cls,
*,
profile: str | None = None,
fs: AsyncFileSystem | None = None,
config_file_path: str | None = None,
credentials_file_path: str | None = None,
**overrides: Unpack[_AsyncWeatherStationConfigOverrides],
) -> Self:
"Resolve the config from overrides, the environment, and config files."
return await cls._resolve(
profile=profile,
fs=fs,
config_file_path=config_file_path,
credentials_file_path=credentials_file_path,
overrides=overrides,
)


type Plugin = Callable[[AsyncWeatherStationConfig], None]
"A callable that customizes the client configuration."
Original file line number Diff line number Diff line change
@@ -0,0 +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


def aws_user_agent_plugin(config: AsyncWeatherStationConfig) -> 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",
)
)
Loading
Loading