athena-intelligence 0.1.125__py3-none-any.whl → 0.1.127__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. athena/__init__.py +7 -0
  2. athena/agents/client.py +88 -36
  3. athena/agents/drive/client.py +80 -32
  4. athena/agents/general/client.py +222 -91
  5. athena/agents/research/client.py +80 -32
  6. athena/agents/sql/client.py +80 -32
  7. athena/base_client.py +13 -11
  8. athena/client.py +161 -61
  9. athena/core/__init__.py +21 -4
  10. athena/core/client_wrapper.py +9 -10
  11. athena/core/file.py +37 -8
  12. athena/core/http_client.py +97 -41
  13. athena/core/jsonable_encoder.py +33 -31
  14. athena/core/pydantic_utilities.py +272 -4
  15. athena/core/query_encoder.py +38 -13
  16. athena/core/request_options.py +5 -2
  17. athena/core/serialization.py +272 -0
  18. athena/errors/internal_server_error.py +2 -3
  19. athena/errors/unauthorized_error.py +2 -3
  20. athena/errors/unprocessable_entity_error.py +2 -3
  21. athena/query/client.py +208 -58
  22. athena/tools/calendar/client.py +82 -30
  23. athena/tools/client.py +956 -188
  24. athena/tools/email/client.py +117 -43
  25. athena/tools/structured_data_extractor/client.py +118 -67
  26. athena/tools/tasks/client.py +41 -17
  27. athena/types/__init__.py +4 -0
  28. athena/types/asset_content_request_out.py +26 -0
  29. athena/types/asset_node.py +14 -24
  30. athena/types/asset_not_found_error.py +11 -21
  31. athena/types/asset_screenshot_response_out.py +43 -0
  32. athena/types/chunk.py +11 -21
  33. athena/types/chunk_content_item.py +21 -41
  34. athena/types/chunk_result.py +13 -23
  35. athena/types/custom_agent_response.py +12 -22
  36. athena/types/data_frame_request_out.py +11 -21
  37. athena/types/data_frame_unknown_format_error.py +11 -21
  38. athena/types/document_chunk.py +12 -22
  39. athena/types/drive_agent_response.py +12 -22
  40. athena/types/file_chunk_request_out.py +11 -21
  41. athena/types/file_too_large_error.py +11 -21
  42. athena/types/folder_response.py +11 -21
  43. athena/types/general_agent_config.py +12 -21
  44. athena/types/general_agent_config_enabled_tools_item.py +0 -1
  45. athena/types/general_agent_request.py +13 -23
  46. athena/types/general_agent_response.py +12 -22
  47. athena/types/image_url_content.py +11 -21
  48. athena/types/parent_folder_error.py +11 -21
  49. athena/types/prompt_message.py +12 -22
  50. athena/types/research_agent_response.py +12 -22
  51. athena/types/save_asset_request_out.py +11 -21
  52. athena/types/sql_agent_response.py +13 -23
  53. athena/types/structured_data_extractor_response.py +15 -25
  54. athena/types/text_content.py +11 -21
  55. athena/types/tool.py +1 -13
  56. athena/types/type.py +1 -21
  57. athena/version.py +0 -1
  58. {athena_intelligence-0.1.125.dist-info → athena_intelligence-0.1.127.dist-info}/METADATA +12 -4
  59. athena_intelligence-0.1.127.dist-info/RECORD +89 -0
  60. {athena_intelligence-0.1.125.dist-info → athena_intelligence-0.1.127.dist-info}/WHEEL +1 -1
  61. athena_intelligence-0.1.125.dist-info/RECORD +0 -86
athena/tools/client.py CHANGED
@@ -1,33 +1,39 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
4
- from json.decoder import JSONDecodeError
5
-
6
- from .. import core
7
- from ..core.api_error import ApiError
8
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.pydantic_utilities import pydantic_v1
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from .calendar.client import CalendarClient
6
+ from .email.client import EmailClient
7
+ from .structured_data_extractor.client import StructuredDataExtractorClient
8
+ from .tasks.client import TasksClient
10
9
  from ..core.request_options import RequestOptions
11
- from ..errors.bad_request_error import BadRequestError
12
- from ..errors.content_too_large_error import ContentTooLargeError
13
- from ..errors.internal_server_error import InternalServerError
14
- from ..errors.not_found_error import NotFoundError
10
+ from ..types.file_chunk_request_out import FileChunkRequestOut
11
+ from ..core.pydantic_utilities import parse_obj_as
15
12
  from ..errors.unauthorized_error import UnauthorizedError
16
- from ..errors.unprocessable_entity_error import UnprocessableEntityError
17
- from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
13
+ from ..errors.not_found_error import NotFoundError
18
14
  from ..types.asset_not_found_error import AssetNotFoundError
19
- from ..types.data_frame_request_out import DataFrameRequestOut
20
- from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
21
- from ..types.file_chunk_request_out import FileChunkRequestOut
22
- from ..types.file_too_large_error import FileTooLargeError
15
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
16
+ from json.decoder import JSONDecodeError
17
+ from ..core.api_error import ApiError
18
+ from ..types.asset_content_request_out import AssetContentRequestOut
19
+ from ..types.asset_screenshot_response_out import AssetScreenshotResponseOut
20
+ from ..errors.internal_server_error import InternalServerError
23
21
  from ..types.folder_response import FolderResponse
22
+ from ..errors.bad_request_error import BadRequestError
24
23
  from ..types.parent_folder_error import ParentFolderError
25
- from ..types.save_asset_request_out import SaveAssetRequestOut
26
- from .calendar.client import AsyncCalendarClient, CalendarClient
27
- from .email.client import AsyncEmailClient, EmailClient
28
- from .structured_data_extractor.client import AsyncStructuredDataExtractorClient, StructuredDataExtractorClient
29
- from .tasks.client import AsyncTasksClient, TasksClient
30
24
  from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
25
+ from ..types.data_frame_request_out import DataFrameRequestOut
26
+ from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
27
+ from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
28
+ from .. import core
29
+ from ..types.save_asset_request_out import SaveAssetRequestOut
30
+ from ..errors.content_too_large_error import ContentTooLargeError
31
+ from ..types.file_too_large_error import FileTooLargeError
32
+ from ..core.client_wrapper import AsyncClientWrapper
33
+ from .calendar.client import AsyncCalendarClient
34
+ from .email.client import AsyncEmailClient
35
+ from .structured_data_extractor.client import AsyncStructuredDataExtractorClient
36
+ from .tasks.client import AsyncTasksClient
31
37
 
32
38
  # this is used as the default value for optional parameters
33
39
  OMIT = typing.cast(typing.Any, ...)
@@ -62,7 +68,7 @@ class ToolsClient:
62
68
 
63
69
  Examples
64
70
  --------
65
- from athena.client import Athena
71
+ from athena import Athena
66
72
 
67
73
  client = Athena(
68
74
  api_key="YOUR_API_KEY",
@@ -77,19 +83,233 @@ class ToolsClient:
77
83
  _response = self._client_wrapper.httpx_client.request(
78
84
  "api/v0/tools/asset/chunks",
79
85
  method="POST",
80
- json={"asset_ids": asset_ids},
86
+ json={
87
+ "asset_ids": asset_ids,
88
+ },
89
+ headers={
90
+ "content-type": "application/json",
91
+ },
81
92
  request_options=request_options,
82
93
  omit=OMIT,
83
94
  )
84
- if 200 <= _response.status_code < 300:
85
- return pydantic_v1.parse_obj_as(FileChunkRequestOut, _response.json()) # type: ignore
86
- if _response.status_code == 401:
87
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
88
- if _response.status_code == 404:
89
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
90
- if _response.status_code == 422:
91
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
92
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)
138
+
139
+ def get_asset_content(
140
+ self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
141
+ ) -> AssetContentRequestOut:
142
+ """
143
+ Get the content of an asset.
144
+
145
+ Parameters
146
+ ----------
147
+ asset_id : str
148
+
149
+ request_options : typing.Optional[RequestOptions]
150
+ Request-specific configuration.
151
+
152
+ Returns
153
+ -------
154
+ AssetContentRequestOut
155
+ Successful Response
156
+
157
+ Examples
158
+ --------
159
+ from athena import Athena
160
+
161
+ client = Athena(
162
+ api_key="YOUR_API_KEY",
163
+ )
164
+ client.tools.get_asset_content(
165
+ asset_id="asset_id",
166
+ )
167
+ """
168
+ _response = self._client_wrapper.httpx_client.request(
169
+ "api/v0/tools/asset/content",
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)
219
+
220
+ def get_asset_screenshot(
221
+ self,
222
+ *,
223
+ asset_id: str,
224
+ page_number: typing.Optional[int] = None,
225
+ request_options: typing.Optional[RequestOptions] = None,
226
+ ) -> AssetScreenshotResponseOut:
227
+ """
228
+ Get a screenshot of a specific page from an asset.
229
+
230
+ Parameters
231
+ ----------
232
+ asset_id : str
233
+
234
+ page_number : typing.Optional[int]
235
+
236
+ request_options : typing.Optional[RequestOptions]
237
+ Request-specific configuration.
238
+
239
+ Returns
240
+ -------
241
+ AssetScreenshotResponseOut
242
+ Successful Response
243
+
244
+ Examples
245
+ --------
246
+ from athena import Athena
247
+
248
+ client = Athena(
249
+ api_key="YOUR_API_KEY",
250
+ )
251
+ client.tools.get_asset_screenshot(
252
+ asset_id="asset_id",
253
+ )
254
+ """
255
+ _response = self._client_wrapper.httpx_client.request(
256
+ "api/v0/tools/asset/screenshot",
257
+ method="GET",
258
+ params={
259
+ "asset_id": asset_id,
260
+ "page_number": page_number,
261
+ },
262
+ request_options=request_options,
263
+ )
264
+ try:
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
+ )
93
313
  _response_json = _response.json()
94
314
  except JSONDecodeError:
95
315
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -101,7 +321,7 @@ class ToolsClient:
101
321
  folder_id: typing.Optional[str] = None,
102
322
  include_asset_details: typing.Optional[bool] = None,
103
323
  include_system_files: typing.Optional[bool] = None,
104
- request_options: typing.Optional[RequestOptions] = None
324
+ request_options: typing.Optional[RequestOptions] = None,
105
325
  ) -> FolderResponse:
106
326
  """
107
327
  List contents of a folder or entire workspace in a tree structure.
@@ -124,7 +344,7 @@ class ToolsClient:
124
344
 
125
345
  Examples
126
346
  --------
127
- from athena.client import Athena
347
+ from athena import Athena
128
348
 
129
349
  client = Athena(
130
350
  api_key="YOUR_API_KEY",
@@ -141,17 +361,55 @@ class ToolsClient:
141
361
  },
142
362
  request_options=request_options,
143
363
  )
144
- if 200 <= _response.status_code < 300:
145
- return pydantic_v1.parse_obj_as(FolderResponse, _response.json()) # type: ignore
146
- if _response.status_code == 400:
147
- raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
148
- if _response.status_code == 401:
149
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
150
- if _response.status_code == 404:
151
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
152
- if _response.status_code == 422:
153
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
154
364
  try:
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
+ )
155
413
  _response_json = _response.json()
156
414
  except JSONDecodeError:
157
415
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -166,9 +424,9 @@ class ToolsClient:
166
424
  columns: typing.Optional[
167
425
  typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
168
426
  ] = None,
169
- sheet_name: typing.Optional[int] = None,
427
+ sheet_name: typing.Optional[str] = None,
170
428
  separator: typing.Optional[str] = None,
171
- request_options: typing.Optional[RequestOptions] = None
429
+ request_options: typing.Optional[RequestOptions] = None,
172
430
  ) -> DataFrameRequestOut:
173
431
  """
174
432
  Parameters
@@ -182,7 +440,7 @@ class ToolsClient:
182
440
  columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
183
441
  should be a list of strings or a list of integers
184
442
 
185
- sheet_name : typing.Optional[int]
443
+ sheet_name : typing.Optional[str]
186
444
  only for excel files
187
445
 
188
446
  separator : typing.Optional[str]
@@ -198,7 +456,7 @@ class ToolsClient:
198
456
 
199
457
  Examples
200
458
  --------
201
- from athena.client import Athena
459
+ from athena import Athena
202
460
 
203
461
  client = Athena(
204
462
  api_key="YOUR_API_KEY",
@@ -220,21 +478,65 @@ class ToolsClient:
220
478
  },
221
479
  request_options=request_options,
222
480
  )
223
- if 200 <= _response.status_code < 300:
224
- return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
225
- if _response.status_code == 401:
226
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
227
- if _response.status_code == 404:
228
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
229
- if _response.status_code == 415:
230
- raise UnsupportedMediaTypeError(
231
- pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
232
- )
233
- if _response.status_code == 422:
234
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
235
- if _response.status_code == 500:
236
- raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
237
481
  try:
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
+ )
238
540
  _response_json = _response.json()
239
541
  except JSONDecodeError:
240
542
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -251,41 +553,68 @@ class ToolsClient:
251
553
  asset_id : str
252
554
 
253
555
  request_options : typing.Optional[RequestOptions]
254
- Request-specific configuration.
556
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
255
557
 
256
558
  Yields
257
559
  ------
258
560
  typing.Iterator[bytes]
259
561
  Stream the file in original format.
260
-
261
- Examples
262
- --------
263
- from athena.client import Athena
264
-
265
- client = Athena(
266
- api_key="YOUR_API_KEY",
267
- )
268
- client.tools.raw_data(
269
- asset_id="string",
270
- )
271
562
  """
272
563
  with self._client_wrapper.httpx_client.stream(
273
- "api/v0/tools/file/raw-data", method="GET", params={"asset_id": asset_id}, request_options=request_options
564
+ "api/v0/tools/file/raw-data",
565
+ method="GET",
566
+ params={
567
+ "asset_id": asset_id,
568
+ },
569
+ request_options=request_options,
274
570
  ) as _response:
275
- if 200 <= _response.status_code < 300:
276
- for _chunk in _response.iter_bytes():
277
- yield _chunk
278
- return
279
- _response.read()
280
- if _response.status_code == 401:
281
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
282
- if _response.status_code == 404:
283
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
284
- if _response.status_code == 422:
285
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
286
- if _response.status_code == 500:
287
- raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
288
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
+ )
289
618
  _response_json = _response.json()
290
619
  except JSONDecodeError:
291
620
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -296,7 +625,7 @@ class ToolsClient:
296
625
  *,
297
626
  file: core.File,
298
627
  parent_folder_id: typing.Optional[str] = None,
299
- request_options: typing.Optional[RequestOptions] = None
628
+ request_options: typing.Optional[RequestOptions] = None,
300
629
  ) -> SaveAssetRequestOut:
301
630
  """
302
631
  Parameters
@@ -317,7 +646,7 @@ class ToolsClient:
317
646
 
318
647
  Examples
319
648
  --------
320
- from athena.client import Athena
649
+ from athena import Athena
321
650
 
322
651
  client = Athena(
323
652
  api_key="YOUR_API_KEY",
@@ -327,21 +656,55 @@ class ToolsClient:
327
656
  _response = self._client_wrapper.httpx_client.request(
328
657
  "api/v0/tools/file/save",
329
658
  method="POST",
330
- params={"parent_folder_id": parent_folder_id},
659
+ params={
660
+ "parent_folder_id": parent_folder_id,
661
+ },
331
662
  data={},
332
- files={"file": file},
663
+ files={
664
+ "file": file,
665
+ },
333
666
  request_options=request_options,
334
667
  omit=OMIT,
335
668
  )
336
- if 200 <= _response.status_code < 300:
337
- return pydantic_v1.parse_obj_as(SaveAssetRequestOut, _response.json()) # type: ignore
338
- if _response.status_code == 400:
339
- raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
340
- if _response.status_code == 413:
341
- raise ContentTooLargeError(pydantic_v1.parse_obj_as(FileTooLargeError, _response.json())) # type: ignore
342
- if _response.status_code == 422:
343
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
344
669
  try:
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
+ )
345
708
  _response_json = _response.json()
346
709
  except JSONDecodeError:
347
710
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -377,34 +740,272 @@ class AsyncToolsClient:
377
740
 
378
741
  Examples
379
742
  --------
380
- from athena.client import AsyncAthena
743
+ import asyncio
744
+
745
+ from athena import AsyncAthena
381
746
 
382
747
  client = AsyncAthena(
383
748
  api_key="YOUR_API_KEY",
384
749
  )
385
- await client.tools.get_asset_chunks(
386
- asset_ids=[
387
- "asset_9249292-d118-42d3-96b4-00eccfe0754f",
388
- "asset_9249292-d118-42d3-95b4-01eccfe0754f",
389
- ],
390
- )
750
+
751
+
752
+ async def main() -> None:
753
+ await client.tools.get_asset_chunks(
754
+ asset_ids=[
755
+ "asset_9249292-d118-42d3-96b4-00eccfe0754f",
756
+ "asset_9249292-d118-42d3-95b4-01eccfe0754f",
757
+ ],
758
+ )
759
+
760
+
761
+ asyncio.run(main())
391
762
  """
392
763
  _response = await self._client_wrapper.httpx_client.request(
393
764
  "api/v0/tools/asset/chunks",
394
765
  method="POST",
395
- json={"asset_ids": asset_ids},
766
+ json={
767
+ "asset_ids": asset_ids,
768
+ },
769
+ headers={
770
+ "content-type": "application/json",
771
+ },
396
772
  request_options=request_options,
397
773
  omit=OMIT,
398
774
  )
399
- if 200 <= _response.status_code < 300:
400
- return pydantic_v1.parse_obj_as(FileChunkRequestOut, _response.json()) # type: ignore
401
- if _response.status_code == 401:
402
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
403
- if _response.status_code == 404:
404
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
405
- if _response.status_code == 422:
406
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
407
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)
818
+
819
+ async def get_asset_content(
820
+ self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
821
+ ) -> AssetContentRequestOut:
822
+ """
823
+ Get the content of an asset.
824
+
825
+ Parameters
826
+ ----------
827
+ asset_id : str
828
+
829
+ request_options : typing.Optional[RequestOptions]
830
+ Request-specific configuration.
831
+
832
+ Returns
833
+ -------
834
+ AssetContentRequestOut
835
+ Successful Response
836
+
837
+ Examples
838
+ --------
839
+ import asyncio
840
+
841
+ from athena import AsyncAthena
842
+
843
+ client = AsyncAthena(
844
+ api_key="YOUR_API_KEY",
845
+ )
846
+
847
+
848
+ async def main() -> None:
849
+ await client.tools.get_asset_content(
850
+ asset_id="asset_id",
851
+ )
852
+
853
+
854
+ asyncio.run(main())
855
+ """
856
+ _response = await self._client_wrapper.httpx_client.request(
857
+ "api/v0/tools/asset/content",
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)
907
+
908
+ async def get_asset_screenshot(
909
+ self,
910
+ *,
911
+ asset_id: str,
912
+ page_number: typing.Optional[int] = None,
913
+ request_options: typing.Optional[RequestOptions] = None,
914
+ ) -> AssetScreenshotResponseOut:
915
+ """
916
+ Get a screenshot of a specific page from an asset.
917
+
918
+ Parameters
919
+ ----------
920
+ asset_id : str
921
+
922
+ page_number : typing.Optional[int]
923
+
924
+ request_options : typing.Optional[RequestOptions]
925
+ Request-specific configuration.
926
+
927
+ Returns
928
+ -------
929
+ AssetScreenshotResponseOut
930
+ Successful Response
931
+
932
+ Examples
933
+ --------
934
+ import asyncio
935
+
936
+ from athena import AsyncAthena
937
+
938
+ client = AsyncAthena(
939
+ api_key="YOUR_API_KEY",
940
+ )
941
+
942
+
943
+ async def main() -> None:
944
+ await client.tools.get_asset_screenshot(
945
+ asset_id="asset_id",
946
+ )
947
+
948
+
949
+ asyncio.run(main())
950
+ """
951
+ _response = await self._client_wrapper.httpx_client.request(
952
+ "api/v0/tools/asset/screenshot",
953
+ method="GET",
954
+ params={
955
+ "asset_id": asset_id,
956
+ "page_number": page_number,
957
+ },
958
+ request_options=request_options,
959
+ )
960
+ try:
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
+ )
408
1009
  _response_json = _response.json()
409
1010
  except JSONDecodeError:
410
1011
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -416,7 +1017,7 @@ class AsyncToolsClient:
416
1017
  folder_id: typing.Optional[str] = None,
417
1018
  include_asset_details: typing.Optional[bool] = None,
418
1019
  include_system_files: typing.Optional[bool] = None,
419
- request_options: typing.Optional[RequestOptions] = None
1020
+ request_options: typing.Optional[RequestOptions] = None,
420
1021
  ) -> FolderResponse:
421
1022
  """
422
1023
  List contents of a folder or entire workspace in a tree structure.
@@ -439,12 +1040,20 @@ class AsyncToolsClient:
439
1040
 
440
1041
  Examples
441
1042
  --------
442
- from athena.client import AsyncAthena
1043
+ import asyncio
1044
+
1045
+ from athena import AsyncAthena
443
1046
 
444
1047
  client = AsyncAthena(
445
1048
  api_key="YOUR_API_KEY",
446
1049
  )
447
- await client.tools.list_contents()
1050
+
1051
+
1052
+ async def main() -> None:
1053
+ await client.tools.list_contents()
1054
+
1055
+
1056
+ asyncio.run(main())
448
1057
  """
449
1058
  _response = await self._client_wrapper.httpx_client.request(
450
1059
  "api/v0/tools/contents",
@@ -456,17 +1065,55 @@ class AsyncToolsClient:
456
1065
  },
457
1066
  request_options=request_options,
458
1067
  )
459
- if 200 <= _response.status_code < 300:
460
- return pydantic_v1.parse_obj_as(FolderResponse, _response.json()) # type: ignore
461
- if _response.status_code == 400:
462
- raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
463
- if _response.status_code == 401:
464
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
465
- if _response.status_code == 404:
466
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
467
- if _response.status_code == 422:
468
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
469
1068
  try:
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
+ )
470
1117
  _response_json = _response.json()
471
1118
  except JSONDecodeError:
472
1119
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -481,9 +1128,9 @@ class AsyncToolsClient:
481
1128
  columns: typing.Optional[
482
1129
  typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
483
1130
  ] = None,
484
- sheet_name: typing.Optional[int] = None,
1131
+ sheet_name: typing.Optional[str] = None,
485
1132
  separator: typing.Optional[str] = None,
486
- request_options: typing.Optional[RequestOptions] = None
1133
+ request_options: typing.Optional[RequestOptions] = None,
487
1134
  ) -> DataFrameRequestOut:
488
1135
  """
489
1136
  Parameters
@@ -497,7 +1144,7 @@ class AsyncToolsClient:
497
1144
  columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
498
1145
  should be a list of strings or a list of integers
499
1146
 
500
- sheet_name : typing.Optional[int]
1147
+ sheet_name : typing.Optional[str]
501
1148
  only for excel files
502
1149
 
503
1150
  separator : typing.Optional[str]
@@ -513,14 +1160,22 @@ class AsyncToolsClient:
513
1160
 
514
1161
  Examples
515
1162
  --------
516
- from athena.client import AsyncAthena
1163
+ import asyncio
1164
+
1165
+ from athena import AsyncAthena
517
1166
 
518
1167
  client = AsyncAthena(
519
1168
  api_key="YOUR_API_KEY",
520
1169
  )
521
- await client.tools.data_frame(
522
- asset_id="asset_id",
523
- )
1170
+
1171
+
1172
+ async def main() -> None:
1173
+ await client.tools.data_frame(
1174
+ asset_id="asset_id",
1175
+ )
1176
+
1177
+
1178
+ asyncio.run(main())
524
1179
  """
525
1180
  _response = await self._client_wrapper.httpx_client.request(
526
1181
  "api/v0/tools/file/data-frame",
@@ -535,21 +1190,65 @@ class AsyncToolsClient:
535
1190
  },
536
1191
  request_options=request_options,
537
1192
  )
538
- if 200 <= _response.status_code < 300:
539
- return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
540
- if _response.status_code == 401:
541
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
542
- if _response.status_code == 404:
543
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
544
- if _response.status_code == 415:
545
- raise UnsupportedMediaTypeError(
546
- pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
547
- )
548
- if _response.status_code == 422:
549
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
550
- if _response.status_code == 500:
551
- raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
552
1193
  try:
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
+ )
553
1252
  _response_json = _response.json()
554
1253
  except JSONDecodeError:
555
1254
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -566,41 +1265,68 @@ class AsyncToolsClient:
566
1265
  asset_id : str
567
1266
 
568
1267
  request_options : typing.Optional[RequestOptions]
569
- Request-specific configuration.
1268
+ Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
570
1269
 
571
1270
  Yields
572
1271
  ------
573
1272
  typing.AsyncIterator[bytes]
574
1273
  Stream the file in original format.
575
-
576
- Examples
577
- --------
578
- from athena.client import AsyncAthena
579
-
580
- client = AsyncAthena(
581
- api_key="YOUR_API_KEY",
582
- )
583
- await client.tools.raw_data(
584
- asset_id="string",
585
- )
586
1274
  """
587
1275
  async with self._client_wrapper.httpx_client.stream(
588
- "api/v0/tools/file/raw-data", method="GET", params={"asset_id": asset_id}, request_options=request_options
1276
+ "api/v0/tools/file/raw-data",
1277
+ method="GET",
1278
+ params={
1279
+ "asset_id": asset_id,
1280
+ },
1281
+ request_options=request_options,
589
1282
  ) as _response:
590
- if 200 <= _response.status_code < 300:
591
- async for _chunk in _response.aiter_bytes():
592
- yield _chunk
593
- return
594
- await _response.aread()
595
- if _response.status_code == 401:
596
- raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
597
- if _response.status_code == 404:
598
- raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
599
- if _response.status_code == 422:
600
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
601
- if _response.status_code == 500:
602
- raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
603
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
+ )
604
1330
  _response_json = _response.json()
605
1331
  except JSONDecodeError:
606
1332
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -611,7 +1337,7 @@ class AsyncToolsClient:
611
1337
  *,
612
1338
  file: core.File,
613
1339
  parent_folder_id: typing.Optional[str] = None,
614
- request_options: typing.Optional[RequestOptions] = None
1340
+ request_options: typing.Optional[RequestOptions] = None,
615
1341
  ) -> SaveAssetRequestOut:
616
1342
  """
617
1343
  Parameters
@@ -632,31 +1358,73 @@ class AsyncToolsClient:
632
1358
 
633
1359
  Examples
634
1360
  --------
635
- from athena.client import AsyncAthena
1361
+ import asyncio
1362
+
1363
+ from athena import AsyncAthena
636
1364
 
637
1365
  client = AsyncAthena(
638
1366
  api_key="YOUR_API_KEY",
639
1367
  )
640
- await client.tools.save_asset()
1368
+
1369
+
1370
+ async def main() -> None:
1371
+ await client.tools.save_asset()
1372
+
1373
+
1374
+ asyncio.run(main())
641
1375
  """
642
1376
  _response = await self._client_wrapper.httpx_client.request(
643
1377
  "api/v0/tools/file/save",
644
1378
  method="POST",
645
- params={"parent_folder_id": parent_folder_id},
1379
+ params={
1380
+ "parent_folder_id": parent_folder_id,
1381
+ },
646
1382
  data={},
647
- files={"file": file},
1383
+ files={
1384
+ "file": file,
1385
+ },
648
1386
  request_options=request_options,
649
1387
  omit=OMIT,
650
1388
  )
651
- if 200 <= _response.status_code < 300:
652
- return pydantic_v1.parse_obj_as(SaveAssetRequestOut, _response.json()) # type: ignore
653
- if _response.status_code == 400:
654
- raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
655
- if _response.status_code == 413:
656
- raise ContentTooLargeError(pydantic_v1.parse_obj_as(FileTooLargeError, _response.json())) # type: ignore
657
- if _response.status_code == 422:
658
- raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
659
1389
  try:
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
+ )
660
1428
  _response_json = _response.json()
661
1429
  except JSONDecodeError:
662
1430
  raise ApiError(status_code=_response.status_code, body=_response.text)