chunkify-sdk 0.6.2__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 (102) hide show
  1. chunkify/__init__.py +104 -0
  2. chunkify/_base_client.py +2001 -0
  3. chunkify/_client.py +836 -0
  4. chunkify/_compat.py +219 -0
  5. chunkify/_constants.py +14 -0
  6. chunkify/_exceptions.py +112 -0
  7. chunkify/_files.py +123 -0
  8. chunkify/_models.py +857 -0
  9. chunkify/_qs.py +150 -0
  10. chunkify/_resource.py +43 -0
  11. chunkify/_response.py +830 -0
  12. chunkify/_streaming.py +333 -0
  13. chunkify/_types.py +261 -0
  14. chunkify/_utils/__init__.py +64 -0
  15. chunkify/_utils/_compat.py +45 -0
  16. chunkify/_utils/_datetime_parse.py +136 -0
  17. chunkify/_utils/_logs.py +25 -0
  18. chunkify/_utils/_proxy.py +65 -0
  19. chunkify/_utils/_reflection.py +42 -0
  20. chunkify/_utils/_resources_proxy.py +24 -0
  21. chunkify/_utils/_streams.py +12 -0
  22. chunkify/_utils/_sync.py +58 -0
  23. chunkify/_utils/_transform.py +457 -0
  24. chunkify/_utils/_typing.py +156 -0
  25. chunkify/_utils/_utils.py +421 -0
  26. chunkify/_version.py +4 -0
  27. chunkify/_wrappers.py +17 -0
  28. chunkify/lib/.keep +4 -0
  29. chunkify/pagination.py +72 -0
  30. chunkify/py.typed +0 -0
  31. chunkify/resources/__init__.py +131 -0
  32. chunkify/resources/files.py +439 -0
  33. chunkify/resources/jobs/__init__.py +61 -0
  34. chunkify/resources/jobs/files.py +163 -0
  35. chunkify/resources/jobs/jobs.py +746 -0
  36. chunkify/resources/jobs/logs.py +199 -0
  37. chunkify/resources/jobs/transcoders.py +163 -0
  38. chunkify/resources/notifications.py +524 -0
  39. chunkify/resources/projects.py +513 -0
  40. chunkify/resources/sources.py +546 -0
  41. chunkify/resources/storages.py +421 -0
  42. chunkify/resources/tokens.py +354 -0
  43. chunkify/resources/uploads.py +510 -0
  44. chunkify/resources/webhooks.py +630 -0
  45. chunkify/types/__init__.py +51 -0
  46. chunkify/types/api_file.py +57 -0
  47. chunkify/types/file_list_params.py +132 -0
  48. chunkify/types/hls_av1.py +192 -0
  49. chunkify/types/hls_av1_param.py +189 -0
  50. chunkify/types/hls_h264.py +202 -0
  51. chunkify/types/hls_h264_param.py +199 -0
  52. chunkify/types/hls_h265.py +198 -0
  53. chunkify/types/hls_h265_param.py +195 -0
  54. chunkify/types/job.py +169 -0
  55. chunkify/types/job_create_params.py +91 -0
  56. chunkify/types/job_list_params.py +49 -0
  57. chunkify/types/jobs/__init__.py +8 -0
  58. chunkify/types/jobs/file_list_response.py +18 -0
  59. chunkify/types/jobs/log_list_params.py +15 -0
  60. chunkify/types/jobs/log_list_response.py +38 -0
  61. chunkify/types/jobs/transcoder_list_response.py +70 -0
  62. chunkify/types/jpg.py +42 -0
  63. chunkify/types/jpg_param.py +41 -0
  64. chunkify/types/mp4_av1.py +157 -0
  65. chunkify/types/mp4_av1_param.py +154 -0
  66. chunkify/types/mp4_h264.py +167 -0
  67. chunkify/types/mp4_h264_param.py +164 -0
  68. chunkify/types/mp4_h265.py +163 -0
  69. chunkify/types/mp4_h265_param.py +160 -0
  70. chunkify/types/new_event_webhook_event.py +73 -0
  71. chunkify/types/notification.py +35 -0
  72. chunkify/types/notification_create_params.py +20 -0
  73. chunkify/types/notification_list_params.py +53 -0
  74. chunkify/types/project.py +24 -0
  75. chunkify/types/project_create_params.py +12 -0
  76. chunkify/types/project_list_response.py +19 -0
  77. chunkify/types/project_update_params.py +15 -0
  78. chunkify/types/shared/__init__.py +3 -0
  79. chunkify/types/shared/chunkify_error.py +30 -0
  80. chunkify/types/source.py +52 -0
  81. chunkify/types/source_create_params.py +19 -0
  82. chunkify/types/source_list_params.py +122 -0
  83. chunkify/types/storage.py +102 -0
  84. chunkify/types/storage_create_params.py +113 -0
  85. chunkify/types/storage_list_response.py +19 -0
  86. chunkify/types/token.py +28 -0
  87. chunkify/types/token_create_params.py +21 -0
  88. chunkify/types/token_list_response.py +22 -0
  89. chunkify/types/unwrap_webhook_event.py +73 -0
  90. chunkify/types/upload.py +39 -0
  91. chunkify/types/upload_create_params.py +19 -0
  92. chunkify/types/upload_list_params.py +43 -0
  93. chunkify/types/webhook.py +27 -0
  94. chunkify/types/webhook_create_params.py +24 -0
  95. chunkify/types/webhook_list_response.py +19 -0
  96. chunkify/types/webhook_update_params.py +18 -0
  97. chunkify/types/webm_vp9.py +142 -0
  98. chunkify/types/webm_vp9_param.py +139 -0
  99. chunkify_sdk-0.6.2.dist-info/METADATA +529 -0
  100. chunkify_sdk-0.6.2.dist-info/RECORD +102 -0
  101. chunkify_sdk-0.6.2.dist-info/WHEEL +4 -0
  102. chunkify_sdk-0.6.2.dist-info/licenses/LICENSE +201 -0
chunkify/_client.py ADDED
@@ -0,0 +1,836 @@
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 jobs, files, tokens, sources, uploads, projects, storages, webhooks, notifications
36
+ from .resources.files import FilesResource, AsyncFilesResource
37
+ from .resources.tokens import TokensResource, AsyncTokensResource
38
+ from .resources.sources import SourcesResource, AsyncSourcesResource
39
+ from .resources.uploads import UploadsResource, AsyncUploadsResource
40
+ from .resources.projects import ProjectsResource, AsyncProjectsResource
41
+ from .resources.storages import StoragesResource, AsyncStoragesResource
42
+ from .resources.webhooks import WebhooksResource, AsyncWebhooksResource
43
+ from .resources.jobs.jobs import JobsResource, AsyncJobsResource
44
+ from .resources.notifications import NotificationsResource, AsyncNotificationsResource
45
+
46
+ __all__ = [
47
+ "Timeout",
48
+ "Transport",
49
+ "ProxiesTypes",
50
+ "RequestOptions",
51
+ "Chunkify",
52
+ "AsyncChunkify",
53
+ "Client",
54
+ "AsyncClient",
55
+ ]
56
+
57
+
58
+ class Chunkify(SyncAPIClient):
59
+ # client options
60
+ project_access_token: str | None
61
+ team_access_token: str | None
62
+ webhook_key: str | None
63
+
64
+ def __init__(
65
+ self,
66
+ *,
67
+ project_access_token: str | None = None,
68
+ team_access_token: str | None = None,
69
+ webhook_key: str | None = None,
70
+ base_url: str | httpx.URL | None = None,
71
+ timeout: float | Timeout | None | NotGiven = not_given,
72
+ max_retries: int = DEFAULT_MAX_RETRIES,
73
+ default_headers: Mapping[str, str] | None = None,
74
+ default_query: Mapping[str, object] | None = None,
75
+ # Configure a custom httpx client.
76
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
77
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
78
+ http_client: httpx.Client | None = None,
79
+ # Enable or disable schema validation for data returned by the API.
80
+ # When enabled an error APIResponseValidationError is raised
81
+ # if the API responds with invalid data for the expected schema.
82
+ #
83
+ # This parameter may be removed or changed in the future.
84
+ # If you rely on this feature, please open a GitHub issue
85
+ # outlining your use-case to help us decide if it should be
86
+ # part of our public interface in the future.
87
+ _strict_response_validation: bool = False,
88
+ ) -> None:
89
+ """Construct a new synchronous Chunkify client instance.
90
+
91
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
92
+ - `project_access_token` from `CHUNKIFY_TOKEN`
93
+ - `team_access_token` from `CHUNKIFY_TEAM_TOKEN`
94
+ - `webhook_key` from `CHUNKIFY_WEBHOOK_SECRET`
95
+ """
96
+ if project_access_token is None:
97
+ project_access_token = os.environ.get("CHUNKIFY_TOKEN")
98
+ self.project_access_token = project_access_token
99
+
100
+ if team_access_token is None:
101
+ team_access_token = os.environ.get("CHUNKIFY_TEAM_TOKEN")
102
+ self.team_access_token = team_access_token
103
+
104
+ if webhook_key is None:
105
+ webhook_key = os.environ.get("CHUNKIFY_WEBHOOK_SECRET")
106
+ self.webhook_key = webhook_key
107
+
108
+ if base_url is None:
109
+ base_url = os.environ.get("CHUNKIFY_BASE_URL")
110
+ if base_url is None:
111
+ base_url = f"https://api.chunkify.dev/v1"
112
+
113
+ super().__init__(
114
+ version=__version__,
115
+ base_url=base_url,
116
+ max_retries=max_retries,
117
+ timeout=timeout,
118
+ http_client=http_client,
119
+ custom_headers=default_headers,
120
+ custom_query=default_query,
121
+ _strict_response_validation=_strict_response_validation,
122
+ )
123
+
124
+ @cached_property
125
+ def files(self) -> FilesResource:
126
+ from .resources.files import FilesResource
127
+
128
+ return FilesResource(self)
129
+
130
+ @cached_property
131
+ def jobs(self) -> JobsResource:
132
+ from .resources.jobs import JobsResource
133
+
134
+ return JobsResource(self)
135
+
136
+ @cached_property
137
+ def notifications(self) -> NotificationsResource:
138
+ from .resources.notifications import NotificationsResource
139
+
140
+ return NotificationsResource(self)
141
+
142
+ @cached_property
143
+ def projects(self) -> ProjectsResource:
144
+ from .resources.projects import ProjectsResource
145
+
146
+ return ProjectsResource(self)
147
+
148
+ @cached_property
149
+ def sources(self) -> SourcesResource:
150
+ from .resources.sources import SourcesResource
151
+
152
+ return SourcesResource(self)
153
+
154
+ @cached_property
155
+ def storages(self) -> StoragesResource:
156
+ from .resources.storages import StoragesResource
157
+
158
+ return StoragesResource(self)
159
+
160
+ @cached_property
161
+ def tokens(self) -> TokensResource:
162
+ from .resources.tokens import TokensResource
163
+
164
+ return TokensResource(self)
165
+
166
+ @cached_property
167
+ def uploads(self) -> UploadsResource:
168
+ from .resources.uploads import UploadsResource
169
+
170
+ return UploadsResource(self)
171
+
172
+ @cached_property
173
+ def webhooks(self) -> WebhooksResource:
174
+ from .resources.webhooks import WebhooksResource
175
+
176
+ return WebhooksResource(self)
177
+
178
+ @cached_property
179
+ def with_raw_response(self) -> ChunkifyWithRawResponse:
180
+ return ChunkifyWithRawResponse(self)
181
+
182
+ @cached_property
183
+ def with_streaming_response(self) -> ChunkifyWithStreamedResponse:
184
+ return ChunkifyWithStreamedResponse(self)
185
+
186
+ @property
187
+ @override
188
+ def qs(self) -> Querystring:
189
+ return Querystring(array_format="repeat")
190
+
191
+ @property
192
+ @override
193
+ def auth_headers(self) -> dict[str, str]:
194
+ return {**self._project_access_token, **self._team_access_token}
195
+
196
+ @property
197
+ def _project_access_token(self) -> dict[str, str]:
198
+ project_access_token = self.project_access_token
199
+ if project_access_token is None:
200
+ return {}
201
+ return {"Authorization": f"Bearer {project_access_token}"}
202
+
203
+ @property
204
+ def _team_access_token(self) -> dict[str, str]:
205
+ team_access_token = self.team_access_token
206
+ if team_access_token is None:
207
+ return {}
208
+ return {"Authorization": f"Bearer {team_access_token}"}
209
+
210
+ @property
211
+ @override
212
+ def default_headers(self) -> dict[str, str | Omit]:
213
+ return {
214
+ **super().default_headers,
215
+ "X-Stainless-Async": "false",
216
+ **self._custom_headers,
217
+ }
218
+
219
+ @override
220
+ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
221
+ if self.project_access_token and headers.get("Authorization"):
222
+ return
223
+ if isinstance(custom_headers.get("Authorization"), Omit):
224
+ return
225
+
226
+ if self.team_access_token and headers.get("Authorization"):
227
+ return
228
+ if isinstance(custom_headers.get("Authorization"), Omit):
229
+ return
230
+
231
+ raise TypeError(
232
+ '"Could not resolve authentication method. Expected either project_access_token or team_access_token to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
233
+ )
234
+
235
+ def copy(
236
+ self,
237
+ *,
238
+ project_access_token: str | None = None,
239
+ team_access_token: str | None = None,
240
+ webhook_key: str | None = None,
241
+ base_url: str | httpx.URL | None = None,
242
+ timeout: float | Timeout | None | NotGiven = not_given,
243
+ http_client: httpx.Client | None = None,
244
+ max_retries: int | NotGiven = not_given,
245
+ default_headers: Mapping[str, str] | None = None,
246
+ set_default_headers: Mapping[str, str] | None = None,
247
+ default_query: Mapping[str, object] | None = None,
248
+ set_default_query: Mapping[str, object] | None = None,
249
+ _extra_kwargs: Mapping[str, Any] = {},
250
+ ) -> Self:
251
+ """
252
+ Create a new client instance re-using the same options given to the current client with optional overriding.
253
+ """
254
+ if default_headers is not None and set_default_headers is not None:
255
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
256
+
257
+ if default_query is not None and set_default_query is not None:
258
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
259
+
260
+ headers = self._custom_headers
261
+ if default_headers is not None:
262
+ headers = {**headers, **default_headers}
263
+ elif set_default_headers is not None:
264
+ headers = set_default_headers
265
+
266
+ params = self._custom_query
267
+ if default_query is not None:
268
+ params = {**params, **default_query}
269
+ elif set_default_query is not None:
270
+ params = set_default_query
271
+
272
+ http_client = http_client or self._client
273
+ return self.__class__(
274
+ project_access_token=project_access_token or self.project_access_token,
275
+ team_access_token=team_access_token or self.team_access_token,
276
+ webhook_key=webhook_key or self.webhook_key,
277
+ base_url=base_url or self.base_url,
278
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
279
+ http_client=http_client,
280
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
281
+ default_headers=headers,
282
+ default_query=params,
283
+ **_extra_kwargs,
284
+ )
285
+
286
+ # Alias for `copy` for nicer inline usage, e.g.
287
+ # client.with_options(timeout=10).foo.create(...)
288
+ with_options = copy
289
+
290
+ @override
291
+ def _make_status_error(
292
+ self,
293
+ err_msg: str,
294
+ *,
295
+ body: object,
296
+ response: httpx.Response,
297
+ ) -> APIStatusError:
298
+ if response.status_code == 400:
299
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
300
+
301
+ if response.status_code == 401:
302
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
303
+
304
+ if response.status_code == 403:
305
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
306
+
307
+ if response.status_code == 404:
308
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
309
+
310
+ if response.status_code == 409:
311
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
312
+
313
+ if response.status_code == 422:
314
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
315
+
316
+ if response.status_code == 429:
317
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
318
+
319
+ if response.status_code >= 500:
320
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
321
+ return APIStatusError(err_msg, response=response, body=body)
322
+
323
+
324
+ class AsyncChunkify(AsyncAPIClient):
325
+ # client options
326
+ project_access_token: str | None
327
+ team_access_token: str | None
328
+ webhook_key: str | None
329
+
330
+ def __init__(
331
+ self,
332
+ *,
333
+ project_access_token: str | None = None,
334
+ team_access_token: str | None = None,
335
+ webhook_key: str | None = None,
336
+ base_url: str | httpx.URL | None = None,
337
+ timeout: float | Timeout | None | NotGiven = not_given,
338
+ max_retries: int = DEFAULT_MAX_RETRIES,
339
+ default_headers: Mapping[str, str] | None = None,
340
+ default_query: Mapping[str, object] | None = None,
341
+ # Configure a custom httpx client.
342
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
343
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
344
+ http_client: httpx.AsyncClient | None = None,
345
+ # Enable or disable schema validation for data returned by the API.
346
+ # When enabled an error APIResponseValidationError is raised
347
+ # if the API responds with invalid data for the expected schema.
348
+ #
349
+ # This parameter may be removed or changed in the future.
350
+ # If you rely on this feature, please open a GitHub issue
351
+ # outlining your use-case to help us decide if it should be
352
+ # part of our public interface in the future.
353
+ _strict_response_validation: bool = False,
354
+ ) -> None:
355
+ """Construct a new async AsyncChunkify client instance.
356
+
357
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
358
+ - `project_access_token` from `CHUNKIFY_TOKEN`
359
+ - `team_access_token` from `CHUNKIFY_TEAM_TOKEN`
360
+ - `webhook_key` from `CHUNKIFY_WEBHOOK_SECRET`
361
+ """
362
+ if project_access_token is None:
363
+ project_access_token = os.environ.get("CHUNKIFY_TOKEN")
364
+ self.project_access_token = project_access_token
365
+
366
+ if team_access_token is None:
367
+ team_access_token = os.environ.get("CHUNKIFY_TEAM_TOKEN")
368
+ self.team_access_token = team_access_token
369
+
370
+ if webhook_key is None:
371
+ webhook_key = os.environ.get("CHUNKIFY_WEBHOOK_SECRET")
372
+ self.webhook_key = webhook_key
373
+
374
+ if base_url is None:
375
+ base_url = os.environ.get("CHUNKIFY_BASE_URL")
376
+ if base_url is None:
377
+ base_url = f"https://api.chunkify.dev/v1"
378
+
379
+ super().__init__(
380
+ version=__version__,
381
+ base_url=base_url,
382
+ max_retries=max_retries,
383
+ timeout=timeout,
384
+ http_client=http_client,
385
+ custom_headers=default_headers,
386
+ custom_query=default_query,
387
+ _strict_response_validation=_strict_response_validation,
388
+ )
389
+
390
+ @cached_property
391
+ def files(self) -> AsyncFilesResource:
392
+ from .resources.files import AsyncFilesResource
393
+
394
+ return AsyncFilesResource(self)
395
+
396
+ @cached_property
397
+ def jobs(self) -> AsyncJobsResource:
398
+ from .resources.jobs import AsyncJobsResource
399
+
400
+ return AsyncJobsResource(self)
401
+
402
+ @cached_property
403
+ def notifications(self) -> AsyncNotificationsResource:
404
+ from .resources.notifications import AsyncNotificationsResource
405
+
406
+ return AsyncNotificationsResource(self)
407
+
408
+ @cached_property
409
+ def projects(self) -> AsyncProjectsResource:
410
+ from .resources.projects import AsyncProjectsResource
411
+
412
+ return AsyncProjectsResource(self)
413
+
414
+ @cached_property
415
+ def sources(self) -> AsyncSourcesResource:
416
+ from .resources.sources import AsyncSourcesResource
417
+
418
+ return AsyncSourcesResource(self)
419
+
420
+ @cached_property
421
+ def storages(self) -> AsyncStoragesResource:
422
+ from .resources.storages import AsyncStoragesResource
423
+
424
+ return AsyncStoragesResource(self)
425
+
426
+ @cached_property
427
+ def tokens(self) -> AsyncTokensResource:
428
+ from .resources.tokens import AsyncTokensResource
429
+
430
+ return AsyncTokensResource(self)
431
+
432
+ @cached_property
433
+ def uploads(self) -> AsyncUploadsResource:
434
+ from .resources.uploads import AsyncUploadsResource
435
+
436
+ return AsyncUploadsResource(self)
437
+
438
+ @cached_property
439
+ def webhooks(self) -> AsyncWebhooksResource:
440
+ from .resources.webhooks import AsyncWebhooksResource
441
+
442
+ return AsyncWebhooksResource(self)
443
+
444
+ @cached_property
445
+ def with_raw_response(self) -> AsyncChunkifyWithRawResponse:
446
+ return AsyncChunkifyWithRawResponse(self)
447
+
448
+ @cached_property
449
+ def with_streaming_response(self) -> AsyncChunkifyWithStreamedResponse:
450
+ return AsyncChunkifyWithStreamedResponse(self)
451
+
452
+ @property
453
+ @override
454
+ def qs(self) -> Querystring:
455
+ return Querystring(array_format="repeat")
456
+
457
+ @property
458
+ @override
459
+ def auth_headers(self) -> dict[str, str]:
460
+ return {**self._project_access_token, **self._team_access_token}
461
+
462
+ @property
463
+ def _project_access_token(self) -> dict[str, str]:
464
+ project_access_token = self.project_access_token
465
+ if project_access_token is None:
466
+ return {}
467
+ return {"Authorization": f"Bearer {project_access_token}"}
468
+
469
+ @property
470
+ def _team_access_token(self) -> dict[str, str]:
471
+ team_access_token = self.team_access_token
472
+ if team_access_token is None:
473
+ return {}
474
+ return {"Authorization": f"Bearer {team_access_token}"}
475
+
476
+ @property
477
+ @override
478
+ def default_headers(self) -> dict[str, str | Omit]:
479
+ return {
480
+ **super().default_headers,
481
+ "X-Stainless-Async": f"async:{get_async_library()}",
482
+ **self._custom_headers,
483
+ }
484
+
485
+ @override
486
+ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
487
+ if self.project_access_token and headers.get("Authorization"):
488
+ return
489
+ if isinstance(custom_headers.get("Authorization"), Omit):
490
+ return
491
+
492
+ if self.team_access_token and headers.get("Authorization"):
493
+ return
494
+ if isinstance(custom_headers.get("Authorization"), Omit):
495
+ return
496
+
497
+ raise TypeError(
498
+ '"Could not resolve authentication method. Expected either project_access_token or team_access_token to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
499
+ )
500
+
501
+ def copy(
502
+ self,
503
+ *,
504
+ project_access_token: str | None = None,
505
+ team_access_token: str | None = None,
506
+ webhook_key: str | None = None,
507
+ base_url: str | httpx.URL | None = None,
508
+ timeout: float | Timeout | None | NotGiven = not_given,
509
+ http_client: httpx.AsyncClient | None = None,
510
+ max_retries: int | NotGiven = not_given,
511
+ default_headers: Mapping[str, str] | None = None,
512
+ set_default_headers: Mapping[str, str] | None = None,
513
+ default_query: Mapping[str, object] | None = None,
514
+ set_default_query: Mapping[str, object] | None = None,
515
+ _extra_kwargs: Mapping[str, Any] = {},
516
+ ) -> Self:
517
+ """
518
+ Create a new client instance re-using the same options given to the current client with optional overriding.
519
+ """
520
+ if default_headers is not None and set_default_headers is not None:
521
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
522
+
523
+ if default_query is not None and set_default_query is not None:
524
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
525
+
526
+ headers = self._custom_headers
527
+ if default_headers is not None:
528
+ headers = {**headers, **default_headers}
529
+ elif set_default_headers is not None:
530
+ headers = set_default_headers
531
+
532
+ params = self._custom_query
533
+ if default_query is not None:
534
+ params = {**params, **default_query}
535
+ elif set_default_query is not None:
536
+ params = set_default_query
537
+
538
+ http_client = http_client or self._client
539
+ return self.__class__(
540
+ project_access_token=project_access_token or self.project_access_token,
541
+ team_access_token=team_access_token or self.team_access_token,
542
+ webhook_key=webhook_key or self.webhook_key,
543
+ base_url=base_url or self.base_url,
544
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
545
+ http_client=http_client,
546
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
547
+ default_headers=headers,
548
+ default_query=params,
549
+ **_extra_kwargs,
550
+ )
551
+
552
+ # Alias for `copy` for nicer inline usage, e.g.
553
+ # client.with_options(timeout=10).foo.create(...)
554
+ with_options = copy
555
+
556
+ @override
557
+ def _make_status_error(
558
+ self,
559
+ err_msg: str,
560
+ *,
561
+ body: object,
562
+ response: httpx.Response,
563
+ ) -> APIStatusError:
564
+ if response.status_code == 400:
565
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
566
+
567
+ if response.status_code == 401:
568
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
569
+
570
+ if response.status_code == 403:
571
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
572
+
573
+ if response.status_code == 404:
574
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
575
+
576
+ if response.status_code == 409:
577
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
578
+
579
+ if response.status_code == 422:
580
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
581
+
582
+ if response.status_code == 429:
583
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
584
+
585
+ if response.status_code >= 500:
586
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
587
+ return APIStatusError(err_msg, response=response, body=body)
588
+
589
+
590
+ class ChunkifyWithRawResponse:
591
+ _client: Chunkify
592
+
593
+ def __init__(self, client: Chunkify) -> None:
594
+ self._client = client
595
+
596
+ @cached_property
597
+ def files(self) -> files.FilesResourceWithRawResponse:
598
+ from .resources.files import FilesResourceWithRawResponse
599
+
600
+ return FilesResourceWithRawResponse(self._client.files)
601
+
602
+ @cached_property
603
+ def jobs(self) -> jobs.JobsResourceWithRawResponse:
604
+ from .resources.jobs import JobsResourceWithRawResponse
605
+
606
+ return JobsResourceWithRawResponse(self._client.jobs)
607
+
608
+ @cached_property
609
+ def notifications(self) -> notifications.NotificationsResourceWithRawResponse:
610
+ from .resources.notifications import NotificationsResourceWithRawResponse
611
+
612
+ return NotificationsResourceWithRawResponse(self._client.notifications)
613
+
614
+ @cached_property
615
+ def projects(self) -> projects.ProjectsResourceWithRawResponse:
616
+ from .resources.projects import ProjectsResourceWithRawResponse
617
+
618
+ return ProjectsResourceWithRawResponse(self._client.projects)
619
+
620
+ @cached_property
621
+ def sources(self) -> sources.SourcesResourceWithRawResponse:
622
+ from .resources.sources import SourcesResourceWithRawResponse
623
+
624
+ return SourcesResourceWithRawResponse(self._client.sources)
625
+
626
+ @cached_property
627
+ def storages(self) -> storages.StoragesResourceWithRawResponse:
628
+ from .resources.storages import StoragesResourceWithRawResponse
629
+
630
+ return StoragesResourceWithRawResponse(self._client.storages)
631
+
632
+ @cached_property
633
+ def tokens(self) -> tokens.TokensResourceWithRawResponse:
634
+ from .resources.tokens import TokensResourceWithRawResponse
635
+
636
+ return TokensResourceWithRawResponse(self._client.tokens)
637
+
638
+ @cached_property
639
+ def uploads(self) -> uploads.UploadsResourceWithRawResponse:
640
+ from .resources.uploads import UploadsResourceWithRawResponse
641
+
642
+ return UploadsResourceWithRawResponse(self._client.uploads)
643
+
644
+ @cached_property
645
+ def webhooks(self) -> webhooks.WebhooksResourceWithRawResponse:
646
+ from .resources.webhooks import WebhooksResourceWithRawResponse
647
+
648
+ return WebhooksResourceWithRawResponse(self._client.webhooks)
649
+
650
+
651
+ class AsyncChunkifyWithRawResponse:
652
+ _client: AsyncChunkify
653
+
654
+ def __init__(self, client: AsyncChunkify) -> None:
655
+ self._client = client
656
+
657
+ @cached_property
658
+ def files(self) -> files.AsyncFilesResourceWithRawResponse:
659
+ from .resources.files import AsyncFilesResourceWithRawResponse
660
+
661
+ return AsyncFilesResourceWithRawResponse(self._client.files)
662
+
663
+ @cached_property
664
+ def jobs(self) -> jobs.AsyncJobsResourceWithRawResponse:
665
+ from .resources.jobs import AsyncJobsResourceWithRawResponse
666
+
667
+ return AsyncJobsResourceWithRawResponse(self._client.jobs)
668
+
669
+ @cached_property
670
+ def notifications(self) -> notifications.AsyncNotificationsResourceWithRawResponse:
671
+ from .resources.notifications import AsyncNotificationsResourceWithRawResponse
672
+
673
+ return AsyncNotificationsResourceWithRawResponse(self._client.notifications)
674
+
675
+ @cached_property
676
+ def projects(self) -> projects.AsyncProjectsResourceWithRawResponse:
677
+ from .resources.projects import AsyncProjectsResourceWithRawResponse
678
+
679
+ return AsyncProjectsResourceWithRawResponse(self._client.projects)
680
+
681
+ @cached_property
682
+ def sources(self) -> sources.AsyncSourcesResourceWithRawResponse:
683
+ from .resources.sources import AsyncSourcesResourceWithRawResponse
684
+
685
+ return AsyncSourcesResourceWithRawResponse(self._client.sources)
686
+
687
+ @cached_property
688
+ def storages(self) -> storages.AsyncStoragesResourceWithRawResponse:
689
+ from .resources.storages import AsyncStoragesResourceWithRawResponse
690
+
691
+ return AsyncStoragesResourceWithRawResponse(self._client.storages)
692
+
693
+ @cached_property
694
+ def tokens(self) -> tokens.AsyncTokensResourceWithRawResponse:
695
+ from .resources.tokens import AsyncTokensResourceWithRawResponse
696
+
697
+ return AsyncTokensResourceWithRawResponse(self._client.tokens)
698
+
699
+ @cached_property
700
+ def uploads(self) -> uploads.AsyncUploadsResourceWithRawResponse:
701
+ from .resources.uploads import AsyncUploadsResourceWithRawResponse
702
+
703
+ return AsyncUploadsResourceWithRawResponse(self._client.uploads)
704
+
705
+ @cached_property
706
+ def webhooks(self) -> webhooks.AsyncWebhooksResourceWithRawResponse:
707
+ from .resources.webhooks import AsyncWebhooksResourceWithRawResponse
708
+
709
+ return AsyncWebhooksResourceWithRawResponse(self._client.webhooks)
710
+
711
+
712
+ class ChunkifyWithStreamedResponse:
713
+ _client: Chunkify
714
+
715
+ def __init__(self, client: Chunkify) -> None:
716
+ self._client = client
717
+
718
+ @cached_property
719
+ def files(self) -> files.FilesResourceWithStreamingResponse:
720
+ from .resources.files import FilesResourceWithStreamingResponse
721
+
722
+ return FilesResourceWithStreamingResponse(self._client.files)
723
+
724
+ @cached_property
725
+ def jobs(self) -> jobs.JobsResourceWithStreamingResponse:
726
+ from .resources.jobs import JobsResourceWithStreamingResponse
727
+
728
+ return JobsResourceWithStreamingResponse(self._client.jobs)
729
+
730
+ @cached_property
731
+ def notifications(self) -> notifications.NotificationsResourceWithStreamingResponse:
732
+ from .resources.notifications import NotificationsResourceWithStreamingResponse
733
+
734
+ return NotificationsResourceWithStreamingResponse(self._client.notifications)
735
+
736
+ @cached_property
737
+ def projects(self) -> projects.ProjectsResourceWithStreamingResponse:
738
+ from .resources.projects import ProjectsResourceWithStreamingResponse
739
+
740
+ return ProjectsResourceWithStreamingResponse(self._client.projects)
741
+
742
+ @cached_property
743
+ def sources(self) -> sources.SourcesResourceWithStreamingResponse:
744
+ from .resources.sources import SourcesResourceWithStreamingResponse
745
+
746
+ return SourcesResourceWithStreamingResponse(self._client.sources)
747
+
748
+ @cached_property
749
+ def storages(self) -> storages.StoragesResourceWithStreamingResponse:
750
+ from .resources.storages import StoragesResourceWithStreamingResponse
751
+
752
+ return StoragesResourceWithStreamingResponse(self._client.storages)
753
+
754
+ @cached_property
755
+ def tokens(self) -> tokens.TokensResourceWithStreamingResponse:
756
+ from .resources.tokens import TokensResourceWithStreamingResponse
757
+
758
+ return TokensResourceWithStreamingResponse(self._client.tokens)
759
+
760
+ @cached_property
761
+ def uploads(self) -> uploads.UploadsResourceWithStreamingResponse:
762
+ from .resources.uploads import UploadsResourceWithStreamingResponse
763
+
764
+ return UploadsResourceWithStreamingResponse(self._client.uploads)
765
+
766
+ @cached_property
767
+ def webhooks(self) -> webhooks.WebhooksResourceWithStreamingResponse:
768
+ from .resources.webhooks import WebhooksResourceWithStreamingResponse
769
+
770
+ return WebhooksResourceWithStreamingResponse(self._client.webhooks)
771
+
772
+
773
+ class AsyncChunkifyWithStreamedResponse:
774
+ _client: AsyncChunkify
775
+
776
+ def __init__(self, client: AsyncChunkify) -> None:
777
+ self._client = client
778
+
779
+ @cached_property
780
+ def files(self) -> files.AsyncFilesResourceWithStreamingResponse:
781
+ from .resources.files import AsyncFilesResourceWithStreamingResponse
782
+
783
+ return AsyncFilesResourceWithStreamingResponse(self._client.files)
784
+
785
+ @cached_property
786
+ def jobs(self) -> jobs.AsyncJobsResourceWithStreamingResponse:
787
+ from .resources.jobs import AsyncJobsResourceWithStreamingResponse
788
+
789
+ return AsyncJobsResourceWithStreamingResponse(self._client.jobs)
790
+
791
+ @cached_property
792
+ def notifications(self) -> notifications.AsyncNotificationsResourceWithStreamingResponse:
793
+ from .resources.notifications import AsyncNotificationsResourceWithStreamingResponse
794
+
795
+ return AsyncNotificationsResourceWithStreamingResponse(self._client.notifications)
796
+
797
+ @cached_property
798
+ def projects(self) -> projects.AsyncProjectsResourceWithStreamingResponse:
799
+ from .resources.projects import AsyncProjectsResourceWithStreamingResponse
800
+
801
+ return AsyncProjectsResourceWithStreamingResponse(self._client.projects)
802
+
803
+ @cached_property
804
+ def sources(self) -> sources.AsyncSourcesResourceWithStreamingResponse:
805
+ from .resources.sources import AsyncSourcesResourceWithStreamingResponse
806
+
807
+ return AsyncSourcesResourceWithStreamingResponse(self._client.sources)
808
+
809
+ @cached_property
810
+ def storages(self) -> storages.AsyncStoragesResourceWithStreamingResponse:
811
+ from .resources.storages import AsyncStoragesResourceWithStreamingResponse
812
+
813
+ return AsyncStoragesResourceWithStreamingResponse(self._client.storages)
814
+
815
+ @cached_property
816
+ def tokens(self) -> tokens.AsyncTokensResourceWithStreamingResponse:
817
+ from .resources.tokens import AsyncTokensResourceWithStreamingResponse
818
+
819
+ return AsyncTokensResourceWithStreamingResponse(self._client.tokens)
820
+
821
+ @cached_property
822
+ def uploads(self) -> uploads.AsyncUploadsResourceWithStreamingResponse:
823
+ from .resources.uploads import AsyncUploadsResourceWithStreamingResponse
824
+
825
+ return AsyncUploadsResourceWithStreamingResponse(self._client.uploads)
826
+
827
+ @cached_property
828
+ def webhooks(self) -> webhooks.AsyncWebhooksResourceWithStreamingResponse:
829
+ from .resources.webhooks import AsyncWebhooksResourceWithStreamingResponse
830
+
831
+ return AsyncWebhooksResourceWithStreamingResponse(self._client.webhooks)
832
+
833
+
834
+ Client = Chunkify
835
+
836
+ AsyncClient = AsyncChunkify