worqhat 3.10.0__py3-none-any.whl → 4.2.0__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.
- worqhat/__init__.py +8 -89
- worqhat/client.py +62 -0
- worqhat/exceptions.py +43 -0
- worqhat/http_client.py +171 -0
- worqhat/py.typed +1 -0
- worqhat/resources/__init__.py +5 -59
- worqhat/resources/database.py +293 -0
- worqhat/resources/flows.py +61 -409
- worqhat/resources/storage.py +41 -431
- worqhat-4.2.0.dist-info/METADATA +538 -0
- worqhat-4.2.0.dist-info/RECORD +13 -0
- {worqhat-3.10.0.dist-info → worqhat-4.2.0.dist-info}/WHEEL +2 -1
- worqhat-4.2.0.dist-info/top_level.txt +1 -0
- worqhat/_base_client.py +0 -1995
- worqhat/_client.py +0 -484
- worqhat/_compat.py +0 -219
- worqhat/_constants.py +0 -14
- worqhat/_exceptions.py +0 -108
- worqhat/_files.py +0 -123
- worqhat/_models.py +0 -835
- worqhat/_qs.py +0 -150
- worqhat/_resource.py +0 -43
- worqhat/_response.py +0 -830
- worqhat/_streaming.py +0 -333
- worqhat/_types.py +0 -260
- worqhat/_utils/__init__.py +0 -64
- worqhat/_utils/_compat.py +0 -45
- worqhat/_utils/_datetime_parse.py +0 -136
- worqhat/_utils/_logs.py +0 -25
- worqhat/_utils/_proxy.py +0 -65
- worqhat/_utils/_reflection.py +0 -42
- worqhat/_utils/_resources_proxy.py +0 -24
- worqhat/_utils/_streams.py +0 -12
- worqhat/_utils/_sync.py +0 -86
- worqhat/_utils/_transform.py +0 -457
- worqhat/_utils/_typing.py +0 -156
- worqhat/_utils/_utils.py +0 -421
- worqhat/_version.py +0 -4
- worqhat/lib/.keep +0 -4
- worqhat/resources/db/__init__.py +0 -33
- worqhat/resources/db/db.py +0 -1650
- worqhat/resources/db/tables.py +0 -389
- worqhat/resources/health.py +0 -143
- worqhat/types/__init__.py +0 -44
- worqhat/types/db/__init__.py +0 -10
- worqhat/types/db/table_get_row_count_params.py +0 -12
- worqhat/types/db/table_get_row_count_response.py +0 -15
- worqhat/types/db/table_list_params.py +0 -15
- worqhat/types/db/table_list_response.py +0 -26
- worqhat/types/db/table_retrieve_schema_params.py +0 -12
- worqhat/types/db/table_retrieve_schema_response.py +0 -29
- worqhat/types/db_cluster_params.py +0 -27
- worqhat/types/db_cluster_response.py +0 -44
- worqhat/types/db_delete_records_params.py +0 -19
- worqhat/types/db_delete_records_response.py +0 -18
- worqhat/types/db_detect_anomalies_params.py +0 -24
- worqhat/types/db_detect_anomalies_response.py +0 -50
- worqhat/types/db_execute_batch_params.py +0 -36
- worqhat/types/db_execute_batch_response.py +0 -27
- worqhat/types/db_execute_query_params.py +0 -24
- worqhat/types/db_execute_query_response.py +0 -21
- worqhat/types/db_find_similar_params.py +0 -31
- worqhat/types/db_find_similar_response.py +0 -30
- worqhat/types/db_hybrid_search_params.py +0 -32
- worqhat/types/db_hybrid_search_response.py +0 -48
- worqhat/types/db_insert_record_params.py +0 -19
- worqhat/types/db_insert_record_response.py +0 -15
- worqhat/types/db_process_nl_query_params.py +0 -19
- worqhat/types/db_process_nl_query_response.py +0 -18
- worqhat/types/db_recommend_params.py +0 -33
- worqhat/types/db_recommend_response.py +0 -36
- worqhat/types/db_semantic_search_params.py +0 -33
- worqhat/types/db_semantic_search_response.py +0 -36
- worqhat/types/db_update_records_params.py +0 -22
- worqhat/types/db_update_records_response.py +0 -18
- worqhat/types/flow_get_metrics_params.py +0 -25
- worqhat/types/flow_get_metrics_response.py +0 -55
- worqhat/types/flow_trigger_with_file_params.py +0 -17
- worqhat/types/flow_trigger_with_file_response.py +0 -18
- worqhat/types/flow_trigger_with_payload_params.py +0 -13
- worqhat/types/flow_trigger_with_payload_response.py +0 -20
- worqhat/types/get_server_info_response.py +0 -15
- worqhat/types/health_check_response.py +0 -33
- worqhat/types/storage_delete_file_by_id_response.py +0 -18
- worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
- worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
- worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
- worqhat/types/storage_upload_file_params.py +0 -17
- worqhat/types/storage_upload_file_response.py +0 -33
- worqhat-3.10.0.dist-info/METADATA +0 -432
- worqhat-3.10.0.dist-info/RECORD +0 -85
- worqhat-3.10.0.dist-info/licenses/LICENSE +0 -201
worqhat/resources/storage.py
CHANGED
|
@@ -1,462 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
"""Storage resource for Worqhat SDK."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import TYPE_CHECKING, Optional, Dict, Any, BinaryIO, Union
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from ..http_client import HTTPClient
|
|
6
7
|
|
|
7
|
-
import httpx
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
|
12
|
-
from .._compat import cached_property
|
|
13
|
-
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
14
|
-
from .._response import (
|
|
15
|
-
to_raw_response_wrapper,
|
|
16
|
-
to_streamed_response_wrapper,
|
|
17
|
-
async_to_raw_response_wrapper,
|
|
18
|
-
async_to_streamed_response_wrapper,
|
|
19
|
-
)
|
|
20
|
-
from .._base_client import make_request_options
|
|
21
|
-
from ..types.storage_upload_file_response import StorageUploadFileResponse
|
|
22
|
-
from ..types.storage_delete_file_by_id_response import StorageDeleteFileByIDResponse
|
|
23
|
-
from ..types.storage_retrieve_file_by_id_response import StorageRetrieveFileByIDResponse
|
|
24
|
-
from ..types.storage_retrieve_file_by_path_response import StorageRetrieveFileByPathResponse
|
|
9
|
+
class StorageResource:
|
|
10
|
+
"""Storage operations resource."""
|
|
25
11
|
|
|
26
|
-
|
|
12
|
+
def __init__(self, client: "HTTPClient"):
|
|
13
|
+
"""Initialize the storage resource."""
|
|
14
|
+
self._client = client
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def with_raw_response(self) -> StorageResourceWithRawResponse:
|
|
32
|
-
"""
|
|
33
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
34
|
-
the raw response object instead of the parsed content.
|
|
35
|
-
|
|
36
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
|
|
37
|
-
"""
|
|
38
|
-
return StorageResourceWithRawResponse(self)
|
|
39
|
-
|
|
40
|
-
@cached_property
|
|
41
|
-
def with_streaming_response(self) -> StorageResourceWithStreamingResponse:
|
|
16
|
+
def upload(
|
|
17
|
+
self, file: Union[BinaryIO, bytes], path: Optional[str] = None
|
|
18
|
+
) -> Dict[str, Any]:
|
|
42
19
|
"""
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
|
|
46
|
-
"""
|
|
47
|
-
return StorageResourceWithStreamingResponse(self)
|
|
48
|
-
|
|
49
|
-
def delete_file_by_id(
|
|
50
|
-
self,
|
|
51
|
-
file_id: str,
|
|
52
|
-
*,
|
|
53
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
54
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
55
|
-
extra_headers: Headers | None = None,
|
|
56
|
-
extra_query: Query | None = None,
|
|
57
|
-
extra_body: Body | None = None,
|
|
58
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
59
|
-
) -> StorageDeleteFileByIDResponse:
|
|
60
|
-
"""Permanently deletes a file from storage by its unique ID.
|
|
61
|
-
|
|
62
|
-
This action cannot be
|
|
63
|
-
undone.
|
|
20
|
+
Upload a file to storage.
|
|
64
21
|
|
|
65
22
|
Args:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
extra_query: Add additional query parameters to the request
|
|
23
|
+
file: File object or bytes to upload.
|
|
24
|
+
path: Optional path prefix for the file.
|
|
69
25
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
26
|
+
Returns:
|
|
27
|
+
Upload response with file ID and URL.
|
|
73
28
|
"""
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return self._delete(
|
|
77
|
-
f"/storage/delete/{file_id}",
|
|
78
|
-
options=make_request_options(
|
|
79
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
80
|
-
),
|
|
81
|
-
cast_to=StorageDeleteFileByIDResponse,
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
def retrieve_file_by_id(
|
|
85
|
-
self,
|
|
86
|
-
file_id: str,
|
|
87
|
-
*,
|
|
88
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
89
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
90
|
-
extra_headers: Headers | None = None,
|
|
91
|
-
extra_query: Query | None = None,
|
|
92
|
-
extra_body: Body | None = None,
|
|
93
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
94
|
-
) -> StorageRetrieveFileByIDResponse:
|
|
95
|
-
"""Retrieves a file from storage by its unique ID.
|
|
96
|
-
|
|
97
|
-
Returns the file metadata and a
|
|
98
|
-
download URL.
|
|
99
|
-
|
|
100
|
-
Args:
|
|
101
|
-
extra_headers: Send extra headers
|
|
29
|
+
files = {"file": file}
|
|
30
|
+
data: Dict[str, str] = {}
|
|
102
31
|
|
|
103
|
-
|
|
32
|
+
if path:
|
|
33
|
+
data["path"] = path
|
|
104
34
|
|
|
105
|
-
|
|
35
|
+
return self._client.post("/api/storage/upload", data=data or None, files=files)
|
|
106
36
|
|
|
107
|
-
|
|
37
|
+
def fetch(self, file_id: str) -> Dict[str, Any]:
|
|
108
38
|
"""
|
|
109
|
-
|
|
110
|
-
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
111
|
-
return self._get(
|
|
112
|
-
f"/storage/fetch/{file_id}",
|
|
113
|
-
options=make_request_options(
|
|
114
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
115
|
-
),
|
|
116
|
-
cast_to=StorageRetrieveFileByIDResponse,
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
def retrieve_file_by_path(
|
|
120
|
-
self,
|
|
121
|
-
*,
|
|
122
|
-
filepath: str,
|
|
123
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
124
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
125
|
-
extra_headers: Headers | None = None,
|
|
126
|
-
extra_query: Query | None = None,
|
|
127
|
-
extra_body: Body | None = None,
|
|
128
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
129
|
-
) -> StorageRetrieveFileByPathResponse:
|
|
130
|
-
"""
|
|
131
|
-
Retrieves a file from storage by its path within the organization's storage.
|
|
132
|
-
Returns the file metadata and a download URL.
|
|
39
|
+
Fetch a file record by ID and get a download URL.
|
|
133
40
|
|
|
134
41
|
Args:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
extra_headers: Send extra headers
|
|
138
|
-
|
|
139
|
-
extra_query: Add additional query parameters to the request
|
|
140
|
-
|
|
141
|
-
extra_body: Add additional JSON properties to the request
|
|
142
|
-
|
|
143
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
144
|
-
"""
|
|
145
|
-
return self._get(
|
|
146
|
-
"/storage/fetch-by-path",
|
|
147
|
-
options=make_request_options(
|
|
148
|
-
extra_headers=extra_headers,
|
|
149
|
-
extra_query=extra_query,
|
|
150
|
-
extra_body=extra_body,
|
|
151
|
-
timeout=timeout,
|
|
152
|
-
query=maybe_transform(
|
|
153
|
-
{"filepath": filepath}, storage_retrieve_file_by_path_params.StorageRetrieveFileByPathParams
|
|
154
|
-
),
|
|
155
|
-
),
|
|
156
|
-
cast_to=StorageRetrieveFileByPathResponse,
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
def upload_file(
|
|
160
|
-
self,
|
|
161
|
-
*,
|
|
162
|
-
file: FileTypes,
|
|
163
|
-
path: str | Omit = omit,
|
|
164
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
165
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
166
|
-
extra_headers: Headers | None = None,
|
|
167
|
-
extra_query: Query | None = None,
|
|
168
|
-
extra_body: Body | None = None,
|
|
169
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
170
|
-
) -> StorageUploadFileResponse:
|
|
171
|
-
"""Uploads a file to S3 storage and returns the file ID and metadata.
|
|
172
|
-
|
|
173
|
-
Optionally
|
|
174
|
-
specify a custom path within the organization's storage bucket.
|
|
175
|
-
|
|
176
|
-
Args:
|
|
177
|
-
file: File to upload (max 50MB)
|
|
178
|
-
|
|
179
|
-
path: Optional custom path within organization storage
|
|
180
|
-
|
|
181
|
-
extra_headers: Send extra headers
|
|
182
|
-
|
|
183
|
-
extra_query: Add additional query parameters to the request
|
|
184
|
-
|
|
185
|
-
extra_body: Add additional JSON properties to the request
|
|
186
|
-
|
|
187
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
188
|
-
"""
|
|
189
|
-
body = deepcopy_minimal(
|
|
190
|
-
{
|
|
191
|
-
"file": file,
|
|
192
|
-
"path": path,
|
|
193
|
-
}
|
|
194
|
-
)
|
|
195
|
-
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
196
|
-
# It should be noted that the actual Content-Type header that will be
|
|
197
|
-
# sent to the server will contain a `boundary` parameter, e.g.
|
|
198
|
-
# multipart/form-data; boundary=---abc--
|
|
199
|
-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
200
|
-
return self._post(
|
|
201
|
-
"/storage/upload",
|
|
202
|
-
body=maybe_transform(body, storage_upload_file_params.StorageUploadFileParams),
|
|
203
|
-
files=files,
|
|
204
|
-
options=make_request_options(
|
|
205
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
206
|
-
),
|
|
207
|
-
cast_to=StorageUploadFileResponse,
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class AsyncStorageResource(AsyncAPIResource):
|
|
212
|
-
@cached_property
|
|
213
|
-
def with_raw_response(self) -> AsyncStorageResourceWithRawResponse:
|
|
214
|
-
"""
|
|
215
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
216
|
-
the raw response object instead of the parsed content.
|
|
217
|
-
|
|
218
|
-
For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
|
|
219
|
-
"""
|
|
220
|
-
return AsyncStorageResourceWithRawResponse(self)
|
|
42
|
+
file_id: File ID.
|
|
221
43
|
|
|
222
|
-
|
|
223
|
-
|
|
44
|
+
Returns:
|
|
45
|
+
File information with download URL.
|
|
224
46
|
"""
|
|
225
|
-
|
|
47
|
+
return self._client.get(f"/api/storage/fetch/{file_id}")
|
|
226
48
|
|
|
227
|
-
|
|
49
|
+
def fetch_by_path(self, filepath: str) -> Dict[str, Any]:
|
|
228
50
|
"""
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
async def delete_file_by_id(
|
|
232
|
-
self,
|
|
233
|
-
file_id: str,
|
|
234
|
-
*,
|
|
235
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
236
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
237
|
-
extra_headers: Headers | None = None,
|
|
238
|
-
extra_query: Query | None = None,
|
|
239
|
-
extra_body: Body | None = None,
|
|
240
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
241
|
-
) -> StorageDeleteFileByIDResponse:
|
|
242
|
-
"""Permanently deletes a file from storage by its unique ID.
|
|
243
|
-
|
|
244
|
-
This action cannot be
|
|
245
|
-
undone.
|
|
51
|
+
Fetch a file record by filepath and get a download URL.
|
|
246
52
|
|
|
247
53
|
Args:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
extra_query: Add additional query parameters to the request
|
|
54
|
+
filepath: File path.
|
|
251
55
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
56
|
+
Returns:
|
|
57
|
+
File information with download URL.
|
|
255
58
|
"""
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return await self._delete(
|
|
259
|
-
f"/storage/delete/{file_id}",
|
|
260
|
-
options=make_request_options(
|
|
261
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
262
|
-
),
|
|
263
|
-
cast_to=StorageDeleteFileByIDResponse,
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
async def retrieve_file_by_id(
|
|
267
|
-
self,
|
|
268
|
-
file_id: str,
|
|
269
|
-
*,
|
|
270
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
271
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
272
|
-
extra_headers: Headers | None = None,
|
|
273
|
-
extra_query: Query | None = None,
|
|
274
|
-
extra_body: Body | None = None,
|
|
275
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
276
|
-
) -> StorageRetrieveFileByIDResponse:
|
|
277
|
-
"""Retrieves a file from storage by its unique ID.
|
|
278
|
-
|
|
279
|
-
Returns the file metadata and a
|
|
280
|
-
download URL.
|
|
281
|
-
|
|
282
|
-
Args:
|
|
283
|
-
extra_headers: Send extra headers
|
|
284
|
-
|
|
285
|
-
extra_query: Add additional query parameters to the request
|
|
286
|
-
|
|
287
|
-
extra_body: Add additional JSON properties to the request
|
|
59
|
+
params = {"filepath": filepath}
|
|
60
|
+
return self._client.get("/api/storage/fetch-by-path", params=params)
|
|
288
61
|
|
|
289
|
-
|
|
62
|
+
def delete(self, file_id: str) -> Dict[str, Any]:
|
|
290
63
|
"""
|
|
291
|
-
|
|
292
|
-
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
|
|
293
|
-
return await self._get(
|
|
294
|
-
f"/storage/fetch/{file_id}",
|
|
295
|
-
options=make_request_options(
|
|
296
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
297
|
-
),
|
|
298
|
-
cast_to=StorageRetrieveFileByIDResponse,
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
async def retrieve_file_by_path(
|
|
302
|
-
self,
|
|
303
|
-
*,
|
|
304
|
-
filepath: str,
|
|
305
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
306
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
307
|
-
extra_headers: Headers | None = None,
|
|
308
|
-
extra_query: Query | None = None,
|
|
309
|
-
extra_body: Body | None = None,
|
|
310
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
311
|
-
) -> StorageRetrieveFileByPathResponse:
|
|
312
|
-
"""
|
|
313
|
-
Retrieves a file from storage by its path within the organization's storage.
|
|
314
|
-
Returns the file metadata and a download URL.
|
|
64
|
+
Delete a file from storage.
|
|
315
65
|
|
|
316
66
|
Args:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
extra_headers: Send extra headers
|
|
320
|
-
|
|
321
|
-
extra_query: Add additional query parameters to the request
|
|
322
|
-
|
|
323
|
-
extra_body: Add additional JSON properties to the request
|
|
67
|
+
file_id: File ID.
|
|
324
68
|
|
|
325
|
-
|
|
69
|
+
Returns:
|
|
70
|
+
Delete response.
|
|
326
71
|
"""
|
|
327
|
-
return
|
|
328
|
-
"/storage/fetch-by-path",
|
|
329
|
-
options=make_request_options(
|
|
330
|
-
extra_headers=extra_headers,
|
|
331
|
-
extra_query=extra_query,
|
|
332
|
-
extra_body=extra_body,
|
|
333
|
-
timeout=timeout,
|
|
334
|
-
query=await async_maybe_transform(
|
|
335
|
-
{"filepath": filepath}, storage_retrieve_file_by_path_params.StorageRetrieveFileByPathParams
|
|
336
|
-
),
|
|
337
|
-
),
|
|
338
|
-
cast_to=StorageRetrieveFileByPathResponse,
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
async def upload_file(
|
|
342
|
-
self,
|
|
343
|
-
*,
|
|
344
|
-
file: FileTypes,
|
|
345
|
-
path: str | Omit = omit,
|
|
346
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
347
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
348
|
-
extra_headers: Headers | None = None,
|
|
349
|
-
extra_query: Query | None = None,
|
|
350
|
-
extra_body: Body | None = None,
|
|
351
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
352
|
-
) -> StorageUploadFileResponse:
|
|
353
|
-
"""Uploads a file to S3 storage and returns the file ID and metadata.
|
|
354
|
-
|
|
355
|
-
Optionally
|
|
356
|
-
specify a custom path within the organization's storage bucket.
|
|
357
|
-
|
|
358
|
-
Args:
|
|
359
|
-
file: File to upload (max 50MB)
|
|
360
|
-
|
|
361
|
-
path: Optional custom path within organization storage
|
|
362
|
-
|
|
363
|
-
extra_headers: Send extra headers
|
|
364
|
-
|
|
365
|
-
extra_query: Add additional query parameters to the request
|
|
366
|
-
|
|
367
|
-
extra_body: Add additional JSON properties to the request
|
|
368
|
-
|
|
369
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
370
|
-
"""
|
|
371
|
-
body = deepcopy_minimal(
|
|
372
|
-
{
|
|
373
|
-
"file": file,
|
|
374
|
-
"path": path,
|
|
375
|
-
}
|
|
376
|
-
)
|
|
377
|
-
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
378
|
-
# It should be noted that the actual Content-Type header that will be
|
|
379
|
-
# sent to the server will contain a `boundary` parameter, e.g.
|
|
380
|
-
# multipart/form-data; boundary=---abc--
|
|
381
|
-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
382
|
-
return await self._post(
|
|
383
|
-
"/storage/upload",
|
|
384
|
-
body=await async_maybe_transform(body, storage_upload_file_params.StorageUploadFileParams),
|
|
385
|
-
files=files,
|
|
386
|
-
options=make_request_options(
|
|
387
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
388
|
-
),
|
|
389
|
-
cast_to=StorageUploadFileResponse,
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
class StorageResourceWithRawResponse:
|
|
394
|
-
def __init__(self, storage: StorageResource) -> None:
|
|
395
|
-
self._storage = storage
|
|
396
|
-
|
|
397
|
-
self.delete_file_by_id = to_raw_response_wrapper(
|
|
398
|
-
storage.delete_file_by_id,
|
|
399
|
-
)
|
|
400
|
-
self.retrieve_file_by_id = to_raw_response_wrapper(
|
|
401
|
-
storage.retrieve_file_by_id,
|
|
402
|
-
)
|
|
403
|
-
self.retrieve_file_by_path = to_raw_response_wrapper(
|
|
404
|
-
storage.retrieve_file_by_path,
|
|
405
|
-
)
|
|
406
|
-
self.upload_file = to_raw_response_wrapper(
|
|
407
|
-
storage.upload_file,
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
class AsyncStorageResourceWithRawResponse:
|
|
412
|
-
def __init__(self, storage: AsyncStorageResource) -> None:
|
|
413
|
-
self._storage = storage
|
|
414
|
-
|
|
415
|
-
self.delete_file_by_id = async_to_raw_response_wrapper(
|
|
416
|
-
storage.delete_file_by_id,
|
|
417
|
-
)
|
|
418
|
-
self.retrieve_file_by_id = async_to_raw_response_wrapper(
|
|
419
|
-
storage.retrieve_file_by_id,
|
|
420
|
-
)
|
|
421
|
-
self.retrieve_file_by_path = async_to_raw_response_wrapper(
|
|
422
|
-
storage.retrieve_file_by_path,
|
|
423
|
-
)
|
|
424
|
-
self.upload_file = async_to_raw_response_wrapper(
|
|
425
|
-
storage.upload_file,
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
class StorageResourceWithStreamingResponse:
|
|
430
|
-
def __init__(self, storage: StorageResource) -> None:
|
|
431
|
-
self._storage = storage
|
|
432
|
-
|
|
433
|
-
self.delete_file_by_id = to_streamed_response_wrapper(
|
|
434
|
-
storage.delete_file_by_id,
|
|
435
|
-
)
|
|
436
|
-
self.retrieve_file_by_id = to_streamed_response_wrapper(
|
|
437
|
-
storage.retrieve_file_by_id,
|
|
438
|
-
)
|
|
439
|
-
self.retrieve_file_by_path = to_streamed_response_wrapper(
|
|
440
|
-
storage.retrieve_file_by_path,
|
|
441
|
-
)
|
|
442
|
-
self.upload_file = to_streamed_response_wrapper(
|
|
443
|
-
storage.upload_file,
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
class AsyncStorageResourceWithStreamingResponse:
|
|
448
|
-
def __init__(self, storage: AsyncStorageResource) -> None:
|
|
449
|
-
self._storage = storage
|
|
450
|
-
|
|
451
|
-
self.delete_file_by_id = async_to_streamed_response_wrapper(
|
|
452
|
-
storage.delete_file_by_id,
|
|
453
|
-
)
|
|
454
|
-
self.retrieve_file_by_id = async_to_streamed_response_wrapper(
|
|
455
|
-
storage.retrieve_file_by_id,
|
|
456
|
-
)
|
|
457
|
-
self.retrieve_file_by_path = async_to_streamed_response_wrapper(
|
|
458
|
-
storage.retrieve_file_by_path,
|
|
459
|
-
)
|
|
460
|
-
self.upload_file = async_to_streamed_response_wrapper(
|
|
461
|
-
storage.upload_file,
|
|
462
|
-
)
|
|
72
|
+
return self._client.delete(f"/api/storage/delete/{file_id}")
|