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.
- athena/__init__.py +28 -3
- athena/agents/__init__.py +2 -0
- athena/agents/client.py +51 -95
- athena/agents/drive/__init__.py +2 -0
- athena/agents/drive/client.py +31 -80
- athena/agents/drive/raw_client.py +155 -0
- athena/agents/general/__init__.py +2 -0
- athena/agents/general/client.py +91 -238
- athena/agents/general/raw_client.py +369 -0
- athena/agents/raw_client.py +176 -0
- athena/agents/research/__init__.py +2 -0
- athena/agents/research/client.py +31 -80
- athena/agents/research/raw_client.py +155 -0
- athena/agents/sql/__init__.py +2 -0
- athena/agents/sql/client.py +31 -80
- athena/agents/sql/raw_client.py +155 -0
- athena/assets/__init__.py +4 -0
- athena/assets/client.py +144 -0
- athena/assets/raw_client.py +164 -0
- athena/base_client.py +25 -11
- athena/client.py +1 -1
- athena/core/__init__.py +5 -0
- athena/core/api_error.py +13 -5
- athena/core/client_wrapper.py +33 -8
- athena/core/force_multipart.py +16 -0
- athena/core/http_client.py +70 -26
- athena/core/http_response.py +55 -0
- athena/core/jsonable_encoder.py +0 -1
- athena/core/pydantic_utilities.py +70 -111
- athena/core/serialization.py +7 -3
- athena/errors/__init__.py +2 -0
- athena/errors/bad_request_error.py +4 -2
- athena/errors/content_too_large_error.py +4 -2
- athena/errors/internal_server_error.py +4 -3
- athena/errors/not_found_error.py +4 -2
- athena/errors/unauthorized_error.py +4 -3
- athena/errors/unprocessable_entity_error.py +4 -3
- athena/errors/unsupported_media_type_error.py +4 -2
- athena/query/__init__.py +2 -0
- athena/query/client.py +39 -219
- athena/query/raw_client.py +344 -0
- athena/query/types/__init__.py +2 -0
- athena/tools/__init__.py +2 -0
- athena/tools/calendar/__init__.py +2 -0
- athena/tools/calendar/client.py +35 -79
- athena/tools/calendar/raw_client.py +172 -0
- athena/tools/client.py +267 -653
- athena/tools/email/__init__.py +2 -0
- athena/tools/email/client.py +39 -115
- athena/tools/email/raw_client.py +248 -0
- athena/tools/raw_client.py +1328 -0
- athena/tools/structured_data_extractor/__init__.py +2 -0
- athena/tools/structured_data_extractor/client.py +42 -96
- athena/tools/structured_data_extractor/raw_client.py +240 -0
- athena/tools/tasks/__init__.py +2 -0
- athena/tools/tasks/client.py +31 -43
- athena/tools/tasks/raw_client.py +96 -0
- athena/tools/types/__init__.py +2 -0
- athena/types/__init__.py +28 -2
- athena/types/asset_content_request_out.py +26 -0
- athena/types/asset_node.py +3 -3
- athena/types/asset_not_found_error.py +2 -2
- athena/types/asset_screenshot_response_out.py +43 -0
- athena/types/chunk.py +3 -3
- athena/types/chunk_content_item.py +3 -2
- athena/types/chunk_result.py +3 -3
- athena/types/content.py +7 -0
- athena/types/custom_agent_response.py +2 -2
- athena/types/data_frame_request_out.py +3 -3
- athena/types/data_frame_unknown_format_error.py +2 -2
- athena/types/document_chunk.py +2 -2
- athena/types/drive_agent_response.py +2 -2
- athena/types/file_chunk_request_out.py +3 -3
- athena/types/file_too_large_error.py +2 -2
- athena/types/folder_response.py +10 -4
- athena/types/general_agent_config.py +4 -3
- athena/types/general_agent_config_enabled_tools_item.py +1 -2
- athena/types/general_agent_request.py +15 -4
- athena/types/general_agent_response.py +4 -3
- athena/types/general_agent_response_message.py +100 -0
- athena/types/general_agent_response_message_kwargs.py +74 -0
- athena/types/{tool.py → id.py} +1 -1
- athena/types/image_url_content.py +2 -2
- athena/types/input_message.py +29 -0
- athena/types/input_message_content_item.py +39 -0
- athena/types/paginated_assets_out.py +52 -0
- athena/types/parent_folder_error.py +2 -2
- athena/types/prompt_message.py +3 -3
- athena/types/public_asset_out.py +97 -0
- athena/types/research_agent_response.py +2 -2
- athena/types/save_asset_request_out.py +2 -2
- athena/types/sql_agent_response.py +2 -2
- athena/types/structured_data_extractor_response.py +3 -3
- athena/types/text_content.py +2 -2
- athena/types/type.py +1 -1
- {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/METADATA +3 -7
- athena_intelligence-0.1.184.dist-info/RECORD +112 -0
- {athena_intelligence-0.1.126.dist-info → athena_intelligence-0.1.184.dist-info}/WHEEL +1 -1
- athena_intelligence-0.1.126.dist-info/RECORD +0 -87
athena/query/client.py
CHANGED
@@ -1,23 +1,28 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
from ..core.client_wrapper import SyncClientWrapper
|
4
|
-
from .types.query_execute_request_database_asset_ids import QueryExecuteRequestDatabaseAssetIds
|
5
3
|
import typing
|
4
|
+
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
6
6
|
from ..core.request_options import RequestOptions
|
7
7
|
from ..types.data_frame_request_out import DataFrameRequestOut
|
8
|
-
from
|
9
|
-
from
|
10
|
-
from ..errors.unauthorized_error import UnauthorizedError
|
11
|
-
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
12
|
-
from ..errors.internal_server_error import InternalServerError
|
13
|
-
from json.decoder import JSONDecodeError
|
14
|
-
from ..core.api_error import ApiError
|
15
|
-
from ..core.client_wrapper import AsyncClientWrapper
|
8
|
+
from .raw_client import AsyncRawQueryClient, RawQueryClient
|
9
|
+
from .types.query_execute_request_database_asset_ids import QueryExecuteRequestDatabaseAssetIds
|
16
10
|
|
17
11
|
|
18
12
|
class QueryClient:
|
19
13
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
20
|
-
self.
|
14
|
+
self._raw_client = RawQueryClient(client_wrapper=client_wrapper)
|
15
|
+
|
16
|
+
@property
|
17
|
+
def with_raw_response(self) -> RawQueryClient:
|
18
|
+
"""
|
19
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
20
|
+
|
21
|
+
Returns
|
22
|
+
-------
|
23
|
+
RawQueryClient
|
24
|
+
"""
|
25
|
+
return self._raw_client
|
21
26
|
|
22
27
|
def execute(
|
23
28
|
self,
|
@@ -57,60 +62,10 @@ class QueryClient:
|
|
57
62
|
database_asset_ids="database_asset_ids",
|
58
63
|
)
|
59
64
|
"""
|
60
|
-
_response = self.
|
61
|
-
|
62
|
-
method="GET",
|
63
|
-
params={
|
64
|
-
"sql_command": sql_command,
|
65
|
-
"database_asset_ids": convert_and_respect_annotation_metadata(
|
66
|
-
object_=database_asset_ids, annotation=QueryExecuteRequestDatabaseAssetIds, direction="write"
|
67
|
-
),
|
68
|
-
},
|
69
|
-
request_options=request_options,
|
65
|
+
_response = self._raw_client.execute(
|
66
|
+
sql_command=sql_command, database_asset_ids=database_asset_ids, request_options=request_options
|
70
67
|
)
|
71
|
-
|
72
|
-
if 200 <= _response.status_code < 300:
|
73
|
-
return typing.cast(
|
74
|
-
DataFrameRequestOut,
|
75
|
-
parse_obj_as(
|
76
|
-
type_=DataFrameRequestOut, # type: ignore
|
77
|
-
object_=_response.json(),
|
78
|
-
),
|
79
|
-
)
|
80
|
-
if _response.status_code == 401:
|
81
|
-
raise UnauthorizedError(
|
82
|
-
typing.cast(
|
83
|
-
typing.Optional[typing.Any],
|
84
|
-
parse_obj_as(
|
85
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
86
|
-
object_=_response.json(),
|
87
|
-
),
|
88
|
-
)
|
89
|
-
)
|
90
|
-
if _response.status_code == 422:
|
91
|
-
raise UnprocessableEntityError(
|
92
|
-
typing.cast(
|
93
|
-
typing.Optional[typing.Any],
|
94
|
-
parse_obj_as(
|
95
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
96
|
-
object_=_response.json(),
|
97
|
-
),
|
98
|
-
)
|
99
|
-
)
|
100
|
-
if _response.status_code == 500:
|
101
|
-
raise InternalServerError(
|
102
|
-
typing.cast(
|
103
|
-
typing.Optional[typing.Any],
|
104
|
-
parse_obj_as(
|
105
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
106
|
-
object_=_response.json(),
|
107
|
-
),
|
108
|
-
)
|
109
|
-
)
|
110
|
-
_response_json = _response.json()
|
111
|
-
except JSONDecodeError:
|
112
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
113
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
68
|
+
return _response.data
|
114
69
|
|
115
70
|
def execute_snippet(
|
116
71
|
self, *, snippet_asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -141,62 +96,24 @@ class QueryClient:
|
|
141
96
|
snippet_asset_id="snippet_asset_id",
|
142
97
|
)
|
143
98
|
"""
|
144
|
-
_response = self.
|
145
|
-
|
146
|
-
method="GET",
|
147
|
-
params={
|
148
|
-
"snippet_asset_id": snippet_asset_id,
|
149
|
-
},
|
150
|
-
request_options=request_options,
|
151
|
-
)
|
152
|
-
try:
|
153
|
-
if 200 <= _response.status_code < 300:
|
154
|
-
return typing.cast(
|
155
|
-
DataFrameRequestOut,
|
156
|
-
parse_obj_as(
|
157
|
-
type_=DataFrameRequestOut, # type: ignore
|
158
|
-
object_=_response.json(),
|
159
|
-
),
|
160
|
-
)
|
161
|
-
if _response.status_code == 401:
|
162
|
-
raise UnauthorizedError(
|
163
|
-
typing.cast(
|
164
|
-
typing.Optional[typing.Any],
|
165
|
-
parse_obj_as(
|
166
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
167
|
-
object_=_response.json(),
|
168
|
-
),
|
169
|
-
)
|
170
|
-
)
|
171
|
-
if _response.status_code == 422:
|
172
|
-
raise UnprocessableEntityError(
|
173
|
-
typing.cast(
|
174
|
-
typing.Optional[typing.Any],
|
175
|
-
parse_obj_as(
|
176
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
177
|
-
object_=_response.json(),
|
178
|
-
),
|
179
|
-
)
|
180
|
-
)
|
181
|
-
if _response.status_code == 500:
|
182
|
-
raise InternalServerError(
|
183
|
-
typing.cast(
|
184
|
-
typing.Optional[typing.Any],
|
185
|
-
parse_obj_as(
|
186
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
187
|
-
object_=_response.json(),
|
188
|
-
),
|
189
|
-
)
|
190
|
-
)
|
191
|
-
_response_json = _response.json()
|
192
|
-
except JSONDecodeError:
|
193
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
194
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
99
|
+
_response = self._raw_client.execute_snippet(snippet_asset_id=snippet_asset_id, request_options=request_options)
|
100
|
+
return _response.data
|
195
101
|
|
196
102
|
|
197
103
|
class AsyncQueryClient:
|
198
104
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
199
|
-
self.
|
105
|
+
self._raw_client = AsyncRawQueryClient(client_wrapper=client_wrapper)
|
106
|
+
|
107
|
+
@property
|
108
|
+
def with_raw_response(self) -> AsyncRawQueryClient:
|
109
|
+
"""
|
110
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
111
|
+
|
112
|
+
Returns
|
113
|
+
-------
|
114
|
+
AsyncRawQueryClient
|
115
|
+
"""
|
116
|
+
return self._raw_client
|
200
117
|
|
201
118
|
async def execute(
|
202
119
|
self,
|
@@ -244,60 +161,10 @@ class AsyncQueryClient:
|
|
244
161
|
|
245
162
|
asyncio.run(main())
|
246
163
|
"""
|
247
|
-
_response = await self.
|
248
|
-
|
249
|
-
method="GET",
|
250
|
-
params={
|
251
|
-
"sql_command": sql_command,
|
252
|
-
"database_asset_ids": convert_and_respect_annotation_metadata(
|
253
|
-
object_=database_asset_ids, annotation=QueryExecuteRequestDatabaseAssetIds, direction="write"
|
254
|
-
),
|
255
|
-
},
|
256
|
-
request_options=request_options,
|
164
|
+
_response = await self._raw_client.execute(
|
165
|
+
sql_command=sql_command, database_asset_ids=database_asset_ids, request_options=request_options
|
257
166
|
)
|
258
|
-
|
259
|
-
if 200 <= _response.status_code < 300:
|
260
|
-
return typing.cast(
|
261
|
-
DataFrameRequestOut,
|
262
|
-
parse_obj_as(
|
263
|
-
type_=DataFrameRequestOut, # type: ignore
|
264
|
-
object_=_response.json(),
|
265
|
-
),
|
266
|
-
)
|
267
|
-
if _response.status_code == 401:
|
268
|
-
raise UnauthorizedError(
|
269
|
-
typing.cast(
|
270
|
-
typing.Optional[typing.Any],
|
271
|
-
parse_obj_as(
|
272
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
273
|
-
object_=_response.json(),
|
274
|
-
),
|
275
|
-
)
|
276
|
-
)
|
277
|
-
if _response.status_code == 422:
|
278
|
-
raise UnprocessableEntityError(
|
279
|
-
typing.cast(
|
280
|
-
typing.Optional[typing.Any],
|
281
|
-
parse_obj_as(
|
282
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
283
|
-
object_=_response.json(),
|
284
|
-
),
|
285
|
-
)
|
286
|
-
)
|
287
|
-
if _response.status_code == 500:
|
288
|
-
raise InternalServerError(
|
289
|
-
typing.cast(
|
290
|
-
typing.Optional[typing.Any],
|
291
|
-
parse_obj_as(
|
292
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
293
|
-
object_=_response.json(),
|
294
|
-
),
|
295
|
-
)
|
296
|
-
)
|
297
|
-
_response_json = _response.json()
|
298
|
-
except JSONDecodeError:
|
299
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
300
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
167
|
+
return _response.data
|
301
168
|
|
302
169
|
async def execute_snippet(
|
303
170
|
self, *, snippet_asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
@@ -336,54 +203,7 @@ class AsyncQueryClient:
|
|
336
203
|
|
337
204
|
asyncio.run(main())
|
338
205
|
"""
|
339
|
-
_response = await self.
|
340
|
-
|
341
|
-
method="GET",
|
342
|
-
params={
|
343
|
-
"snippet_asset_id": snippet_asset_id,
|
344
|
-
},
|
345
|
-
request_options=request_options,
|
206
|
+
_response = await self._raw_client.execute_snippet(
|
207
|
+
snippet_asset_id=snippet_asset_id, request_options=request_options
|
346
208
|
)
|
347
|
-
|
348
|
-
if 200 <= _response.status_code < 300:
|
349
|
-
return typing.cast(
|
350
|
-
DataFrameRequestOut,
|
351
|
-
parse_obj_as(
|
352
|
-
type_=DataFrameRequestOut, # type: ignore
|
353
|
-
object_=_response.json(),
|
354
|
-
),
|
355
|
-
)
|
356
|
-
if _response.status_code == 401:
|
357
|
-
raise UnauthorizedError(
|
358
|
-
typing.cast(
|
359
|
-
typing.Optional[typing.Any],
|
360
|
-
parse_obj_as(
|
361
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
362
|
-
object_=_response.json(),
|
363
|
-
),
|
364
|
-
)
|
365
|
-
)
|
366
|
-
if _response.status_code == 422:
|
367
|
-
raise UnprocessableEntityError(
|
368
|
-
typing.cast(
|
369
|
-
typing.Optional[typing.Any],
|
370
|
-
parse_obj_as(
|
371
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
372
|
-
object_=_response.json(),
|
373
|
-
),
|
374
|
-
)
|
375
|
-
)
|
376
|
-
if _response.status_code == 500:
|
377
|
-
raise InternalServerError(
|
378
|
-
typing.cast(
|
379
|
-
typing.Optional[typing.Any],
|
380
|
-
parse_obj_as(
|
381
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
382
|
-
object_=_response.json(),
|
383
|
-
),
|
384
|
-
)
|
385
|
-
)
|
386
|
-
_response_json = _response.json()
|
387
|
-
except JSONDecodeError:
|
388
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
389
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
209
|
+
return _response.data
|
@@ -0,0 +1,344 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
from json.decoder import JSONDecodeError
|
5
|
+
|
6
|
+
from ..core.api_error import ApiError
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
10
|
+
from ..core.request_options import RequestOptions
|
11
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
12
|
+
from ..errors.internal_server_error import InternalServerError
|
13
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
14
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
15
|
+
from ..types.data_frame_request_out import DataFrameRequestOut
|
16
|
+
from .types.query_execute_request_database_asset_ids import QueryExecuteRequestDatabaseAssetIds
|
17
|
+
|
18
|
+
|
19
|
+
class RawQueryClient:
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
21
|
+
self._client_wrapper = client_wrapper
|
22
|
+
|
23
|
+
def execute(
|
24
|
+
self,
|
25
|
+
*,
|
26
|
+
sql_command: str,
|
27
|
+
database_asset_ids: QueryExecuteRequestDatabaseAssetIds,
|
28
|
+
request_options: typing.Optional[RequestOptions] = None,
|
29
|
+
) -> HttpResponse[DataFrameRequestOut]:
|
30
|
+
"""
|
31
|
+
Get the result of an SQL query over given assets.
|
32
|
+
|
33
|
+
Parameters
|
34
|
+
----------
|
35
|
+
sql_command : str
|
36
|
+
SQL query string
|
37
|
+
|
38
|
+
database_asset_ids : QueryExecuteRequestDatabaseAssetIds
|
39
|
+
Single ID or list of asset IDs
|
40
|
+
|
41
|
+
request_options : typing.Optional[RequestOptions]
|
42
|
+
Request-specific configuration.
|
43
|
+
|
44
|
+
Returns
|
45
|
+
-------
|
46
|
+
HttpResponse[DataFrameRequestOut]
|
47
|
+
Successful Response
|
48
|
+
"""
|
49
|
+
_response = self._client_wrapper.httpx_client.request(
|
50
|
+
"api/v0/query/sql/code/execute",
|
51
|
+
method="GET",
|
52
|
+
params={
|
53
|
+
"sql_command": sql_command,
|
54
|
+
"database_asset_ids": convert_and_respect_annotation_metadata(
|
55
|
+
object_=database_asset_ids, annotation=QueryExecuteRequestDatabaseAssetIds, direction="write"
|
56
|
+
),
|
57
|
+
},
|
58
|
+
request_options=request_options,
|
59
|
+
)
|
60
|
+
try:
|
61
|
+
if 200 <= _response.status_code < 300:
|
62
|
+
_data = typing.cast(
|
63
|
+
DataFrameRequestOut,
|
64
|
+
parse_obj_as(
|
65
|
+
type_=DataFrameRequestOut, # type: ignore
|
66
|
+
object_=_response.json(),
|
67
|
+
),
|
68
|
+
)
|
69
|
+
return HttpResponse(response=_response, data=_data)
|
70
|
+
if _response.status_code == 401:
|
71
|
+
raise UnauthorizedError(
|
72
|
+
headers=dict(_response.headers),
|
73
|
+
body=typing.cast(
|
74
|
+
typing.Optional[typing.Any],
|
75
|
+
parse_obj_as(
|
76
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
77
|
+
object_=_response.json(),
|
78
|
+
),
|
79
|
+
),
|
80
|
+
)
|
81
|
+
if _response.status_code == 422:
|
82
|
+
raise UnprocessableEntityError(
|
83
|
+
headers=dict(_response.headers),
|
84
|
+
body=typing.cast(
|
85
|
+
typing.Optional[typing.Any],
|
86
|
+
parse_obj_as(
|
87
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
88
|
+
object_=_response.json(),
|
89
|
+
),
|
90
|
+
),
|
91
|
+
)
|
92
|
+
if _response.status_code == 500:
|
93
|
+
raise InternalServerError(
|
94
|
+
headers=dict(_response.headers),
|
95
|
+
body=typing.cast(
|
96
|
+
typing.Optional[typing.Any],
|
97
|
+
parse_obj_as(
|
98
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
99
|
+
object_=_response.json(),
|
100
|
+
),
|
101
|
+
),
|
102
|
+
)
|
103
|
+
_response_json = _response.json()
|
104
|
+
except JSONDecodeError:
|
105
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
106
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
107
|
+
|
108
|
+
def execute_snippet(
|
109
|
+
self, *, snippet_asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
110
|
+
) -> HttpResponse[DataFrameRequestOut]:
|
111
|
+
"""
|
112
|
+
Get the result of an SQL query over given assets.
|
113
|
+
|
114
|
+
Parameters
|
115
|
+
----------
|
116
|
+
snippet_asset_id : str
|
117
|
+
|
118
|
+
request_options : typing.Optional[RequestOptions]
|
119
|
+
Request-specific configuration.
|
120
|
+
|
121
|
+
Returns
|
122
|
+
-------
|
123
|
+
HttpResponse[DataFrameRequestOut]
|
124
|
+
Successful Response
|
125
|
+
"""
|
126
|
+
_response = self._client_wrapper.httpx_client.request(
|
127
|
+
"api/v0/query/sql/snippet/execute",
|
128
|
+
method="GET",
|
129
|
+
params={
|
130
|
+
"snippet_asset_id": snippet_asset_id,
|
131
|
+
},
|
132
|
+
request_options=request_options,
|
133
|
+
)
|
134
|
+
try:
|
135
|
+
if 200 <= _response.status_code < 300:
|
136
|
+
_data = typing.cast(
|
137
|
+
DataFrameRequestOut,
|
138
|
+
parse_obj_as(
|
139
|
+
type_=DataFrameRequestOut, # type: ignore
|
140
|
+
object_=_response.json(),
|
141
|
+
),
|
142
|
+
)
|
143
|
+
return HttpResponse(response=_response, data=_data)
|
144
|
+
if _response.status_code == 401:
|
145
|
+
raise UnauthorizedError(
|
146
|
+
headers=dict(_response.headers),
|
147
|
+
body=typing.cast(
|
148
|
+
typing.Optional[typing.Any],
|
149
|
+
parse_obj_as(
|
150
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
151
|
+
object_=_response.json(),
|
152
|
+
),
|
153
|
+
),
|
154
|
+
)
|
155
|
+
if _response.status_code == 422:
|
156
|
+
raise UnprocessableEntityError(
|
157
|
+
headers=dict(_response.headers),
|
158
|
+
body=typing.cast(
|
159
|
+
typing.Optional[typing.Any],
|
160
|
+
parse_obj_as(
|
161
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
162
|
+
object_=_response.json(),
|
163
|
+
),
|
164
|
+
),
|
165
|
+
)
|
166
|
+
if _response.status_code == 500:
|
167
|
+
raise InternalServerError(
|
168
|
+
headers=dict(_response.headers),
|
169
|
+
body=typing.cast(
|
170
|
+
typing.Optional[typing.Any],
|
171
|
+
parse_obj_as(
|
172
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
173
|
+
object_=_response.json(),
|
174
|
+
),
|
175
|
+
),
|
176
|
+
)
|
177
|
+
_response_json = _response.json()
|
178
|
+
except JSONDecodeError:
|
179
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
180
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
181
|
+
|
182
|
+
|
183
|
+
class AsyncRawQueryClient:
|
184
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
185
|
+
self._client_wrapper = client_wrapper
|
186
|
+
|
187
|
+
async def execute(
|
188
|
+
self,
|
189
|
+
*,
|
190
|
+
sql_command: str,
|
191
|
+
database_asset_ids: QueryExecuteRequestDatabaseAssetIds,
|
192
|
+
request_options: typing.Optional[RequestOptions] = None,
|
193
|
+
) -> AsyncHttpResponse[DataFrameRequestOut]:
|
194
|
+
"""
|
195
|
+
Get the result of an SQL query over given assets.
|
196
|
+
|
197
|
+
Parameters
|
198
|
+
----------
|
199
|
+
sql_command : str
|
200
|
+
SQL query string
|
201
|
+
|
202
|
+
database_asset_ids : QueryExecuteRequestDatabaseAssetIds
|
203
|
+
Single ID or list of asset IDs
|
204
|
+
|
205
|
+
request_options : typing.Optional[RequestOptions]
|
206
|
+
Request-specific configuration.
|
207
|
+
|
208
|
+
Returns
|
209
|
+
-------
|
210
|
+
AsyncHttpResponse[DataFrameRequestOut]
|
211
|
+
Successful Response
|
212
|
+
"""
|
213
|
+
_response = await self._client_wrapper.httpx_client.request(
|
214
|
+
"api/v0/query/sql/code/execute",
|
215
|
+
method="GET",
|
216
|
+
params={
|
217
|
+
"sql_command": sql_command,
|
218
|
+
"database_asset_ids": convert_and_respect_annotation_metadata(
|
219
|
+
object_=database_asset_ids, annotation=QueryExecuteRequestDatabaseAssetIds, direction="write"
|
220
|
+
),
|
221
|
+
},
|
222
|
+
request_options=request_options,
|
223
|
+
)
|
224
|
+
try:
|
225
|
+
if 200 <= _response.status_code < 300:
|
226
|
+
_data = typing.cast(
|
227
|
+
DataFrameRequestOut,
|
228
|
+
parse_obj_as(
|
229
|
+
type_=DataFrameRequestOut, # type: ignore
|
230
|
+
object_=_response.json(),
|
231
|
+
),
|
232
|
+
)
|
233
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
234
|
+
if _response.status_code == 401:
|
235
|
+
raise UnauthorizedError(
|
236
|
+
headers=dict(_response.headers),
|
237
|
+
body=typing.cast(
|
238
|
+
typing.Optional[typing.Any],
|
239
|
+
parse_obj_as(
|
240
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
241
|
+
object_=_response.json(),
|
242
|
+
),
|
243
|
+
),
|
244
|
+
)
|
245
|
+
if _response.status_code == 422:
|
246
|
+
raise UnprocessableEntityError(
|
247
|
+
headers=dict(_response.headers),
|
248
|
+
body=typing.cast(
|
249
|
+
typing.Optional[typing.Any],
|
250
|
+
parse_obj_as(
|
251
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
252
|
+
object_=_response.json(),
|
253
|
+
),
|
254
|
+
),
|
255
|
+
)
|
256
|
+
if _response.status_code == 500:
|
257
|
+
raise InternalServerError(
|
258
|
+
headers=dict(_response.headers),
|
259
|
+
body=typing.cast(
|
260
|
+
typing.Optional[typing.Any],
|
261
|
+
parse_obj_as(
|
262
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
263
|
+
object_=_response.json(),
|
264
|
+
),
|
265
|
+
),
|
266
|
+
)
|
267
|
+
_response_json = _response.json()
|
268
|
+
except JSONDecodeError:
|
269
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
270
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
271
|
+
|
272
|
+
async def execute_snippet(
|
273
|
+
self, *, snippet_asset_id: str, request_options: typing.Optional[RequestOptions] = None
|
274
|
+
) -> AsyncHttpResponse[DataFrameRequestOut]:
|
275
|
+
"""
|
276
|
+
Get the result of an SQL query over given assets.
|
277
|
+
|
278
|
+
Parameters
|
279
|
+
----------
|
280
|
+
snippet_asset_id : str
|
281
|
+
|
282
|
+
request_options : typing.Optional[RequestOptions]
|
283
|
+
Request-specific configuration.
|
284
|
+
|
285
|
+
Returns
|
286
|
+
-------
|
287
|
+
AsyncHttpResponse[DataFrameRequestOut]
|
288
|
+
Successful Response
|
289
|
+
"""
|
290
|
+
_response = await self._client_wrapper.httpx_client.request(
|
291
|
+
"api/v0/query/sql/snippet/execute",
|
292
|
+
method="GET",
|
293
|
+
params={
|
294
|
+
"snippet_asset_id": snippet_asset_id,
|
295
|
+
},
|
296
|
+
request_options=request_options,
|
297
|
+
)
|
298
|
+
try:
|
299
|
+
if 200 <= _response.status_code < 300:
|
300
|
+
_data = typing.cast(
|
301
|
+
DataFrameRequestOut,
|
302
|
+
parse_obj_as(
|
303
|
+
type_=DataFrameRequestOut, # type: ignore
|
304
|
+
object_=_response.json(),
|
305
|
+
),
|
306
|
+
)
|
307
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
308
|
+
if _response.status_code == 401:
|
309
|
+
raise UnauthorizedError(
|
310
|
+
headers=dict(_response.headers),
|
311
|
+
body=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 == 422:
|
320
|
+
raise UnprocessableEntityError(
|
321
|
+
headers=dict(_response.headers),
|
322
|
+
body=typing.cast(
|
323
|
+
typing.Optional[typing.Any],
|
324
|
+
parse_obj_as(
|
325
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
326
|
+
object_=_response.json(),
|
327
|
+
),
|
328
|
+
),
|
329
|
+
)
|
330
|
+
if _response.status_code == 500:
|
331
|
+
raise InternalServerError(
|
332
|
+
headers=dict(_response.headers),
|
333
|
+
body=typing.cast(
|
334
|
+
typing.Optional[typing.Any],
|
335
|
+
parse_obj_as(
|
336
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
337
|
+
object_=_response.json(),
|
338
|
+
),
|
339
|
+
),
|
340
|
+
)
|
341
|
+
_response_json = _response.json()
|
342
|
+
except JSONDecodeError:
|
343
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
344
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
athena/query/types/__init__.py
CHANGED
athena/tools/__init__.py
CHANGED