cliV1 0.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cliv1-0.0.7.dist-info/METADATA +212 -0
- cliv1-0.0.7.dist-info/RECORD +92 -0
- cliv1-0.0.7.dist-info/WHEEL +4 -0
- cliv1-0.0.7.dist-info/licenses/LICENSE +21 -0
- swagger_petstore_open_api_3_1_0/__init__.py +15 -0
- swagger_petstore_open_api_3_1_0/apis/__init__.py +5 -0
- swagger_petstore_open_api_3_1_0/apis/pet_api.py +922 -0
- swagger_petstore_open_api_3_1_0/apis/store.py +432 -0
- swagger_petstore_open_api_3_1_0/apis/user_api.py +829 -0
- swagger_petstore_open_api_3_1_0/async_client.py +87 -0
- swagger_petstore_open_api_3_1_0/auth.py +17 -0
- swagger_petstore_open_api_3_1_0/base_client.py +27 -0
- swagger_petstore_open_api_3_1_0/client.py +85 -0
- swagger_petstore_open_api_3_1_0/core/__init__.py +395 -0
- swagger_petstore_open_api_3_1_0/core/_internal/__init__.py +9 -0
- swagger_petstore_open_api_3_1_0/core/_internal/content_disposition.py +154 -0
- swagger_petstore_open_api_3_1_0/core/_internal/flattening.py +104 -0
- swagger_petstore_open_api_3_1_0/core/_internal/headers.py +243 -0
- swagger_petstore_open_api_3_1_0/core/_internal/redaction.py +208 -0
- swagger_petstore_open_api_3_1_0/core/_internal/sse_parser.py +124 -0
- swagger_petstore_open_api_3_1_0/core/_internal/subscripts.py +50 -0
- swagger_petstore_open_api_3_1_0/core/_internal/urls.py +172 -0
- swagger_petstore_open_api_3_1_0/core/_internal/wire.py +201 -0
- swagger_petstore_open_api_3_1_0/core/adapters.py +177 -0
- swagger_petstore_open_api_3_1_0/core/auth/__init__.py +70 -0
- swagger_petstore_open_api_3_1_0/core/auth/composition.py +175 -0
- swagger_petstore_open_api_3_1_0/core/auth/models.py +216 -0
- swagger_petstore_open_api_3_1_0/core/auth/protocols.py +103 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/__init__.py +94 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/api_key_auth.py +53 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/basic_auth.py +73 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/bearer_auth.py +21 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/oauth2_authorization_code.py +395 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/oauth2_client_credentials.py +130 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/oauth2_password.py +145 -0
- swagger_petstore_open_api_3_1_0/core/auth/schemes/oauth2_schemes.py +300 -0
- swagger_petstore_open_api_3_1_0/core/base_raw_response.py +49 -0
- swagger_petstore_open_api_3_1_0/core/bodies.py +590 -0
- swagger_petstore_open_api_3_1_0/core/converters/__init__.py +68 -0
- swagger_petstore_open_api_3_1_0/core/converters/date_time.py +237 -0
- swagger_petstore_open_api_3_1_0/core/converters/encoded_bytes.py +273 -0
- swagger_petstore_open_api_3_1_0/core/converters/open_enum.py +35 -0
- swagger_petstore_open_api_3_1_0/core/decoding.py +498 -0
- swagger_petstore_open_api_3_1_0/core/discriminators.py +129 -0
- swagger_petstore_open_api_3_1_0/core/event_streams.py +225 -0
- swagger_petstore_open_api_3_1_0/core/exceptions.py +78 -0
- swagger_petstore_open_api_3_1_0/core/file_responses.py +337 -0
- swagger_petstore_open_api_3_1_0/core/files.py +174 -0
- swagger_petstore_open_api_3_1_0/core/httpx2_transport.py +748 -0
- swagger_petstore_open_api_3_1_0/core/logging.py +472 -0
- swagger_petstore_open_api_3_1_0/core/models.py +143 -0
- swagger_petstore_open_api_3_1_0/core/optionality.py +144 -0
- swagger_petstore_open_api_3_1_0/core/pagination.py +452 -0
- swagger_petstore_open_api_3_1_0/core/paginator.py +55 -0
- swagger_petstore_open_api_3_1_0/core/params.py +157 -0
- swagger_petstore_open_api_3_1_0/core/raw_client.py +480 -0
- swagger_petstore_open_api_3_1_0/core/request_options.py +172 -0
- swagger_petstore_open_api_3_1_0/core/results.py +178 -0
- swagger_petstore_open_api_3_1_0/core/retries.py +237 -0
- swagger_petstore_open_api_3_1_0/core/runtime_env.py +43 -0
- swagger_petstore_open_api_3_1_0/core/servers.py +33 -0
- swagger_petstore_open_api_3_1_0/core/transport.py +218 -0
- swagger_petstore_open_api_3_1_0/errors/__init__.py +48 -0
- swagger_petstore_open_api_3_1_0/errors/add_pet_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/delete_order_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/delete_pet_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/delete_user_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/find_pets_by_status_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/find_pets_by_tags_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/get_order_by_id_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/get_pet_by_id_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/get_user_by_name_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/login_user_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/place_order_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/update_pet_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/update_pet_with_form_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/update_user_error.py +21 -0
- swagger_petstore_open_api_3_1_0/errors/upload_file_error.py +21 -0
- swagger_petstore_open_api_3_1_0/models/__init__.py +23 -0
- swagger_petstore_open_api_3_1_0/models/api_response.py +18 -0
- swagger_petstore_open_api_3_1_0/models/category.py +15 -0
- swagger_petstore_open_api_3_1_0/models/enums/__init__.py +4 -0
- swagger_petstore_open_api_3_1_0/models/enums/order_status.py +17 -0
- swagger_petstore_open_api_3_1_0/models/enums/pet_status.py +17 -0
- swagger_petstore_open_api_3_1_0/models/order.py +27 -0
- swagger_petstore_open_api_3_1_0/models/pet.py +28 -0
- swagger_petstore_open_api_3_1_0/models/tag_model.py +15 -0
- swagger_petstore_open_api_3_1_0/models/user.py +29 -0
- swagger_petstore_open_api_3_1_0/py.typed +0 -0
- swagger_petstore_open_api_3_1_0/server/__init__.py +21 -0
- swagger_petstore_open_api_3_1_0/server/server.py +17 -0
- swagger_petstore_open_api_3_1_0/server/server_config.py +52 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""What a caller may hand an endpoint as file input, and how a part describes itself.
|
|
2
|
+
|
|
3
|
+
A file never reaches the model layer. It is not validated by pydantic, not dumped through an
|
|
4
|
+
adapter, and not carried on ``SdkBaseModel`` -- which is why a file parameter names no declared
|
|
5
|
+
type in a subscript where every other parameter does: there is no adapter for it to name.
|
|
6
|
+
|
|
7
|
+
**One vocabulary, both destinations.** ``FileInput`` is what a raw request body and a multipart
|
|
8
|
+
part alike accept, and only the concurrency flavour tells it from ``AsyncFileInput``. Where a
|
|
9
|
+
destination cannot carry an arm natively it is adapted rather than refused, so nothing type-checks
|
|
10
|
+
here that does not reach the wire.
|
|
11
|
+
|
|
12
|
+
**Memory and ownership.** Every spelling below streams except ``bytes``, which the caller already
|
|
13
|
+
holds. A ``Path`` is opened by the transport on the send's ``ExitStack`` and read in 64 KiB chunks,
|
|
14
|
+
so the safest spelling is also the shortest one -- and the handle the transport opened is closed
|
|
15
|
+
when the send returns or raises, never later and never by a finalizer. A handle *you* open stays
|
|
16
|
+
yours: the SDK never closes a caller-supplied reader.
|
|
17
|
+
|
|
18
|
+
**Position, and single use.** A multipart part rewinds a seekable handle to 0 before reading it; a
|
|
19
|
+
raw body reads from wherever it sits. That is the underlying library's rule, and it is stated here
|
|
20
|
+
because it decides what happens to a handle you hand in mid-file. An iterable of chunks has no
|
|
21
|
+
position at all: it is consumed once, in either destination, and cannot be re-sent.
|
|
22
|
+
|
|
23
|
+
**The async multipart caveat, stated where it bites.** The shipped transport's HTTP library
|
|
24
|
+
encodes a multipart body from a synchronous chunk generator in both flavours
|
|
25
|
+
(``MultipartStream.__aiter__`` yields from ``iter_chunks``), so on the async client each 64 KiB
|
|
26
|
+
read of a *sync* arm is a blocking syscall on the loop thread. An *async* source cannot be pulled
|
|
27
|
+
from inside that generator at all, so one handed to a part is drained to a temp file first --
|
|
28
|
+
awaited natively, a chunk at a time, so it costs a write and not residency; the file lives on the
|
|
29
|
+
send's ``ExitStack`` and carries a real ``fileno``, which is what keeps the part sized and
|
|
30
|
+
re-sendable. **The chunk is 64 KiB for a reader, and your own for an iterable** -- an
|
|
31
|
+
``AsyncIterable``'s pieces are forwarded as you yield them, so a generator that yields its whole
|
|
32
|
+
payload in one ``bytes`` has already made it resident before the SDK sees it, where one that yields
|
|
33
|
+
windows never does. Nothing accumulates on top of that in either case. A raw binary body has
|
|
34
|
+
neither cost: every sync arm is adapted to an async stream reading through ``asyncio.to_thread``,
|
|
35
|
+
and the two async arms are consumed natively.
|
|
36
|
+
|
|
37
|
+
**If those bytes are a file on disk, hand over the ``Path`` and not an async handle.** This is the
|
|
38
|
+
one place in the file surface where the natural-looking spelling is the wrong one. A ``Path`` in a
|
|
39
|
+
multipart part is read once, straight to the socket. The same file behind an ``anyio`` handle is
|
|
40
|
+
read, written to the spill file, and read back -- two reads and a write to deliver bytes that were
|
|
41
|
+
already sitting on disk in the form the encoder wanted. The async arms are for content that has no
|
|
42
|
+
path: bytes arriving from another connection, a queue, a subprocess. Reach for them when there is
|
|
43
|
+
nothing to name, not when naming it is merely less convenient.
|
|
44
|
+
|
|
45
|
+
**And what the spill costs, since it is the one place the SDK writes to disk.** It is created by
|
|
46
|
+
``mkstemp`` -- mode 0600 on POSIX, the temp directory's own ACL on Windows -- and unlinked
|
|
47
|
+
immediately where the platform allows, so on POSIX it has no name for the whole of its life and is
|
|
48
|
+
reclaimed even if the process is killed. Three consequences a deployment may care about, none of
|
|
49
|
+
them hidden:
|
|
50
|
+
|
|
51
|
+
* the location is the standard one, so ``TMPDIR`` / ``TEMP`` redirects it -- and if that directory
|
|
52
|
+
is a **tmpfs**, the bytes are back in RAM, bounded page cache rather than bounded memory;
|
|
53
|
+
* it needs room. A payload larger than the temp filesystem, or a read-only one with nowhere to
|
|
54
|
+
write, raises ``OSError`` from the drain, where the same upload previously only risked memory;
|
|
55
|
+
* the payload is briefly at rest on disk. Unnamed and per-user, but on disk, which a policy that
|
|
56
|
+
forbids that will care about.
|
|
57
|
+
|
|
58
|
+
The time cost is smaller than it reads: the read-back comes from the page cache rather than the
|
|
59
|
+
platter (measured at memory speed), and past a few hundred MiB the drain is *faster* than the
|
|
60
|
+
``bytes`` it replaced, because allocating and copying a payload that size costs more than streaming
|
|
61
|
+
it through a file. None of this applies to any other arm -- nothing else here writes to disk."""
|
|
62
|
+
|
|
63
|
+
from __future__ import annotations
|
|
64
|
+
|
|
65
|
+
from collections.abc import AsyncIterable, Iterator
|
|
66
|
+
from dataclasses import dataclass
|
|
67
|
+
from pathlib import Path
|
|
68
|
+
from typing import Generic, Protocol, TypeAlias, runtime_checkable
|
|
69
|
+
|
|
70
|
+
# ``TypeVar`` from here and not ``typing``: PEP 696 defaults reach ``typing`` at 3.13, and
|
|
71
|
+
# ``ContentT_co`` below needs one at the 3.10 floor.
|
|
72
|
+
from typing_extensions import TypeVar
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@runtime_checkable
|
|
76
|
+
class BinaryReader(Protocol):
|
|
77
|
+
"""Anything with a binary ``read`` -- a file object, a ``SpooledTemporaryFile``, a ``GzipFile``.
|
|
78
|
+
|
|
79
|
+
Structural rather than a list of concrete classes, which is what lets every custom reader work
|
|
80
|
+
without being enumerated."""
|
|
81
|
+
|
|
82
|
+
def read(self, size: int = -1, /) -> bytes: ...
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@runtime_checkable
|
|
86
|
+
class AsyncBinaryReader(Protocol):
|
|
87
|
+
"""Anything with an awaitable binary ``read`` -- ``anyio.AsyncFile`` and kin.
|
|
88
|
+
|
|
89
|
+
Note for the transport, stated once here: ``isinstance`` cannot tell this protocol from
|
|
90
|
+
:class:`BinaryReader` -- ``runtime_checkable`` checks only that ``read`` exists -- so runtime
|
|
91
|
+
dispatch goes through a ``TypeIs`` guard on ``iscoroutinefunction``, never a class pattern."""
|
|
92
|
+
|
|
93
|
+
async def read(self, size: int = -1, /) -> bytes: ...
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
BinaryContent: TypeAlias = bytes | bytearray | Path | BinaryReader | Iterator[bytes]
|
|
97
|
+
"""Where an upload's bytes come from, on the sync client.
|
|
98
|
+
|
|
99
|
+
Deliberately no ``str`` arm: a bare string is unresolvably either a path or the content itself, and
|
|
100
|
+
the library this rides on reads it as the content. The iterator arm is the progress hook: a
|
|
101
|
+
generator that yields chunks may count them on the way past.
|
|
102
|
+
|
|
103
|
+
``Iterator`` rather than ``Iterable``, so that one file's content and a *list of files* are disjoint
|
|
104
|
+
types: a ``list[bytes]`` is only ever many files, and one file arriving in chunks says so by handing
|
|
105
|
+
over an iterator. That is what lets :func:`file_part`'s two overloads stand without overlapping, and
|
|
106
|
+
it costs a caller holding a chunk list one ``iter(...)`` -- refused statically, never silently
|
|
107
|
+
(ADR-0049)."""
|
|
108
|
+
|
|
109
|
+
AsyncBinaryContent: TypeAlias = BinaryContent | AsyncBinaryReader | AsyncIterable[bytes]
|
|
110
|
+
"""The same, plus the two arms only an async client can consume.
|
|
111
|
+
|
|
112
|
+
In a raw body every sync arm is adapted to an async stream that reads through ``asyncio.to_thread``,
|
|
113
|
+
so the leg streams *and* leaves the loop free, and the two async arms are consumed natively. In a
|
|
114
|
+
multipart part the two async arms are drained to a temp file first -- see the module docstring."""
|
|
115
|
+
|
|
116
|
+
ContentT_co = TypeVar("ContentT_co", bound=AsyncBinaryContent, default=BinaryContent, covariant=True)
|
|
117
|
+
"""Which content union a :class:`NamedFile` holds -- the flavour, carried on the wrapper.
|
|
118
|
+
|
|
119
|
+
Covariant, so wrapping content never narrows where it may go: a ``NamedFile(b"x")`` fits an async
|
|
120
|
+
signature as readily as a sync one. **Defaulted**, and that is what keeps the flavour fence -- an
|
|
121
|
+
unsubscripted ``NamedFile`` in an annotation would otherwise mean ``NamedFile[Any]``, through which
|
|
122
|
+
an async source would reach a sync client."""
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass(frozen=True, slots=True)
|
|
126
|
+
class NamedFile(Generic[ContentT_co]):
|
|
127
|
+
"""File content plus the two things a caller may want to override about how it is sent.
|
|
128
|
+
|
|
129
|
+
Pass bare content when the defaults are right -- the filename comes from a ``Path`` or from a
|
|
130
|
+
handle's own ``name``, at either destination, and the media type from the operation's declared
|
|
131
|
+
one. Name this only to override either.
|
|
132
|
+
|
|
133
|
+
Two, and deliberately not three: RFC 7578 §4.8 allows a form-data part only ``Content-Type``,
|
|
134
|
+
``Content-Disposition`` and a deprecated ``Content-Transfer-Encoding``, and both live ones are
|
|
135
|
+
owned already -- the media type by this class, the disposition by the resolved filename. A
|
|
136
|
+
``headers`` field could carry only fields a conforming receiver must ignore."""
|
|
137
|
+
|
|
138
|
+
content: ContentT_co
|
|
139
|
+
"""The bytes, however you hold them.
|
|
140
|
+
|
|
141
|
+
The flavour rides on the wrapper rather than being fixed here: a sync signature names
|
|
142
|
+
``NamedFile[BinaryContent]`` and an async one ``NamedFile[AsyncBinaryContent]``. So an async
|
|
143
|
+
source may carry an explicit filename on the async client, and still cannot reach a sync one."""
|
|
144
|
+
|
|
145
|
+
filename: str | None = None
|
|
146
|
+
"""The name this file is sent under.
|
|
147
|
+
|
|
148
|
+
Honoured at both destinations, and **derived** at both when left unset: a part is sent under it,
|
|
149
|
+
a raw body carries it as the whole request's ``Content-Disposition``.
|
|
150
|
+
|
|
151
|
+
Set it and it wins -- over a ``Path``'s own name and over a handle's ``.name`` alike, so wrapping
|
|
152
|
+
a named source renames it rather than being ignored. Leave it unset and the content's own name is
|
|
153
|
+
used, reduced to a basename so a directory never reaches the wire. A source that has no name at
|
|
154
|
+
all -- ``bytes``, a ``BytesIO``, a chunk iterator -- sends none rather than an invented one
|
|
155
|
+
(ADR-0053, amended)."""
|
|
156
|
+
|
|
157
|
+
media_type: str | None = None
|
|
158
|
+
"""Overrides the media type the operation declares, at either destination."""
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
FileInput: TypeAlias = BinaryContent | NamedFile[BinaryContent]
|
|
162
|
+
"""What every upload parameter accepts on the sync client.
|
|
163
|
+
|
|
164
|
+
A raw request body's and a multipart part's alike: the content, or the content with its media type
|
|
165
|
+
or filename overridden. One name at both destinations -- only the flavour distinguishes it from
|
|
166
|
+
:data:`AsyncFileInput`.
|
|
167
|
+
|
|
168
|
+
The wrapper's parameter is spelled rather than left to its default, so the two aliases below and
|
|
169
|
+
above read as the one pair they are."""
|
|
170
|
+
|
|
171
|
+
AsyncFileInput: TypeAlias = AsyncBinaryContent | NamedFile[AsyncBinaryContent]
|
|
172
|
+
"""What every upload parameter accepts on the async client.
|
|
173
|
+
|
|
174
|
+
The same one name at both destinations, over the wider content union."""
|