athena-intelligence 0.1.127__py3-none-any.whl → 0.1.184__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.184.dist-info}/METADATA +3 -7
- athena_intelligence-0.1.184.dist-info/RECORD +112 -0
- {athena_intelligence-0.1.127.dist-info → athena_intelligence-0.1.184.dist-info}/WHEEL +1 -1
- athena_intelligence-0.1.127.dist-info/RECORD +0 -89
athena/tools/client.py
CHANGED
@@ -1,39 +1,22 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
import typing
|
4
|
-
|
5
|
-
from
|
6
|
-
from .
|
7
|
-
from .structured_data_extractor.client import StructuredDataExtractorClient
|
8
|
-
from .tasks.client import TasksClient
|
4
|
+
|
5
|
+
from .. import core
|
6
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
7
|
from ..core.request_options import RequestOptions
|
10
|
-
from ..types.file_chunk_request_out import FileChunkRequestOut
|
11
|
-
from ..core.pydantic_utilities import parse_obj_as
|
12
|
-
from ..errors.unauthorized_error import UnauthorizedError
|
13
|
-
from ..errors.not_found_error import NotFoundError
|
14
|
-
from ..types.asset_not_found_error import AssetNotFoundError
|
15
|
-
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
16
|
-
from json.decoder import JSONDecodeError
|
17
|
-
from ..core.api_error import ApiError
|
18
8
|
from ..types.asset_content_request_out import AssetContentRequestOut
|
19
9
|
from ..types.asset_screenshot_response_out import AssetScreenshotResponseOut
|
20
|
-
from ..errors.internal_server_error import InternalServerError
|
21
|
-
from ..types.folder_response import FolderResponse
|
22
|
-
from ..errors.bad_request_error import BadRequestError
|
23
|
-
from ..types.parent_folder_error import ParentFolderError
|
24
|
-
from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
|
25
10
|
from ..types.data_frame_request_out import DataFrameRequestOut
|
26
|
-
from ..
|
27
|
-
from ..types.
|
28
|
-
from .. import core
|
11
|
+
from ..types.file_chunk_request_out import FileChunkRequestOut
|
12
|
+
from ..types.folder_response import FolderResponse
|
29
13
|
from ..types.save_asset_request_out import SaveAssetRequestOut
|
30
|
-
from
|
31
|
-
from
|
32
|
-
from
|
33
|
-
from .
|
34
|
-
from .
|
35
|
-
from .
|
36
|
-
from .tasks.client import AsyncTasksClient
|
14
|
+
from .calendar.client import AsyncCalendarClient, CalendarClient
|
15
|
+
from .email.client import AsyncEmailClient, EmailClient
|
16
|
+
from .raw_client import AsyncRawToolsClient, RawToolsClient
|
17
|
+
from .structured_data_extractor.client import AsyncStructuredDataExtractorClient, StructuredDataExtractorClient
|
18
|
+
from .tasks.client import AsyncTasksClient, TasksClient
|
19
|
+
from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
|
37
20
|
|
38
21
|
# this is used as the default value for optional parameters
|
39
22
|
OMIT = typing.cast(typing.Any, ...)
|
@@ -41,11 +24,25 @@ OMIT = typing.cast(typing.Any, ...)
|
|
41
24
|
|
42
25
|
class ToolsClient:
|
43
26
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
44
|
-
self.
|
45
|
-
self.calendar = CalendarClient(client_wrapper=
|
46
|
-
|
47
|
-
self.
|
48
|
-
|
27
|
+
self._raw_client = RawToolsClient(client_wrapper=client_wrapper)
|
28
|
+
self.calendar = CalendarClient(client_wrapper=client_wrapper)
|
29
|
+
|
30
|
+
self.email = EmailClient(client_wrapper=client_wrapper)
|
31
|
+
|
32
|
+
self.structured_data_extractor = StructuredDataExtractorClient(client_wrapper=client_wrapper)
|
33
|
+
|
34
|
+
self.tasks = TasksClient(client_wrapper=client_wrapper)
|
35
|
+
|
36
|
+
@property
|
37
|
+
def with_raw_response(self) -> RawToolsClient:
|
38
|
+
"""
|
39
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
40
|
+
|
41
|
+
Returns
|
42
|
+
-------
|
43
|
+
RawToolsClient
|
44
|
+
"""
|
45
|
+
return self._raw_client
|
49
46
|
|
50
47
|
def get_asset_chunks(
|
51
48
|
self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
@@ -80,61 +77,8 @@ class ToolsClient:
|
|
80
77
|
],
|
81
78
|
)
|
82
79
|
"""
|
83
|
-
_response = self.
|
84
|
-
|
85
|
-
method="POST",
|
86
|
-
json={
|
87
|
-
"asset_ids": asset_ids,
|
88
|
-
},
|
89
|
-
headers={
|
90
|
-
"content-type": "application/json",
|
91
|
-
},
|
92
|
-
request_options=request_options,
|
93
|
-
omit=OMIT,
|
94
|
-
)
|
95
|
-
try:
|
96
|
-
if 200 <= _response.status_code < 300:
|
97
|
-
return typing.cast(
|
98
|
-
FileChunkRequestOut,
|
99
|
-
parse_obj_as(
|
100
|
-
type_=FileChunkRequestOut, # type: ignore
|
101
|
-
object_=_response.json(),
|
102
|
-
),
|
103
|
-
)
|
104
|
-
if _response.status_code == 401:
|
105
|
-
raise UnauthorizedError(
|
106
|
-
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
|
-
if _response.status_code == 404:
|
115
|
-
raise NotFoundError(
|
116
|
-
typing.cast(
|
117
|
-
AssetNotFoundError,
|
118
|
-
parse_obj_as(
|
119
|
-
type_=AssetNotFoundError, # type: ignore
|
120
|
-
object_=_response.json(),
|
121
|
-
),
|
122
|
-
)
|
123
|
-
)
|
124
|
-
if _response.status_code == 422:
|
125
|
-
raise UnprocessableEntityError(
|
126
|
-
typing.cast(
|
127
|
-
typing.Optional[typing.Any],
|
128
|
-
parse_obj_as(
|
129
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
130
|
-
object_=_response.json(),
|
131
|
-
),
|
132
|
-
)
|
133
|
-
)
|
134
|
-
_response_json = _response.json()
|
135
|
-
except JSONDecodeError:
|
136
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
137
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
80
|
+
_response = self._raw_client.get_asset_chunks(asset_ids=asset_ids, request_options=request_options)
|
81
|
+
return _response.data
|
138
82
|
|
139
83
|
def get_asset_content(
|
140
84
|
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -165,57 +109,8 @@ class ToolsClient:
|
|
165
109
|
asset_id="asset_id",
|
166
110
|
)
|
167
111
|
"""
|
168
|
-
_response = self.
|
169
|
-
|
170
|
-
method="GET",
|
171
|
-
params={
|
172
|
-
"asset_id": asset_id,
|
173
|
-
},
|
174
|
-
request_options=request_options,
|
175
|
-
)
|
176
|
-
try:
|
177
|
-
if 200 <= _response.status_code < 300:
|
178
|
-
return typing.cast(
|
179
|
-
AssetContentRequestOut,
|
180
|
-
parse_obj_as(
|
181
|
-
type_=AssetContentRequestOut, # type: ignore
|
182
|
-
object_=_response.json(),
|
183
|
-
),
|
184
|
-
)
|
185
|
-
if _response.status_code == 401:
|
186
|
-
raise UnauthorizedError(
|
187
|
-
typing.cast(
|
188
|
-
typing.Optional[typing.Any],
|
189
|
-
parse_obj_as(
|
190
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
191
|
-
object_=_response.json(),
|
192
|
-
),
|
193
|
-
)
|
194
|
-
)
|
195
|
-
if _response.status_code == 404:
|
196
|
-
raise NotFoundError(
|
197
|
-
typing.cast(
|
198
|
-
AssetNotFoundError,
|
199
|
-
parse_obj_as(
|
200
|
-
type_=AssetNotFoundError, # type: ignore
|
201
|
-
object_=_response.json(),
|
202
|
-
),
|
203
|
-
)
|
204
|
-
)
|
205
|
-
if _response.status_code == 422:
|
206
|
-
raise UnprocessableEntityError(
|
207
|
-
typing.cast(
|
208
|
-
typing.Optional[typing.Any],
|
209
|
-
parse_obj_as(
|
210
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
211
|
-
object_=_response.json(),
|
212
|
-
),
|
213
|
-
)
|
214
|
-
)
|
215
|
-
_response_json = _response.json()
|
216
|
-
except JSONDecodeError:
|
217
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
218
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
112
|
+
_response = self._raw_client.get_asset_content(asset_id=asset_id, request_options=request_options)
|
113
|
+
return _response.data
|
219
114
|
|
220
115
|
def get_asset_screenshot(
|
221
116
|
self,
|
@@ -252,82 +147,27 @@ class ToolsClient:
|
|
252
147
|
asset_id="asset_id",
|
253
148
|
)
|
254
149
|
"""
|
255
|
-
_response = self.
|
256
|
-
|
257
|
-
method="GET",
|
258
|
-
params={
|
259
|
-
"asset_id": asset_id,
|
260
|
-
"page_number": page_number,
|
261
|
-
},
|
262
|
-
request_options=request_options,
|
150
|
+
_response = self._raw_client.get_asset_screenshot(
|
151
|
+
asset_id=asset_id, page_number=page_number, request_options=request_options
|
263
152
|
)
|
264
|
-
|
265
|
-
if 200 <= _response.status_code < 300:
|
266
|
-
return typing.cast(
|
267
|
-
AssetScreenshotResponseOut,
|
268
|
-
parse_obj_as(
|
269
|
-
type_=AssetScreenshotResponseOut, # type: ignore
|
270
|
-
object_=_response.json(),
|
271
|
-
),
|
272
|
-
)
|
273
|
-
if _response.status_code == 401:
|
274
|
-
raise UnauthorizedError(
|
275
|
-
typing.cast(
|
276
|
-
typing.Optional[typing.Any],
|
277
|
-
parse_obj_as(
|
278
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
279
|
-
object_=_response.json(),
|
280
|
-
),
|
281
|
-
)
|
282
|
-
)
|
283
|
-
if _response.status_code == 404:
|
284
|
-
raise NotFoundError(
|
285
|
-
typing.cast(
|
286
|
-
AssetNotFoundError,
|
287
|
-
parse_obj_as(
|
288
|
-
type_=AssetNotFoundError, # type: ignore
|
289
|
-
object_=_response.json(),
|
290
|
-
),
|
291
|
-
)
|
292
|
-
)
|
293
|
-
if _response.status_code == 422:
|
294
|
-
raise UnprocessableEntityError(
|
295
|
-
typing.cast(
|
296
|
-
typing.Optional[typing.Any],
|
297
|
-
parse_obj_as(
|
298
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
299
|
-
object_=_response.json(),
|
300
|
-
),
|
301
|
-
)
|
302
|
-
)
|
303
|
-
if _response.status_code == 500:
|
304
|
-
raise InternalServerError(
|
305
|
-
typing.cast(
|
306
|
-
typing.Optional[typing.Any],
|
307
|
-
parse_obj_as(
|
308
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
309
|
-
object_=_response.json(),
|
310
|
-
),
|
311
|
-
)
|
312
|
-
)
|
313
|
-
_response_json = _response.json()
|
314
|
-
except JSONDecodeError:
|
315
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
316
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
153
|
+
return _response.data
|
317
154
|
|
318
155
|
def list_contents(
|
319
156
|
self,
|
320
157
|
*,
|
158
|
+
asset_id: typing.Optional[str] = None,
|
321
159
|
folder_id: typing.Optional[str] = None,
|
322
160
|
include_asset_details: typing.Optional[bool] = None,
|
323
161
|
include_system_files: typing.Optional[bool] = None,
|
324
162
|
request_options: typing.Optional[RequestOptions] = None,
|
325
163
|
) -> FolderResponse:
|
326
164
|
"""
|
327
|
-
List contents of
|
165
|
+
List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
|
328
166
|
|
329
167
|
Parameters
|
330
168
|
----------
|
169
|
+
asset_id : typing.Optional[str]
|
170
|
+
|
331
171
|
folder_id : typing.Optional[str]
|
332
172
|
|
333
173
|
include_asset_details : typing.Optional[bool]
|
@@ -351,69 +191,14 @@ class ToolsClient:
|
|
351
191
|
)
|
352
192
|
client.tools.list_contents()
|
353
193
|
"""
|
354
|
-
_response = self.
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
"include_asset_details": include_asset_details,
|
360
|
-
"include_system_files": include_system_files,
|
361
|
-
},
|
194
|
+
_response = self._raw_client.list_contents(
|
195
|
+
asset_id=asset_id,
|
196
|
+
folder_id=folder_id,
|
197
|
+
include_asset_details=include_asset_details,
|
198
|
+
include_system_files=include_system_files,
|
362
199
|
request_options=request_options,
|
363
200
|
)
|
364
|
-
|
365
|
-
if 200 <= _response.status_code < 300:
|
366
|
-
return typing.cast(
|
367
|
-
FolderResponse,
|
368
|
-
parse_obj_as(
|
369
|
-
type_=FolderResponse, # type: ignore
|
370
|
-
object_=_response.json(),
|
371
|
-
),
|
372
|
-
)
|
373
|
-
if _response.status_code == 400:
|
374
|
-
raise BadRequestError(
|
375
|
-
typing.cast(
|
376
|
-
ParentFolderError,
|
377
|
-
parse_obj_as(
|
378
|
-
type_=ParentFolderError, # type: ignore
|
379
|
-
object_=_response.json(),
|
380
|
-
),
|
381
|
-
)
|
382
|
-
)
|
383
|
-
if _response.status_code == 401:
|
384
|
-
raise UnauthorizedError(
|
385
|
-
typing.cast(
|
386
|
-
typing.Optional[typing.Any],
|
387
|
-
parse_obj_as(
|
388
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
389
|
-
object_=_response.json(),
|
390
|
-
),
|
391
|
-
)
|
392
|
-
)
|
393
|
-
if _response.status_code == 404:
|
394
|
-
raise NotFoundError(
|
395
|
-
typing.cast(
|
396
|
-
AssetNotFoundError,
|
397
|
-
parse_obj_as(
|
398
|
-
type_=AssetNotFoundError, # type: ignore
|
399
|
-
object_=_response.json(),
|
400
|
-
),
|
401
|
-
)
|
402
|
-
)
|
403
|
-
if _response.status_code == 422:
|
404
|
-
raise UnprocessableEntityError(
|
405
|
-
typing.cast(
|
406
|
-
typing.Optional[typing.Any],
|
407
|
-
parse_obj_as(
|
408
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
409
|
-
object_=_response.json(),
|
410
|
-
),
|
411
|
-
)
|
412
|
-
)
|
413
|
-
_response_json = _response.json()
|
414
|
-
except JSONDecodeError:
|
415
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
416
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
201
|
+
return _response.data
|
417
202
|
|
418
203
|
def data_frame(
|
419
204
|
self,
|
@@ -465,82 +250,16 @@ class ToolsClient:
|
|
465
250
|
asset_id="asset_id",
|
466
251
|
)
|
467
252
|
"""
|
468
|
-
_response = self.
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
"columns": columns,
|
476
|
-
"sheet_name": sheet_name,
|
477
|
-
"separator": separator,
|
478
|
-
},
|
253
|
+
_response = self._raw_client.data_frame(
|
254
|
+
asset_id=asset_id,
|
255
|
+
row_limit=row_limit,
|
256
|
+
index_column=index_column,
|
257
|
+
columns=columns,
|
258
|
+
sheet_name=sheet_name,
|
259
|
+
separator=separator,
|
479
260
|
request_options=request_options,
|
480
261
|
)
|
481
|
-
|
482
|
-
if 200 <= _response.status_code < 300:
|
483
|
-
return typing.cast(
|
484
|
-
DataFrameRequestOut,
|
485
|
-
parse_obj_as(
|
486
|
-
type_=DataFrameRequestOut, # type: ignore
|
487
|
-
object_=_response.json(),
|
488
|
-
),
|
489
|
-
)
|
490
|
-
if _response.status_code == 401:
|
491
|
-
raise UnauthorizedError(
|
492
|
-
typing.cast(
|
493
|
-
typing.Optional[typing.Any],
|
494
|
-
parse_obj_as(
|
495
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
496
|
-
object_=_response.json(),
|
497
|
-
),
|
498
|
-
)
|
499
|
-
)
|
500
|
-
if _response.status_code == 404:
|
501
|
-
raise NotFoundError(
|
502
|
-
typing.cast(
|
503
|
-
AssetNotFoundError,
|
504
|
-
parse_obj_as(
|
505
|
-
type_=AssetNotFoundError, # type: ignore
|
506
|
-
object_=_response.json(),
|
507
|
-
),
|
508
|
-
)
|
509
|
-
)
|
510
|
-
if _response.status_code == 415:
|
511
|
-
raise UnsupportedMediaTypeError(
|
512
|
-
typing.cast(
|
513
|
-
DataFrameUnknownFormatError,
|
514
|
-
parse_obj_as(
|
515
|
-
type_=DataFrameUnknownFormatError, # type: ignore
|
516
|
-
object_=_response.json(),
|
517
|
-
),
|
518
|
-
)
|
519
|
-
)
|
520
|
-
if _response.status_code == 422:
|
521
|
-
raise UnprocessableEntityError(
|
522
|
-
typing.cast(
|
523
|
-
typing.Optional[typing.Any],
|
524
|
-
parse_obj_as(
|
525
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
526
|
-
object_=_response.json(),
|
527
|
-
),
|
528
|
-
)
|
529
|
-
)
|
530
|
-
if _response.status_code == 500:
|
531
|
-
raise InternalServerError(
|
532
|
-
typing.cast(
|
533
|
-
typing.Optional[typing.Any],
|
534
|
-
parse_obj_as(
|
535
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
536
|
-
object_=_response.json(),
|
537
|
-
),
|
538
|
-
)
|
539
|
-
)
|
540
|
-
_response_json = _response.json()
|
541
|
-
except JSONDecodeError:
|
542
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
543
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
262
|
+
return _response.data
|
544
263
|
|
545
264
|
def raw_data(
|
546
265
|
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -555,70 +274,13 @@ class ToolsClient:
|
|
555
274
|
request_options : typing.Optional[RequestOptions]
|
556
275
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
557
276
|
|
558
|
-
|
559
|
-
|
277
|
+
Returns
|
278
|
+
-------
|
560
279
|
typing.Iterator[bytes]
|
561
280
|
Stream the file in original format.
|
562
281
|
"""
|
563
|
-
with self.
|
564
|
-
|
565
|
-
method="GET",
|
566
|
-
params={
|
567
|
-
"asset_id": asset_id,
|
568
|
-
},
|
569
|
-
request_options=request_options,
|
570
|
-
) as _response:
|
571
|
-
try:
|
572
|
-
if 200 <= _response.status_code < 300:
|
573
|
-
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
574
|
-
for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
|
575
|
-
yield _chunk
|
576
|
-
return
|
577
|
-
_response.read()
|
578
|
-
if _response.status_code == 401:
|
579
|
-
raise UnauthorizedError(
|
580
|
-
typing.cast(
|
581
|
-
typing.Optional[typing.Any],
|
582
|
-
parse_obj_as(
|
583
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
584
|
-
object_=_response.json(),
|
585
|
-
),
|
586
|
-
)
|
587
|
-
)
|
588
|
-
if _response.status_code == 404:
|
589
|
-
raise NotFoundError(
|
590
|
-
typing.cast(
|
591
|
-
AssetNotFoundError,
|
592
|
-
parse_obj_as(
|
593
|
-
type_=AssetNotFoundError, # type: ignore
|
594
|
-
object_=_response.json(),
|
595
|
-
),
|
596
|
-
)
|
597
|
-
)
|
598
|
-
if _response.status_code == 422:
|
599
|
-
raise UnprocessableEntityError(
|
600
|
-
typing.cast(
|
601
|
-
typing.Optional[typing.Any],
|
602
|
-
parse_obj_as(
|
603
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
604
|
-
object_=_response.json(),
|
605
|
-
),
|
606
|
-
)
|
607
|
-
)
|
608
|
-
if _response.status_code == 500:
|
609
|
-
raise InternalServerError(
|
610
|
-
typing.cast(
|
611
|
-
typing.Optional[typing.Any],
|
612
|
-
parse_obj_as(
|
613
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
614
|
-
object_=_response.json(),
|
615
|
-
),
|
616
|
-
)
|
617
|
-
)
|
618
|
-
_response_json = _response.json()
|
619
|
-
except JSONDecodeError:
|
620
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
621
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
282
|
+
with self._raw_client.raw_data(asset_id=asset_id, request_options=request_options) as r:
|
283
|
+
yield from r.data
|
622
284
|
|
623
285
|
def save_asset(
|
624
286
|
self,
|
@@ -653,71 +315,33 @@ class ToolsClient:
|
|
653
315
|
)
|
654
316
|
client.tools.save_asset()
|
655
317
|
"""
|
656
|
-
_response = self.
|
657
|
-
|
658
|
-
method="POST",
|
659
|
-
params={
|
660
|
-
"parent_folder_id": parent_folder_id,
|
661
|
-
},
|
662
|
-
data={},
|
663
|
-
files={
|
664
|
-
"file": file,
|
665
|
-
},
|
666
|
-
request_options=request_options,
|
667
|
-
omit=OMIT,
|
318
|
+
_response = self._raw_client.save_asset(
|
319
|
+
file=file, parent_folder_id=parent_folder_id, request_options=request_options
|
668
320
|
)
|
669
|
-
|
670
|
-
if 200 <= _response.status_code < 300:
|
671
|
-
return typing.cast(
|
672
|
-
SaveAssetRequestOut,
|
673
|
-
parse_obj_as(
|
674
|
-
type_=SaveAssetRequestOut, # type: ignore
|
675
|
-
object_=_response.json(),
|
676
|
-
),
|
677
|
-
)
|
678
|
-
if _response.status_code == 400:
|
679
|
-
raise BadRequestError(
|
680
|
-
typing.cast(
|
681
|
-
ParentFolderError,
|
682
|
-
parse_obj_as(
|
683
|
-
type_=ParentFolderError, # type: ignore
|
684
|
-
object_=_response.json(),
|
685
|
-
),
|
686
|
-
)
|
687
|
-
)
|
688
|
-
if _response.status_code == 413:
|
689
|
-
raise ContentTooLargeError(
|
690
|
-
typing.cast(
|
691
|
-
FileTooLargeError,
|
692
|
-
parse_obj_as(
|
693
|
-
type_=FileTooLargeError, # type: ignore
|
694
|
-
object_=_response.json(),
|
695
|
-
),
|
696
|
-
)
|
697
|
-
)
|
698
|
-
if _response.status_code == 422:
|
699
|
-
raise UnprocessableEntityError(
|
700
|
-
typing.cast(
|
701
|
-
typing.Optional[typing.Any],
|
702
|
-
parse_obj_as(
|
703
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
704
|
-
object_=_response.json(),
|
705
|
-
),
|
706
|
-
)
|
707
|
-
)
|
708
|
-
_response_json = _response.json()
|
709
|
-
except JSONDecodeError:
|
710
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
711
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
321
|
+
return _response.data
|
712
322
|
|
713
323
|
|
714
324
|
class AsyncToolsClient:
|
715
325
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
716
|
-
self.
|
717
|
-
self.calendar = AsyncCalendarClient(client_wrapper=
|
718
|
-
|
719
|
-
self.
|
720
|
-
|
326
|
+
self._raw_client = AsyncRawToolsClient(client_wrapper=client_wrapper)
|
327
|
+
self.calendar = AsyncCalendarClient(client_wrapper=client_wrapper)
|
328
|
+
|
329
|
+
self.email = AsyncEmailClient(client_wrapper=client_wrapper)
|
330
|
+
|
331
|
+
self.structured_data_extractor = AsyncStructuredDataExtractorClient(client_wrapper=client_wrapper)
|
332
|
+
|
333
|
+
self.tasks = AsyncTasksClient(client_wrapper=client_wrapper)
|
334
|
+
|
335
|
+
@property
|
336
|
+
def with_raw_response(self) -> AsyncRawToolsClient:
|
337
|
+
"""
|
338
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
339
|
+
|
340
|
+
Returns
|
341
|
+
-------
|
342
|
+
AsyncRawToolsClient
|
343
|
+
"""
|
344
|
+
return self._raw_client
|
721
345
|
|
722
346
|
async def get_asset_chunks(
|
723
347
|
self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
|
@@ -760,61 +384,8 @@ class AsyncToolsClient:
|
|
760
384
|
|
761
385
|
asyncio.run(main())
|
762
386
|
"""
|
763
|
-
_response = await self.
|
764
|
-
|
765
|
-
method="POST",
|
766
|
-
json={
|
767
|
-
"asset_ids": asset_ids,
|
768
|
-
},
|
769
|
-
headers={
|
770
|
-
"content-type": "application/json",
|
771
|
-
},
|
772
|
-
request_options=request_options,
|
773
|
-
omit=OMIT,
|
774
|
-
)
|
775
|
-
try:
|
776
|
-
if 200 <= _response.status_code < 300:
|
777
|
-
return typing.cast(
|
778
|
-
FileChunkRequestOut,
|
779
|
-
parse_obj_as(
|
780
|
-
type_=FileChunkRequestOut, # type: ignore
|
781
|
-
object_=_response.json(),
|
782
|
-
),
|
783
|
-
)
|
784
|
-
if _response.status_code == 401:
|
785
|
-
raise UnauthorizedError(
|
786
|
-
typing.cast(
|
787
|
-
typing.Optional[typing.Any],
|
788
|
-
parse_obj_as(
|
789
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
790
|
-
object_=_response.json(),
|
791
|
-
),
|
792
|
-
)
|
793
|
-
)
|
794
|
-
if _response.status_code == 404:
|
795
|
-
raise NotFoundError(
|
796
|
-
typing.cast(
|
797
|
-
AssetNotFoundError,
|
798
|
-
parse_obj_as(
|
799
|
-
type_=AssetNotFoundError, # type: ignore
|
800
|
-
object_=_response.json(),
|
801
|
-
),
|
802
|
-
)
|
803
|
-
)
|
804
|
-
if _response.status_code == 422:
|
805
|
-
raise UnprocessableEntityError(
|
806
|
-
typing.cast(
|
807
|
-
typing.Optional[typing.Any],
|
808
|
-
parse_obj_as(
|
809
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
810
|
-
object_=_response.json(),
|
811
|
-
),
|
812
|
-
)
|
813
|
-
)
|
814
|
-
_response_json = _response.json()
|
815
|
-
except JSONDecodeError:
|
816
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
817
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
387
|
+
_response = await self._raw_client.get_asset_chunks(asset_ids=asset_ids, request_options=request_options)
|
388
|
+
return _response.data
|
818
389
|
|
819
390
|
async def get_asset_content(
|
820
391
|
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -853,57 +424,8 @@ class AsyncToolsClient:
|
|
853
424
|
|
854
425
|
asyncio.run(main())
|
855
426
|
"""
|
856
|
-
_response = await self.
|
857
|
-
|
858
|
-
method="GET",
|
859
|
-
params={
|
860
|
-
"asset_id": asset_id,
|
861
|
-
},
|
862
|
-
request_options=request_options,
|
863
|
-
)
|
864
|
-
try:
|
865
|
-
if 200 <= _response.status_code < 300:
|
866
|
-
return typing.cast(
|
867
|
-
AssetContentRequestOut,
|
868
|
-
parse_obj_as(
|
869
|
-
type_=AssetContentRequestOut, # type: ignore
|
870
|
-
object_=_response.json(),
|
871
|
-
),
|
872
|
-
)
|
873
|
-
if _response.status_code == 401:
|
874
|
-
raise UnauthorizedError(
|
875
|
-
typing.cast(
|
876
|
-
typing.Optional[typing.Any],
|
877
|
-
parse_obj_as(
|
878
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
879
|
-
object_=_response.json(),
|
880
|
-
),
|
881
|
-
)
|
882
|
-
)
|
883
|
-
if _response.status_code == 404:
|
884
|
-
raise NotFoundError(
|
885
|
-
typing.cast(
|
886
|
-
AssetNotFoundError,
|
887
|
-
parse_obj_as(
|
888
|
-
type_=AssetNotFoundError, # type: ignore
|
889
|
-
object_=_response.json(),
|
890
|
-
),
|
891
|
-
)
|
892
|
-
)
|
893
|
-
if _response.status_code == 422:
|
894
|
-
raise UnprocessableEntityError(
|
895
|
-
typing.cast(
|
896
|
-
typing.Optional[typing.Any],
|
897
|
-
parse_obj_as(
|
898
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
899
|
-
object_=_response.json(),
|
900
|
-
),
|
901
|
-
)
|
902
|
-
)
|
903
|
-
_response_json = _response.json()
|
904
|
-
except JSONDecodeError:
|
905
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
906
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
427
|
+
_response = await self._raw_client.get_asset_content(asset_id=asset_id, request_options=request_options)
|
428
|
+
return _response.data
|
907
429
|
|
908
430
|
async def get_asset_screenshot(
|
909
431
|
self,
|
@@ -948,82 +470,27 @@ class AsyncToolsClient:
|
|
948
470
|
|
949
471
|
asyncio.run(main())
|
950
472
|
"""
|
951
|
-
_response = await self.
|
952
|
-
|
953
|
-
method="GET",
|
954
|
-
params={
|
955
|
-
"asset_id": asset_id,
|
956
|
-
"page_number": page_number,
|
957
|
-
},
|
958
|
-
request_options=request_options,
|
473
|
+
_response = await self._raw_client.get_asset_screenshot(
|
474
|
+
asset_id=asset_id, page_number=page_number, request_options=request_options
|
959
475
|
)
|
960
|
-
|
961
|
-
if 200 <= _response.status_code < 300:
|
962
|
-
return typing.cast(
|
963
|
-
AssetScreenshotResponseOut,
|
964
|
-
parse_obj_as(
|
965
|
-
type_=AssetScreenshotResponseOut, # type: ignore
|
966
|
-
object_=_response.json(),
|
967
|
-
),
|
968
|
-
)
|
969
|
-
if _response.status_code == 401:
|
970
|
-
raise UnauthorizedError(
|
971
|
-
typing.cast(
|
972
|
-
typing.Optional[typing.Any],
|
973
|
-
parse_obj_as(
|
974
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
975
|
-
object_=_response.json(),
|
976
|
-
),
|
977
|
-
)
|
978
|
-
)
|
979
|
-
if _response.status_code == 404:
|
980
|
-
raise NotFoundError(
|
981
|
-
typing.cast(
|
982
|
-
AssetNotFoundError,
|
983
|
-
parse_obj_as(
|
984
|
-
type_=AssetNotFoundError, # type: ignore
|
985
|
-
object_=_response.json(),
|
986
|
-
),
|
987
|
-
)
|
988
|
-
)
|
989
|
-
if _response.status_code == 422:
|
990
|
-
raise UnprocessableEntityError(
|
991
|
-
typing.cast(
|
992
|
-
typing.Optional[typing.Any],
|
993
|
-
parse_obj_as(
|
994
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
995
|
-
object_=_response.json(),
|
996
|
-
),
|
997
|
-
)
|
998
|
-
)
|
999
|
-
if _response.status_code == 500:
|
1000
|
-
raise InternalServerError(
|
1001
|
-
typing.cast(
|
1002
|
-
typing.Optional[typing.Any],
|
1003
|
-
parse_obj_as(
|
1004
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1005
|
-
object_=_response.json(),
|
1006
|
-
),
|
1007
|
-
)
|
1008
|
-
)
|
1009
|
-
_response_json = _response.json()
|
1010
|
-
except JSONDecodeError:
|
1011
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1012
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
476
|
+
return _response.data
|
1013
477
|
|
1014
478
|
async def list_contents(
|
1015
479
|
self,
|
1016
480
|
*,
|
481
|
+
asset_id: typing.Optional[str] = None,
|
1017
482
|
folder_id: typing.Optional[str] = None,
|
1018
483
|
include_asset_details: typing.Optional[bool] = None,
|
1019
484
|
include_system_files: typing.Optional[bool] = None,
|
1020
485
|
request_options: typing.Optional[RequestOptions] = None,
|
1021
486
|
) -> FolderResponse:
|
1022
487
|
"""
|
1023
|
-
List contents of
|
488
|
+
List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
|
1024
489
|
|
1025
490
|
Parameters
|
1026
491
|
----------
|
492
|
+
asset_id : typing.Optional[str]
|
493
|
+
|
1027
494
|
folder_id : typing.Optional[str]
|
1028
495
|
|
1029
496
|
include_asset_details : typing.Optional[bool]
|
@@ -1055,69 +522,14 @@ class AsyncToolsClient:
|
|
1055
522
|
|
1056
523
|
asyncio.run(main())
|
1057
524
|
"""
|
1058
|
-
_response = await self.
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
"include_asset_details": include_asset_details,
|
1064
|
-
"include_system_files": include_system_files,
|
1065
|
-
},
|
525
|
+
_response = await self._raw_client.list_contents(
|
526
|
+
asset_id=asset_id,
|
527
|
+
folder_id=folder_id,
|
528
|
+
include_asset_details=include_asset_details,
|
529
|
+
include_system_files=include_system_files,
|
1066
530
|
request_options=request_options,
|
1067
531
|
)
|
1068
|
-
|
1069
|
-
if 200 <= _response.status_code < 300:
|
1070
|
-
return typing.cast(
|
1071
|
-
FolderResponse,
|
1072
|
-
parse_obj_as(
|
1073
|
-
type_=FolderResponse, # type: ignore
|
1074
|
-
object_=_response.json(),
|
1075
|
-
),
|
1076
|
-
)
|
1077
|
-
if _response.status_code == 400:
|
1078
|
-
raise BadRequestError(
|
1079
|
-
typing.cast(
|
1080
|
-
ParentFolderError,
|
1081
|
-
parse_obj_as(
|
1082
|
-
type_=ParentFolderError, # type: ignore
|
1083
|
-
object_=_response.json(),
|
1084
|
-
),
|
1085
|
-
)
|
1086
|
-
)
|
1087
|
-
if _response.status_code == 401:
|
1088
|
-
raise UnauthorizedError(
|
1089
|
-
typing.cast(
|
1090
|
-
typing.Optional[typing.Any],
|
1091
|
-
parse_obj_as(
|
1092
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1093
|
-
object_=_response.json(),
|
1094
|
-
),
|
1095
|
-
)
|
1096
|
-
)
|
1097
|
-
if _response.status_code == 404:
|
1098
|
-
raise NotFoundError(
|
1099
|
-
typing.cast(
|
1100
|
-
AssetNotFoundError,
|
1101
|
-
parse_obj_as(
|
1102
|
-
type_=AssetNotFoundError, # type: ignore
|
1103
|
-
object_=_response.json(),
|
1104
|
-
),
|
1105
|
-
)
|
1106
|
-
)
|
1107
|
-
if _response.status_code == 422:
|
1108
|
-
raise UnprocessableEntityError(
|
1109
|
-
typing.cast(
|
1110
|
-
typing.Optional[typing.Any],
|
1111
|
-
parse_obj_as(
|
1112
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1113
|
-
object_=_response.json(),
|
1114
|
-
),
|
1115
|
-
)
|
1116
|
-
)
|
1117
|
-
_response_json = _response.json()
|
1118
|
-
except JSONDecodeError:
|
1119
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1120
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
532
|
+
return _response.data
|
1121
533
|
|
1122
534
|
async def data_frame(
|
1123
535
|
self,
|
@@ -1177,82 +589,16 @@ class AsyncToolsClient:
|
|
1177
589
|
|
1178
590
|
asyncio.run(main())
|
1179
591
|
"""
|
1180
|
-
_response = await self.
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
"columns": columns,
|
1188
|
-
"sheet_name": sheet_name,
|
1189
|
-
"separator": separator,
|
1190
|
-
},
|
592
|
+
_response = await self._raw_client.data_frame(
|
593
|
+
asset_id=asset_id,
|
594
|
+
row_limit=row_limit,
|
595
|
+
index_column=index_column,
|
596
|
+
columns=columns,
|
597
|
+
sheet_name=sheet_name,
|
598
|
+
separator=separator,
|
1191
599
|
request_options=request_options,
|
1192
600
|
)
|
1193
|
-
|
1194
|
-
if 200 <= _response.status_code < 300:
|
1195
|
-
return typing.cast(
|
1196
|
-
DataFrameRequestOut,
|
1197
|
-
parse_obj_as(
|
1198
|
-
type_=DataFrameRequestOut, # type: ignore
|
1199
|
-
object_=_response.json(),
|
1200
|
-
),
|
1201
|
-
)
|
1202
|
-
if _response.status_code == 401:
|
1203
|
-
raise UnauthorizedError(
|
1204
|
-
typing.cast(
|
1205
|
-
typing.Optional[typing.Any],
|
1206
|
-
parse_obj_as(
|
1207
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1208
|
-
object_=_response.json(),
|
1209
|
-
),
|
1210
|
-
)
|
1211
|
-
)
|
1212
|
-
if _response.status_code == 404:
|
1213
|
-
raise NotFoundError(
|
1214
|
-
typing.cast(
|
1215
|
-
AssetNotFoundError,
|
1216
|
-
parse_obj_as(
|
1217
|
-
type_=AssetNotFoundError, # type: ignore
|
1218
|
-
object_=_response.json(),
|
1219
|
-
),
|
1220
|
-
)
|
1221
|
-
)
|
1222
|
-
if _response.status_code == 415:
|
1223
|
-
raise UnsupportedMediaTypeError(
|
1224
|
-
typing.cast(
|
1225
|
-
DataFrameUnknownFormatError,
|
1226
|
-
parse_obj_as(
|
1227
|
-
type_=DataFrameUnknownFormatError, # type: ignore
|
1228
|
-
object_=_response.json(),
|
1229
|
-
),
|
1230
|
-
)
|
1231
|
-
)
|
1232
|
-
if _response.status_code == 422:
|
1233
|
-
raise UnprocessableEntityError(
|
1234
|
-
typing.cast(
|
1235
|
-
typing.Optional[typing.Any],
|
1236
|
-
parse_obj_as(
|
1237
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1238
|
-
object_=_response.json(),
|
1239
|
-
),
|
1240
|
-
)
|
1241
|
-
)
|
1242
|
-
if _response.status_code == 500:
|
1243
|
-
raise InternalServerError(
|
1244
|
-
typing.cast(
|
1245
|
-
typing.Optional[typing.Any],
|
1246
|
-
parse_obj_as(
|
1247
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1248
|
-
object_=_response.json(),
|
1249
|
-
),
|
1250
|
-
)
|
1251
|
-
)
|
1252
|
-
_response_json = _response.json()
|
1253
|
-
except JSONDecodeError:
|
1254
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1255
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
601
|
+
return _response.data
|
1256
602
|
|
1257
603
|
async def raw_data(
|
1258
604
|
self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -1267,70 +613,14 @@ class AsyncToolsClient:
|
|
1267
613
|
request_options : typing.Optional[RequestOptions]
|
1268
614
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
1269
615
|
|
1270
|
-
|
1271
|
-
|
616
|
+
Returns
|
617
|
+
-------
|
1272
618
|
typing.AsyncIterator[bytes]
|
1273
619
|
Stream the file in original format.
|
1274
620
|
"""
|
1275
|
-
async with self.
|
1276
|
-
|
1277
|
-
|
1278
|
-
params={
|
1279
|
-
"asset_id": asset_id,
|
1280
|
-
},
|
1281
|
-
request_options=request_options,
|
1282
|
-
) as _response:
|
1283
|
-
try:
|
1284
|
-
if 200 <= _response.status_code < 300:
|
1285
|
-
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
1286
|
-
async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
|
1287
|
-
yield _chunk
|
1288
|
-
return
|
1289
|
-
await _response.aread()
|
1290
|
-
if _response.status_code == 401:
|
1291
|
-
raise UnauthorizedError(
|
1292
|
-
typing.cast(
|
1293
|
-
typing.Optional[typing.Any],
|
1294
|
-
parse_obj_as(
|
1295
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1296
|
-
object_=_response.json(),
|
1297
|
-
),
|
1298
|
-
)
|
1299
|
-
)
|
1300
|
-
if _response.status_code == 404:
|
1301
|
-
raise NotFoundError(
|
1302
|
-
typing.cast(
|
1303
|
-
AssetNotFoundError,
|
1304
|
-
parse_obj_as(
|
1305
|
-
type_=AssetNotFoundError, # type: ignore
|
1306
|
-
object_=_response.json(),
|
1307
|
-
),
|
1308
|
-
)
|
1309
|
-
)
|
1310
|
-
if _response.status_code == 422:
|
1311
|
-
raise UnprocessableEntityError(
|
1312
|
-
typing.cast(
|
1313
|
-
typing.Optional[typing.Any],
|
1314
|
-
parse_obj_as(
|
1315
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1316
|
-
object_=_response.json(),
|
1317
|
-
),
|
1318
|
-
)
|
1319
|
-
)
|
1320
|
-
if _response.status_code == 500:
|
1321
|
-
raise InternalServerError(
|
1322
|
-
typing.cast(
|
1323
|
-
typing.Optional[typing.Any],
|
1324
|
-
parse_obj_as(
|
1325
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1326
|
-
object_=_response.json(),
|
1327
|
-
),
|
1328
|
-
)
|
1329
|
-
)
|
1330
|
-
_response_json = _response.json()
|
1331
|
-
except JSONDecodeError:
|
1332
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1333
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
621
|
+
async with self._raw_client.raw_data(asset_id=asset_id, request_options=request_options) as r:
|
622
|
+
async for _chunk in r.data:
|
623
|
+
yield _chunk
|
1334
624
|
|
1335
625
|
async def save_asset(
|
1336
626
|
self,
|
@@ -1373,59 +663,7 @@ class AsyncToolsClient:
|
|
1373
663
|
|
1374
664
|
asyncio.run(main())
|
1375
665
|
"""
|
1376
|
-
_response = await self.
|
1377
|
-
|
1378
|
-
method="POST",
|
1379
|
-
params={
|
1380
|
-
"parent_folder_id": parent_folder_id,
|
1381
|
-
},
|
1382
|
-
data={},
|
1383
|
-
files={
|
1384
|
-
"file": file,
|
1385
|
-
},
|
1386
|
-
request_options=request_options,
|
1387
|
-
omit=OMIT,
|
666
|
+
_response = await self._raw_client.save_asset(
|
667
|
+
file=file, parent_folder_id=parent_folder_id, request_options=request_options
|
1388
668
|
)
|
1389
|
-
|
1390
|
-
if 200 <= _response.status_code < 300:
|
1391
|
-
return typing.cast(
|
1392
|
-
SaveAssetRequestOut,
|
1393
|
-
parse_obj_as(
|
1394
|
-
type_=SaveAssetRequestOut, # type: ignore
|
1395
|
-
object_=_response.json(),
|
1396
|
-
),
|
1397
|
-
)
|
1398
|
-
if _response.status_code == 400:
|
1399
|
-
raise BadRequestError(
|
1400
|
-
typing.cast(
|
1401
|
-
ParentFolderError,
|
1402
|
-
parse_obj_as(
|
1403
|
-
type_=ParentFolderError, # type: ignore
|
1404
|
-
object_=_response.json(),
|
1405
|
-
),
|
1406
|
-
)
|
1407
|
-
)
|
1408
|
-
if _response.status_code == 413:
|
1409
|
-
raise ContentTooLargeError(
|
1410
|
-
typing.cast(
|
1411
|
-
FileTooLargeError,
|
1412
|
-
parse_obj_as(
|
1413
|
-
type_=FileTooLargeError, # type: ignore
|
1414
|
-
object_=_response.json(),
|
1415
|
-
),
|
1416
|
-
)
|
1417
|
-
)
|
1418
|
-
if _response.status_code == 422:
|
1419
|
-
raise UnprocessableEntityError(
|
1420
|
-
typing.cast(
|
1421
|
-
typing.Optional[typing.Any],
|
1422
|
-
parse_obj_as(
|
1423
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
1424
|
-
object_=_response.json(),
|
1425
|
-
),
|
1426
|
-
)
|
1427
|
-
)
|
1428
|
-
_response_json = _response.json()
|
1429
|
-
except JSONDecodeError:
|
1430
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
1431
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
669
|
+
return _response.data
|