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