athena-intelligence 0.1.126__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.
Files changed (99) hide show
  1. athena/__init__.py +28 -3
  2. athena/agents/__init__.py +2 -0
  3. athena/agents/client.py +51 -95
  4. athena/agents/drive/__init__.py +2 -0
  5. athena/agents/drive/client.py +31 -80
  6. athena/agents/drive/raw_client.py +155 -0
  7. athena/agents/general/__init__.py +2 -0
  8. athena/agents/general/client.py +91 -238
  9. athena/agents/general/raw_client.py +369 -0
  10. athena/agents/raw_client.py +176 -0
  11. athena/agents/research/__init__.py +2 -0
  12. athena/agents/research/client.py +31 -80
  13. athena/agents/research/raw_client.py +155 -0
  14. athena/agents/sql/__init__.py +2 -0
  15. athena/agents/sql/client.py +31 -80
  16. athena/agents/sql/raw_client.py +155 -0
  17. athena/assets/__init__.py +4 -0
  18. athena/assets/client.py +144 -0
  19. athena/assets/raw_client.py +164 -0
  20. athena/base_client.py +25 -11
  21. athena/client.py +1 -1
  22. athena/core/__init__.py +5 -0
  23. athena/core/api_error.py +13 -5
  24. athena/core/client_wrapper.py +33 -8
  25. athena/core/force_multipart.py +16 -0
  26. athena/core/http_client.py +70 -26
  27. athena/core/http_response.py +55 -0
  28. athena/core/jsonable_encoder.py +0 -1
  29. athena/core/pydantic_utilities.py +70 -111
  30. athena/core/serialization.py +7 -3
  31. athena/errors/__init__.py +2 -0
  32. athena/errors/bad_request_error.py +4 -2
  33. athena/errors/content_too_large_error.py +4 -2
  34. athena/errors/internal_server_error.py +4 -3
  35. athena/errors/not_found_error.py +4 -2
  36. athena/errors/unauthorized_error.py +4 -3
  37. athena/errors/unprocessable_entity_error.py +4 -3
  38. athena/errors/unsupported_media_type_error.py +4 -2
  39. athena/query/__init__.py +2 -0
  40. athena/query/client.py +39 -219
  41. athena/query/raw_client.py +344 -0
  42. athena/query/types/__init__.py +2 -0
  43. athena/tools/__init__.py +2 -0
  44. athena/tools/calendar/__init__.py +2 -0
  45. athena/tools/calendar/client.py +35 -79
  46. athena/tools/calendar/raw_client.py +172 -0
  47. athena/tools/client.py +267 -653
  48. athena/tools/email/__init__.py +2 -0
  49. athena/tools/email/client.py +39 -115
  50. athena/tools/email/raw_client.py +248 -0
  51. athena/tools/raw_client.py +1328 -0
  52. athena/tools/structured_data_extractor/__init__.py +2 -0
  53. athena/tools/structured_data_extractor/client.py +42 -96
  54. athena/tools/structured_data_extractor/raw_client.py +240 -0
  55. athena/tools/tasks/__init__.py +2 -0
  56. athena/tools/tasks/client.py +31 -43
  57. athena/tools/tasks/raw_client.py +96 -0
  58. athena/tools/types/__init__.py +2 -0
  59. athena/types/__init__.py +28 -2
  60. athena/types/asset_content_request_out.py +26 -0
  61. athena/types/asset_node.py +3 -3
  62. athena/types/asset_not_found_error.py +2 -2
  63. athena/types/asset_screenshot_response_out.py +43 -0
  64. athena/types/chunk.py +3 -3
  65. athena/types/chunk_content_item.py +3 -2
  66. athena/types/chunk_result.py +3 -3
  67. athena/types/content.py +7 -0
  68. athena/types/custom_agent_response.py +2 -2
  69. athena/types/data_frame_request_out.py +3 -3
  70. athena/types/data_frame_unknown_format_error.py +2 -2
  71. athena/types/document_chunk.py +2 -2
  72. athena/types/drive_agent_response.py +2 -2
  73. athena/types/file_chunk_request_out.py +3 -3
  74. athena/types/file_too_large_error.py +2 -2
  75. athena/types/folder_response.py +10 -4
  76. athena/types/general_agent_config.py +4 -3
  77. athena/types/general_agent_config_enabled_tools_item.py +1 -2
  78. athena/types/general_agent_request.py +15 -4
  79. athena/types/general_agent_response.py +4 -3
  80. athena/types/general_agent_response_message.py +100 -0
  81. athena/types/general_agent_response_message_kwargs.py +74 -0
  82. athena/types/{tool.py → id.py} +1 -1
  83. athena/types/image_url_content.py +2 -2
  84. athena/types/input_message.py +29 -0
  85. athena/types/input_message_content_item.py +39 -0
  86. athena/types/paginated_assets_out.py +52 -0
  87. athena/types/parent_folder_error.py +2 -2
  88. athena/types/prompt_message.py +3 -3
  89. athena/types/public_asset_out.py +97 -0
  90. athena/types/research_agent_response.py +2 -2
  91. athena/types/save_asset_request_out.py +2 -2
  92. athena/types/sql_agent_response.py +2 -2
  93. athena/types/structured_data_extractor_response.py +3 -3
  94. athena/types/text_content.py +2 -2
  95. athena/types/type.py +1 -1
  96. {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/METADATA +3 -7
  97. athena_intelligence-0.1.184.dist-info/RECORD +112 -0
  98. {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/WHEEL +1 -1
  99. athena_intelligence-0.1.126.dist-info/RECORD +0 -87
athena/tools/client.py CHANGED
@@ -1,37 +1,22 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  import typing
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
4
+
5
+ from .. import core
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
7
  from ..core.request_options import RequestOptions
8
+ from ..types.asset_content_request_out import AssetContentRequestOut
9
+ from ..types.asset_screenshot_response_out import AssetScreenshotResponseOut
10
+ from ..types.data_frame_request_out import DataFrameRequestOut
10
11
  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
12
  from ..types.folder_response import FolderResponse
19
- from ..errors.bad_request_error import BadRequestError
20
- from ..types.parent_folder_error import ParentFolderError
21
- from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
22
- from ..types.data_frame_request_out import DataFrameRequestOut
23
- from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
24
- from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
25
- from ..errors.internal_server_error import InternalServerError
26
- from .. import core
27
13
  from ..types.save_asset_request_out import SaveAssetRequestOut
28
- from ..errors.content_too_large_error import ContentTooLargeError
29
- from ..types.file_too_large_error import FileTooLargeError
30
- from ..core.client_wrapper import AsyncClientWrapper
31
- from .calendar.client import AsyncCalendarClient
32
- from .email.client import AsyncEmailClient
33
- from .structured_data_extractor.client import AsyncStructuredDataExtractorClient
34
- 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
35
20
 
36
21
  # this is used as the default value for optional parameters
37
22
  OMIT = typing.cast(typing.Any, ...)
@@ -39,11 +24,25 @@ OMIT = typing.cast(typing.Any, ...)
39
24
 
40
25
  class ToolsClient:
41
26
  def __init__(self, *, client_wrapper: SyncClientWrapper):
42
- self._client_wrapper = client_wrapper
43
- self.calendar = CalendarClient(client_wrapper=self._client_wrapper)
44
- self.email = EmailClient(client_wrapper=self._client_wrapper)
45
- self.structured_data_extractor = StructuredDataExtractorClient(client_wrapper=self._client_wrapper)
46
- self.tasks = TasksClient(client_wrapper=self._client_wrapper)
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
47
46
 
48
47
  def get_asset_chunks(
49
48
  self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
@@ -78,75 +77,97 @@ class ToolsClient:
78
77
  ],
79
78
  )
80
79
  """
81
- _response = self._client_wrapper.httpx_client.request(
82
- "api/v0/tools/asset/chunks",
83
- method="POST",
84
- json={
85
- "asset_ids": asset_ids,
86
- },
87
- headers={
88
- "content-type": "application/json",
89
- },
90
- request_options=request_options,
91
- omit=OMIT,
80
+ _response = self._raw_client.get_asset_chunks(asset_ids=asset_ids, request_options=request_options)
81
+ return _response.data
82
+
83
+ def get_asset_content(
84
+ self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
85
+ ) -> AssetContentRequestOut:
86
+ """
87
+ Get the content of an asset.
88
+
89
+ Parameters
90
+ ----------
91
+ asset_id : str
92
+
93
+ request_options : typing.Optional[RequestOptions]
94
+ Request-specific configuration.
95
+
96
+ Returns
97
+ -------
98
+ AssetContentRequestOut
99
+ Successful Response
100
+
101
+ Examples
102
+ --------
103
+ from athena import Athena
104
+
105
+ client = Athena(
106
+ api_key="YOUR_API_KEY",
92
107
  )
93
- try:
94
- if 200 <= _response.status_code < 300:
95
- return typing.cast(
96
- FileChunkRequestOut,
97
- parse_obj_as(
98
- type_=FileChunkRequestOut, # type: ignore
99
- object_=_response.json(),
100
- ),
101
- )
102
- if _response.status_code == 401:
103
- raise UnauthorizedError(
104
- typing.cast(
105
- typing.Optional[typing.Any],
106
- parse_obj_as(
107
- type_=typing.Optional[typing.Any], # type: ignore
108
- object_=_response.json(),
109
- ),
110
- )
111
- )
112
- if _response.status_code == 404:
113
- raise NotFoundError(
114
- typing.cast(
115
- AssetNotFoundError,
116
- parse_obj_as(
117
- type_=AssetNotFoundError, # type: ignore
118
- object_=_response.json(),
119
- ),
120
- )
121
- )
122
- if _response.status_code == 422:
123
- raise UnprocessableEntityError(
124
- typing.cast(
125
- typing.Optional[typing.Any],
126
- parse_obj_as(
127
- type_=typing.Optional[typing.Any], # type: ignore
128
- object_=_response.json(),
129
- ),
130
- )
131
- )
132
- _response_json = _response.json()
133
- except JSONDecodeError:
134
- raise ApiError(status_code=_response.status_code, body=_response.text)
135
- raise ApiError(status_code=_response.status_code, body=_response_json)
108
+ client.tools.get_asset_content(
109
+ asset_id="asset_id",
110
+ )
111
+ """
112
+ _response = self._raw_client.get_asset_content(asset_id=asset_id, request_options=request_options)
113
+ return _response.data
114
+
115
+ def get_asset_screenshot(
116
+ self,
117
+ *,
118
+ asset_id: str,
119
+ page_number: typing.Optional[int] = None,
120
+ request_options: typing.Optional[RequestOptions] = None,
121
+ ) -> AssetScreenshotResponseOut:
122
+ """
123
+ Get a screenshot of a specific page from an asset.
124
+
125
+ Parameters
126
+ ----------
127
+ asset_id : str
128
+
129
+ page_number : typing.Optional[int]
130
+
131
+ request_options : typing.Optional[RequestOptions]
132
+ Request-specific configuration.
133
+
134
+ Returns
135
+ -------
136
+ AssetScreenshotResponseOut
137
+ Successful Response
138
+
139
+ Examples
140
+ --------
141
+ from athena import Athena
142
+
143
+ client = Athena(
144
+ api_key="YOUR_API_KEY",
145
+ )
146
+ client.tools.get_asset_screenshot(
147
+ asset_id="asset_id",
148
+ )
149
+ """
150
+ _response = self._raw_client.get_asset_screenshot(
151
+ asset_id=asset_id, page_number=page_number, request_options=request_options
152
+ )
153
+ return _response.data
136
154
 
137
155
  def list_contents(
138
156
  self,
139
157
  *,
158
+ asset_id: typing.Optional[str] = None,
140
159
  folder_id: typing.Optional[str] = None,
141
160
  include_asset_details: typing.Optional[bool] = None,
142
161
  include_system_files: typing.Optional[bool] = None,
143
162
  request_options: typing.Optional[RequestOptions] = None,
144
163
  ) -> FolderResponse:
145
164
  """
146
- List contents of a folder or entire workspace in a tree structure.
165
+ List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
147
166
 
148
167
  Parameters
149
168
  ----------
169
+ asset_id : typing.Optional[str]
170
+
150
171
  folder_id : typing.Optional[str]
151
172
 
152
173
  include_asset_details : typing.Optional[bool]
@@ -170,69 +191,14 @@ class ToolsClient:
170
191
  )
171
192
  client.tools.list_contents()
172
193
  """
173
- _response = self._client_wrapper.httpx_client.request(
174
- "api/v0/tools/contents",
175
- method="GET",
176
- params={
177
- "folder_id": folder_id,
178
- "include_asset_details": include_asset_details,
179
- "include_system_files": include_system_files,
180
- },
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,
181
199
  request_options=request_options,
182
200
  )
183
- try:
184
- if 200 <= _response.status_code < 300:
185
- return typing.cast(
186
- FolderResponse,
187
- parse_obj_as(
188
- type_=FolderResponse, # type: ignore
189
- object_=_response.json(),
190
- ),
191
- )
192
- if _response.status_code == 400:
193
- raise BadRequestError(
194
- typing.cast(
195
- ParentFolderError,
196
- parse_obj_as(
197
- type_=ParentFolderError, # type: ignore
198
- object_=_response.json(),
199
- ),
200
- )
201
- )
202
- if _response.status_code == 401:
203
- raise UnauthorizedError(
204
- typing.cast(
205
- typing.Optional[typing.Any],
206
- parse_obj_as(
207
- type_=typing.Optional[typing.Any], # type: ignore
208
- object_=_response.json(),
209
- ),
210
- )
211
- )
212
- if _response.status_code == 404:
213
- raise NotFoundError(
214
- typing.cast(
215
- AssetNotFoundError,
216
- parse_obj_as(
217
- type_=AssetNotFoundError, # type: ignore
218
- object_=_response.json(),
219
- ),
220
- )
221
- )
222
- if _response.status_code == 422:
223
- raise UnprocessableEntityError(
224
- typing.cast(
225
- typing.Optional[typing.Any],
226
- parse_obj_as(
227
- type_=typing.Optional[typing.Any], # type: ignore
228
- object_=_response.json(),
229
- ),
230
- )
231
- )
232
- _response_json = _response.json()
233
- except JSONDecodeError:
234
- raise ApiError(status_code=_response.status_code, body=_response.text)
235
- raise ApiError(status_code=_response.status_code, body=_response_json)
201
+ return _response.data
236
202
 
237
203
  def data_frame(
238
204
  self,
@@ -243,7 +209,7 @@ class ToolsClient:
243
209
  columns: typing.Optional[
244
210
  typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
245
211
  ] = None,
246
- sheet_name: typing.Optional[int] = None,
212
+ sheet_name: typing.Optional[str] = None,
247
213
  separator: typing.Optional[str] = None,
248
214
  request_options: typing.Optional[RequestOptions] = None,
249
215
  ) -> DataFrameRequestOut:
@@ -259,7 +225,7 @@ class ToolsClient:
259
225
  columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
260
226
  should be a list of strings or a list of integers
261
227
 
262
- sheet_name : typing.Optional[int]
228
+ sheet_name : typing.Optional[str]
263
229
  only for excel files
264
230
 
265
231
  separator : typing.Optional[str]
@@ -284,82 +250,16 @@ class ToolsClient:
284
250
  asset_id="asset_id",
285
251
  )
286
252
  """
287
- _response = self._client_wrapper.httpx_client.request(
288
- "api/v0/tools/file/data-frame",
289
- method="GET",
290
- params={
291
- "asset_id": asset_id,
292
- "row_limit": row_limit,
293
- "index_column": index_column,
294
- "columns": columns,
295
- "sheet_name": sheet_name,
296
- "separator": separator,
297
- },
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,
298
260
  request_options=request_options,
299
261
  )
300
- try:
301
- if 200 <= _response.status_code < 300:
302
- return typing.cast(
303
- DataFrameRequestOut,
304
- parse_obj_as(
305
- type_=DataFrameRequestOut, # type: ignore
306
- object_=_response.json(),
307
- ),
308
- )
309
- if _response.status_code == 401:
310
- raise UnauthorizedError(
311
- typing.cast(
312
- typing.Optional[typing.Any],
313
- parse_obj_as(
314
- type_=typing.Optional[typing.Any], # type: ignore
315
- object_=_response.json(),
316
- ),
317
- )
318
- )
319
- if _response.status_code == 404:
320
- raise NotFoundError(
321
- typing.cast(
322
- AssetNotFoundError,
323
- parse_obj_as(
324
- type_=AssetNotFoundError, # type: ignore
325
- object_=_response.json(),
326
- ),
327
- )
328
- )
329
- if _response.status_code == 415:
330
- raise UnsupportedMediaTypeError(
331
- typing.cast(
332
- DataFrameUnknownFormatError,
333
- parse_obj_as(
334
- type_=DataFrameUnknownFormatError, # type: ignore
335
- object_=_response.json(),
336
- ),
337
- )
338
- )
339
- if _response.status_code == 422:
340
- raise UnprocessableEntityError(
341
- typing.cast(
342
- typing.Optional[typing.Any],
343
- parse_obj_as(
344
- type_=typing.Optional[typing.Any], # type: ignore
345
- object_=_response.json(),
346
- ),
347
- )
348
- )
349
- if _response.status_code == 500:
350
- raise InternalServerError(
351
- typing.cast(
352
- typing.Optional[typing.Any],
353
- parse_obj_as(
354
- type_=typing.Optional[typing.Any], # type: ignore
355
- object_=_response.json(),
356
- ),
357
- )
358
- )
359
- _response_json = _response.json()
360
- except JSONDecodeError:
361
- raise ApiError(status_code=_response.status_code, body=_response.text)
362
- raise ApiError(status_code=_response.status_code, body=_response_json)
262
+ return _response.data
363
263
 
364
264
  def raw_data(
365
265
  self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
@@ -374,70 +274,13 @@ class ToolsClient:
374
274
  request_options : typing.Optional[RequestOptions]
375
275
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
376
276
 
377
- Yields
378
- ------
277
+ Returns
278
+ -------
379
279
  typing.Iterator[bytes]
380
280
  Stream the file in original format.
381
281
  """
382
- with self._client_wrapper.httpx_client.stream(
383
- "api/v0/tools/file/raw-data",
384
- method="GET",
385
- params={
386
- "asset_id": asset_id,
387
- },
388
- request_options=request_options,
389
- ) as _response:
390
- try:
391
- if 200 <= _response.status_code < 300:
392
- _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
393
- for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
394
- yield _chunk
395
- return
396
- _response.read()
397
- if _response.status_code == 401:
398
- raise UnauthorizedError(
399
- typing.cast(
400
- typing.Optional[typing.Any],
401
- parse_obj_as(
402
- type_=typing.Optional[typing.Any], # type: ignore
403
- object_=_response.json(),
404
- ),
405
- )
406
- )
407
- if _response.status_code == 404:
408
- raise NotFoundError(
409
- typing.cast(
410
- AssetNotFoundError,
411
- parse_obj_as(
412
- type_=AssetNotFoundError, # type: ignore
413
- object_=_response.json(),
414
- ),
415
- )
416
- )
417
- if _response.status_code == 422:
418
- raise UnprocessableEntityError(
419
- typing.cast(
420
- typing.Optional[typing.Any],
421
- parse_obj_as(
422
- type_=typing.Optional[typing.Any], # type: ignore
423
- object_=_response.json(),
424
- ),
425
- )
426
- )
427
- if _response.status_code == 500:
428
- raise InternalServerError(
429
- typing.cast(
430
- typing.Optional[typing.Any],
431
- parse_obj_as(
432
- type_=typing.Optional[typing.Any], # type: ignore
433
- object_=_response.json(),
434
- ),
435
- )
436
- )
437
- _response_json = _response.json()
438
- except JSONDecodeError:
439
- raise ApiError(status_code=_response.status_code, body=_response.text)
440
- 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
441
284
 
442
285
  def save_asset(
443
286
  self,
@@ -472,71 +315,33 @@ class ToolsClient:
472
315
  )
473
316
  client.tools.save_asset()
474
317
  """
475
- _response = self._client_wrapper.httpx_client.request(
476
- "api/v0/tools/file/save",
477
- method="POST",
478
- params={
479
- "parent_folder_id": parent_folder_id,
480
- },
481
- data={},
482
- files={
483
- "file": file,
484
- },
485
- request_options=request_options,
486
- omit=OMIT,
318
+ _response = self._raw_client.save_asset(
319
+ file=file, parent_folder_id=parent_folder_id, request_options=request_options
487
320
  )
488
- try:
489
- if 200 <= _response.status_code < 300:
490
- return typing.cast(
491
- SaveAssetRequestOut,
492
- parse_obj_as(
493
- type_=SaveAssetRequestOut, # type: ignore
494
- object_=_response.json(),
495
- ),
496
- )
497
- if _response.status_code == 400:
498
- raise BadRequestError(
499
- typing.cast(
500
- ParentFolderError,
501
- parse_obj_as(
502
- type_=ParentFolderError, # type: ignore
503
- object_=_response.json(),
504
- ),
505
- )
506
- )
507
- if _response.status_code == 413:
508
- raise ContentTooLargeError(
509
- typing.cast(
510
- FileTooLargeError,
511
- parse_obj_as(
512
- type_=FileTooLargeError, # type: ignore
513
- object_=_response.json(),
514
- ),
515
- )
516
- )
517
- if _response.status_code == 422:
518
- raise UnprocessableEntityError(
519
- typing.cast(
520
- typing.Optional[typing.Any],
521
- parse_obj_as(
522
- type_=typing.Optional[typing.Any], # type: ignore
523
- object_=_response.json(),
524
- ),
525
- )
526
- )
527
- _response_json = _response.json()
528
- except JSONDecodeError:
529
- raise ApiError(status_code=_response.status_code, body=_response.text)
530
- raise ApiError(status_code=_response.status_code, body=_response_json)
321
+ return _response.data
531
322
 
532
323
 
533
324
  class AsyncToolsClient:
534
325
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
535
- self._client_wrapper = client_wrapper
536
- self.calendar = AsyncCalendarClient(client_wrapper=self._client_wrapper)
537
- self.email = AsyncEmailClient(client_wrapper=self._client_wrapper)
538
- self.structured_data_extractor = AsyncStructuredDataExtractorClient(client_wrapper=self._client_wrapper)
539
- self.tasks = AsyncTasksClient(client_wrapper=self._client_wrapper)
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
540
345
 
541
346
  async def get_asset_chunks(
542
347
  self, *, asset_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
@@ -579,75 +384,113 @@ class AsyncToolsClient:
579
384
 
580
385
  asyncio.run(main())
581
386
  """
582
- _response = await self._client_wrapper.httpx_client.request(
583
- "api/v0/tools/asset/chunks",
584
- method="POST",
585
- json={
586
- "asset_ids": asset_ids,
587
- },
588
- headers={
589
- "content-type": "application/json",
590
- },
591
- request_options=request_options,
592
- omit=OMIT,
387
+ _response = await self._raw_client.get_asset_chunks(asset_ids=asset_ids, request_options=request_options)
388
+ return _response.data
389
+
390
+ async def get_asset_content(
391
+ self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
392
+ ) -> AssetContentRequestOut:
393
+ """
394
+ Get the content of an asset.
395
+
396
+ Parameters
397
+ ----------
398
+ asset_id : str
399
+
400
+ request_options : typing.Optional[RequestOptions]
401
+ Request-specific configuration.
402
+
403
+ Returns
404
+ -------
405
+ AssetContentRequestOut
406
+ Successful Response
407
+
408
+ Examples
409
+ --------
410
+ import asyncio
411
+
412
+ from athena import AsyncAthena
413
+
414
+ client = AsyncAthena(
415
+ api_key="YOUR_API_KEY",
416
+ )
417
+
418
+
419
+ async def main() -> None:
420
+ await client.tools.get_asset_content(
421
+ asset_id="asset_id",
422
+ )
423
+
424
+
425
+ asyncio.run(main())
426
+ """
427
+ _response = await self._raw_client.get_asset_content(asset_id=asset_id, request_options=request_options)
428
+ return _response.data
429
+
430
+ async def get_asset_screenshot(
431
+ self,
432
+ *,
433
+ asset_id: str,
434
+ page_number: typing.Optional[int] = None,
435
+ request_options: typing.Optional[RequestOptions] = None,
436
+ ) -> AssetScreenshotResponseOut:
437
+ """
438
+ Get a screenshot of a specific page from an asset.
439
+
440
+ Parameters
441
+ ----------
442
+ asset_id : str
443
+
444
+ page_number : typing.Optional[int]
445
+
446
+ request_options : typing.Optional[RequestOptions]
447
+ Request-specific configuration.
448
+
449
+ Returns
450
+ -------
451
+ AssetScreenshotResponseOut
452
+ Successful Response
453
+
454
+ Examples
455
+ --------
456
+ import asyncio
457
+
458
+ from athena import AsyncAthena
459
+
460
+ client = AsyncAthena(
461
+ api_key="YOUR_API_KEY",
462
+ )
463
+
464
+
465
+ async def main() -> None:
466
+ await client.tools.get_asset_screenshot(
467
+ asset_id="asset_id",
468
+ )
469
+
470
+
471
+ asyncio.run(main())
472
+ """
473
+ _response = await self._raw_client.get_asset_screenshot(
474
+ asset_id=asset_id, page_number=page_number, request_options=request_options
593
475
  )
594
- try:
595
- if 200 <= _response.status_code < 300:
596
- return typing.cast(
597
- FileChunkRequestOut,
598
- parse_obj_as(
599
- type_=FileChunkRequestOut, # type: ignore
600
- object_=_response.json(),
601
- ),
602
- )
603
- if _response.status_code == 401:
604
- raise UnauthorizedError(
605
- typing.cast(
606
- typing.Optional[typing.Any],
607
- parse_obj_as(
608
- type_=typing.Optional[typing.Any], # type: ignore
609
- object_=_response.json(),
610
- ),
611
- )
612
- )
613
- if _response.status_code == 404:
614
- raise NotFoundError(
615
- typing.cast(
616
- AssetNotFoundError,
617
- parse_obj_as(
618
- type_=AssetNotFoundError, # type: ignore
619
- object_=_response.json(),
620
- ),
621
- )
622
- )
623
- if _response.status_code == 422:
624
- raise UnprocessableEntityError(
625
- typing.cast(
626
- typing.Optional[typing.Any],
627
- parse_obj_as(
628
- type_=typing.Optional[typing.Any], # type: ignore
629
- object_=_response.json(),
630
- ),
631
- )
632
- )
633
- _response_json = _response.json()
634
- except JSONDecodeError:
635
- raise ApiError(status_code=_response.status_code, body=_response.text)
636
- raise ApiError(status_code=_response.status_code, body=_response_json)
476
+ return _response.data
637
477
 
638
478
  async def list_contents(
639
479
  self,
640
480
  *,
481
+ asset_id: typing.Optional[str] = None,
641
482
  folder_id: typing.Optional[str] = None,
642
483
  include_asset_details: typing.Optional[bool] = None,
643
484
  include_system_files: typing.Optional[bool] = None,
644
485
  request_options: typing.Optional[RequestOptions] = None,
645
486
  ) -> FolderResponse:
646
487
  """
647
- List contents of a folder or entire workspace in a tree structure.
488
+ List contents of an asset (Folder, Collection, Project) or entire workspace in a tree structure.
648
489
 
649
490
  Parameters
650
491
  ----------
492
+ asset_id : typing.Optional[str]
493
+
651
494
  folder_id : typing.Optional[str]
652
495
 
653
496
  include_asset_details : typing.Optional[bool]
@@ -679,69 +522,14 @@ class AsyncToolsClient:
679
522
 
680
523
  asyncio.run(main())
681
524
  """
682
- _response = await self._client_wrapper.httpx_client.request(
683
- "api/v0/tools/contents",
684
- method="GET",
685
- params={
686
- "folder_id": folder_id,
687
- "include_asset_details": include_asset_details,
688
- "include_system_files": include_system_files,
689
- },
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,
690
530
  request_options=request_options,
691
531
  )
692
- try:
693
- if 200 <= _response.status_code < 300:
694
- return typing.cast(
695
- FolderResponse,
696
- parse_obj_as(
697
- type_=FolderResponse, # type: ignore
698
- object_=_response.json(),
699
- ),
700
- )
701
- if _response.status_code == 400:
702
- raise BadRequestError(
703
- typing.cast(
704
- ParentFolderError,
705
- parse_obj_as(
706
- type_=ParentFolderError, # type: ignore
707
- object_=_response.json(),
708
- ),
709
- )
710
- )
711
- if _response.status_code == 401:
712
- raise UnauthorizedError(
713
- typing.cast(
714
- typing.Optional[typing.Any],
715
- parse_obj_as(
716
- type_=typing.Optional[typing.Any], # type: ignore
717
- object_=_response.json(),
718
- ),
719
- )
720
- )
721
- if _response.status_code == 404:
722
- raise NotFoundError(
723
- typing.cast(
724
- AssetNotFoundError,
725
- parse_obj_as(
726
- type_=AssetNotFoundError, # type: ignore
727
- object_=_response.json(),
728
- ),
729
- )
730
- )
731
- if _response.status_code == 422:
732
- raise UnprocessableEntityError(
733
- typing.cast(
734
- typing.Optional[typing.Any],
735
- parse_obj_as(
736
- type_=typing.Optional[typing.Any], # type: ignore
737
- object_=_response.json(),
738
- ),
739
- )
740
- )
741
- _response_json = _response.json()
742
- except JSONDecodeError:
743
- raise ApiError(status_code=_response.status_code, body=_response.text)
744
- raise ApiError(status_code=_response.status_code, body=_response_json)
532
+ return _response.data
745
533
 
746
534
  async def data_frame(
747
535
  self,
@@ -752,7 +540,7 @@ class AsyncToolsClient:
752
540
  columns: typing.Optional[
753
541
  typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]
754
542
  ] = None,
755
- sheet_name: typing.Optional[int] = None,
543
+ sheet_name: typing.Optional[str] = None,
756
544
  separator: typing.Optional[str] = None,
757
545
  request_options: typing.Optional[RequestOptions] = None,
758
546
  ) -> DataFrameRequestOut:
@@ -768,7 +556,7 @@ class AsyncToolsClient:
768
556
  columns : typing.Optional[typing.Union[ToolsDataFrameRequestColumnsItem, typing.Sequence[ToolsDataFrameRequestColumnsItem]]]
769
557
  should be a list of strings or a list of integers
770
558
 
771
- sheet_name : typing.Optional[int]
559
+ sheet_name : typing.Optional[str]
772
560
  only for excel files
773
561
 
774
562
  separator : typing.Optional[str]
@@ -801,82 +589,16 @@ class AsyncToolsClient:
801
589
 
802
590
  asyncio.run(main())
803
591
  """
804
- _response = await self._client_wrapper.httpx_client.request(
805
- "api/v0/tools/file/data-frame",
806
- method="GET",
807
- params={
808
- "asset_id": asset_id,
809
- "row_limit": row_limit,
810
- "index_column": index_column,
811
- "columns": columns,
812
- "sheet_name": sheet_name,
813
- "separator": separator,
814
- },
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,
815
599
  request_options=request_options,
816
600
  )
817
- try:
818
- if 200 <= _response.status_code < 300:
819
- return typing.cast(
820
- DataFrameRequestOut,
821
- parse_obj_as(
822
- type_=DataFrameRequestOut, # type: ignore
823
- object_=_response.json(),
824
- ),
825
- )
826
- if _response.status_code == 401:
827
- raise UnauthorizedError(
828
- typing.cast(
829
- typing.Optional[typing.Any],
830
- parse_obj_as(
831
- type_=typing.Optional[typing.Any], # type: ignore
832
- object_=_response.json(),
833
- ),
834
- )
835
- )
836
- if _response.status_code == 404:
837
- raise NotFoundError(
838
- typing.cast(
839
- AssetNotFoundError,
840
- parse_obj_as(
841
- type_=AssetNotFoundError, # type: ignore
842
- object_=_response.json(),
843
- ),
844
- )
845
- )
846
- if _response.status_code == 415:
847
- raise UnsupportedMediaTypeError(
848
- typing.cast(
849
- DataFrameUnknownFormatError,
850
- parse_obj_as(
851
- type_=DataFrameUnknownFormatError, # type: ignore
852
- object_=_response.json(),
853
- ),
854
- )
855
- )
856
- if _response.status_code == 422:
857
- raise UnprocessableEntityError(
858
- typing.cast(
859
- typing.Optional[typing.Any],
860
- parse_obj_as(
861
- type_=typing.Optional[typing.Any], # type: ignore
862
- object_=_response.json(),
863
- ),
864
- )
865
- )
866
- if _response.status_code == 500:
867
- raise InternalServerError(
868
- typing.cast(
869
- typing.Optional[typing.Any],
870
- parse_obj_as(
871
- type_=typing.Optional[typing.Any], # type: ignore
872
- object_=_response.json(),
873
- ),
874
- )
875
- )
876
- _response_json = _response.json()
877
- except JSONDecodeError:
878
- raise ApiError(status_code=_response.status_code, body=_response.text)
879
- raise ApiError(status_code=_response.status_code, body=_response_json)
601
+ return _response.data
880
602
 
881
603
  async def raw_data(
882
604
  self, *, asset_id: str, request_options: typing.Optional[RequestOptions] = None
@@ -891,70 +613,14 @@ class AsyncToolsClient:
891
613
  request_options : typing.Optional[RequestOptions]
892
614
  Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
893
615
 
894
- Yields
895
- ------
616
+ Returns
617
+ -------
896
618
  typing.AsyncIterator[bytes]
897
619
  Stream the file in original format.
898
620
  """
899
- async with self._client_wrapper.httpx_client.stream(
900
- "api/v0/tools/file/raw-data",
901
- method="GET",
902
- params={
903
- "asset_id": asset_id,
904
- },
905
- request_options=request_options,
906
- ) as _response:
907
- try:
908
- if 200 <= _response.status_code < 300:
909
- _chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
910
- async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
911
- yield _chunk
912
- return
913
- await _response.aread()
914
- if _response.status_code == 401:
915
- raise UnauthorizedError(
916
- typing.cast(
917
- typing.Optional[typing.Any],
918
- parse_obj_as(
919
- type_=typing.Optional[typing.Any], # type: ignore
920
- object_=_response.json(),
921
- ),
922
- )
923
- )
924
- if _response.status_code == 404:
925
- raise NotFoundError(
926
- typing.cast(
927
- AssetNotFoundError,
928
- parse_obj_as(
929
- type_=AssetNotFoundError, # type: ignore
930
- object_=_response.json(),
931
- ),
932
- )
933
- )
934
- if _response.status_code == 422:
935
- raise UnprocessableEntityError(
936
- typing.cast(
937
- typing.Optional[typing.Any],
938
- parse_obj_as(
939
- type_=typing.Optional[typing.Any], # type: ignore
940
- object_=_response.json(),
941
- ),
942
- )
943
- )
944
- if _response.status_code == 500:
945
- raise InternalServerError(
946
- typing.cast(
947
- typing.Optional[typing.Any],
948
- parse_obj_as(
949
- type_=typing.Optional[typing.Any], # type: ignore
950
- object_=_response.json(),
951
- ),
952
- )
953
- )
954
- _response_json = _response.json()
955
- except JSONDecodeError:
956
- raise ApiError(status_code=_response.status_code, body=_response.text)
957
- 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
958
624
 
959
625
  async def save_asset(
960
626
  self,
@@ -997,59 +663,7 @@ class AsyncToolsClient:
997
663
 
998
664
  asyncio.run(main())
999
665
  """
1000
- _response = await self._client_wrapper.httpx_client.request(
1001
- "api/v0/tools/file/save",
1002
- method="POST",
1003
- params={
1004
- "parent_folder_id": parent_folder_id,
1005
- },
1006
- data={},
1007
- files={
1008
- "file": file,
1009
- },
1010
- request_options=request_options,
1011
- omit=OMIT,
666
+ _response = await self._raw_client.save_asset(
667
+ file=file, parent_folder_id=parent_folder_id, request_options=request_options
1012
668
  )
1013
- try:
1014
- if 200 <= _response.status_code < 300:
1015
- return typing.cast(
1016
- SaveAssetRequestOut,
1017
- parse_obj_as(
1018
- type_=SaveAssetRequestOut, # type: ignore
1019
- object_=_response.json(),
1020
- ),
1021
- )
1022
- if _response.status_code == 400:
1023
- raise BadRequestError(
1024
- typing.cast(
1025
- ParentFolderError,
1026
- parse_obj_as(
1027
- type_=ParentFolderError, # type: ignore
1028
- object_=_response.json(),
1029
- ),
1030
- )
1031
- )
1032
- if _response.status_code == 413:
1033
- raise ContentTooLargeError(
1034
- typing.cast(
1035
- FileTooLargeError,
1036
- parse_obj_as(
1037
- type_=FileTooLargeError, # type: ignore
1038
- object_=_response.json(),
1039
- ),
1040
- )
1041
- )
1042
- if _response.status_code == 422:
1043
- raise UnprocessableEntityError(
1044
- typing.cast(
1045
- typing.Optional[typing.Any],
1046
- parse_obj_as(
1047
- type_=typing.Optional[typing.Any], # type: ignore
1048
- object_=_response.json(),
1049
- ),
1050
- )
1051
- )
1052
- _response_json = _response.json()
1053
- except JSONDecodeError:
1054
- raise ApiError(status_code=_response.status_code, body=_response.text)
1055
- raise ApiError(status_code=_response.status_code, body=_response_json)
669
+ return _response.data