chunkr-ai 0.1.0a2__py3-none-any.whl → 0.1.0a4__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.
- chunkr_ai/__init__.py +3 -0
- chunkr_ai/_client.py +18 -10
- chunkr_ai/_files.py +1 -1
- chunkr_ai/_version.py +1 -1
- chunkr_ai/lib/tasks_poll.py +122 -0
- chunkr_ai/pagination.py +61 -1
- chunkr_ai/resources/__init__.py +27 -13
- chunkr_ai/resources/files.py +712 -0
- chunkr_ai/resources/{task → tasks}/__init__.py +14 -14
- chunkr_ai/resources/{task → tasks}/parse.py +48 -52
- chunkr_ai/resources/{task/task.py → tasks/tasks.py} +58 -126
- chunkr_ai/types/__init__.py +7 -0
- chunkr_ai/types/delete.py +10 -0
- chunkr_ai/types/file.py +30 -0
- chunkr_ai/types/file_create_params.py +17 -0
- chunkr_ai/types/file_list_params.py +28 -0
- chunkr_ai/types/file_url.py +15 -0
- chunkr_ai/types/file_url_params.py +15 -0
- chunkr_ai/types/files_list_response.py +20 -0
- chunkr_ai/types/{task/task.py → task.py} +55 -23
- chunkr_ai/types/{task → tasks}/__init__.py +0 -1
- chunkr_ai/types/{task → tasks}/parse_create_params.py +61 -23
- chunkr_ai/types/{task → tasks}/parse_update_params.py +54 -22
- {chunkr_ai-0.1.0a2.dist-info → chunkr_ai-0.1.0a4.dist-info}/METADATA +38 -20
- chunkr_ai-0.1.0a4.dist-info/RECORD +53 -0
- chunkr_ai-0.1.0a2.dist-info/RECORD +0 -44
- {chunkr_ai-0.1.0a2.dist-info → chunkr_ai-0.1.0a4.dist-info}/WHEEL +0 -0
- {chunkr_ai-0.1.0a2.dist-info → chunkr_ai-0.1.0a4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,712 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing import Union, Mapping, cast
|
6
|
+
from datetime import datetime
|
7
|
+
from typing_extensions import Literal
|
8
|
+
|
9
|
+
import httpx
|
10
|
+
|
11
|
+
from ..types import file_url_params, file_list_params, file_create_params
|
12
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
|
13
|
+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
14
|
+
from .._compat import cached_property
|
15
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
16
|
+
from .._response import (
|
17
|
+
to_raw_response_wrapper,
|
18
|
+
to_streamed_response_wrapper,
|
19
|
+
async_to_raw_response_wrapper,
|
20
|
+
async_to_streamed_response_wrapper,
|
21
|
+
)
|
22
|
+
from ..pagination import SyncFilesPage, AsyncFilesPage
|
23
|
+
from ..types.file import File
|
24
|
+
from .._base_client import AsyncPaginator, make_request_options
|
25
|
+
from ..types.delete import Delete
|
26
|
+
from ..types.file_url import FileURL
|
27
|
+
|
28
|
+
__all__ = ["FilesResource", "AsyncFilesResource"]
|
29
|
+
|
30
|
+
|
31
|
+
class FilesResource(SyncAPIResource):
|
32
|
+
@cached_property
|
33
|
+
def with_raw_response(self) -> FilesResourceWithRawResponse:
|
34
|
+
"""
|
35
|
+
This property can be used as a prefix for any HTTP method call to return
|
36
|
+
the raw response object instead of the parsed content.
|
37
|
+
|
38
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
|
39
|
+
"""
|
40
|
+
return FilesResourceWithRawResponse(self)
|
41
|
+
|
42
|
+
@cached_property
|
43
|
+
def with_streaming_response(self) -> FilesResourceWithStreamingResponse:
|
44
|
+
"""
|
45
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
46
|
+
|
47
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
|
48
|
+
"""
|
49
|
+
return FilesResourceWithStreamingResponse(self)
|
50
|
+
|
51
|
+
def create(
|
52
|
+
self,
|
53
|
+
*,
|
54
|
+
file: FileTypes,
|
55
|
+
file_metadata: str,
|
56
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
57
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
58
|
+
extra_headers: Headers | None = None,
|
59
|
+
extra_query: Query | None = None,
|
60
|
+
extra_body: Body | None = None,
|
61
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
62
|
+
) -> File:
|
63
|
+
"""
|
64
|
+
Accepts multipart/form-data with fields:
|
65
|
+
|
66
|
+
- file: binary (required)
|
67
|
+
- file_metadata: string (optional, JSON string)
|
68
|
+
|
69
|
+
Args:
|
70
|
+
file: The file to upload
|
71
|
+
|
72
|
+
file_metadata: Arbitrary JSON metadata associated with the file.
|
73
|
+
|
74
|
+
extra_headers: Send extra headers
|
75
|
+
|
76
|
+
extra_query: Add additional query parameters to the request
|
77
|
+
|
78
|
+
extra_body: Add additional JSON properties to the request
|
79
|
+
|
80
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
81
|
+
"""
|
82
|
+
body = deepcopy_minimal(
|
83
|
+
{
|
84
|
+
"file": file,
|
85
|
+
"file_metadata": file_metadata,
|
86
|
+
}
|
87
|
+
)
|
88
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
89
|
+
# It should be noted that the actual Content-Type header that will be
|
90
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
91
|
+
# multipart/form-data; boundary=---abc--
|
92
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
93
|
+
return self._post(
|
94
|
+
"/files",
|
95
|
+
body=maybe_transform(body, file_create_params.FileCreateParams),
|
96
|
+
files=files,
|
97
|
+
options=make_request_options(
|
98
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
99
|
+
),
|
100
|
+
cast_to=File,
|
101
|
+
)
|
102
|
+
|
103
|
+
def list(
|
104
|
+
self,
|
105
|
+
*,
|
106
|
+
cursor: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
107
|
+
end: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
108
|
+
limit: int | NotGiven = NOT_GIVEN,
|
109
|
+
sort: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
110
|
+
start: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
111
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
112
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
113
|
+
extra_headers: Headers | None = None,
|
114
|
+
extra_query: Query | None = None,
|
115
|
+
extra_body: Body | None = None,
|
116
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
117
|
+
) -> SyncFilesPage[File]:
|
118
|
+
"""
|
119
|
+
Lists files for the authenticated user with cursor-based pagination and optional
|
120
|
+
filtering by date range.
|
121
|
+
|
122
|
+
Args:
|
123
|
+
cursor: Cursor for pagination (created_at)
|
124
|
+
|
125
|
+
end: End date
|
126
|
+
|
127
|
+
limit: Number of files per page
|
128
|
+
|
129
|
+
sort: Sort order: 'asc' for ascending, 'desc' for descending (default)
|
130
|
+
|
131
|
+
start: Start date
|
132
|
+
|
133
|
+
extra_headers: Send extra headers
|
134
|
+
|
135
|
+
extra_query: Add additional query parameters to the request
|
136
|
+
|
137
|
+
extra_body: Add additional JSON properties to the request
|
138
|
+
|
139
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
140
|
+
"""
|
141
|
+
return self._get_api_list(
|
142
|
+
"/files",
|
143
|
+
page=SyncFilesPage[File],
|
144
|
+
options=make_request_options(
|
145
|
+
extra_headers=extra_headers,
|
146
|
+
extra_query=extra_query,
|
147
|
+
extra_body=extra_body,
|
148
|
+
timeout=timeout,
|
149
|
+
query=maybe_transform(
|
150
|
+
{
|
151
|
+
"cursor": cursor,
|
152
|
+
"end": end,
|
153
|
+
"limit": limit,
|
154
|
+
"sort": sort,
|
155
|
+
"start": start,
|
156
|
+
},
|
157
|
+
file_list_params.FileListParams,
|
158
|
+
),
|
159
|
+
),
|
160
|
+
model=File,
|
161
|
+
)
|
162
|
+
|
163
|
+
def delete(
|
164
|
+
self,
|
165
|
+
file_id: str,
|
166
|
+
*,
|
167
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
168
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
169
|
+
extra_headers: Headers | None = None,
|
170
|
+
extra_query: Query | None = None,
|
171
|
+
extra_body: Body | None = None,
|
172
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
173
|
+
) -> Delete:
|
174
|
+
"""Delete file contents and scrub sensitive metadata.
|
175
|
+
|
176
|
+
Minimal metadata is retained
|
177
|
+
for audit and usage reporting per ZDR policy
|
178
|
+
|
179
|
+
Args:
|
180
|
+
extra_headers: Send extra headers
|
181
|
+
|
182
|
+
extra_query: Add additional query parameters to the request
|
183
|
+
|
184
|
+
extra_body: Add additional JSON properties to the request
|
185
|
+
|
186
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
187
|
+
"""
|
188
|
+
if not file_id:
|
189
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
190
|
+
return self._delete(
|
191
|
+
f"/files/{file_id}",
|
192
|
+
options=make_request_options(
|
193
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
194
|
+
),
|
195
|
+
cast_to=Delete,
|
196
|
+
)
|
197
|
+
|
198
|
+
def content(
|
199
|
+
self,
|
200
|
+
file_id: str,
|
201
|
+
*,
|
202
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
203
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
204
|
+
extra_headers: Headers | None = None,
|
205
|
+
extra_query: Query | None = None,
|
206
|
+
extra_body: Body | None = None,
|
207
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
208
|
+
) -> None:
|
209
|
+
"""Streams the file bytes directly if authorized.
|
210
|
+
|
211
|
+
The response will set the
|
212
|
+
`Content-Type` header to the file's detected MIME type.
|
213
|
+
|
214
|
+
Args:
|
215
|
+
extra_headers: Send extra headers
|
216
|
+
|
217
|
+
extra_query: Add additional query parameters to the request
|
218
|
+
|
219
|
+
extra_body: Add additional JSON properties to the request
|
220
|
+
|
221
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
222
|
+
"""
|
223
|
+
if not file_id:
|
224
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
225
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
226
|
+
return self._get(
|
227
|
+
f"/files/{file_id}/content",
|
228
|
+
options=make_request_options(
|
229
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
230
|
+
),
|
231
|
+
cast_to=NoneType,
|
232
|
+
)
|
233
|
+
|
234
|
+
def get(
|
235
|
+
self,
|
236
|
+
file_id: str,
|
237
|
+
*,
|
238
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
239
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
240
|
+
extra_headers: Headers | None = None,
|
241
|
+
extra_query: Query | None = None,
|
242
|
+
extra_body: Body | None = None,
|
243
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
244
|
+
) -> File:
|
245
|
+
"""Returns metadata for a file owned by the authenticated user.
|
246
|
+
|
247
|
+
The response
|
248
|
+
includes a permanent `ch://files/{file_id}` URL, file name, content type, size,
|
249
|
+
user-provided metadata, and timestamps.
|
250
|
+
|
251
|
+
If the file is not found or the user is not authorized, the response will be 401
|
252
|
+
Unauthorized.
|
253
|
+
|
254
|
+
Args:
|
255
|
+
extra_headers: Send extra headers
|
256
|
+
|
257
|
+
extra_query: Add additional query parameters to the request
|
258
|
+
|
259
|
+
extra_body: Add additional JSON properties to the request
|
260
|
+
|
261
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
262
|
+
"""
|
263
|
+
if not file_id:
|
264
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
265
|
+
return self._get(
|
266
|
+
f"/files/{file_id}",
|
267
|
+
options=make_request_options(
|
268
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
269
|
+
),
|
270
|
+
cast_to=File,
|
271
|
+
)
|
272
|
+
|
273
|
+
def url(
|
274
|
+
self,
|
275
|
+
file_id: str,
|
276
|
+
*,
|
277
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
278
|
+
expires_in: int | NotGiven = NOT_GIVEN,
|
279
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
280
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
281
|
+
extra_headers: Headers | None = None,
|
282
|
+
extra_query: Query | None = None,
|
283
|
+
extra_body: Body | None = None,
|
284
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
285
|
+
) -> FileURL:
|
286
|
+
"""Returns a presigned download URL by default.
|
287
|
+
|
288
|
+
If `base64_urls=true`, returns
|
289
|
+
base64-encoded file content. Control expiry with `expires_in` (seconds).
|
290
|
+
|
291
|
+
Args:
|
292
|
+
base64_urls: If true, returns base64 data instead of a presigned URL
|
293
|
+
|
294
|
+
expires_in: Expiry in seconds for the presigned URL (default 3600)
|
295
|
+
|
296
|
+
extra_headers: Send extra headers
|
297
|
+
|
298
|
+
extra_query: Add additional query parameters to the request
|
299
|
+
|
300
|
+
extra_body: Add additional JSON properties to the request
|
301
|
+
|
302
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
303
|
+
"""
|
304
|
+
if not file_id:
|
305
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
306
|
+
return self._get(
|
307
|
+
f"/files/{file_id}/url",
|
308
|
+
options=make_request_options(
|
309
|
+
extra_headers=extra_headers,
|
310
|
+
extra_query=extra_query,
|
311
|
+
extra_body=extra_body,
|
312
|
+
timeout=timeout,
|
313
|
+
query=maybe_transform(
|
314
|
+
{
|
315
|
+
"base64_urls": base64_urls,
|
316
|
+
"expires_in": expires_in,
|
317
|
+
},
|
318
|
+
file_url_params.FileURLParams,
|
319
|
+
),
|
320
|
+
),
|
321
|
+
cast_to=FileURL,
|
322
|
+
)
|
323
|
+
|
324
|
+
|
325
|
+
class AsyncFilesResource(AsyncAPIResource):
|
326
|
+
@cached_property
|
327
|
+
def with_raw_response(self) -> AsyncFilesResourceWithRawResponse:
|
328
|
+
"""
|
329
|
+
This property can be used as a prefix for any HTTP method call to return
|
330
|
+
the raw response object instead of the parsed content.
|
331
|
+
|
332
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
|
333
|
+
"""
|
334
|
+
return AsyncFilesResourceWithRawResponse(self)
|
335
|
+
|
336
|
+
@cached_property
|
337
|
+
def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse:
|
338
|
+
"""
|
339
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
340
|
+
|
341
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
|
342
|
+
"""
|
343
|
+
return AsyncFilesResourceWithStreamingResponse(self)
|
344
|
+
|
345
|
+
async def create(
|
346
|
+
self,
|
347
|
+
*,
|
348
|
+
file: FileTypes,
|
349
|
+
file_metadata: str,
|
350
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
351
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
352
|
+
extra_headers: Headers | None = None,
|
353
|
+
extra_query: Query | None = None,
|
354
|
+
extra_body: Body | None = None,
|
355
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
356
|
+
) -> File:
|
357
|
+
"""
|
358
|
+
Accepts multipart/form-data with fields:
|
359
|
+
|
360
|
+
- file: binary (required)
|
361
|
+
- file_metadata: string (optional, JSON string)
|
362
|
+
|
363
|
+
Args:
|
364
|
+
file: The file to upload
|
365
|
+
|
366
|
+
file_metadata: Arbitrary JSON metadata associated with the file.
|
367
|
+
|
368
|
+
extra_headers: Send extra headers
|
369
|
+
|
370
|
+
extra_query: Add additional query parameters to the request
|
371
|
+
|
372
|
+
extra_body: Add additional JSON properties to the request
|
373
|
+
|
374
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
375
|
+
"""
|
376
|
+
body = deepcopy_minimal(
|
377
|
+
{
|
378
|
+
"file": file,
|
379
|
+
"file_metadata": file_metadata,
|
380
|
+
}
|
381
|
+
)
|
382
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
383
|
+
# It should be noted that the actual Content-Type header that will be
|
384
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
385
|
+
# multipart/form-data; boundary=---abc--
|
386
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
387
|
+
return await self._post(
|
388
|
+
"/files",
|
389
|
+
body=await async_maybe_transform(body, file_create_params.FileCreateParams),
|
390
|
+
files=files,
|
391
|
+
options=make_request_options(
|
392
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
393
|
+
),
|
394
|
+
cast_to=File,
|
395
|
+
)
|
396
|
+
|
397
|
+
def list(
|
398
|
+
self,
|
399
|
+
*,
|
400
|
+
cursor: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
401
|
+
end: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
402
|
+
limit: int | NotGiven = NOT_GIVEN,
|
403
|
+
sort: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
404
|
+
start: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
405
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
406
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
407
|
+
extra_headers: Headers | None = None,
|
408
|
+
extra_query: Query | None = None,
|
409
|
+
extra_body: Body | None = None,
|
410
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
411
|
+
) -> AsyncPaginator[File, AsyncFilesPage[File]]:
|
412
|
+
"""
|
413
|
+
Lists files for the authenticated user with cursor-based pagination and optional
|
414
|
+
filtering by date range.
|
415
|
+
|
416
|
+
Args:
|
417
|
+
cursor: Cursor for pagination (created_at)
|
418
|
+
|
419
|
+
end: End date
|
420
|
+
|
421
|
+
limit: Number of files per page
|
422
|
+
|
423
|
+
sort: Sort order: 'asc' for ascending, 'desc' for descending (default)
|
424
|
+
|
425
|
+
start: Start date
|
426
|
+
|
427
|
+
extra_headers: Send extra headers
|
428
|
+
|
429
|
+
extra_query: Add additional query parameters to the request
|
430
|
+
|
431
|
+
extra_body: Add additional JSON properties to the request
|
432
|
+
|
433
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
434
|
+
"""
|
435
|
+
return self._get_api_list(
|
436
|
+
"/files",
|
437
|
+
page=AsyncFilesPage[File],
|
438
|
+
options=make_request_options(
|
439
|
+
extra_headers=extra_headers,
|
440
|
+
extra_query=extra_query,
|
441
|
+
extra_body=extra_body,
|
442
|
+
timeout=timeout,
|
443
|
+
query=maybe_transform(
|
444
|
+
{
|
445
|
+
"cursor": cursor,
|
446
|
+
"end": end,
|
447
|
+
"limit": limit,
|
448
|
+
"sort": sort,
|
449
|
+
"start": start,
|
450
|
+
},
|
451
|
+
file_list_params.FileListParams,
|
452
|
+
),
|
453
|
+
),
|
454
|
+
model=File,
|
455
|
+
)
|
456
|
+
|
457
|
+
async def delete(
|
458
|
+
self,
|
459
|
+
file_id: str,
|
460
|
+
*,
|
461
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
462
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
463
|
+
extra_headers: Headers | None = None,
|
464
|
+
extra_query: Query | None = None,
|
465
|
+
extra_body: Body | None = None,
|
466
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
467
|
+
) -> Delete:
|
468
|
+
"""Delete file contents and scrub sensitive metadata.
|
469
|
+
|
470
|
+
Minimal metadata is retained
|
471
|
+
for audit and usage reporting per ZDR policy
|
472
|
+
|
473
|
+
Args:
|
474
|
+
extra_headers: Send extra headers
|
475
|
+
|
476
|
+
extra_query: Add additional query parameters to the request
|
477
|
+
|
478
|
+
extra_body: Add additional JSON properties to the request
|
479
|
+
|
480
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
481
|
+
"""
|
482
|
+
if not file_id:
|
483
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
484
|
+
return await self._delete(
|
485
|
+
f"/files/{file_id}",
|
486
|
+
options=make_request_options(
|
487
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
488
|
+
),
|
489
|
+
cast_to=Delete,
|
490
|
+
)
|
491
|
+
|
492
|
+
async def content(
|
493
|
+
self,
|
494
|
+
file_id: str,
|
495
|
+
*,
|
496
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
497
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
498
|
+
extra_headers: Headers | None = None,
|
499
|
+
extra_query: Query | None = None,
|
500
|
+
extra_body: Body | None = None,
|
501
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
502
|
+
) -> None:
|
503
|
+
"""Streams the file bytes directly if authorized.
|
504
|
+
|
505
|
+
The response will set the
|
506
|
+
`Content-Type` header to the file's detected MIME type.
|
507
|
+
|
508
|
+
Args:
|
509
|
+
extra_headers: Send extra headers
|
510
|
+
|
511
|
+
extra_query: Add additional query parameters to the request
|
512
|
+
|
513
|
+
extra_body: Add additional JSON properties to the request
|
514
|
+
|
515
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
516
|
+
"""
|
517
|
+
if not file_id:
|
518
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
519
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
520
|
+
return await self._get(
|
521
|
+
f"/files/{file_id}/content",
|
522
|
+
options=make_request_options(
|
523
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
524
|
+
),
|
525
|
+
cast_to=NoneType,
|
526
|
+
)
|
527
|
+
|
528
|
+
async def get(
|
529
|
+
self,
|
530
|
+
file_id: str,
|
531
|
+
*,
|
532
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
533
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
534
|
+
extra_headers: Headers | None = None,
|
535
|
+
extra_query: Query | None = None,
|
536
|
+
extra_body: Body | None = None,
|
537
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
538
|
+
) -> File:
|
539
|
+
"""Returns metadata for a file owned by the authenticated user.
|
540
|
+
|
541
|
+
The response
|
542
|
+
includes a permanent `ch://files/{file_id}` URL, file name, content type, size,
|
543
|
+
user-provided metadata, and timestamps.
|
544
|
+
|
545
|
+
If the file is not found or the user is not authorized, the response will be 401
|
546
|
+
Unauthorized.
|
547
|
+
|
548
|
+
Args:
|
549
|
+
extra_headers: Send extra headers
|
550
|
+
|
551
|
+
extra_query: Add additional query parameters to the request
|
552
|
+
|
553
|
+
extra_body: Add additional JSON properties to the request
|
554
|
+
|
555
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
556
|
+
"""
|
557
|
+
if not file_id:
|
558
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
559
|
+
return await self._get(
|
560
|
+
f"/files/{file_id}",
|
561
|
+
options=make_request_options(
|
562
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
563
|
+
),
|
564
|
+
cast_to=File,
|
565
|
+
)
|
566
|
+
|
567
|
+
async def url(
|
568
|
+
self,
|
569
|
+
file_id: str,
|
570
|
+
*,
|
571
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
572
|
+
expires_in: int | NotGiven = NOT_GIVEN,
|
573
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
574
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
575
|
+
extra_headers: Headers | None = None,
|
576
|
+
extra_query: Query | None = None,
|
577
|
+
extra_body: Body | None = None,
|
578
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
579
|
+
) -> FileURL:
|
580
|
+
"""Returns a presigned download URL by default.
|
581
|
+
|
582
|
+
If `base64_urls=true`, returns
|
583
|
+
base64-encoded file content. Control expiry with `expires_in` (seconds).
|
584
|
+
|
585
|
+
Args:
|
586
|
+
base64_urls: If true, returns base64 data instead of a presigned URL
|
587
|
+
|
588
|
+
expires_in: Expiry in seconds for the presigned URL (default 3600)
|
589
|
+
|
590
|
+
extra_headers: Send extra headers
|
591
|
+
|
592
|
+
extra_query: Add additional query parameters to the request
|
593
|
+
|
594
|
+
extra_body: Add additional JSON properties to the request
|
595
|
+
|
596
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
597
|
+
"""
|
598
|
+
if not file_id:
|
599
|
+
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
600
|
+
return await self._get(
|
601
|
+
f"/files/{file_id}/url",
|
602
|
+
options=make_request_options(
|
603
|
+
extra_headers=extra_headers,
|
604
|
+
extra_query=extra_query,
|
605
|
+
extra_body=extra_body,
|
606
|
+
timeout=timeout,
|
607
|
+
query=await async_maybe_transform(
|
608
|
+
{
|
609
|
+
"base64_urls": base64_urls,
|
610
|
+
"expires_in": expires_in,
|
611
|
+
},
|
612
|
+
file_url_params.FileURLParams,
|
613
|
+
),
|
614
|
+
),
|
615
|
+
cast_to=FileURL,
|
616
|
+
)
|
617
|
+
|
618
|
+
|
619
|
+
class FilesResourceWithRawResponse:
|
620
|
+
def __init__(self, files: FilesResource) -> None:
|
621
|
+
self._files = files
|
622
|
+
|
623
|
+
self.create = to_raw_response_wrapper(
|
624
|
+
files.create,
|
625
|
+
)
|
626
|
+
self.list = to_raw_response_wrapper(
|
627
|
+
files.list,
|
628
|
+
)
|
629
|
+
self.delete = to_raw_response_wrapper(
|
630
|
+
files.delete,
|
631
|
+
)
|
632
|
+
self.content = to_raw_response_wrapper(
|
633
|
+
files.content,
|
634
|
+
)
|
635
|
+
self.get = to_raw_response_wrapper(
|
636
|
+
files.get,
|
637
|
+
)
|
638
|
+
self.url = to_raw_response_wrapper(
|
639
|
+
files.url,
|
640
|
+
)
|
641
|
+
|
642
|
+
|
643
|
+
class AsyncFilesResourceWithRawResponse:
|
644
|
+
def __init__(self, files: AsyncFilesResource) -> None:
|
645
|
+
self._files = files
|
646
|
+
|
647
|
+
self.create = async_to_raw_response_wrapper(
|
648
|
+
files.create,
|
649
|
+
)
|
650
|
+
self.list = async_to_raw_response_wrapper(
|
651
|
+
files.list,
|
652
|
+
)
|
653
|
+
self.delete = async_to_raw_response_wrapper(
|
654
|
+
files.delete,
|
655
|
+
)
|
656
|
+
self.content = async_to_raw_response_wrapper(
|
657
|
+
files.content,
|
658
|
+
)
|
659
|
+
self.get = async_to_raw_response_wrapper(
|
660
|
+
files.get,
|
661
|
+
)
|
662
|
+
self.url = async_to_raw_response_wrapper(
|
663
|
+
files.url,
|
664
|
+
)
|
665
|
+
|
666
|
+
|
667
|
+
class FilesResourceWithStreamingResponse:
|
668
|
+
def __init__(self, files: FilesResource) -> None:
|
669
|
+
self._files = files
|
670
|
+
|
671
|
+
self.create = to_streamed_response_wrapper(
|
672
|
+
files.create,
|
673
|
+
)
|
674
|
+
self.list = to_streamed_response_wrapper(
|
675
|
+
files.list,
|
676
|
+
)
|
677
|
+
self.delete = to_streamed_response_wrapper(
|
678
|
+
files.delete,
|
679
|
+
)
|
680
|
+
self.content = to_streamed_response_wrapper(
|
681
|
+
files.content,
|
682
|
+
)
|
683
|
+
self.get = to_streamed_response_wrapper(
|
684
|
+
files.get,
|
685
|
+
)
|
686
|
+
self.url = to_streamed_response_wrapper(
|
687
|
+
files.url,
|
688
|
+
)
|
689
|
+
|
690
|
+
|
691
|
+
class AsyncFilesResourceWithStreamingResponse:
|
692
|
+
def __init__(self, files: AsyncFilesResource) -> None:
|
693
|
+
self._files = files
|
694
|
+
|
695
|
+
self.create = async_to_streamed_response_wrapper(
|
696
|
+
files.create,
|
697
|
+
)
|
698
|
+
self.list = async_to_streamed_response_wrapper(
|
699
|
+
files.list,
|
700
|
+
)
|
701
|
+
self.delete = async_to_streamed_response_wrapper(
|
702
|
+
files.delete,
|
703
|
+
)
|
704
|
+
self.content = async_to_streamed_response_wrapper(
|
705
|
+
files.content,
|
706
|
+
)
|
707
|
+
self.get = async_to_streamed_response_wrapper(
|
708
|
+
files.get,
|
709
|
+
)
|
710
|
+
self.url = async_to_streamed_response_wrapper(
|
711
|
+
files.url,
|
712
|
+
)
|