codeset 0.4.4__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.
- codeset/__init__.py +92 -0
- codeset/_base_client.py +2001 -0
- codeset/_client.py +572 -0
- codeset/_compat.py +219 -0
- codeset/_constants.py +14 -0
- codeset/_exceptions.py +108 -0
- codeset/_files.py +123 -0
- codeset/_models.py +857 -0
- codeset/_qs.py +150 -0
- codeset/_resource.py +43 -0
- codeset/_response.py +830 -0
- codeset/_streaming.py +333 -0
- codeset/_types.py +261 -0
- codeset/_utils/__init__.py +66 -0
- codeset/_utils/_compat.py +45 -0
- codeset/_utils/_datetime_parse.py +136 -0
- codeset/_utils/_logs.py +25 -0
- codeset/_utils/_proxy.py +65 -0
- codeset/_utils/_reflection.py +42 -0
- codeset/_utils/_resources_proxy.py +24 -0
- codeset/_utils/_streams.py +12 -0
- codeset/_utils/_sync.py +58 -0
- codeset/_utils/_transform.py +457 -0
- codeset/_utils/_typing.py +156 -0
- codeset/_utils/_utils.py +474 -0
- codeset/_version.py +4 -0
- codeset/lib/.keep +4 -0
- codeset/py.typed +0 -0
- codeset/resources/__init__.py +61 -0
- codeset/resources/datasets.py +135 -0
- codeset/resources/health.py +135 -0
- codeset/resources/samples.py +303 -0
- codeset/resources/sessions/__init__.py +33 -0
- codeset/resources/sessions/sessions.py +891 -0
- codeset/resources/sessions/verify.py +335 -0
- codeset/types/__init__.py +22 -0
- codeset/types/container_info.py +32 -0
- codeset/types/dataset_list_response.py +28 -0
- codeset/types/error_info.py +15 -0
- codeset/types/health_check_response.py +21 -0
- codeset/types/interaction.py +37 -0
- codeset/types/interaction_status.py +7 -0
- codeset/types/sample_download_params.py +14 -0
- codeset/types/sample_list_params.py +22 -0
- codeset/types/sample_list_response.py +95 -0
- codeset/types/session.py +48 -0
- codeset/types/session_close_response.py +15 -0
- codeset/types/session_create_params.py +18 -0
- codeset/types/session_create_response.py +21 -0
- codeset/types/session_execute_command_params.py +15 -0
- codeset/types/session_execute_command_response.py +15 -0
- codeset/types/session_list_response.py +20 -0
- codeset/types/session_status.py +7 -0
- codeset/types/session_str_replace_params.py +18 -0
- codeset/types/session_str_replace_response.py +15 -0
- codeset/types/sessions/__init__.py +7 -0
- codeset/types/sessions/job_status.py +7 -0
- codeset/types/sessions/verify_start_response.py +21 -0
- codeset/types/sessions/verify_status_response.py +79 -0
- codeset-0.4.4.dist-info/METADATA +399 -0
- codeset-0.4.4.dist-info/RECORD +63 -0
- codeset-0.4.4.dist-info/WHEEL +4 -0
- codeset-0.4.4.dist-info/licenses/LICENSE +201 -0
codeset/_client.py
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Mapping
|
|
7
|
+
from typing_extensions import Self, override
|
|
8
|
+
|
|
9
|
+
import httpx
|
|
10
|
+
|
|
11
|
+
from . import _exceptions
|
|
12
|
+
from ._qs import Querystring
|
|
13
|
+
from ._types import (
|
|
14
|
+
Omit,
|
|
15
|
+
Headers,
|
|
16
|
+
Timeout,
|
|
17
|
+
NotGiven,
|
|
18
|
+
Transport,
|
|
19
|
+
ProxiesTypes,
|
|
20
|
+
RequestOptions,
|
|
21
|
+
not_given,
|
|
22
|
+
)
|
|
23
|
+
from ._utils import is_given, get_async_library
|
|
24
|
+
from ._compat import cached_property
|
|
25
|
+
from ._version import __version__
|
|
26
|
+
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
27
|
+
from ._exceptions import APIStatusError
|
|
28
|
+
from ._base_client import (
|
|
29
|
+
DEFAULT_MAX_RETRIES,
|
|
30
|
+
SyncAPIClient,
|
|
31
|
+
AsyncAPIClient,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if TYPE_CHECKING:
|
|
35
|
+
from .resources import health, samples, datasets, sessions
|
|
36
|
+
from .resources.health import HealthResource, AsyncHealthResource
|
|
37
|
+
from .resources.samples import SamplesResource, AsyncSamplesResource
|
|
38
|
+
from .resources.datasets import DatasetsResource, AsyncDatasetsResource
|
|
39
|
+
from .resources.sessions.sessions import SessionsResource, AsyncSessionsResource
|
|
40
|
+
|
|
41
|
+
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Codeset", "AsyncCodeset", "Client", "AsyncClient"]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Codeset(SyncAPIClient):
|
|
45
|
+
# client options
|
|
46
|
+
api_key: str | None
|
|
47
|
+
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
*,
|
|
51
|
+
api_key: str | None = None,
|
|
52
|
+
base_url: str | httpx.URL | None = None,
|
|
53
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
54
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
55
|
+
default_headers: Mapping[str, str] | None = None,
|
|
56
|
+
default_query: Mapping[str, object] | None = None,
|
|
57
|
+
# Configure a custom httpx client.
|
|
58
|
+
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
|
59
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
|
|
60
|
+
http_client: httpx.Client | None = None,
|
|
61
|
+
# Enable or disable schema validation for data returned by the API.
|
|
62
|
+
# When enabled an error APIResponseValidationError is raised
|
|
63
|
+
# if the API responds with invalid data for the expected schema.
|
|
64
|
+
#
|
|
65
|
+
# This parameter may be removed or changed in the future.
|
|
66
|
+
# If you rely on this feature, please open a GitHub issue
|
|
67
|
+
# outlining your use-case to help us decide if it should be
|
|
68
|
+
# part of our public interface in the future.
|
|
69
|
+
_strict_response_validation: bool = False,
|
|
70
|
+
) -> None:
|
|
71
|
+
"""Construct a new synchronous Codeset client instance.
|
|
72
|
+
|
|
73
|
+
This automatically infers the `api_key` argument from the `CODESET_API_KEY` environment variable if it is not provided.
|
|
74
|
+
"""
|
|
75
|
+
if api_key is None:
|
|
76
|
+
api_key = os.environ.get("CODESET_API_KEY")
|
|
77
|
+
self.api_key = api_key
|
|
78
|
+
|
|
79
|
+
if base_url is None:
|
|
80
|
+
base_url = os.environ.get("CODESET_BASE_URL")
|
|
81
|
+
if base_url is None:
|
|
82
|
+
base_url = f"https://api.codeset.ai/api/v1/"
|
|
83
|
+
|
|
84
|
+
super().__init__(
|
|
85
|
+
version=__version__,
|
|
86
|
+
base_url=base_url,
|
|
87
|
+
max_retries=max_retries,
|
|
88
|
+
timeout=timeout,
|
|
89
|
+
http_client=http_client,
|
|
90
|
+
custom_headers=default_headers,
|
|
91
|
+
custom_query=default_query,
|
|
92
|
+
_strict_response_validation=_strict_response_validation,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
@cached_property
|
|
96
|
+
def health(self) -> HealthResource:
|
|
97
|
+
from .resources.health import HealthResource
|
|
98
|
+
|
|
99
|
+
return HealthResource(self)
|
|
100
|
+
|
|
101
|
+
@cached_property
|
|
102
|
+
def samples(self) -> SamplesResource:
|
|
103
|
+
from .resources.samples import SamplesResource
|
|
104
|
+
|
|
105
|
+
return SamplesResource(self)
|
|
106
|
+
|
|
107
|
+
@cached_property
|
|
108
|
+
def datasets(self) -> DatasetsResource:
|
|
109
|
+
from .resources.datasets import DatasetsResource
|
|
110
|
+
|
|
111
|
+
return DatasetsResource(self)
|
|
112
|
+
|
|
113
|
+
@cached_property
|
|
114
|
+
def sessions(self) -> SessionsResource:
|
|
115
|
+
from .resources.sessions import SessionsResource
|
|
116
|
+
|
|
117
|
+
return SessionsResource(self)
|
|
118
|
+
|
|
119
|
+
@cached_property
|
|
120
|
+
def with_raw_response(self) -> CodesetWithRawResponse:
|
|
121
|
+
return CodesetWithRawResponse(self)
|
|
122
|
+
|
|
123
|
+
@cached_property
|
|
124
|
+
def with_streaming_response(self) -> CodesetWithStreamedResponse:
|
|
125
|
+
return CodesetWithStreamedResponse(self)
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
@override
|
|
129
|
+
def qs(self) -> Querystring:
|
|
130
|
+
return Querystring(array_format="comma")
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
@override
|
|
134
|
+
def auth_headers(self) -> dict[str, str]:
|
|
135
|
+
api_key = self.api_key
|
|
136
|
+
if api_key is None:
|
|
137
|
+
return {}
|
|
138
|
+
return {"Authorization": f"Bearer {api_key}"}
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
@override
|
|
142
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
|
143
|
+
return {
|
|
144
|
+
**super().default_headers,
|
|
145
|
+
"X-Stainless-Async": "false",
|
|
146
|
+
**self._custom_headers,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@override
|
|
150
|
+
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
|
|
151
|
+
if self.api_key and headers.get("Authorization"):
|
|
152
|
+
return
|
|
153
|
+
if isinstance(custom_headers.get("Authorization"), Omit):
|
|
154
|
+
return
|
|
155
|
+
|
|
156
|
+
raise TypeError(
|
|
157
|
+
'"Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"'
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
def copy(
|
|
161
|
+
self,
|
|
162
|
+
*,
|
|
163
|
+
api_key: str | None = None,
|
|
164
|
+
base_url: str | httpx.URL | None = None,
|
|
165
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
166
|
+
http_client: httpx.Client | None = None,
|
|
167
|
+
max_retries: int | NotGiven = not_given,
|
|
168
|
+
default_headers: Mapping[str, str] | None = None,
|
|
169
|
+
set_default_headers: Mapping[str, str] | None = None,
|
|
170
|
+
default_query: Mapping[str, object] | None = None,
|
|
171
|
+
set_default_query: Mapping[str, object] | None = None,
|
|
172
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
|
173
|
+
) -> Self:
|
|
174
|
+
"""
|
|
175
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
176
|
+
"""
|
|
177
|
+
if default_headers is not None and set_default_headers is not None:
|
|
178
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
|
179
|
+
|
|
180
|
+
if default_query is not None and set_default_query is not None:
|
|
181
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
|
182
|
+
|
|
183
|
+
headers = self._custom_headers
|
|
184
|
+
if default_headers is not None:
|
|
185
|
+
headers = {**headers, **default_headers}
|
|
186
|
+
elif set_default_headers is not None:
|
|
187
|
+
headers = set_default_headers
|
|
188
|
+
|
|
189
|
+
params = self._custom_query
|
|
190
|
+
if default_query is not None:
|
|
191
|
+
params = {**params, **default_query}
|
|
192
|
+
elif set_default_query is not None:
|
|
193
|
+
params = set_default_query
|
|
194
|
+
|
|
195
|
+
http_client = http_client or self._client
|
|
196
|
+
return self.__class__(
|
|
197
|
+
api_key=api_key or self.api_key,
|
|
198
|
+
base_url=base_url or self.base_url,
|
|
199
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
200
|
+
http_client=http_client,
|
|
201
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
|
202
|
+
default_headers=headers,
|
|
203
|
+
default_query=params,
|
|
204
|
+
**_extra_kwargs,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
|
208
|
+
# client.with_options(timeout=10).foo.create(...)
|
|
209
|
+
with_options = copy
|
|
210
|
+
|
|
211
|
+
@override
|
|
212
|
+
def _make_status_error(
|
|
213
|
+
self,
|
|
214
|
+
err_msg: str,
|
|
215
|
+
*,
|
|
216
|
+
body: object,
|
|
217
|
+
response: httpx.Response,
|
|
218
|
+
) -> APIStatusError:
|
|
219
|
+
if response.status_code == 400:
|
|
220
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
|
221
|
+
|
|
222
|
+
if response.status_code == 401:
|
|
223
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
|
224
|
+
|
|
225
|
+
if response.status_code == 403:
|
|
226
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
|
227
|
+
|
|
228
|
+
if response.status_code == 404:
|
|
229
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
|
230
|
+
|
|
231
|
+
if response.status_code == 409:
|
|
232
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
|
233
|
+
|
|
234
|
+
if response.status_code == 422:
|
|
235
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
|
236
|
+
|
|
237
|
+
if response.status_code == 429:
|
|
238
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
|
239
|
+
|
|
240
|
+
if response.status_code >= 500:
|
|
241
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
|
242
|
+
return APIStatusError(err_msg, response=response, body=body)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class AsyncCodeset(AsyncAPIClient):
|
|
246
|
+
# client options
|
|
247
|
+
api_key: str | None
|
|
248
|
+
|
|
249
|
+
def __init__(
|
|
250
|
+
self,
|
|
251
|
+
*,
|
|
252
|
+
api_key: str | None = None,
|
|
253
|
+
base_url: str | httpx.URL | None = None,
|
|
254
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
255
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
256
|
+
default_headers: Mapping[str, str] | None = None,
|
|
257
|
+
default_query: Mapping[str, object] | None = None,
|
|
258
|
+
# Configure a custom httpx client.
|
|
259
|
+
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
|
260
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
|
|
261
|
+
http_client: httpx.AsyncClient | None = None,
|
|
262
|
+
# Enable or disable schema validation for data returned by the API.
|
|
263
|
+
# When enabled an error APIResponseValidationError is raised
|
|
264
|
+
# if the API responds with invalid data for the expected schema.
|
|
265
|
+
#
|
|
266
|
+
# This parameter may be removed or changed in the future.
|
|
267
|
+
# If you rely on this feature, please open a GitHub issue
|
|
268
|
+
# outlining your use-case to help us decide if it should be
|
|
269
|
+
# part of our public interface in the future.
|
|
270
|
+
_strict_response_validation: bool = False,
|
|
271
|
+
) -> None:
|
|
272
|
+
"""Construct a new async AsyncCodeset client instance.
|
|
273
|
+
|
|
274
|
+
This automatically infers the `api_key` argument from the `CODESET_API_KEY` environment variable if it is not provided.
|
|
275
|
+
"""
|
|
276
|
+
if api_key is None:
|
|
277
|
+
api_key = os.environ.get("CODESET_API_KEY")
|
|
278
|
+
self.api_key = api_key
|
|
279
|
+
|
|
280
|
+
if base_url is None:
|
|
281
|
+
base_url = os.environ.get("CODESET_BASE_URL")
|
|
282
|
+
if base_url is None:
|
|
283
|
+
base_url = f"https://api.codeset.ai/api/v1/"
|
|
284
|
+
|
|
285
|
+
super().__init__(
|
|
286
|
+
version=__version__,
|
|
287
|
+
base_url=base_url,
|
|
288
|
+
max_retries=max_retries,
|
|
289
|
+
timeout=timeout,
|
|
290
|
+
http_client=http_client,
|
|
291
|
+
custom_headers=default_headers,
|
|
292
|
+
custom_query=default_query,
|
|
293
|
+
_strict_response_validation=_strict_response_validation,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
@cached_property
|
|
297
|
+
def health(self) -> AsyncHealthResource:
|
|
298
|
+
from .resources.health import AsyncHealthResource
|
|
299
|
+
|
|
300
|
+
return AsyncHealthResource(self)
|
|
301
|
+
|
|
302
|
+
@cached_property
|
|
303
|
+
def samples(self) -> AsyncSamplesResource:
|
|
304
|
+
from .resources.samples import AsyncSamplesResource
|
|
305
|
+
|
|
306
|
+
return AsyncSamplesResource(self)
|
|
307
|
+
|
|
308
|
+
@cached_property
|
|
309
|
+
def datasets(self) -> AsyncDatasetsResource:
|
|
310
|
+
from .resources.datasets import AsyncDatasetsResource
|
|
311
|
+
|
|
312
|
+
return AsyncDatasetsResource(self)
|
|
313
|
+
|
|
314
|
+
@cached_property
|
|
315
|
+
def sessions(self) -> AsyncSessionsResource:
|
|
316
|
+
from .resources.sessions import AsyncSessionsResource
|
|
317
|
+
|
|
318
|
+
return AsyncSessionsResource(self)
|
|
319
|
+
|
|
320
|
+
@cached_property
|
|
321
|
+
def with_raw_response(self) -> AsyncCodesetWithRawResponse:
|
|
322
|
+
return AsyncCodesetWithRawResponse(self)
|
|
323
|
+
|
|
324
|
+
@cached_property
|
|
325
|
+
def with_streaming_response(self) -> AsyncCodesetWithStreamedResponse:
|
|
326
|
+
return AsyncCodesetWithStreamedResponse(self)
|
|
327
|
+
|
|
328
|
+
@property
|
|
329
|
+
@override
|
|
330
|
+
def qs(self) -> Querystring:
|
|
331
|
+
return Querystring(array_format="comma")
|
|
332
|
+
|
|
333
|
+
@property
|
|
334
|
+
@override
|
|
335
|
+
def auth_headers(self) -> dict[str, str]:
|
|
336
|
+
api_key = self.api_key
|
|
337
|
+
if api_key is None:
|
|
338
|
+
return {}
|
|
339
|
+
return {"Authorization": f"Bearer {api_key}"}
|
|
340
|
+
|
|
341
|
+
@property
|
|
342
|
+
@override
|
|
343
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
|
344
|
+
return {
|
|
345
|
+
**super().default_headers,
|
|
346
|
+
"X-Stainless-Async": f"async:{get_async_library()}",
|
|
347
|
+
**self._custom_headers,
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@override
|
|
351
|
+
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
|
|
352
|
+
if self.api_key and headers.get("Authorization"):
|
|
353
|
+
return
|
|
354
|
+
if isinstance(custom_headers.get("Authorization"), Omit):
|
|
355
|
+
return
|
|
356
|
+
|
|
357
|
+
raise TypeError(
|
|
358
|
+
'"Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"'
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
def copy(
|
|
362
|
+
self,
|
|
363
|
+
*,
|
|
364
|
+
api_key: str | None = None,
|
|
365
|
+
base_url: str | httpx.URL | None = None,
|
|
366
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
367
|
+
http_client: httpx.AsyncClient | None = None,
|
|
368
|
+
max_retries: int | NotGiven = not_given,
|
|
369
|
+
default_headers: Mapping[str, str] | None = None,
|
|
370
|
+
set_default_headers: Mapping[str, str] | None = None,
|
|
371
|
+
default_query: Mapping[str, object] | None = None,
|
|
372
|
+
set_default_query: Mapping[str, object] | None = None,
|
|
373
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
|
374
|
+
) -> Self:
|
|
375
|
+
"""
|
|
376
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
377
|
+
"""
|
|
378
|
+
if default_headers is not None and set_default_headers is not None:
|
|
379
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
|
380
|
+
|
|
381
|
+
if default_query is not None and set_default_query is not None:
|
|
382
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
|
383
|
+
|
|
384
|
+
headers = self._custom_headers
|
|
385
|
+
if default_headers is not None:
|
|
386
|
+
headers = {**headers, **default_headers}
|
|
387
|
+
elif set_default_headers is not None:
|
|
388
|
+
headers = set_default_headers
|
|
389
|
+
|
|
390
|
+
params = self._custom_query
|
|
391
|
+
if default_query is not None:
|
|
392
|
+
params = {**params, **default_query}
|
|
393
|
+
elif set_default_query is not None:
|
|
394
|
+
params = set_default_query
|
|
395
|
+
|
|
396
|
+
http_client = http_client or self._client
|
|
397
|
+
return self.__class__(
|
|
398
|
+
api_key=api_key or self.api_key,
|
|
399
|
+
base_url=base_url or self.base_url,
|
|
400
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
401
|
+
http_client=http_client,
|
|
402
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
|
403
|
+
default_headers=headers,
|
|
404
|
+
default_query=params,
|
|
405
|
+
**_extra_kwargs,
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
|
409
|
+
# client.with_options(timeout=10).foo.create(...)
|
|
410
|
+
with_options = copy
|
|
411
|
+
|
|
412
|
+
@override
|
|
413
|
+
def _make_status_error(
|
|
414
|
+
self,
|
|
415
|
+
err_msg: str,
|
|
416
|
+
*,
|
|
417
|
+
body: object,
|
|
418
|
+
response: httpx.Response,
|
|
419
|
+
) -> APIStatusError:
|
|
420
|
+
if response.status_code == 400:
|
|
421
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
|
422
|
+
|
|
423
|
+
if response.status_code == 401:
|
|
424
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
|
425
|
+
|
|
426
|
+
if response.status_code == 403:
|
|
427
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
|
428
|
+
|
|
429
|
+
if response.status_code == 404:
|
|
430
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
|
431
|
+
|
|
432
|
+
if response.status_code == 409:
|
|
433
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
|
434
|
+
|
|
435
|
+
if response.status_code == 422:
|
|
436
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
|
437
|
+
|
|
438
|
+
if response.status_code == 429:
|
|
439
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
|
440
|
+
|
|
441
|
+
if response.status_code >= 500:
|
|
442
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
|
443
|
+
return APIStatusError(err_msg, response=response, body=body)
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class CodesetWithRawResponse:
|
|
447
|
+
_client: Codeset
|
|
448
|
+
|
|
449
|
+
def __init__(self, client: Codeset) -> None:
|
|
450
|
+
self._client = client
|
|
451
|
+
|
|
452
|
+
@cached_property
|
|
453
|
+
def health(self) -> health.HealthResourceWithRawResponse:
|
|
454
|
+
from .resources.health import HealthResourceWithRawResponse
|
|
455
|
+
|
|
456
|
+
return HealthResourceWithRawResponse(self._client.health)
|
|
457
|
+
|
|
458
|
+
@cached_property
|
|
459
|
+
def samples(self) -> samples.SamplesResourceWithRawResponse:
|
|
460
|
+
from .resources.samples import SamplesResourceWithRawResponse
|
|
461
|
+
|
|
462
|
+
return SamplesResourceWithRawResponse(self._client.samples)
|
|
463
|
+
|
|
464
|
+
@cached_property
|
|
465
|
+
def datasets(self) -> datasets.DatasetsResourceWithRawResponse:
|
|
466
|
+
from .resources.datasets import DatasetsResourceWithRawResponse
|
|
467
|
+
|
|
468
|
+
return DatasetsResourceWithRawResponse(self._client.datasets)
|
|
469
|
+
|
|
470
|
+
@cached_property
|
|
471
|
+
def sessions(self) -> sessions.SessionsResourceWithRawResponse:
|
|
472
|
+
from .resources.sessions import SessionsResourceWithRawResponse
|
|
473
|
+
|
|
474
|
+
return SessionsResourceWithRawResponse(self._client.sessions)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
class AsyncCodesetWithRawResponse:
|
|
478
|
+
_client: AsyncCodeset
|
|
479
|
+
|
|
480
|
+
def __init__(self, client: AsyncCodeset) -> None:
|
|
481
|
+
self._client = client
|
|
482
|
+
|
|
483
|
+
@cached_property
|
|
484
|
+
def health(self) -> health.AsyncHealthResourceWithRawResponse:
|
|
485
|
+
from .resources.health import AsyncHealthResourceWithRawResponse
|
|
486
|
+
|
|
487
|
+
return AsyncHealthResourceWithRawResponse(self._client.health)
|
|
488
|
+
|
|
489
|
+
@cached_property
|
|
490
|
+
def samples(self) -> samples.AsyncSamplesResourceWithRawResponse:
|
|
491
|
+
from .resources.samples import AsyncSamplesResourceWithRawResponse
|
|
492
|
+
|
|
493
|
+
return AsyncSamplesResourceWithRawResponse(self._client.samples)
|
|
494
|
+
|
|
495
|
+
@cached_property
|
|
496
|
+
def datasets(self) -> datasets.AsyncDatasetsResourceWithRawResponse:
|
|
497
|
+
from .resources.datasets import AsyncDatasetsResourceWithRawResponse
|
|
498
|
+
|
|
499
|
+
return AsyncDatasetsResourceWithRawResponse(self._client.datasets)
|
|
500
|
+
|
|
501
|
+
@cached_property
|
|
502
|
+
def sessions(self) -> sessions.AsyncSessionsResourceWithRawResponse:
|
|
503
|
+
from .resources.sessions import AsyncSessionsResourceWithRawResponse
|
|
504
|
+
|
|
505
|
+
return AsyncSessionsResourceWithRawResponse(self._client.sessions)
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
class CodesetWithStreamedResponse:
|
|
509
|
+
_client: Codeset
|
|
510
|
+
|
|
511
|
+
def __init__(self, client: Codeset) -> None:
|
|
512
|
+
self._client = client
|
|
513
|
+
|
|
514
|
+
@cached_property
|
|
515
|
+
def health(self) -> health.HealthResourceWithStreamingResponse:
|
|
516
|
+
from .resources.health import HealthResourceWithStreamingResponse
|
|
517
|
+
|
|
518
|
+
return HealthResourceWithStreamingResponse(self._client.health)
|
|
519
|
+
|
|
520
|
+
@cached_property
|
|
521
|
+
def samples(self) -> samples.SamplesResourceWithStreamingResponse:
|
|
522
|
+
from .resources.samples import SamplesResourceWithStreamingResponse
|
|
523
|
+
|
|
524
|
+
return SamplesResourceWithStreamingResponse(self._client.samples)
|
|
525
|
+
|
|
526
|
+
@cached_property
|
|
527
|
+
def datasets(self) -> datasets.DatasetsResourceWithStreamingResponse:
|
|
528
|
+
from .resources.datasets import DatasetsResourceWithStreamingResponse
|
|
529
|
+
|
|
530
|
+
return DatasetsResourceWithStreamingResponse(self._client.datasets)
|
|
531
|
+
|
|
532
|
+
@cached_property
|
|
533
|
+
def sessions(self) -> sessions.SessionsResourceWithStreamingResponse:
|
|
534
|
+
from .resources.sessions import SessionsResourceWithStreamingResponse
|
|
535
|
+
|
|
536
|
+
return SessionsResourceWithStreamingResponse(self._client.sessions)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
class AsyncCodesetWithStreamedResponse:
|
|
540
|
+
_client: AsyncCodeset
|
|
541
|
+
|
|
542
|
+
def __init__(self, client: AsyncCodeset) -> None:
|
|
543
|
+
self._client = client
|
|
544
|
+
|
|
545
|
+
@cached_property
|
|
546
|
+
def health(self) -> health.AsyncHealthResourceWithStreamingResponse:
|
|
547
|
+
from .resources.health import AsyncHealthResourceWithStreamingResponse
|
|
548
|
+
|
|
549
|
+
return AsyncHealthResourceWithStreamingResponse(self._client.health)
|
|
550
|
+
|
|
551
|
+
@cached_property
|
|
552
|
+
def samples(self) -> samples.AsyncSamplesResourceWithStreamingResponse:
|
|
553
|
+
from .resources.samples import AsyncSamplesResourceWithStreamingResponse
|
|
554
|
+
|
|
555
|
+
return AsyncSamplesResourceWithStreamingResponse(self._client.samples)
|
|
556
|
+
|
|
557
|
+
@cached_property
|
|
558
|
+
def datasets(self) -> datasets.AsyncDatasetsResourceWithStreamingResponse:
|
|
559
|
+
from .resources.datasets import AsyncDatasetsResourceWithStreamingResponse
|
|
560
|
+
|
|
561
|
+
return AsyncDatasetsResourceWithStreamingResponse(self._client.datasets)
|
|
562
|
+
|
|
563
|
+
@cached_property
|
|
564
|
+
def sessions(self) -> sessions.AsyncSessionsResourceWithStreamingResponse:
|
|
565
|
+
from .resources.sessions import AsyncSessionsResourceWithStreamingResponse
|
|
566
|
+
|
|
567
|
+
return AsyncSessionsResourceWithStreamingResponse(self._client.sessions)
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
Client = Codeset
|
|
571
|
+
|
|
572
|
+
AsyncClient = AsyncCodeset
|