athena-intelligence 0.1.127__py3-none-any.whl → 0.1.185__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.
- athena/__init__.py +24 -3
- athena/agents/__init__.py +2 -0
- athena/agents/client.py +51 -95
- athena/agents/drive/__init__.py +2 -0
- athena/agents/drive/client.py +31 -80
- athena/agents/drive/raw_client.py +155 -0
- athena/agents/general/__init__.py +2 -0
- athena/agents/general/client.py +91 -238
- athena/agents/general/raw_client.py +369 -0
- athena/agents/raw_client.py +176 -0
- athena/agents/research/__init__.py +2 -0
- athena/agents/research/client.py +31 -80
- athena/agents/research/raw_client.py +155 -0
- athena/agents/sql/__init__.py +2 -0
- athena/agents/sql/client.py +31 -80
- athena/agents/sql/raw_client.py +155 -0
- athena/assets/__init__.py +4 -0
- athena/assets/client.py +144 -0
- athena/assets/raw_client.py +164 -0
- athena/base_client.py +25 -11
- athena/client.py +1 -1
- athena/core/__init__.py +5 -0
- athena/core/api_error.py +13 -5
- athena/core/client_wrapper.py +33 -8
- athena/core/force_multipart.py +16 -0
- athena/core/http_client.py +70 -26
- athena/core/http_response.py +55 -0
- athena/core/jsonable_encoder.py +0 -1
- athena/core/pydantic_utilities.py +70 -111
- athena/core/serialization.py +7 -3
- athena/errors/__init__.py +2 -0
- athena/errors/bad_request_error.py +4 -2
- athena/errors/content_too_large_error.py +4 -2
- athena/errors/internal_server_error.py +4 -3
- athena/errors/not_found_error.py +4 -2
- athena/errors/unauthorized_error.py +4 -3
- athena/errors/unprocessable_entity_error.py +4 -3
- athena/errors/unsupported_media_type_error.py +4 -2
- athena/query/__init__.py +2 -0
- athena/query/client.py +39 -219
- athena/query/raw_client.py +344 -0
- athena/query/types/__init__.py +2 -0
- athena/tools/__init__.py +2 -0
- athena/tools/calendar/__init__.py +2 -0
- athena/tools/calendar/client.py +35 -79
- athena/tools/calendar/raw_client.py +172 -0
- athena/tools/client.py +114 -876
- athena/tools/email/__init__.py +2 -0
- athena/tools/email/client.py +39 -115
- athena/tools/email/raw_client.py +248 -0
- athena/tools/raw_client.py +1328 -0
- athena/tools/structured_data_extractor/__init__.py +2 -0
- athena/tools/structured_data_extractor/client.py +42 -96
- athena/tools/structured_data_extractor/raw_client.py +240 -0
- athena/tools/tasks/__init__.py +2 -0
- athena/tools/tasks/client.py +31 -43
- athena/tools/tasks/raw_client.py +96 -0
- athena/tools/types/__init__.py +2 -0
- athena/types/__init__.py +24 -2
- athena/types/asset_content_request_out.py +3 -3
- athena/types/asset_node.py +3 -3
- athena/types/asset_not_found_error.py +2 -2
- athena/types/asset_screenshot_response_out.py +4 -4
- athena/types/chunk.py +3 -3
- athena/types/chunk_content_item.py +3 -2
- athena/types/chunk_result.py +3 -3
- athena/types/content.py +7 -0
- athena/types/custom_agent_response.py +2 -2
- athena/types/data_frame_request_out.py +3 -3
- athena/types/data_frame_unknown_format_error.py +2 -2
- athena/types/document_chunk.py +2 -2
- athena/types/drive_agent_response.py +2 -2
- athena/types/file_chunk_request_out.py +3 -3
- athena/types/file_too_large_error.py +2 -2
- athena/types/folder_response.py +10 -4
- athena/types/general_agent_config.py +3 -3
- athena/types/general_agent_config_enabled_tools_item.py +1 -2
- athena/types/general_agent_request.py +15 -4
- athena/types/general_agent_response.py +4 -3
- athena/types/general_agent_response_message.py +100 -0
- athena/types/general_agent_response_message_kwargs.py +74 -0
- athena/types/{tool.py → id.py} +1 -1
- athena/types/image_url_content.py +2 -2
- athena/types/input_message.py +29 -0
- athena/types/input_message_content_item.py +39 -0
- athena/types/paginated_assets_out.py +52 -0
- athena/types/parent_folder_error.py +2 -2
- athena/types/prompt_message.py +3 -3
- athena/types/public_asset_out.py +97 -0
- athena/types/research_agent_response.py +2 -2
- athena/types/save_asset_request_out.py +2 -2
- athena/types/sql_agent_response.py +2 -2
- athena/types/structured_data_extractor_response.py +3 -3
- athena/types/text_content.py +2 -2
- athena/types/type.py +1 -1
- {athena_intelligence-0.1.127.dist-info → athena_intelligence-0.1.185.dist-info}/METADATA +3 -7
- athena_intelligence-0.1.185.dist-info/RECORD +112 -0
- {athena_intelligence-0.1.127.dist-info → athena_intelligence-0.1.185.dist-info}/WHEEL +1 -1
- athena_intelligence-0.1.127.dist-info/RECORD +0 -89
@@ -0,0 +1,1328 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import contextlib
|
4
|
+
import typing
|
5
|
+
from json.decoder import JSONDecodeError
|
6
|
+
|
7
|
+
from .. import core
|
8
|
+
from ..core.api_error import ApiError
|
9
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
10
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
12
|
+
from ..core.request_options import RequestOptions
|
13
|
+
from ..errors.bad_request_error import BadRequestError
|
14
|
+
from ..errors.content_too_large_error import ContentTooLargeError
|
15
|
+
from ..errors.internal_server_error import InternalServerError
|
16
|
+
from ..errors.not_found_error import NotFoundError
|
17
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
18
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
19
|
+
from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
|
20
|
+
from ..types.asset_content_request_out import AssetContentRequestOut
|
21
|
+
from ..types.asset_not_found_error import AssetNotFoundError
|
22
|
+
from ..types.asset_screenshot_response_out import AssetScreenshotResponseOut
|
23
|
+
from ..types.data_frame_request_out import DataFrameRequestOut
|
24
|
+
from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
|
25
|
+
from ..types.file_chunk_request_out import FileChunkRequestOut
|
26
|
+
from ..types.file_too_large_error import FileTooLargeError
|
27
|
+
from ..types.folder_response import FolderResponse
|
28
|
+
from ..types.parent_folder_error import ParentFolderError
|
29
|
+
from ..types.save_asset_request_out import SaveAssetRequestOut
|
30
|
+
from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
|
31
|
+
|
32
|
+
# this is used as the default value for optional parameters
|
33
|
+
OMIT = typing.cast(typing.Any, ...)
|
34
|
+
|
35
|
+
|
36
|
+
class RawToolsClient:
|
37
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
38
|
+
self._client_wrapper = client_wrapper
|
39
|
+
|
40
|
+
def get_asset_chunks(
|
41
|
+
self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
42
|
+
) -> HttpResponse[FileChunkRequestOut]:
|
43
|
+
"""
|
44
|
+
Get the chunks of a file.
|
45
|
+
|
46
|
+
Parameters
|
47
|
+
----------
|
48
|
+
asset_ids : typing.Sequence[str]
|
49
|
+
Identifiers of the assets
|
50
|
+
|
51
|
+
request_options : typing.Optional[RequestOptions]
|
52
|
+
Request-specific configuration.
|
53
|
+
|
54
|
+
Returns
|
55
|
+
-------
|
56
|
+
HttpResponse[FileChunkRequestOut]
|
57
|
+
Successful Response
|
58
|
+
"""
|
59
|
+
_response = self._client_wrapper.httpx_client.request(
|
60
|
+
"api/v0/tools/asset/chunks",
|
61
|
+
method="POST",
|
62
|
+
json={
|
63
|
+
"asset_ids": asset_ids,
|
64
|
+
},
|
65
|
+
headers={
|
66
|
+
"content-type": "application/json",
|
67
|
+
},
|
68
|
+
request_options=request_options,
|
69
|
+
omit=OMIT,
|
70
|
+
)
|
71
|
+
try:
|
72
|
+
if 200 <= _response.status_code < 300:
|
73
|
+
_data = typing.cast(
|
74
|
+
FileChunkRequestOut,
|
75
|
+
parse_obj_as(
|
76
|
+
type_=FileChunkRequestOut, # type: ignore
|
77
|
+
object_=_response.json(),
|
78
|
+
),
|
79
|
+
)
|
80
|
+
return HttpResponse(response=_response, data=_data)
|
81
|
+
if _response.status_code == 401:
|
82
|
+
raise UnauthorizedError(
|
83
|
+
headers=dict(_response.headers),
|
84
|
+
body=typing.cast(
|
85
|
+
typing.Optional[typing.Any],
|
86
|
+
parse_obj_as(
|
87
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
88
|
+
object_=_response.json(),
|
89
|
+
),
|
90
|
+
),
|
91
|
+
)
|
92
|
+
if _response.status_code == 404:
|
93
|
+
raise NotFoundError(
|
94
|
+
headers=dict(_response.headers),
|
95
|
+
body=typing.cast(
|
96
|
+
AssetNotFoundError,
|
97
|
+
parse_obj_as(
|
98
|
+
type_=AssetNotFoundError, # type: ignore
|
99
|
+
object_=_response.json(),
|
100
|
+
),
|
101
|
+
),
|
102
|
+
)
|
103
|
+
if _response.status_code == 422:
|
104
|
+
raise UnprocessableEntityError(
|
105
|
+
headers=dict(_response.headers),
|
106
|
+
body=typing.cast(
|
107
|
+
typing.Optional[typing.Any],
|
108
|
+
parse_obj_as(
|
109
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
110
|
+
object_=_response.json(),
|
111
|
+
),
|
112
|
+
),
|
113
|
+
)
|
114
|
+
_response_json = _response.json()
|
115
|
+
except JSONDecodeError:
|
116
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
117
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
118
|
+
|
119
|
+
def get_asset_content(
|
120
|
+
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
121
|
+
) -> HttpResponse[AssetContentRequestOut]:
|
122
|
+
"""
|
123
|
+
Get the content of an asset.
|
124
|
+
|
125
|
+
Parameters
|
126
|
+
----------
|
127
|
+
asset_id : str
|
128
|
+
|
129
|
+
request_options : typing.Optional[RequestOptions]
|
130
|
+
Request-specific configuration.
|
131
|
+
|
132
|
+
Returns
|
133
|
+
-------
|
134
|
+
HttpResponse[AssetContentRequestOut]
|
135
|
+
Successful Response
|
136
|
+
"""
|
137
|
+
_response = self._client_wrapper.httpx_client.request(
|
138
|
+
"api/v0/tools/asset/content",
|
139
|
+
method="GET",
|
140
|
+
params={
|
141
|
+
"asset_id": asset_id,
|
142
|
+
},
|
143
|
+
request_options=request_options,
|
144
|
+
)
|
145
|
+
try:
|
146
|
+
if 200 <= _response.status_code < 300:
|
147
|
+
_data = typing.cast(
|
148
|
+
AssetContentRequestOut,
|
149
|
+
parse_obj_as(
|
150
|
+
type_=AssetContentRequestOut, # type: ignore
|
151
|
+
object_=_response.json(),
|
152
|
+
),
|
153
|
+
)
|
154
|
+
return HttpResponse(response=_response, data=_data)
|
155
|
+
if _response.status_code == 401:
|
156
|
+
raise UnauthorizedError(
|
157
|
+
headers=dict(_response.headers),
|
158
|
+
body=typing.cast(
|
159
|
+
typing.Optional[typing.Any],
|
160
|
+
parse_obj_as(
|
161
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
162
|
+
object_=_response.json(),
|
163
|
+
),
|
164
|
+
),
|
165
|
+
)
|
166
|
+
if _response.status_code == 404:
|
167
|
+
raise NotFoundError(
|
168
|
+
headers=dict(_response.headers),
|
169
|
+
body=typing.cast(
|
170
|
+
AssetNotFoundError,
|
171
|
+
parse_obj_as(
|
172
|
+
type_=AssetNotFoundError, # type: ignore
|
173
|
+
object_=_response.json(),
|
174
|
+
),
|
175
|
+
),
|
176
|
+
)
|
177
|
+
if _response.status_code == 422:
|
178
|
+
raise UnprocessableEntityError(
|
179
|
+
headers=dict(_response.headers),
|
180
|
+
body=typing.cast(
|
181
|
+
typing.Optional[typing.Any],
|
182
|
+
parse_obj_as(
|
183
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
184
|
+
object_=_response.json(),
|
185
|
+
),
|
186
|
+
),
|
187
|
+
)
|
188
|
+
_response_json = _response.json()
|
189
|
+
except JSONDecodeError:
|
190
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
191
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
192
|
+
|
193
|
+
def get_asset_screenshot(
|
194
|
+
self,
|
195
|
+
*,
|
196
|
+
asset_id: str,
|
197
|
+
page_number: typing.Optional[int] = None,
|
198
|
+
request_options: typing.Optional[RequestOptions] = None,
|
199
|
+
) -> HttpResponse[AssetScreenshotResponseOut]:
|
200
|
+
"""
|
201
|
+
Get a screenshot of a specific page from an asset.
|
202
|
+
|
203
|
+
Parameters
|
204
|
+
----------
|
205
|
+
asset_id : str
|
206
|
+
|
207
|
+
page_number : typing.Optional[int]
|
208
|
+
|
209
|
+
request_options : typing.Optional[RequestOptions]
|
210
|
+
Request-specific configuration.
|
211
|
+
|
212
|
+
Returns
|
213
|
+
-------
|
214
|
+
HttpResponse[AssetScreenshotResponseOut]
|
215
|
+
Successful Response
|
216
|
+
"""
|
217
|
+
_response = self._client_wrapper.httpx_client.request(
|
218
|
+
"api/v0/tools/asset/screenshot",
|
219
|
+
method="GET",
|
220
|
+
params={
|
221
|
+
"asset_id": asset_id,
|
222
|
+
"page_number": page_number,
|
223
|
+
},
|
224
|
+
request_options=request_options,
|
225
|
+
)
|
226
|
+
try:
|
227
|
+
if 200 <= _response.status_code < 300:
|
228
|
+
_data = typing.cast(
|
229
|
+
AssetScreenshotResponseOut,
|
230
|
+
parse_obj_as(
|
231
|
+
type_=AssetScreenshotResponseOut, # type: ignore
|
232
|
+
object_=_response.json(),
|
233
|
+
),
|
234
|
+
)
|
235
|
+
return HttpResponse(response=_response, data=_data)
|
236
|
+
if _response.status_code == 401:
|
237
|
+
raise UnauthorizedError(
|
238
|
+
headers=dict(_response.headers),
|
239
|
+
body=typing.cast(
|
240
|
+
typing.Optional[typing.Any],
|
241
|
+
parse_obj_as(
|
242
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
243
|
+
object_=_response.json(),
|
244
|
+
),
|
245
|
+
),
|
246
|
+
)
|
247
|
+
if _response.status_code == 404:
|
248
|
+
raise NotFoundError(
|
249
|
+
headers=dict(_response.headers),
|
250
|
+
body=typing.cast(
|
251
|
+
AssetNotFoundError,
|
252
|
+
parse_obj_as(
|
253
|
+
type_=AssetNotFoundError, # type: ignore
|
254
|
+
object_=_response.json(),
|
255
|
+
),
|
256
|
+
),
|
257
|
+
)
|
258
|
+
if _response.status_code == 422:
|
259
|
+
raise UnprocessableEntityError(
|
260
|
+
headers=dict(_response.headers),
|
261
|
+
body=typing.cast(
|
262
|
+
typing.Optional[typing.Any],
|
263
|
+
parse_obj_as(
|
264
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
265
|
+
object_=_response.json(),
|
266
|
+
),
|
267
|
+
),
|
268
|
+
)
|
269
|
+
if _response.status_code == 500:
|
270
|
+
raise InternalServerError(
|
271
|
+
headers=dict(_response.headers),
|
272
|
+
body=typing.cast(
|
273
|
+
typing.Optional[typing.Any],
|
274
|
+
parse_obj_as(
|
275
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
276
|
+
object_=_response.json(),
|
277
|
+
),
|
278
|
+
),
|
279
|
+
)
|
280
|
+
_response_json = _response.json()
|
281
|
+
except JSONDecodeError:
|
282
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
283
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
284
|
+
|
285
|
+
def list_contents(
|
286
|
+
self,
|
287
|
+
*,
|
288
|
+
asset_id: typing.Optional[str] = None,
|
289
|
+
folder_id: typing.Optional[str] = None,
|
290
|
+
include_asset_details: typing.Optional[bool] = None,
|
291
|
+
include_system_files: typing.Optional[bool] = None,
|
292
|
+
request_options: typing.Optional[RequestOptions] = None,
|
293
|
+
) -> HttpResponse[FolderResponse]:
|
294
|
+
"""
|
295
|
+
List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
|
296
|
+
|
297
|
+
Parameters
|
298
|
+
----------
|
299
|
+
asset_id : typing.Optional[str]
|
300
|
+
|
301
|
+
folder_id : typing.Optional[str]
|
302
|
+
|
303
|
+
include_asset_details : typing.Optional[bool]
|
304
|
+
|
305
|
+
include_system_files : typing.Optional[bool]
|
306
|
+
|
307
|
+
request_options : typing.Optional[RequestOptions]
|
308
|
+
Request-specific configuration.
|
309
|
+
|
310
|
+
Returns
|
311
|
+
-------
|
312
|
+
HttpResponse[FolderResponse]
|
313
|
+
Successful Response
|
314
|
+
"""
|
315
|
+
_response = self._client_wrapper.httpx_client.request(
|
316
|
+
"api/v0/tools/contents",
|
317
|
+
method="GET",
|
318
|
+
params={
|
319
|
+
"asset_id": asset_id,
|
320
|
+
"folder_id": folder_id,
|
321
|
+
"include_asset_details": include_asset_details,
|
322
|
+
"include_system_files": include_system_files,
|
323
|
+
},
|
324
|
+
request_options=request_options,
|
325
|
+
)
|
326
|
+
try:
|
327
|
+
if 200 <= _response.status_code < 300:
|
328
|
+
_data = typing.cast(
|
329
|
+
FolderResponse,
|
330
|
+
parse_obj_as(
|
331
|
+
type_=FolderResponse, # type: ignore
|
332
|
+
object_=_response.json(),
|
333
|
+
),
|
334
|
+
)
|
335
|
+
return HttpResponse(response=_response, data=_data)
|
336
|
+
if _response.status_code == 400:
|
337
|
+
raise BadRequestError(
|
338
|
+
headers=dict(_response.headers),
|
339
|
+
body=typing.cast(
|
340
|
+
ParentFolderError,
|
341
|
+
parse_obj_as(
|
342
|
+
type_=ParentFolderError, # type: ignore
|
343
|
+
object_=_response.json(),
|
344
|
+
),
|
345
|
+
),
|
346
|
+
)
|
347
|
+
if _response.status_code == 401:
|
348
|
+
raise UnauthorizedError(
|
349
|
+
headers=dict(_response.headers),
|
350
|
+
body=typing.cast(
|
351
|
+
typing.Optional[typing.Any],
|
352
|
+
parse_obj_as(
|
353
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
354
|
+
object_=_response.json(),
|
355
|
+
),
|
356
|
+
),
|
357
|
+
)
|
358
|
+
if _response.status_code == 404:
|
359
|
+
raise NotFoundError(
|
360
|
+
headers=dict(_response.headers),
|
361
|
+
body=typing.cast(
|
362
|
+
AssetNotFoundError,
|
363
|
+
parse_obj_as(
|
364
|
+
type_=AssetNotFoundError, # type: ignore
|
365
|
+
object_=_response.json(),
|
366
|
+
),
|
367
|
+
),
|
368
|
+
)
|
369
|
+
if _response.status_code == 422:
|
370
|
+
raise UnprocessableEntityError(
|
371
|
+
headers=dict(_response.headers),
|
372
|
+
body=typing.cast(
|
373
|
+
typing.Optional[typing.Any],
|
374
|
+
parse_obj_as(
|
375
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
376
|
+
object_=_response.json(),
|
377
|
+
),
|
378
|
+
),
|
379
|
+
)
|
380
|
+
_response_json = _response.json()
|
381
|
+
except JSONDecodeError:
|
382
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
383
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
384
|
+
|
385
|
+
def data_frame(
|
386
|
+
self,
|
387
|
+
*,
|
388
|
+
asset_id: str,
|
389
|
+
row_limit: typing.Optional[int] = None,
|
390
|
+
index_column: typing.Optional[int] = None,
|
391
|
+
columns: typing.Optional[
|
392
|
+
typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
|
393
|
+
] = None,
|
394
|
+
sheet_name: typing.Optional[str] = None,
|
395
|
+
separator: typing.Optional[str] = None,
|
396
|
+
request_options: typing.Optional[RequestOptions] = None,
|
397
|
+
) -> HttpResponse[DataFrameRequestOut]:
|
398
|
+
"""
|
399
|
+
Parameters
|
400
|
+
----------
|
401
|
+
asset_id : str
|
402
|
+
|
403
|
+
row_limit : typing.Optional[int]
|
404
|
+
|
405
|
+
index_column : typing.Optional[int]
|
406
|
+
|
407
|
+
columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
|
408
|
+
should be a list of strings or a list of integers
|
409
|
+
|
410
|
+
sheet_name : typing.Optional[str]
|
411
|
+
only for excel files
|
412
|
+
|
413
|
+
separator : typing.Optional[str]
|
414
|
+
only for csv files
|
415
|
+
|
416
|
+
request_options : typing.Optional[RequestOptions]
|
417
|
+
Request-specific configuration.
|
418
|
+
|
419
|
+
Returns
|
420
|
+
-------
|
421
|
+
HttpResponse[DataFrameRequestOut]
|
422
|
+
Successful Response
|
423
|
+
"""
|
424
|
+
_response = self._client_wrapper.httpx_client.request(
|
425
|
+
"api/v0/tools/file/data-frame",
|
426
|
+
method="GET",
|
427
|
+
params={
|
428
|
+
"asset_id": asset_id,
|
429
|
+
"row_limit": row_limit,
|
430
|
+
"index_column": index_column,
|
431
|
+
"columns": columns,
|
432
|
+
"sheet_name": sheet_name,
|
433
|
+
"separator": separator,
|
434
|
+
},
|
435
|
+
request_options=request_options,
|
436
|
+
)
|
437
|
+
try:
|
438
|
+
if 200 <= _response.status_code < 300:
|
439
|
+
_data = typing.cast(
|
440
|
+
DataFrameRequestOut,
|
441
|
+
parse_obj_as(
|
442
|
+
type_=DataFrameRequestOut, # type: ignore
|
443
|
+
object_=_response.json(),
|
444
|
+
),
|
445
|
+
)
|
446
|
+
return HttpResponse(response=_response, data=_data)
|
447
|
+
if _response.status_code == 401:
|
448
|
+
raise UnauthorizedError(
|
449
|
+
headers=dict(_response.headers),
|
450
|
+
body=typing.cast(
|
451
|
+
typing.Optional[typing.Any],
|
452
|
+
parse_obj_as(
|
453
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
454
|
+
object_=_response.json(),
|
455
|
+
),
|
456
|
+
),
|
457
|
+
)
|
458
|
+
if _response.status_code == 404:
|
459
|
+
raise NotFoundError(
|
460
|
+
headers=dict(_response.headers),
|
461
|
+
body=typing.cast(
|
462
|
+
AssetNotFoundError,
|
463
|
+
parse_obj_as(
|
464
|
+
type_=AssetNotFoundError, # type: ignore
|
465
|
+
object_=_response.json(),
|
466
|
+
),
|
467
|
+
),
|
468
|
+
)
|
469
|
+
if _response.status_code == 415:
|
470
|
+
raise UnsupportedMediaTypeError(
|
471
|
+
headers=dict(_response.headers),
|
472
|
+
body=typing.cast(
|
473
|
+
DataFrameUnknownFormatError,
|
474
|
+
parse_obj_as(
|
475
|
+
type_=DataFrameUnknownFormatError, # type: ignore
|
476
|
+
object_=_response.json(),
|
477
|
+
),
|
478
|
+
),
|
479
|
+
)
|
480
|
+
if _response.status_code == 422:
|
481
|
+
raise UnprocessableEntityError(
|
482
|
+
headers=dict(_response.headers),
|
483
|
+
body=typing.cast(
|
484
|
+
typing.Optional[typing.Any],
|
485
|
+
parse_obj_as(
|
486
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
487
|
+
object_=_response.json(),
|
488
|
+
),
|
489
|
+
),
|
490
|
+
)
|
491
|
+
if _response.status_code == 500:
|
492
|
+
raise InternalServerError(
|
493
|
+
headers=dict(_response.headers),
|
494
|
+
body=typing.cast(
|
495
|
+
typing.Optional[typing.Any],
|
496
|
+
parse_obj_as(
|
497
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
498
|
+
object_=_response.json(),
|
499
|
+
),
|
500
|
+
),
|
501
|
+
)
|
502
|
+
_response_json = _response.json()
|
503
|
+
except JSONDecodeError:
|
504
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
505
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
506
|
+
|
507
|
+
@contextlib.contextmanager
|
508
|
+
def raw_data(
|
509
|
+
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
510
|
+
) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
|
511
|
+
"""
|
512
|
+
Get the raw file data for given asset.
|
513
|
+
|
514
|
+
Parameters
|
515
|
+
----------
|
516
|
+
asset_id : str
|
517
|
+
|
518
|
+
request_options : typing.Optional[RequestOptions]
|
519
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
520
|
+
|
521
|
+
Returns
|
522
|
+
-------
|
523
|
+
typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
|
524
|
+
Stream the file in original format.
|
525
|
+
"""
|
526
|
+
with self._client_wrapper.httpx_client.stream(
|
527
|
+
"api/v0/tools/file/raw-data",
|
528
|
+
method="GET",
|
529
|
+
params={
|
530
|
+
"asset_id": asset_id,
|
531
|
+
},
|
532
|
+
request_options=request_options,
|
533
|
+
) as _response:
|
534
|
+
|
535
|
+
def _stream() -> HttpResponse[typing.Iterator[bytes]]:
|
536
|
+
try:
|
537
|
+
if 200 <= _response.status_code < 300:
|
538
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
539
|
+
return HttpResponse(
|
540
|
+
response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
|
541
|
+
)
|
542
|
+
_response.read()
|
543
|
+
if _response.status_code == 401:
|
544
|
+
raise UnauthorizedError(
|
545
|
+
headers=dict(_response.headers),
|
546
|
+
body=typing.cast(
|
547
|
+
typing.Optional[typing.Any],
|
548
|
+
parse_obj_as(
|
549
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
550
|
+
object_=_response.json(),
|
551
|
+
),
|
552
|
+
),
|
553
|
+
)
|
554
|
+
if _response.status_code == 404:
|
555
|
+
raise NotFoundError(
|
556
|
+
headers=dict(_response.headers),
|
557
|
+
body=typing.cast(
|
558
|
+
AssetNotFoundError,
|
559
|
+
parse_obj_as(
|
560
|
+
type_=AssetNotFoundError, # type: ignore
|
561
|
+
object_=_response.json(),
|
562
|
+
),
|
563
|
+
),
|
564
|
+
)
|
565
|
+
if _response.status_code == 422:
|
566
|
+
raise UnprocessableEntityError(
|
567
|
+
headers=dict(_response.headers),
|
568
|
+
body=typing.cast(
|
569
|
+
typing.Optional[typing.Any],
|
570
|
+
parse_obj_as(
|
571
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
572
|
+
object_=_response.json(),
|
573
|
+
),
|
574
|
+
),
|
575
|
+
)
|
576
|
+
if _response.status_code == 500:
|
577
|
+
raise InternalServerError(
|
578
|
+
headers=dict(_response.headers),
|
579
|
+
body=typing.cast(
|
580
|
+
typing.Optional[typing.Any],
|
581
|
+
parse_obj_as(
|
582
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
583
|
+
object_=_response.json(),
|
584
|
+
),
|
585
|
+
),
|
586
|
+
)
|
587
|
+
_response_json = _response.json()
|
588
|
+
except JSONDecodeError:
|
589
|
+
raise ApiError(
|
590
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
591
|
+
)
|
592
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
593
|
+
|
594
|
+
yield _stream()
|
595
|
+
|
596
|
+
def save_asset(
|
597
|
+
self,
|
598
|
+
*,
|
599
|
+
file: core.File,
|
600
|
+
parent_folder_id: typing.Optional[str] = None,
|
601
|
+
request_options: typing.Optional[RequestOptions] = None,
|
602
|
+
) -> HttpResponse[SaveAssetRequestOut]:
|
603
|
+
"""
|
604
|
+
Parameters
|
605
|
+
----------
|
606
|
+
file : core.File
|
607
|
+
See core.File for more documentation
|
608
|
+
|
609
|
+
parent_folder_id : typing.Optional[str]
|
610
|
+
Identifier of the folder into which the asset should be saved
|
611
|
+
|
612
|
+
request_options : typing.Optional[RequestOptions]
|
613
|
+
Request-specific configuration.
|
614
|
+
|
615
|
+
Returns
|
616
|
+
-------
|
617
|
+
HttpResponse[SaveAssetRequestOut]
|
618
|
+
Successful Response
|
619
|
+
"""
|
620
|
+
_response = self._client_wrapper.httpx_client.request(
|
621
|
+
"api/v0/tools/file/save",
|
622
|
+
method="POST",
|
623
|
+
params={
|
624
|
+
"parent_folder_id": parent_folder_id,
|
625
|
+
},
|
626
|
+
data={},
|
627
|
+
files={
|
628
|
+
"file": file,
|
629
|
+
},
|
630
|
+
request_options=request_options,
|
631
|
+
omit=OMIT,
|
632
|
+
force_multipart=True,
|
633
|
+
)
|
634
|
+
try:
|
635
|
+
if 200 <= _response.status_code < 300:
|
636
|
+
_data = typing.cast(
|
637
|
+
SaveAssetRequestOut,
|
638
|
+
parse_obj_as(
|
639
|
+
type_=SaveAssetRequestOut, # type: ignore
|
640
|
+
object_=_response.json(),
|
641
|
+
),
|
642
|
+
)
|
643
|
+
return HttpResponse(response=_response, data=_data)
|
644
|
+
if _response.status_code == 400:
|
645
|
+
raise BadRequestError(
|
646
|
+
headers=dict(_response.headers),
|
647
|
+
body=typing.cast(
|
648
|
+
ParentFolderError,
|
649
|
+
parse_obj_as(
|
650
|
+
type_=ParentFolderError, # type: ignore
|
651
|
+
object_=_response.json(),
|
652
|
+
),
|
653
|
+
),
|
654
|
+
)
|
655
|
+
if _response.status_code == 413:
|
656
|
+
raise ContentTooLargeError(
|
657
|
+
headers=dict(_response.headers),
|
658
|
+
body=typing.cast(
|
659
|
+
FileTooLargeError,
|
660
|
+
parse_obj_as(
|
661
|
+
type_=FileTooLargeError, # type: ignore
|
662
|
+
object_=_response.json(),
|
663
|
+
),
|
664
|
+
),
|
665
|
+
)
|
666
|
+
if _response.status_code == 422:
|
667
|
+
raise UnprocessableEntityError(
|
668
|
+
headers=dict(_response.headers),
|
669
|
+
body=typing.cast(
|
670
|
+
typing.Optional[typing.Any],
|
671
|
+
parse_obj_as(
|
672
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
673
|
+
object_=_response.json(),
|
674
|
+
),
|
675
|
+
),
|
676
|
+
)
|
677
|
+
_response_json = _response.json()
|
678
|
+
except JSONDecodeError:
|
679
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
680
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
681
|
+
|
682
|
+
|
683
|
+
class AsyncRawToolsClient:
|
684
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
685
|
+
self._client_wrapper = client_wrapper
|
686
|
+
|
687
|
+
async def get_asset_chunks(
|
688
|
+
self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
689
|
+
) -> AsyncHttpResponse[FileChunkRequestOut]:
|
690
|
+
"""
|
691
|
+
Get the chunks of a file.
|
692
|
+
|
693
|
+
Parameters
|
694
|
+
----------
|
695
|
+
asset_ids : typing.Sequence[str]
|
696
|
+
Identifiers of the assets
|
697
|
+
|
698
|
+
request_options : typing.Optional[RequestOptions]
|
699
|
+
Request-specific configuration.
|
700
|
+
|
701
|
+
Returns
|
702
|
+
-------
|
703
|
+
AsyncHttpResponse[FileChunkRequestOut]
|
704
|
+
Successful Response
|
705
|
+
"""
|
706
|
+
_response = await self._client_wrapper.httpx_client.request(
|
707
|
+
"api/v0/tools/asset/chunks",
|
708
|
+
method="POST",
|
709
|
+
json={
|
710
|
+
"asset_ids": asset_ids,
|
711
|
+
},
|
712
|
+
headers={
|
713
|
+
"content-type": "application/json",
|
714
|
+
},
|
715
|
+
request_options=request_options,
|
716
|
+
omit=OMIT,
|
717
|
+
)
|
718
|
+
try:
|
719
|
+
if 200 <= _response.status_code < 300:
|
720
|
+
_data = typing.cast(
|
721
|
+
FileChunkRequestOut,
|
722
|
+
parse_obj_as(
|
723
|
+
type_=FileChunkRequestOut, # type: ignore
|
724
|
+
object_=_response.json(),
|
725
|
+
),
|
726
|
+
)
|
727
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
728
|
+
if _response.status_code == 401:
|
729
|
+
raise UnauthorizedError(
|
730
|
+
headers=dict(_response.headers),
|
731
|
+
body=typing.cast(
|
732
|
+
typing.Optional[typing.Any],
|
733
|
+
parse_obj_as(
|
734
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
735
|
+
object_=_response.json(),
|
736
|
+
),
|
737
|
+
),
|
738
|
+
)
|
739
|
+
if _response.status_code == 404:
|
740
|
+
raise NotFoundError(
|
741
|
+
headers=dict(_response.headers),
|
742
|
+
body=typing.cast(
|
743
|
+
AssetNotFoundError,
|
744
|
+
parse_obj_as(
|
745
|
+
type_=AssetNotFoundError, # type: ignore
|
746
|
+
object_=_response.json(),
|
747
|
+
),
|
748
|
+
),
|
749
|
+
)
|
750
|
+
if _response.status_code == 422:
|
751
|
+
raise UnprocessableEntityError(
|
752
|
+
headers=dict(_response.headers),
|
753
|
+
body=typing.cast(
|
754
|
+
typing.Optional[typing.Any],
|
755
|
+
parse_obj_as(
|
756
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
757
|
+
object_=_response.json(),
|
758
|
+
),
|
759
|
+
),
|
760
|
+
)
|
761
|
+
_response_json = _response.json()
|
762
|
+
except JSONDecodeError:
|
763
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
764
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
765
|
+
|
766
|
+
async def get_asset_content(
|
767
|
+
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
768
|
+
) -> AsyncHttpResponse[AssetContentRequestOut]:
|
769
|
+
"""
|
770
|
+
Get the content of an asset.
|
771
|
+
|
772
|
+
Parameters
|
773
|
+
----------
|
774
|
+
asset_id : str
|
775
|
+
|
776
|
+
request_options : typing.Optional[RequestOptions]
|
777
|
+
Request-specific configuration.
|
778
|
+
|
779
|
+
Returns
|
780
|
+
-------
|
781
|
+
AsyncHttpResponse[AssetContentRequestOut]
|
782
|
+
Successful Response
|
783
|
+
"""
|
784
|
+
_response = await self._client_wrapper.httpx_client.request(
|
785
|
+
"api/v0/tools/asset/content",
|
786
|
+
method="GET",
|
787
|
+
params={
|
788
|
+
"asset_id": asset_id,
|
789
|
+
},
|
790
|
+
request_options=request_options,
|
791
|
+
)
|
792
|
+
try:
|
793
|
+
if 200 <= _response.status_code < 300:
|
794
|
+
_data = typing.cast(
|
795
|
+
AssetContentRequestOut,
|
796
|
+
parse_obj_as(
|
797
|
+
type_=AssetContentRequestOut, # type: ignore
|
798
|
+
object_=_response.json(),
|
799
|
+
),
|
800
|
+
)
|
801
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
802
|
+
if _response.status_code == 401:
|
803
|
+
raise UnauthorizedError(
|
804
|
+
headers=dict(_response.headers),
|
805
|
+
body=typing.cast(
|
806
|
+
typing.Optional[typing.Any],
|
807
|
+
parse_obj_as(
|
808
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
809
|
+
object_=_response.json(),
|
810
|
+
),
|
811
|
+
),
|
812
|
+
)
|
813
|
+
if _response.status_code == 404:
|
814
|
+
raise NotFoundError(
|
815
|
+
headers=dict(_response.headers),
|
816
|
+
body=typing.cast(
|
817
|
+
AssetNotFoundError,
|
818
|
+
parse_obj_as(
|
819
|
+
type_=AssetNotFoundError, # type: ignore
|
820
|
+
object_=_response.json(),
|
821
|
+
),
|
822
|
+
),
|
823
|
+
)
|
824
|
+
if _response.status_code == 422:
|
825
|
+
raise UnprocessableEntityError(
|
826
|
+
headers=dict(_response.headers),
|
827
|
+
body=typing.cast(
|
828
|
+
typing.Optional[typing.Any],
|
829
|
+
parse_obj_as(
|
830
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
831
|
+
object_=_response.json(),
|
832
|
+
),
|
833
|
+
),
|
834
|
+
)
|
835
|
+
_response_json = _response.json()
|
836
|
+
except JSONDecodeError:
|
837
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
838
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
839
|
+
|
840
|
+
async def get_asset_screenshot(
|
841
|
+
self,
|
842
|
+
*,
|
843
|
+
asset_id: str,
|
844
|
+
page_number: typing.Optional[int] = None,
|
845
|
+
request_options: typing.Optional[RequestOptions] = None,
|
846
|
+
) -> AsyncHttpResponse[AssetScreenshotResponseOut]:
|
847
|
+
"""
|
848
|
+
Get a screenshot of a specific page from an asset.
|
849
|
+
|
850
|
+
Parameters
|
851
|
+
----------
|
852
|
+
asset_id : str
|
853
|
+
|
854
|
+
page_number : typing.Optional[int]
|
855
|
+
|
856
|
+
request_options : typing.Optional[RequestOptions]
|
857
|
+
Request-specific configuration.
|
858
|
+
|
859
|
+
Returns
|
860
|
+
-------
|
861
|
+
AsyncHttpResponse[AssetScreenshotResponseOut]
|
862
|
+
Successful Response
|
863
|
+
"""
|
864
|
+
_response = await self._client_wrapper.httpx_client.request(
|
865
|
+
"api/v0/tools/asset/screenshot",
|
866
|
+
method="GET",
|
867
|
+
params={
|
868
|
+
"asset_id": asset_id,
|
869
|
+
"page_number": page_number,
|
870
|
+
},
|
871
|
+
request_options=request_options,
|
872
|
+
)
|
873
|
+
try:
|
874
|
+
if 200 <= _response.status_code < 300:
|
875
|
+
_data = typing.cast(
|
876
|
+
AssetScreenshotResponseOut,
|
877
|
+
parse_obj_as(
|
878
|
+
type_=AssetScreenshotResponseOut, # type: ignore
|
879
|
+
object_=_response.json(),
|
880
|
+
),
|
881
|
+
)
|
882
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
883
|
+
if _response.status_code == 401:
|
884
|
+
raise UnauthorizedError(
|
885
|
+
headers=dict(_response.headers),
|
886
|
+
body=typing.cast(
|
887
|
+
typing.Optional[typing.Any],
|
888
|
+
parse_obj_as(
|
889
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
890
|
+
object_=_response.json(),
|
891
|
+
),
|
892
|
+
),
|
893
|
+
)
|
894
|
+
if _response.status_code == 404:
|
895
|
+
raise NotFoundError(
|
896
|
+
headers=dict(_response.headers),
|
897
|
+
body=typing.cast(
|
898
|
+
AssetNotFoundError,
|
899
|
+
parse_obj_as(
|
900
|
+
type_=AssetNotFoundError, # type: ignore
|
901
|
+
object_=_response.json(),
|
902
|
+
),
|
903
|
+
),
|
904
|
+
)
|
905
|
+
if _response.status_code == 422:
|
906
|
+
raise UnprocessableEntityError(
|
907
|
+
headers=dict(_response.headers),
|
908
|
+
body=typing.cast(
|
909
|
+
typing.Optional[typing.Any],
|
910
|
+
parse_obj_as(
|
911
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
912
|
+
object_=_response.json(),
|
913
|
+
),
|
914
|
+
),
|
915
|
+
)
|
916
|
+
if _response.status_code == 500:
|
917
|
+
raise InternalServerError(
|
918
|
+
headers=dict(_response.headers),
|
919
|
+
body=typing.cast(
|
920
|
+
typing.Optional[typing.Any],
|
921
|
+
parse_obj_as(
|
922
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
923
|
+
object_=_response.json(),
|
924
|
+
),
|
925
|
+
),
|
926
|
+
)
|
927
|
+
_response_json = _response.json()
|
928
|
+
except JSONDecodeError:
|
929
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
930
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
931
|
+
|
932
|
+
async def list_contents(
|
933
|
+
self,
|
934
|
+
*,
|
935
|
+
asset_id: typing.Optional[str] = None,
|
936
|
+
folder_id: typing.Optional[str] = None,
|
937
|
+
include_asset_details: typing.Optional[bool] = None,
|
938
|
+
include_system_files: typing.Optional[bool] = None,
|
939
|
+
request_options: typing.Optional[RequestOptions] = None,
|
940
|
+
) -> AsyncHttpResponse[FolderResponse]:
|
941
|
+
"""
|
942
|
+
List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
|
943
|
+
|
944
|
+
Parameters
|
945
|
+
----------
|
946
|
+
asset_id : typing.Optional[str]
|
947
|
+
|
948
|
+
folder_id : typing.Optional[str]
|
949
|
+
|
950
|
+
include_asset_details : typing.Optional[bool]
|
951
|
+
|
952
|
+
include_system_files : typing.Optional[bool]
|
953
|
+
|
954
|
+
request_options : typing.Optional[RequestOptions]
|
955
|
+
Request-specific configuration.
|
956
|
+
|
957
|
+
Returns
|
958
|
+
-------
|
959
|
+
AsyncHttpResponse[FolderResponse]
|
960
|
+
Successful Response
|
961
|
+
"""
|
962
|
+
_response = await self._client_wrapper.httpx_client.request(
|
963
|
+
"api/v0/tools/contents",
|
964
|
+
method="GET",
|
965
|
+
params={
|
966
|
+
"asset_id": asset_id,
|
967
|
+
"folder_id": folder_id,
|
968
|
+
"include_asset_details": include_asset_details,
|
969
|
+
"include_system_files": include_system_files,
|
970
|
+
},
|
971
|
+
request_options=request_options,
|
972
|
+
)
|
973
|
+
try:
|
974
|
+
if 200 <= _response.status_code < 300:
|
975
|
+
_data = typing.cast(
|
976
|
+
FolderResponse,
|
977
|
+
parse_obj_as(
|
978
|
+
type_=FolderResponse, # type: ignore
|
979
|
+
object_=_response.json(),
|
980
|
+
),
|
981
|
+
)
|
982
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
983
|
+
if _response.status_code == 400:
|
984
|
+
raise BadRequestError(
|
985
|
+
headers=dict(_response.headers),
|
986
|
+
body=typing.cast(
|
987
|
+
ParentFolderError,
|
988
|
+
parse_obj_as(
|
989
|
+
type_=ParentFolderError, # type: ignore
|
990
|
+
object_=_response.json(),
|
991
|
+
),
|
992
|
+
),
|
993
|
+
)
|
994
|
+
if _response.status_code == 401:
|
995
|
+
raise UnauthorizedError(
|
996
|
+
headers=dict(_response.headers),
|
997
|
+
body=typing.cast(
|
998
|
+
typing.Optional[typing.Any],
|
999
|
+
parse_obj_as(
|
1000
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1001
|
+
object_=_response.json(),
|
1002
|
+
),
|
1003
|
+
),
|
1004
|
+
)
|
1005
|
+
if _response.status_code == 404:
|
1006
|
+
raise NotFoundError(
|
1007
|
+
headers=dict(_response.headers),
|
1008
|
+
body=typing.cast(
|
1009
|
+
AssetNotFoundError,
|
1010
|
+
parse_obj_as(
|
1011
|
+
type_=AssetNotFoundError, # type: ignore
|
1012
|
+
object_=_response.json(),
|
1013
|
+
),
|
1014
|
+
),
|
1015
|
+
)
|
1016
|
+
if _response.status_code == 422:
|
1017
|
+
raise UnprocessableEntityError(
|
1018
|
+
headers=dict(_response.headers),
|
1019
|
+
body=typing.cast(
|
1020
|
+
typing.Optional[typing.Any],
|
1021
|
+
parse_obj_as(
|
1022
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1023
|
+
object_=_response.json(),
|
1024
|
+
),
|
1025
|
+
),
|
1026
|
+
)
|
1027
|
+
_response_json = _response.json()
|
1028
|
+
except JSONDecodeError:
|
1029
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
1030
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
1031
|
+
|
1032
|
+
async def data_frame(
|
1033
|
+
self,
|
1034
|
+
*,
|
1035
|
+
asset_id: str,
|
1036
|
+
row_limit: typing.Optional[int] = None,
|
1037
|
+
index_column: typing.Optional[int] = None,
|
1038
|
+
columns: typing.Optional[
|
1039
|
+
typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
|
1040
|
+
] = None,
|
1041
|
+
sheet_name: typing.Optional[str] = None,
|
1042
|
+
separator: typing.Optional[str] = None,
|
1043
|
+
request_options: typing.Optional[RequestOptions] = None,
|
1044
|
+
) -> AsyncHttpResponse[DataFrameRequestOut]:
|
1045
|
+
"""
|
1046
|
+
Parameters
|
1047
|
+
----------
|
1048
|
+
asset_id : str
|
1049
|
+
|
1050
|
+
row_limit : typing.Optional[int]
|
1051
|
+
|
1052
|
+
index_column : typing.Optional[int]
|
1053
|
+
|
1054
|
+
columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
|
1055
|
+
should be a list of strings or a list of integers
|
1056
|
+
|
1057
|
+
sheet_name : typing.Optional[str]
|
1058
|
+
only for excel files
|
1059
|
+
|
1060
|
+
separator : typing.Optional[str]
|
1061
|
+
only for csv files
|
1062
|
+
|
1063
|
+
request_options : typing.Optional[RequestOptions]
|
1064
|
+
Request-specific configuration.
|
1065
|
+
|
1066
|
+
Returns
|
1067
|
+
-------
|
1068
|
+
AsyncHttpResponse[DataFrameRequestOut]
|
1069
|
+
Successful Response
|
1070
|
+
"""
|
1071
|
+
_response = await self._client_wrapper.httpx_client.request(
|
1072
|
+
"api/v0/tools/file/data-frame",
|
1073
|
+
method="GET",
|
1074
|
+
params={
|
1075
|
+
"asset_id": asset_id,
|
1076
|
+
"row_limit": row_limit,
|
1077
|
+
"index_column": index_column,
|
1078
|
+
"columns": columns,
|
1079
|
+
"sheet_name": sheet_name,
|
1080
|
+
"separator": separator,
|
1081
|
+
},
|
1082
|
+
request_options=request_options,
|
1083
|
+
)
|
1084
|
+
try:
|
1085
|
+
if 200 <= _response.status_code < 300:
|
1086
|
+
_data = typing.cast(
|
1087
|
+
DataFrameRequestOut,
|
1088
|
+
parse_obj_as(
|
1089
|
+
type_=DataFrameRequestOut, # type: ignore
|
1090
|
+
object_=_response.json(),
|
1091
|
+
),
|
1092
|
+
)
|
1093
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
1094
|
+
if _response.status_code == 401:
|
1095
|
+
raise UnauthorizedError(
|
1096
|
+
headers=dict(_response.headers),
|
1097
|
+
body=typing.cast(
|
1098
|
+
typing.Optional[typing.Any],
|
1099
|
+
parse_obj_as(
|
1100
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1101
|
+
object_=_response.json(),
|
1102
|
+
),
|
1103
|
+
),
|
1104
|
+
)
|
1105
|
+
if _response.status_code == 404:
|
1106
|
+
raise NotFoundError(
|
1107
|
+
headers=dict(_response.headers),
|
1108
|
+
body=typing.cast(
|
1109
|
+
AssetNotFoundError,
|
1110
|
+
parse_obj_as(
|
1111
|
+
type_=AssetNotFoundError, # type: ignore
|
1112
|
+
object_=_response.json(),
|
1113
|
+
),
|
1114
|
+
),
|
1115
|
+
)
|
1116
|
+
if _response.status_code == 415:
|
1117
|
+
raise UnsupportedMediaTypeError(
|
1118
|
+
headers=dict(_response.headers),
|
1119
|
+
body=typing.cast(
|
1120
|
+
DataFrameUnknownFormatError,
|
1121
|
+
parse_obj_as(
|
1122
|
+
type_=DataFrameUnknownFormatError, # type: ignore
|
1123
|
+
object_=_response.json(),
|
1124
|
+
),
|
1125
|
+
),
|
1126
|
+
)
|
1127
|
+
if _response.status_code == 422:
|
1128
|
+
raise UnprocessableEntityError(
|
1129
|
+
headers=dict(_response.headers),
|
1130
|
+
body=typing.cast(
|
1131
|
+
typing.Optional[typing.Any],
|
1132
|
+
parse_obj_as(
|
1133
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1134
|
+
object_=_response.json(),
|
1135
|
+
),
|
1136
|
+
),
|
1137
|
+
)
|
1138
|
+
if _response.status_code == 500:
|
1139
|
+
raise InternalServerError(
|
1140
|
+
headers=dict(_response.headers),
|
1141
|
+
body=typing.cast(
|
1142
|
+
typing.Optional[typing.Any],
|
1143
|
+
parse_obj_as(
|
1144
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1145
|
+
object_=_response.json(),
|
1146
|
+
),
|
1147
|
+
),
|
1148
|
+
)
|
1149
|
+
_response_json = _response.json()
|
1150
|
+
except JSONDecodeError:
|
1151
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
1152
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
1153
|
+
|
1154
|
+
@contextlib.asynccontextmanager
|
1155
|
+
async def raw_data(
|
1156
|
+
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
1157
|
+
) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
|
1158
|
+
"""
|
1159
|
+
Get the raw file data for given asset.
|
1160
|
+
|
1161
|
+
Parameters
|
1162
|
+
----------
|
1163
|
+
asset_id : str
|
1164
|
+
|
1165
|
+
request_options : typing.Optional[RequestOptions]
|
1166
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
1167
|
+
|
1168
|
+
Returns
|
1169
|
+
-------
|
1170
|
+
typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
|
1171
|
+
Stream the file in original format.
|
1172
|
+
"""
|
1173
|
+
async with self._client_wrapper.httpx_client.stream(
|
1174
|
+
"api/v0/tools/file/raw-data",
|
1175
|
+
method="GET",
|
1176
|
+
params={
|
1177
|
+
"asset_id": asset_id,
|
1178
|
+
},
|
1179
|
+
request_options=request_options,
|
1180
|
+
) as _response:
|
1181
|
+
|
1182
|
+
async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
|
1183
|
+
try:
|
1184
|
+
if 200 <= _response.status_code < 300:
|
1185
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
1186
|
+
return AsyncHttpResponse(
|
1187
|
+
response=_response,
|
1188
|
+
data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
|
1189
|
+
)
|
1190
|
+
await _response.aread()
|
1191
|
+
if _response.status_code == 401:
|
1192
|
+
raise UnauthorizedError(
|
1193
|
+
headers=dict(_response.headers),
|
1194
|
+
body=typing.cast(
|
1195
|
+
typing.Optional[typing.Any],
|
1196
|
+
parse_obj_as(
|
1197
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1198
|
+
object_=_response.json(),
|
1199
|
+
),
|
1200
|
+
),
|
1201
|
+
)
|
1202
|
+
if _response.status_code == 404:
|
1203
|
+
raise NotFoundError(
|
1204
|
+
headers=dict(_response.headers),
|
1205
|
+
body=typing.cast(
|
1206
|
+
AssetNotFoundError,
|
1207
|
+
parse_obj_as(
|
1208
|
+
type_=AssetNotFoundError, # type: ignore
|
1209
|
+
object_=_response.json(),
|
1210
|
+
),
|
1211
|
+
),
|
1212
|
+
)
|
1213
|
+
if _response.status_code == 422:
|
1214
|
+
raise UnprocessableEntityError(
|
1215
|
+
headers=dict(_response.headers),
|
1216
|
+
body=typing.cast(
|
1217
|
+
typing.Optional[typing.Any],
|
1218
|
+
parse_obj_as(
|
1219
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1220
|
+
object_=_response.json(),
|
1221
|
+
),
|
1222
|
+
),
|
1223
|
+
)
|
1224
|
+
if _response.status_code == 500:
|
1225
|
+
raise InternalServerError(
|
1226
|
+
headers=dict(_response.headers),
|
1227
|
+
body=typing.cast(
|
1228
|
+
typing.Optional[typing.Any],
|
1229
|
+
parse_obj_as(
|
1230
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1231
|
+
object_=_response.json(),
|
1232
|
+
),
|
1233
|
+
),
|
1234
|
+
)
|
1235
|
+
_response_json = _response.json()
|
1236
|
+
except JSONDecodeError:
|
1237
|
+
raise ApiError(
|
1238
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
1239
|
+
)
|
1240
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
1241
|
+
|
1242
|
+
yield await _stream()
|
1243
|
+
|
1244
|
+
async def save_asset(
|
1245
|
+
self,
|
1246
|
+
*,
|
1247
|
+
file: core.File,
|
1248
|
+
parent_folder_id: typing.Optional[str] = None,
|
1249
|
+
request_options: typing.Optional[RequestOptions] = None,
|
1250
|
+
) -> AsyncHttpResponse[SaveAssetRequestOut]:
|
1251
|
+
"""
|
1252
|
+
Parameters
|
1253
|
+
----------
|
1254
|
+
file : core.File
|
1255
|
+
See core.File for more documentation
|
1256
|
+
|
1257
|
+
parent_folder_id : typing.Optional[str]
|
1258
|
+
Identifier of the folder into which the asset should be saved
|
1259
|
+
|
1260
|
+
request_options : typing.Optional[RequestOptions]
|
1261
|
+
Request-specific configuration.
|
1262
|
+
|
1263
|
+
Returns
|
1264
|
+
-------
|
1265
|
+
AsyncHttpResponse[SaveAssetRequestOut]
|
1266
|
+
Successful Response
|
1267
|
+
"""
|
1268
|
+
_response = await self._client_wrapper.httpx_client.request(
|
1269
|
+
"api/v0/tools/file/save",
|
1270
|
+
method="POST",
|
1271
|
+
params={
|
1272
|
+
"parent_folder_id": parent_folder_id,
|
1273
|
+
},
|
1274
|
+
data={},
|
1275
|
+
files={
|
1276
|
+
"file": file,
|
1277
|
+
},
|
1278
|
+
request_options=request_options,
|
1279
|
+
omit=OMIT,
|
1280
|
+
force_multipart=True,
|
1281
|
+
)
|
1282
|
+
try:
|
1283
|
+
if 200 <= _response.status_code < 300:
|
1284
|
+
_data = typing.cast(
|
1285
|
+
SaveAssetRequestOut,
|
1286
|
+
parse_obj_as(
|
1287
|
+
type_=SaveAssetRequestOut, # type: ignore
|
1288
|
+
object_=_response.json(),
|
1289
|
+
),
|
1290
|
+
)
|
1291
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
1292
|
+
if _response.status_code == 400:
|
1293
|
+
raise BadRequestError(
|
1294
|
+
headers=dict(_response.headers),
|
1295
|
+
body=typing.cast(
|
1296
|
+
ParentFolderError,
|
1297
|
+
parse_obj_as(
|
1298
|
+
type_=ParentFolderError, # type: ignore
|
1299
|
+
object_=_response.json(),
|
1300
|
+
),
|
1301
|
+
),
|
1302
|
+
)
|
1303
|
+
if _response.status_code == 413:
|
1304
|
+
raise ContentTooLargeError(
|
1305
|
+
headers=dict(_response.headers),
|
1306
|
+
body=typing.cast(
|
1307
|
+
FileTooLargeError,
|
1308
|
+
parse_obj_as(
|
1309
|
+
type_=FileTooLargeError, # type: ignore
|
1310
|
+
object_=_response.json(),
|
1311
|
+
),
|
1312
|
+
),
|
1313
|
+
)
|
1314
|
+
if _response.status_code == 422:
|
1315
|
+
raise UnprocessableEntityError(
|
1316
|
+
headers=dict(_response.headers),
|
1317
|
+
body=typing.cast(
|
1318
|
+
typing.Optional[typing.Any],
|
1319
|
+
parse_obj_as(
|
1320
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
1321
|
+
object_=_response.json(),
|
1322
|
+
),
|
1323
|
+
),
|
1324
|
+
)
|
1325
|
+
_response_json = _response.json()
|
1326
|
+
except JSONDecodeError:
|
1327
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
1328
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|