athena-intelligence 0.1.103__py3-none-any.whl → 0.1.105__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 +12 -4
- athena/client.py +73 -1
- athena/core/client_wrapper.py +1 -1
- athena/errors/__init__.py +4 -0
- athena/errors/bad_request_error.py +9 -0
- athena/errors/content_too_large_error.py +9 -0
- athena/errors/not_found_error.py +2 -2
- athena/errors/unauthorized_error.py +3 -2
- athena/query/client.py +4 -5
- athena/tools/client.py +139 -5
- athena/tools/types/tools_data_frame_request_columns_item.py +1 -1
- athena/types/__init__.py +8 -4
- athena/types/{sql_unauthorized_error.py → asset_not_found_error.py} +1 -1
- athena/types/{file_fetch_error.py → file_too_large_error.py} +1 -2
- athena/types/parent_folder_error.py +29 -0
- athena/types/save_asset_request_out.py +33 -0
- {athena_intelligence-0.1.103.dist-info → athena_intelligence-0.1.105.dist-info}/METADATA +1 -1
- {athena_intelligence-0.1.103.dist-info → athena_intelligence-0.1.105.dist-info}/RECORD +19 -15
- {athena_intelligence-0.1.103.dist-info → athena_intelligence-0.1.105.dist-info}/WHEEL +0 -0
athena/__init__.py
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
from .types import (
|
4
|
+
AssetNotFoundError,
|
4
5
|
DataFrameRequestOut,
|
5
6
|
DataFrameRequestOutColumnsItem,
|
6
7
|
DataFrameRequestOutDataItemItem,
|
7
8
|
DataFrameRequestOutIndexItem,
|
8
9
|
DataFrameUnknownFormatError,
|
9
|
-
|
10
|
-
|
10
|
+
FileTooLargeError,
|
11
|
+
ParentFolderError,
|
12
|
+
SaveAssetRequestOut,
|
11
13
|
)
|
12
14
|
from .errors import (
|
15
|
+
BadRequestError,
|
16
|
+
ContentTooLargeError,
|
13
17
|
InternalServerError,
|
14
18
|
NotFoundError,
|
15
19
|
UnauthorizedError,
|
@@ -23,17 +27,21 @@ from .tools import ToolsDataFrameRequestColumnsItem
|
|
23
27
|
from .version import __version__
|
24
28
|
|
25
29
|
__all__ = [
|
30
|
+
"AssetNotFoundError",
|
26
31
|
"AthenaEnvironment",
|
32
|
+
"BadRequestError",
|
33
|
+
"ContentTooLargeError",
|
27
34
|
"DataFrameRequestOut",
|
28
35
|
"DataFrameRequestOutColumnsItem",
|
29
36
|
"DataFrameRequestOutDataItemItem",
|
30
37
|
"DataFrameRequestOutIndexItem",
|
31
38
|
"DataFrameUnknownFormatError",
|
32
|
-
"
|
39
|
+
"FileTooLargeError",
|
33
40
|
"InternalServerError",
|
34
41
|
"NotFoundError",
|
42
|
+
"ParentFolderError",
|
35
43
|
"QueryExecuteRequestDatabaseAssetIds",
|
36
|
-
"
|
44
|
+
"SaveAssetRequestOut",
|
37
45
|
"ToolsDataFrameRequestColumnsItem",
|
38
46
|
"UnauthorizedError",
|
39
47
|
"UnprocessableEntityError",
|
athena/client.py
CHANGED
@@ -8,11 +8,13 @@ import httpx
|
|
8
8
|
from typing import cast, List, Union
|
9
9
|
from typing_extensions import TypeVar, ParamSpec
|
10
10
|
|
11
|
+
from . import core
|
11
12
|
from .base_client import BaseAthena, AsyncBaseAthena
|
12
13
|
from .environment import AthenaEnvironment
|
13
14
|
from .tools.client import AsyncToolsClient, ToolsClient
|
14
15
|
from .query.client import AsyncQueryClient, QueryClient
|
15
16
|
from .types.data_frame_request_out import DataFrameRequestOut
|
17
|
+
from .types.save_asset_request_out import SaveAssetRequestOut
|
16
18
|
|
17
19
|
if typing.TYPE_CHECKING:
|
18
20
|
import pandas as pd
|
@@ -96,6 +98,43 @@ class WrappedToolsClient(ToolsClient):
|
|
96
98
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
97
99
|
|
98
100
|
|
101
|
+
def save_asset( # type: ignore[override]
|
102
|
+
self,
|
103
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
104
|
+
*,
|
105
|
+
parent_folder_id: Union[str, None] = None,
|
106
|
+
name: Union[str, None] = None,
|
107
|
+
**kwargs,
|
108
|
+
) -> SaveAssetRequestOut:
|
109
|
+
"""
|
110
|
+
Parameters
|
111
|
+
----------
|
112
|
+
asset_object : pd.DataFrame | pd.Series | core.File
|
113
|
+
A pandas data frame, series, or core.File
|
114
|
+
|
115
|
+
parent_folder_id : typing.Optional[str]
|
116
|
+
|
117
|
+
request_options : typing.Optional[RequestOptions]
|
118
|
+
Request-specific configuration.
|
119
|
+
|
120
|
+
Returns
|
121
|
+
-------
|
122
|
+
SaveAssetRequestOut
|
123
|
+
Successful Response
|
124
|
+
|
125
|
+
Examples
|
126
|
+
--------
|
127
|
+
from athena.client import Athena
|
128
|
+
|
129
|
+
client = Athena(api_key="YOUR_API_KEY")
|
130
|
+
client.tools.save_asset(df)
|
131
|
+
"""
|
132
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
133
|
+
return super().save_asset(
|
134
|
+
file=asset_object, parent_folder_id=parent_folder_id, **kwargs
|
135
|
+
)
|
136
|
+
|
137
|
+
|
99
138
|
class WrappedQueryClient(QueryClient):
|
100
139
|
|
101
140
|
@_inherit_signature_and_doc(QueryClient.execute, {'DataFrameRequestOut': 'pd.DataFrame'})
|
@@ -148,6 +187,20 @@ class WrappedAsyncToolsClient(AsyncToolsClient):
|
|
148
187
|
file_bytes = await self.get_file(asset_id)
|
149
188
|
return _to_pandas_df(file_bytes, *args, **kwargs)
|
150
189
|
|
190
|
+
@_add_docs_for_async_variant(WrappedToolsClient.save_asset)
|
191
|
+
async def save_asset(
|
192
|
+
self,
|
193
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
194
|
+
*,
|
195
|
+
parent_folder_id: Union[str, None] = None,
|
196
|
+
name: Union[str, None] = None,
|
197
|
+
**kwargs,
|
198
|
+
) -> SaveAssetRequestOut:
|
199
|
+
asset_object = _convert_asset_object(asset_object=asset_object, name=name)
|
200
|
+
return await super().save_asset(
|
201
|
+
file=asset_object, parent_folder_id=parent_folder_id, **kwargs
|
202
|
+
)
|
203
|
+
|
151
204
|
|
152
205
|
class WrappedAsyncQueryClient(AsyncQueryClient):
|
153
206
|
|
@@ -333,9 +386,28 @@ def _to_pandas_df(bytes_io: io.BytesIO, *args, **kwargs):
|
|
333
386
|
|
334
387
|
if media_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
335
388
|
return pd.read_excel(bytes_io, *args, engine='openpyxl', **kwargs)
|
389
|
+
elif media_type == 'application/vnd.apache.parquet':
|
390
|
+
return pd.read_parquet(bytes_io, *args, **kwargs)
|
336
391
|
elif media_type == 'application/vnd.ms-excel':
|
337
392
|
return pd.read_excel(bytes_io, *args, **kwargs)
|
338
|
-
elif media_type
|
393
|
+
elif media_type in {'text/csv', 'application/csv'}:
|
339
394
|
return pd.read_csv(bytes_io, *args, **kwargs)
|
340
395
|
else:
|
341
396
|
raise Exception("Unknown media type")
|
397
|
+
|
398
|
+
|
399
|
+
def _convert_asset_object(
|
400
|
+
asset_object: Union["pd.DataFrame", "pd.Series", core.File],
|
401
|
+
name: Union[str, None] = None,
|
402
|
+
) -> core.File:
|
403
|
+
import pandas as pd
|
404
|
+
|
405
|
+
if isinstance(asset_object, pd.Series):
|
406
|
+
asset_object = asset_object.to_frame()
|
407
|
+
if isinstance(asset_object, pd.DataFrame):
|
408
|
+
return (
|
409
|
+
name or "Uploaded data frame",
|
410
|
+
asset_object.to_parquet(path=None),
|
411
|
+
"application/vnd.apache.parquet",
|
412
|
+
)
|
413
|
+
return asset_object # type: ignore[return-value]
|
athena/core/client_wrapper.py
CHANGED
@@ -17,7 +17,7 @@ class BaseClientWrapper:
|
|
17
17
|
headers: typing.Dict[str, str] = {
|
18
18
|
"X-Fern-Language": "Python",
|
19
19
|
"X-Fern-SDK-Name": "athena-intelligence",
|
20
|
-
"X-Fern-SDK-Version": "0.1.
|
20
|
+
"X-Fern-SDK-Version": "0.1.105",
|
21
21
|
}
|
22
22
|
headers["X-API-KEY"] = self.api_key
|
23
23
|
return headers
|
athena/errors/__init__.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
+
from .bad_request_error import BadRequestError
|
4
|
+
from .content_too_large_error import ContentTooLargeError
|
3
5
|
from .internal_server_error import InternalServerError
|
4
6
|
from .not_found_error import NotFoundError
|
5
7
|
from .unauthorized_error import UnauthorizedError
|
@@ -7,6 +9,8 @@ from .unprocessable_entity_error import UnprocessableEntityError
|
|
7
9
|
from .unsupported_media_type_error import UnsupportedMediaTypeError
|
8
10
|
|
9
11
|
__all__ = [
|
12
|
+
"BadRequestError",
|
13
|
+
"ContentTooLargeError",
|
10
14
|
"InternalServerError",
|
11
15
|
"NotFoundError",
|
12
16
|
"UnauthorizedError",
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ..core.api_error import ApiError
|
4
|
+
from ..types.parent_folder_error import ParentFolderError
|
5
|
+
|
6
|
+
|
7
|
+
class BadRequestError(ApiError):
|
8
|
+
def __init__(self, body: ParentFolderError):
|
9
|
+
super().__init__(status_code=400, body=body)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ..core.api_error import ApiError
|
4
|
+
from ..types.file_too_large_error import FileTooLargeError
|
5
|
+
|
6
|
+
|
7
|
+
class ContentTooLargeError(ApiError):
|
8
|
+
def __init__(self, body: FileTooLargeError):
|
9
|
+
super().__init__(status_code=413, body=body)
|
athena/errors/not_found_error.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
from ..core.api_error import ApiError
|
4
|
-
from ..types.
|
4
|
+
from ..types.asset_not_found_error import AssetNotFoundError
|
5
5
|
|
6
6
|
|
7
7
|
class NotFoundError(ApiError):
|
8
|
-
def __init__(self, body:
|
8
|
+
def __init__(self, body: AssetNotFoundError):
|
9
9
|
super().__init__(status_code=404, body=body)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
+
import typing
|
4
|
+
|
3
5
|
from ..core.api_error import ApiError
|
4
|
-
from ..types.sql_unauthorized_error import SqlUnauthorizedError
|
5
6
|
|
6
7
|
|
7
8
|
class UnauthorizedError(ApiError):
|
8
|
-
def __init__(self, body:
|
9
|
+
def __init__(self, body: typing.Any):
|
9
10
|
super().__init__(status_code=401, body=body)
|
athena/query/client.py
CHANGED
@@ -12,7 +12,6 @@ from ..errors.internal_server_error import InternalServerError
|
|
12
12
|
from ..errors.unauthorized_error import UnauthorizedError
|
13
13
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
14
14
|
from ..types.data_frame_request_out import DataFrameRequestOut
|
15
|
-
from ..types.sql_unauthorized_error import SqlUnauthorizedError
|
16
15
|
from .types.query_execute_request_database_asset_ids import QueryExecuteRequestDatabaseAssetIds
|
17
16
|
|
18
17
|
|
@@ -67,7 +66,7 @@ class QueryClient:
|
|
67
66
|
if 200 <= _response.status_code < 300:
|
68
67
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
69
68
|
if _response.status_code == 401:
|
70
|
-
raise UnauthorizedError(pydantic_v1.parse_obj_as(
|
69
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
71
70
|
if _response.status_code == 422:
|
72
71
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
73
72
|
if _response.status_code == 500:
|
@@ -116,7 +115,7 @@ class QueryClient:
|
|
116
115
|
if 200 <= _response.status_code < 300:
|
117
116
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
118
117
|
if _response.status_code == 401:
|
119
|
-
raise UnauthorizedError(pydantic_v1.parse_obj_as(
|
118
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
120
119
|
if _response.status_code == 422:
|
121
120
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
122
121
|
if _response.status_code == 500:
|
@@ -179,7 +178,7 @@ class AsyncQueryClient:
|
|
179
178
|
if 200 <= _response.status_code < 300:
|
180
179
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
181
180
|
if _response.status_code == 401:
|
182
|
-
raise UnauthorizedError(pydantic_v1.parse_obj_as(
|
181
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
183
182
|
if _response.status_code == 422:
|
184
183
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
185
184
|
if _response.status_code == 500:
|
@@ -228,7 +227,7 @@ class AsyncQueryClient:
|
|
228
227
|
if 200 <= _response.status_code < 300:
|
229
228
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
230
229
|
if _response.status_code == 401:
|
231
|
-
raise UnauthorizedError(pydantic_v1.parse_obj_as(
|
230
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
232
231
|
if _response.status_code == 422:
|
233
232
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
234
233
|
if _response.status_code == 500:
|
athena/tools/client.py
CHANGED
@@ -3,19 +3,29 @@
|
|
3
3
|
import typing
|
4
4
|
from json.decoder import JSONDecodeError
|
5
5
|
|
6
|
+
from .. import core
|
6
7
|
from ..core.api_error import ApiError
|
7
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
8
9
|
from ..core.pydantic_utilities import pydantic_v1
|
9
10
|
from ..core.request_options import RequestOptions
|
11
|
+
from ..errors.bad_request_error import BadRequestError
|
12
|
+
from ..errors.content_too_large_error import ContentTooLargeError
|
10
13
|
from ..errors.internal_server_error import InternalServerError
|
11
14
|
from ..errors.not_found_error import NotFoundError
|
15
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
12
16
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
13
17
|
from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
|
18
|
+
from ..types.asset_not_found_error import AssetNotFoundError
|
14
19
|
from ..types.data_frame_request_out import DataFrameRequestOut
|
15
20
|
from ..types.data_frame_unknown_format_error import DataFrameUnknownFormatError
|
16
|
-
from ..types.
|
21
|
+
from ..types.file_too_large_error import FileTooLargeError
|
22
|
+
from ..types.parent_folder_error import ParentFolderError
|
23
|
+
from ..types.save_asset_request_out import SaveAssetRequestOut
|
17
24
|
from .types.tools_data_frame_request_columns_item import ToolsDataFrameRequestColumnsItem
|
18
25
|
|
26
|
+
# this is used as the default value for optional parameters
|
27
|
+
OMIT = typing.cast(typing.Any, ...)
|
28
|
+
|
19
29
|
|
20
30
|
class ToolsClient:
|
21
31
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
@@ -86,8 +96,10 @@ class ToolsClient:
|
|
86
96
|
)
|
87
97
|
if 200 <= _response.status_code < 300:
|
88
98
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
99
|
+
if _response.status_code == 401:
|
100
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
89
101
|
if _response.status_code == 404:
|
90
|
-
raise NotFoundError(pydantic_v1.parse_obj_as(
|
102
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
|
91
103
|
if _response.status_code == 415:
|
92
104
|
raise UnsupportedMediaTypeError(
|
93
105
|
pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
|
@@ -139,16 +151,76 @@ class ToolsClient:
|
|
139
151
|
yield _chunk
|
140
152
|
return
|
141
153
|
_response.read()
|
154
|
+
if _response.status_code == 401:
|
155
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
142
156
|
if _response.status_code == 404:
|
143
|
-
raise NotFoundError(pydantic_v1.parse_obj_as(
|
157
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
|
144
158
|
if _response.status_code == 422:
|
145
159
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
160
|
+
if _response.status_code == 500:
|
161
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
146
162
|
try:
|
147
163
|
_response_json = _response.json()
|
148
164
|
except JSONDecodeError:
|
149
165
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
150
166
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
151
167
|
|
168
|
+
def save_asset(
|
169
|
+
self,
|
170
|
+
*,
|
171
|
+
file: core.File,
|
172
|
+
parent_folder_id: typing.Optional[str] = None,
|
173
|
+
request_options: typing.Optional[RequestOptions] = None
|
174
|
+
) -> SaveAssetRequestOut:
|
175
|
+
"""
|
176
|
+
Parameters
|
177
|
+
----------
|
178
|
+
file : core.File
|
179
|
+
See core.File for more documentation
|
180
|
+
|
181
|
+
parent_folder_id : typing.Optional[str]
|
182
|
+
Identifier of the folder into which the asset should be saved
|
183
|
+
|
184
|
+
request_options : typing.Optional[RequestOptions]
|
185
|
+
Request-specific configuration.
|
186
|
+
|
187
|
+
Returns
|
188
|
+
-------
|
189
|
+
SaveAssetRequestOut
|
190
|
+
Successful Response
|
191
|
+
|
192
|
+
Examples
|
193
|
+
--------
|
194
|
+
from athena.client import Athena
|
195
|
+
|
196
|
+
client = Athena(
|
197
|
+
api_key="YOUR_API_KEY",
|
198
|
+
)
|
199
|
+
client.tools.save_asset()
|
200
|
+
"""
|
201
|
+
_response = self._client_wrapper.httpx_client.request(
|
202
|
+
"api/v0/tools/file/save",
|
203
|
+
method="POST",
|
204
|
+
params={"parent_folder_id": parent_folder_id},
|
205
|
+
data={},
|
206
|
+
files={"file": file},
|
207
|
+
request_options=request_options,
|
208
|
+
omit=OMIT,
|
209
|
+
)
|
210
|
+
if 200 <= _response.status_code < 300:
|
211
|
+
return pydantic_v1.parse_obj_as(SaveAssetRequestOut, _response.json()) # type: ignore
|
212
|
+
if _response.status_code == 400:
|
213
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
|
214
|
+
if _response.status_code == 413:
|
215
|
+
raise ContentTooLargeError(pydantic_v1.parse_obj_as(FileTooLargeError, _response.json())) # type: ignore
|
216
|
+
if _response.status_code == 422:
|
217
|
+
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
218
|
+
try:
|
219
|
+
_response_json = _response.json()
|
220
|
+
except JSONDecodeError:
|
221
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
222
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
223
|
+
|
152
224
|
|
153
225
|
class AsyncToolsClient:
|
154
226
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
@@ -219,8 +291,10 @@ class AsyncToolsClient:
|
|
219
291
|
)
|
220
292
|
if 200 <= _response.status_code < 300:
|
221
293
|
return pydantic_v1.parse_obj_as(DataFrameRequestOut, _response.json()) # type: ignore
|
294
|
+
if _response.status_code == 401:
|
295
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
222
296
|
if _response.status_code == 404:
|
223
|
-
raise NotFoundError(pydantic_v1.parse_obj_as(
|
297
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
|
224
298
|
if _response.status_code == 415:
|
225
299
|
raise UnsupportedMediaTypeError(
|
226
300
|
pydantic_v1.parse_obj_as(DataFrameUnknownFormatError, _response.json()) # type: ignore
|
@@ -272,12 +346,72 @@ class AsyncToolsClient:
|
|
272
346
|
yield _chunk
|
273
347
|
return
|
274
348
|
await _response.aread()
|
349
|
+
if _response.status_code == 401:
|
350
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
275
351
|
if _response.status_code == 404:
|
276
|
-
raise NotFoundError(pydantic_v1.parse_obj_as(
|
352
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(AssetNotFoundError, _response.json())) # type: ignore
|
277
353
|
if _response.status_code == 422:
|
278
354
|
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
355
|
+
if _response.status_code == 500:
|
356
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
279
357
|
try:
|
280
358
|
_response_json = _response.json()
|
281
359
|
except JSONDecodeError:
|
282
360
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
283
361
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
362
|
+
|
363
|
+
async def save_asset(
|
364
|
+
self,
|
365
|
+
*,
|
366
|
+
file: core.File,
|
367
|
+
parent_folder_id: typing.Optional[str] = None,
|
368
|
+
request_options: typing.Optional[RequestOptions] = None
|
369
|
+
) -> SaveAssetRequestOut:
|
370
|
+
"""
|
371
|
+
Parameters
|
372
|
+
----------
|
373
|
+
file : core.File
|
374
|
+
See core.File for more documentation
|
375
|
+
|
376
|
+
parent_folder_id : typing.Optional[str]
|
377
|
+
Identifier of the folder into which the asset should be saved
|
378
|
+
|
379
|
+
request_options : typing.Optional[RequestOptions]
|
380
|
+
Request-specific configuration.
|
381
|
+
|
382
|
+
Returns
|
383
|
+
-------
|
384
|
+
SaveAssetRequestOut
|
385
|
+
Successful Response
|
386
|
+
|
387
|
+
Examples
|
388
|
+
--------
|
389
|
+
from athena.client import AsyncAthena
|
390
|
+
|
391
|
+
client = AsyncAthena(
|
392
|
+
api_key="YOUR_API_KEY",
|
393
|
+
)
|
394
|
+
await client.tools.save_asset()
|
395
|
+
"""
|
396
|
+
_response = await self._client_wrapper.httpx_client.request(
|
397
|
+
"api/v0/tools/file/save",
|
398
|
+
method="POST",
|
399
|
+
params={"parent_folder_id": parent_folder_id},
|
400
|
+
data={},
|
401
|
+
files={"file": file},
|
402
|
+
request_options=request_options,
|
403
|
+
omit=OMIT,
|
404
|
+
)
|
405
|
+
if 200 <= _response.status_code < 300:
|
406
|
+
return pydantic_v1.parse_obj_as(SaveAssetRequestOut, _response.json()) # type: ignore
|
407
|
+
if _response.status_code == 400:
|
408
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ParentFolderError, _response.json())) # type: ignore
|
409
|
+
if _response.status_code == 413:
|
410
|
+
raise ContentTooLargeError(pydantic_v1.parse_obj_as(FileTooLargeError, _response.json())) # type: ignore
|
411
|
+
if _response.status_code == 422:
|
412
|
+
raise UnprocessableEntityError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
413
|
+
try:
|
414
|
+
_response_json = _response.json()
|
415
|
+
except JSONDecodeError:
|
416
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
417
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
athena/types/__init__.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
+
from .asset_not_found_error import AssetNotFoundError
|
3
4
|
from .data_frame_request_out import DataFrameRequestOut
|
4
5
|
from .data_frame_request_out_columns_item import DataFrameRequestOutColumnsItem
|
5
6
|
from .data_frame_request_out_data_item_item import DataFrameRequestOutDataItemItem
|
6
7
|
from .data_frame_request_out_index_item import DataFrameRequestOutIndexItem
|
7
8
|
from .data_frame_unknown_format_error import DataFrameUnknownFormatError
|
8
|
-
from .
|
9
|
-
from .
|
9
|
+
from .file_too_large_error import FileTooLargeError
|
10
|
+
from .parent_folder_error import ParentFolderError
|
11
|
+
from .save_asset_request_out import SaveAssetRequestOut
|
10
12
|
|
11
13
|
__all__ = [
|
14
|
+
"AssetNotFoundError",
|
12
15
|
"DataFrameRequestOut",
|
13
16
|
"DataFrameRequestOutColumnsItem",
|
14
17
|
"DataFrameRequestOutDataItemItem",
|
15
18
|
"DataFrameRequestOutIndexItem",
|
16
19
|
"DataFrameUnknownFormatError",
|
17
|
-
"
|
18
|
-
"
|
20
|
+
"FileTooLargeError",
|
21
|
+
"ParentFolderError",
|
22
|
+
"SaveAssetRequestOut",
|
19
23
|
]
|
@@ -7,7 +7,7 @@ from ..core.datetime_utils import serialize_datetime
|
|
7
7
|
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class AssetNotFoundError(pydantic_v1.BaseModel):
|
11
11
|
message: str
|
12
12
|
|
13
13
|
def json(self, **kwargs: typing.Any) -> str:
|
@@ -7,9 +7,8 @@ from ..core.datetime_utils import serialize_datetime
|
|
7
7
|
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class FileTooLargeError(pydantic_v1.BaseModel):
|
11
11
|
message: str
|
12
|
-
status_code: typing.Optional[int] = None
|
13
12
|
|
14
13
|
def json(self, **kwargs: typing.Any) -> str:
|
15
14
|
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import datetime as dt
|
4
|
+
import typing
|
5
|
+
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
8
|
+
|
9
|
+
|
10
|
+
class ParentFolderError(pydantic_v1.BaseModel):
|
11
|
+
message: str
|
12
|
+
|
13
|
+
def json(self, **kwargs: typing.Any) -> str:
|
14
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
15
|
+
return super().json(**kwargs_with_defaults)
|
16
|
+
|
17
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
18
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
19
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
20
|
+
|
21
|
+
return deep_union_pydantic_dicts(
|
22
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
23
|
+
)
|
24
|
+
|
25
|
+
class Config:
|
26
|
+
frozen = True
|
27
|
+
smart_union = True
|
28
|
+
extra = pydantic_v1.Extra.allow
|
29
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import datetime as dt
|
4
|
+
import typing
|
5
|
+
|
6
|
+
from ..core.datetime_utils import serialize_datetime
|
7
|
+
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
|
8
|
+
|
9
|
+
|
10
|
+
class SaveAssetRequestOut(pydantic_v1.BaseModel):
|
11
|
+
"""
|
12
|
+
Response model asset information representation.
|
13
|
+
"""
|
14
|
+
|
15
|
+
asset_id: str
|
16
|
+
|
17
|
+
def json(self, **kwargs: typing.Any) -> str:
|
18
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
19
|
+
return super().json(**kwargs_with_defaults)
|
20
|
+
|
21
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
22
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
23
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
24
|
+
|
25
|
+
return deep_union_pydantic_dicts(
|
26
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
27
|
+
)
|
28
|
+
|
29
|
+
class Config:
|
30
|
+
frozen = True
|
31
|
+
smart_union = True
|
32
|
+
extra = pydantic_v1.Extra.allow
|
33
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
athena/__init__.py,sha256=
|
1
|
+
athena/__init__.py,sha256=EtDa2cZbHfqJnBxCrjErWF1oJWH0cbJbFB7bkxeOFnE,1392
|
2
2
|
athena/base_client.py,sha256=TlP599mOBvj7Tk8IpFe5dgrDM98GJu3lEQh_zwl4vtA,5439
|
3
|
-
athena/client.py,sha256=
|
3
|
+
athena/client.py,sha256=9hj9SzW7OhAIY8yKHA0WObOtx8-1W4aLSHduqkBHJT0,14722
|
4
4
|
athena/core/__init__.py,sha256=UFXpYzcGxWQUucU1TkjOQ9mGWN3A5JohluOIWVYKU4I,973
|
5
5
|
athena/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
6
|
-
athena/core/client_wrapper.py,sha256=
|
6
|
+
athena/core/client_wrapper.py,sha256=ijXhms74o95_1sms0mC87d_xv0uBTKXzxH7pmz9YEKE,1806
|
7
7
|
athena/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
8
8
|
athena/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
|
9
9
|
athena/core/http_client.py,sha256=Z4NuAsJD-51yqmoME17O5sxwx5orSp1wsnd6bPyKcgA,17768
|
@@ -13,30 +13,34 @@ athena/core/query_encoder.py,sha256=sI6XiwFby-WRIk4MVN_5wlAlm30aCHE73Uvm09fb9qQ,
|
|
13
13
|
athena/core/remove_none_from_dict.py,sha256=EU9SGgYidWq7SexuJbNs4-PZ-5Bl3Vppd864mS6vQZw,342
|
14
14
|
athena/core/request_options.py,sha256=-3QoOMMHI2exIyHH6Q2MD7rpo_6w-i6zMAy0nqWTN8c,1420
|
15
15
|
athena/environment.py,sha256=_e7YwByXALEk7fNJNJvjF81caYTbsx4c7wwftCJHQ7g,214
|
16
|
-
athena/errors/__init__.py,sha256=
|
16
|
+
athena/errors/__init__.py,sha256=WlRIo4aGYcnxtY2DtoWS5YzmaKQHFp4Uh3mXxrakU_c,655
|
17
|
+
athena/errors/bad_request_error.py,sha256=wfNVQgYe-5jsfeex-IBMrqn05oArDz0PT0ddj01S9aE,298
|
18
|
+
athena/errors/content_too_large_error.py,sha256=_Jacqup8-YwalVeCv6NWDo9bqZhByXoUaApAxfFc9tU,304
|
17
19
|
athena/errors/internal_server_error.py,sha256=E0rgqJC0-LcetLi1HmSi92KpvNkGSRCIdBeEqT_ln1s,252
|
18
|
-
athena/errors/not_found_error.py,sha256=
|
19
|
-
athena/errors/unauthorized_error.py,sha256=
|
20
|
+
athena/errors/not_found_error.py,sha256=fIMBz7ubqcX3HpLIoqmF7-kFCoN6-Uj1lW4OuBnaK6s,300
|
21
|
+
athena/errors/unauthorized_error.py,sha256=T-UWUDnIEmguQei9CYcRJ2SCt4DhZVxpuZRNAwK0Ru4,250
|
20
22
|
athena/errors/unprocessable_entity_error.py,sha256=OztAzRntOJVxbZtXwoR4epahhG6chKOB5chVLUC8D9Q,257
|
21
23
|
athena/errors/unsupported_media_type_error.py,sha256=fQ7TYQ3QYcT_YzFzO4f8_bLger7UQfZmuF22I9jYxFA,340
|
22
24
|
athena/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
25
|
athena/query/__init__.py,sha256=EIeVs3aDVNAqLyWetSrQldzc2yUdJkf_cJXyrLdMDj0,171
|
24
|
-
athena/query/client.py,sha256=
|
26
|
+
athena/query/client.py,sha256=GYvBV7YFYjL3gyskeF6C8BJZlLvU7R045gJ5kGiYkvg,9043
|
25
27
|
athena/query/types/__init__.py,sha256=WX-Or2h5NY2sv93ojrZsHcmiFHGYdqd0yxNo-5iGHR4,206
|
26
28
|
athena/query/types/query_execute_request_database_asset_ids.py,sha256=aoVl5Xb34Q27hYGuVTnByGIxtHkL67wAwzXh7eJctew,154
|
27
29
|
athena/tools/__init__.py,sha256=3n7oOoMebo06MAQqYRE2CX9Q0fTNnKBYE0cTlh1MPkM,165
|
28
|
-
athena/tools/client.py,sha256=
|
30
|
+
athena/tools/client.py,sha256=5oFszmOEfdzZJNV5QHjkdyThhEswWAnWXObmK8halkE,16114
|
29
31
|
athena/tools/types/__init__.py,sha256=cA-ZQm6veQAP3_vKu9KkZpISsQqgTBN_Z--FGY1c2iA,197
|
30
|
-
athena/tools/types/tools_data_frame_request_columns_item.py,sha256=
|
31
|
-
athena/types/__init__.py,sha256=
|
32
|
+
athena/tools/types/tools_data_frame_request_columns_item.py,sha256=GA1FUlTV_CfSc-KToTAwFf4Exl0rr4fsweVZupztjw0,138
|
33
|
+
athena/types/__init__.py,sha256=rN0nC7uMZooYmwp7F7rSIb4tIaH2bIr_yd5P1c7e-XY,939
|
34
|
+
athena/types/asset_not_found_error.py,sha256=ZcgqRuzvO4Z8vVVxwtDB-QtKhpVIVV3hqQuJeUoOoJE,1121
|
32
35
|
athena/types/data_frame_request_out.py,sha256=1CEBe-baDQi0uz_EgMw0TKGYXGj6KV44cL3ViRTZLKM,1669
|
33
36
|
athena/types/data_frame_request_out_columns_item.py,sha256=9cjzciFv6C8n8Griytt_q_8ovkzHViS5tvUcMDfkfKE,143
|
34
37
|
athena/types/data_frame_request_out_data_item_item.py,sha256=KMTJRr-1bdKDNMbUericCliwRoPHLGRV-n2bJtxdRW0,144
|
35
38
|
athena/types/data_frame_request_out_index_item.py,sha256=bW7oe912trpkYKodj-I_AiTXXy61yWzliekcsUZkZE0,141
|
36
39
|
athena/types/data_frame_unknown_format_error.py,sha256=lbgAUArEgIYZt3P5Ji4Clp-xyXnKJR7-v5VzXwKu0J8,1168
|
37
|
-
athena/types/
|
38
|
-
athena/types/
|
40
|
+
athena/types/file_too_large_error.py,sha256=AinkrcgR7lcTILAD8RX0x48P3GlSoAh1OihxMvSvRuo,1120
|
41
|
+
athena/types/parent_folder_error.py,sha256=ZMF-i3mZY6Mu1n5uQ60Q3mIIfehlWuXtgFUkSYspkx8,1120
|
42
|
+
athena/types/save_asset_request_out.py,sha256=5bpBaUV3oeuL_hz4s07c-6MQHkn4cBsyxgT_SD5oi6I,1193
|
39
43
|
athena/version.py,sha256=8aYAOJtVLaJLpRp6mTiEIhnl8gXA7yE0aDtZ-3mKQ4k,87
|
40
|
-
athena_intelligence-0.1.
|
41
|
-
athena_intelligence-0.1.
|
42
|
-
athena_intelligence-0.1.
|
44
|
+
athena_intelligence-0.1.105.dist-info/METADATA,sha256=0-dSyqtK9SICscX0vlve617c46HjDvYdj6NdWuZcn9k,5274
|
45
|
+
athena_intelligence-0.1.105.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
46
|
+
athena_intelligence-0.1.105.dist-info/RECORD,,
|
File without changes
|