Skip to content
Merged
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
13 changes: 13 additions & 0 deletions codegen-output/my-handwritten-json-model/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Code generated by smithy-python-codegen DO NOT EDIT. -->

## My Handwritten JSON Model Client

my_handwritten_json_model client

### Documentation

The rpcv2Json counterpart of
smithy.python.tests.handwritten#MyHandwrittenModel, used to drive the
duplex event-stream integration test over rpcv2Json. Shapes are local
copies (not shared with the CBOR service) so each service's shape
closure, default namespace, and generated client stay independent.
71 changes: 71 additions & 0 deletions codegen-output/my-handwritten-json-model/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

[project]
name = "my_handwritten_json_model"
version = "0.0.1"
description = "my_handwritten_json_model client"
readme = "README.md"
requires-python = ">=3.12"
keywords = ["smithy", "my_handwritten_json_model"]
license = {text = "Apache-2.0"}
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15"
]

dependencies = [
"smithy_aws_core[eventstream]~=0.13.0",
"smithy_core~=0.10.0",
"smithy_http[json, aiohttp, urllib3]~=0.7.0"
]

[project.optional-dependencies]
awscrt = [
"smithy_http[awscrt]~=0.7.0"
]

[dependency-groups]
test = [
"pytest>=9.0.3,<10.0.0",
"pytest-asyncio>=1.3.0,<1.4.0",
"smithy_test~=0.2.0"
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.pyright]
typeCheckingMode = "strict"
reportPrivateUsage = false
reportUnusedFunction = false
reportUnusedVariable = false
reportUnnecessaryComparison = false
reportUnusedClass = false
enableExperimentalFeatures = true
# models.py is the dynamic runtime; models.pyi carries the typed
# surface for consumers, so don't type-check the implementation body.
exclude = ["**/models.py"]

[tool.ruff]
target-version = "py312"

[tool.ruff.lint]
ignore = ["F841"]

[tool.ruff.format]
skip-magic-trailing-comma = true

[tool.pytest.ini_options]
python_classes = ["!Test"]
asyncio_mode = "auto"
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

from importlib import import_module
from typing import Any, TYPE_CHECKING


if TYPE_CHECKING:
from .client import MyHandwrittenJsonModel
from .config import Config
from .aio.client import AsyncMyHandwrittenJsonModel
from .aio.config import AsyncConfig

__all__ = [
"MyHandwrittenJsonModel",
"Config",
"AsyncMyHandwrittenJsonModel",
"AsyncConfig",
]

_EXPORTS = {
"MyHandwrittenJsonModel": ".client",
"Config": ".config",
"AsyncMyHandwrittenJsonModel": ".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}")


__version__: str = "0.0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Code generated by smithy-python-codegen DO NOT EDIT.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

"""Endpoint BDD for smithy.python.tests.handwritten.json#MyHandwrittenJsonModel."""

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

from types import MappingProxyType

from smithy_core._schema_compact import StaticOperationSchema, StaticSchema


n0 = "smithy.python.tests.handwritten.json"
_A = "Alpha"
_i = "id"
_t = "timestamp"
_DSN = "DifferentShapeName"
_n = "name"
_nu = "number"
_IL = "IntegerList"
_m = "member"
_GP = "GammaPayload"
_me = "message"
_v = "values"
_G = "Gamma"
_sN = "sequenceNumber"
_sH = "smithy.api#eventHeader"
_p = "payload"
_sP = "smithy.api#eventPayload"
_SSE = "StreamServiceError"
_s = "smithy.api#error"
_se = "server"
_TE = "ThrottlingEvent"
_c = "client"
_TEr = "TradeEvents"
_sm = "smithy.api#streaming"
_a = "alpha"
_b = "beta"
_g = "gamma"
_d = "delta"
_th = "throttle"
_TESI = "TradeEventStreamInput"
_smi = "smithy.api#input"
_sI = "sessionId"
_e = "events"
_TESO = "TradeEventStreamOutput"
_smit = "smithy.api#output"
_gr = "greeting"
_TES = "TradeEventStream"
_MHJM = "MyHandwrittenJsonModel"
_sJ = "smithy.protocols#rpcv2Json"

ALPHA: StaticSchema = (18, n0, _A, 0, (_i, _t), ((3, 0), (4, 0)))

DIFFERENT_SHAPE_NAME: StaticSchema = (18, n0, _DSN, 0, (_n, _nu), ((3, 0), (7, 0)))

INTEGER_LIST: StaticSchema = (16, n0, _IL, 0, (_m,), ((7, 0),))

GAMMA_PAYLOAD: StaticSchema = (18, n0, _GP, 0, (_me, _v), ((3, 0), (INTEGER_LIST, 0)))

GAMMA: StaticSchema = (
18,
n0,
_G,
0,
(_sN, _p),
((7, {_sH: None}), (GAMMA_PAYLOAD, {_sP: None})),
)

STREAM_SERVICE_ERROR: StaticSchema = (18, n0, _SSE, {_s: _se}, (_me,), ((3, 0),))

THROTTLING_EVENT: StaticSchema = (18, n0, _TE, {_s: _c}, (_me,), ((3, 0),))

TRADE_EVENTS: StaticSchema = (
19,
n0,
_TEr,
{_sm: None},
(_a, _b, _g, _d, _th),
((ALPHA, 0), (-1, 0), (GAMMA, 0), (DIFFERENT_SHAPE_NAME, 0), (THROTTLING_EVENT, 0)),
)

TRADE_EVENT_STREAM_INPUT: StaticSchema = (
18,
n0,
_TESI,
{_smi: None},
(_sI, _e),
((3, 0), (TRADE_EVENTS, 0)),
)

TRADE_EVENT_STREAM_OUTPUT: StaticSchema = (
18,
n0,
_TESO,
{_smit: None},
(_gr, _e),
((3, 0), (TRADE_EVENTS, 0)),
)

TRADE_EVENT_STREAM: StaticOperationSchema = (
23,
n0,
_TES,
0,
TRADE_EVENT_STREAM_INPUT,
TRADE_EVENT_STREAM_OUTPUT,
(STREAM_SERVICE_ERROR,),
)

MY_HANDWRITTEN_JSON_MODEL: StaticSchema = (
21,
n0,
_MHJM,
{_sJ: MappingProxyType({"http": ("h2", "http/1.1"), "eventStreamHttp": ("h2",)})},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

from importlib import import_module
from typing import Any, TYPE_CHECKING


if TYPE_CHECKING:
from .client import AsyncMyHandwrittenJsonModel
from .config import AsyncConfig

__all__ = ["AsyncMyHandwrittenJsonModel", "AsyncConfig"]

_EXPORTS = {"AsyncMyHandwrittenJsonModel": ".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}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

import logging

from smithy_core.aio.client import AsyncClient
from smithy_core.aio.eventstream import AsyncDuplexEventStream
from smithy_http.plugins import user_agent_plugin

from .. import models as _models
from ..models import (
TradeEventStreamInput,
TradeEventStreamOutput,
TradeEvents,
_TradeEventsDeserializer,
)
from .config import AsyncConfig, Plugin
from .user_agent import aws_user_agent_plugin


logger = logging.getLogger(__name__)


class AsyncMyHandwrittenJsonModel(AsyncClient[AsyncConfig]):
"""
The rpcv2Json counterpart of
smithy.python.tests.handwritten#MyHandwrittenModel, used to drive the
duplex event-stream integration test over rpcv2Json. Shapes are local
copies (not shared with the CBOR service) so each service's shape
closure, default namespace, and generated client stay independent.
"""

_client_plugins = (aws_user_agent_plugin, user_agent_plugin)

async def trade_event_stream(
self, input: TradeEventStreamInput, plugins: list[Plugin] | None = None
) -> AsyncDuplexEventStream[TradeEvents, TradeEvents, TradeEventStreamOutput]:
"""
Bidirectional (duplex) stream. The non-stream members (sessionId,
greeting) are carried as the initial-request and initial-response
messages.

Args:
input:
An instance of `TradeEventStreamInput`.
plugins:
A list of callables that modify the configuration dynamically.
Changes made by these plugins only apply for the duration of the
operation execution and will not affect any other operation
invocations.

Returns:
An `AsyncDuplexEventStream` for bidirectional streaming.
"""
pipeline, call = await self._prepare_call(
input, _models.TRADE_EVENT_STREAM, [], plugins
)
return await pipeline.duplex_stream(
call, TradeEvents, TradeEvents, _TradeEventsDeserializer().deserialize
)

async def _new_config(self) -> AsyncConfig:
return AsyncConfig()
Loading
Loading