airia 0.1.13__py3-none-any.whl → 0.1.15__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.
- airia/client/_request_handler/__init__.py +4 -0
- airia/client/_request_handler/async_request_handler.py +272 -0
- airia/client/_request_handler/base_request_handler.py +108 -0
- airia/client/_request_handler/sync_request_handler.py +255 -0
- airia/client/async_client.py +27 -678
- airia/client/base_client.py +2 -368
- airia/client/conversations/__init__.py +4 -0
- airia/client/conversations/async_conversations.py +187 -0
- airia/client/conversations/base_conversations.py +135 -0
- airia/client/conversations/sync_conversations.py +182 -0
- airia/client/deployments/__init__.py +11 -0
- airia/client/deployments/async_deployments.py +112 -0
- airia/client/deployments/base_deployments.py +95 -0
- airia/client/deployments/sync_deployments.py +112 -0
- airia/client/pipeline_execution/__init__.py +4 -0
- airia/client/pipeline_execution/async_pipeline_execution.py +178 -0
- airia/client/pipeline_execution/base_pipeline_execution.py +96 -0
- airia/client/pipeline_execution/sync_pipeline_execution.py +178 -0
- airia/client/pipelines_config/__init__.py +4 -0
- airia/client/pipelines_config/async_pipelines_config.py +65 -0
- airia/client/pipelines_config/base_pipelines_config.py +44 -0
- airia/client/pipelines_config/sync_pipelines_config.py +65 -0
- airia/client/project/__init__.py +4 -0
- airia/client/project/async_project.py +122 -0
- airia/client/project/base_project.py +74 -0
- airia/client/project/sync_project.py +120 -0
- airia/client/store/__init__.py +4 -0
- airia/client/store/async_store.py +377 -0
- airia/client/store/base_store.py +243 -0
- airia/client/store/sync_store.py +352 -0
- airia/client/sync_client.py +27 -656
- airia/constants.py +1 -1
- airia/exceptions.py +8 -8
- airia/logs.py +9 -9
- airia/types/_request_data.py +11 -4
- airia/types/api/__init__.py +0 -27
- airia/types/api/conversations/__init__.py +13 -0
- airia/types/api/{conversations.py → conversations/_conversations.py} +49 -12
- airia/types/api/deployments/__init__.py +26 -0
- airia/types/api/deployments/get_deployment.py +106 -0
- airia/types/api/deployments/get_deployments.py +224 -0
- airia/types/api/pipeline_execution/__init__.py +13 -0
- airia/types/api/{pipeline_execution.py → pipeline_execution/_pipeline_execution.py} +30 -13
- airia/types/api/pipelines_config/__init__.py +35 -0
- airia/types/api/pipelines_config/get_pipeline_config.py +554 -0
- airia/types/api/project/__init__.py +3 -0
- airia/types/api/{get_projects.py → project/get_projects.py} +16 -4
- airia/types/api/store/__init__.py +19 -0
- airia/types/api/store/get_file.py +145 -0
- airia/types/api/store/get_files.py +21 -0
- airia/types/sse/__init__.py +1 -0
- airia/types/sse/sse_messages.py +364 -48
- airia/utils/sse_parser.py +5 -4
- {airia-0.1.13.dist-info → airia-0.1.15.dist-info}/METADATA +4 -2
- airia-0.1.15.dist-info/RECORD +62 -0
- airia/types/api/get_pipeline_config.py +0 -214
- airia-0.1.13.dist-info/RECORD +0 -24
- {airia-0.1.13.dist-info → airia-0.1.15.dist-info}/WHEEL +0 -0
- {airia-0.1.13.dist-info → airia-0.1.15.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.13.dist-info → airia-0.1.15.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from mimetypes import guess_type
|
|
3
|
+
from typing import Optional, Union
|
|
4
|
+
from urllib.parse import urljoin
|
|
5
|
+
|
|
6
|
+
from ...types._api_version import ApiVersion
|
|
7
|
+
from .._request_handler import AsyncRequestHandler, RequestHandler
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BaseStore:
|
|
11
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
12
|
+
self._request_handler = request_handler
|
|
13
|
+
|
|
14
|
+
def _pre_upload_file(
|
|
15
|
+
self,
|
|
16
|
+
store_connector_id: str,
|
|
17
|
+
project_id: str,
|
|
18
|
+
file_path: str,
|
|
19
|
+
folder_id: Optional[str] = None,
|
|
20
|
+
pending_ingestion: bool = True,
|
|
21
|
+
correlation_id: Optional[str] = None,
|
|
22
|
+
api_version: str = ApiVersion.V1.value,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Prepare request data for file upload endpoint.
|
|
26
|
+
|
|
27
|
+
This internal method constructs the URL for file upload requests
|
|
28
|
+
and prepares the multipart form data payload.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
store_connector_id: ID of the store connector
|
|
32
|
+
project_id: ID of the project
|
|
33
|
+
file_path: Path to the file on disk
|
|
34
|
+
folder_id: Optional folder ID
|
|
35
|
+
pending_ingestion: Whether the file is pending ingestion
|
|
36
|
+
correlation_id: Optional correlation ID for tracing
|
|
37
|
+
api_version: API version to use for the request
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
RequestData: Prepared request data for the file upload endpoint
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
ValueError: If an invalid API version is provided
|
|
44
|
+
"""
|
|
45
|
+
if api_version not in ApiVersion.as_list():
|
|
46
|
+
raise ValueError(
|
|
47
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
48
|
+
)
|
|
49
|
+
url = urljoin(self._request_handler.base_url, f"{api_version}/Store/UploadFile")
|
|
50
|
+
|
|
51
|
+
payload = {
|
|
52
|
+
"StoreConnectorId": store_connector_id,
|
|
53
|
+
"ProjectId": project_id,
|
|
54
|
+
"PendingIngestion": str(pending_ingestion).lower(),
|
|
55
|
+
"FolderId": folder_id or "",
|
|
56
|
+
}
|
|
57
|
+
files = {
|
|
58
|
+
"File": (
|
|
59
|
+
os.path.basename(file_path),
|
|
60
|
+
open(file_path, "rb"),
|
|
61
|
+
guess_type(file_path)[0],
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
request_data = self._request_handler.prepare_request(
|
|
66
|
+
url, payload=payload, files=files, correlation_id=correlation_id
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return request_data
|
|
70
|
+
|
|
71
|
+
def _pre_update_file(
|
|
72
|
+
self,
|
|
73
|
+
store_connector_id: str,
|
|
74
|
+
store_file_id: str,
|
|
75
|
+
project_id: str,
|
|
76
|
+
file_path: str,
|
|
77
|
+
pending_ingestion: bool = True,
|
|
78
|
+
correlation_id: Optional[str] = None,
|
|
79
|
+
api_version: str = ApiVersion.V1.value,
|
|
80
|
+
):
|
|
81
|
+
"""
|
|
82
|
+
Prepare request data for file update endpoint.
|
|
83
|
+
|
|
84
|
+
This internal method constructs the URL for file update requests
|
|
85
|
+
and prepares the multipart form data payload.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
store_connector_id: ID of the store connector
|
|
89
|
+
store_file_id: ID of the file to update
|
|
90
|
+
project_id: ID of the project
|
|
91
|
+
file_path: Path to the file on disk
|
|
92
|
+
pending_ingestion: Whether the file is pending ingestion
|
|
93
|
+
correlation_id: Optional correlation ID for tracing
|
|
94
|
+
api_version: API version to use for the request
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
RequestData: Prepared request data for the file update endpoint
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
ValueError: If an invalid API version is provided
|
|
101
|
+
"""
|
|
102
|
+
if api_version not in ApiVersion.as_list():
|
|
103
|
+
raise ValueError(
|
|
104
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
105
|
+
)
|
|
106
|
+
url = urljoin(self._request_handler.base_url, f"{api_version}/Store/UpdateFile")
|
|
107
|
+
|
|
108
|
+
payload = {
|
|
109
|
+
"StoreConnectorId": store_connector_id,
|
|
110
|
+
"StoreFileId": store_file_id,
|
|
111
|
+
"ProjectId": project_id,
|
|
112
|
+
"PendingIngestion": str(pending_ingestion).lower(),
|
|
113
|
+
}
|
|
114
|
+
files = {
|
|
115
|
+
"File": (
|
|
116
|
+
os.path.basename(file_path),
|
|
117
|
+
open(file_path, "rb"),
|
|
118
|
+
guess_type(file_path)[0],
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
request_data = self._request_handler.prepare_request(
|
|
123
|
+
url, payload=payload, files=files, correlation_id=correlation_id
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
return request_data
|
|
127
|
+
|
|
128
|
+
def _pre_get_file(
|
|
129
|
+
self,
|
|
130
|
+
project_id: str,
|
|
131
|
+
file_id: str,
|
|
132
|
+
correlation_id: Optional[str] = None,
|
|
133
|
+
api_version: str = ApiVersion.V1.value,
|
|
134
|
+
):
|
|
135
|
+
"""
|
|
136
|
+
Prepare request data for get file endpoint.
|
|
137
|
+
|
|
138
|
+
This internal method constructs the URL for file retrieval requests.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
project_id: ID of the project
|
|
142
|
+
file_id: ID of the file
|
|
143
|
+
correlation_id: Optional correlation ID for tracing
|
|
144
|
+
api_version: API version to use for the request
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
RequestData: Prepared request data for the get file endpoint
|
|
148
|
+
|
|
149
|
+
Raises:
|
|
150
|
+
ValueError: If an invalid API version is provided
|
|
151
|
+
"""
|
|
152
|
+
if api_version not in ApiVersion.as_list():
|
|
153
|
+
raise ValueError(
|
|
154
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
155
|
+
)
|
|
156
|
+
url = urljoin(
|
|
157
|
+
self._request_handler.base_url,
|
|
158
|
+
f"{api_version}/Store/GetFile/{project_id}/{file_id}",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
request_data = self._request_handler.prepare_request(
|
|
162
|
+
url, payload=None, correlation_id=correlation_id
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
return request_data
|
|
166
|
+
|
|
167
|
+
def _pre_get_files(
|
|
168
|
+
self,
|
|
169
|
+
project_id: str,
|
|
170
|
+
store_connector_id: str,
|
|
171
|
+
correlation_id: Optional[str] = None,
|
|
172
|
+
api_version: str = ApiVersion.V1.value,
|
|
173
|
+
):
|
|
174
|
+
"""
|
|
175
|
+
Prepare request data for get files endpoint.
|
|
176
|
+
|
|
177
|
+
This internal method constructs the URL for files retrieval requests.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
project_id: ID of the project
|
|
181
|
+
store_connector_id: ID of the store connector
|
|
182
|
+
correlation_id: Optional correlation ID for tracing
|
|
183
|
+
api_version: API version to use for the request
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
RequestData: Prepared request data for the get files endpoint
|
|
187
|
+
|
|
188
|
+
Raises:
|
|
189
|
+
ValueError: If an invalid API version is provided
|
|
190
|
+
"""
|
|
191
|
+
if api_version not in ApiVersion.as_list():
|
|
192
|
+
raise ValueError(
|
|
193
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
194
|
+
)
|
|
195
|
+
url = urljoin(
|
|
196
|
+
self._request_handler.base_url,
|
|
197
|
+
f"{api_version}/Store/GetAllFiles/{project_id}/{store_connector_id}",
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
request_data = self._request_handler.prepare_request(
|
|
201
|
+
url, payload=None, correlation_id=correlation_id
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
return request_data
|
|
205
|
+
|
|
206
|
+
def _pre_delete_file(
|
|
207
|
+
self,
|
|
208
|
+
project_id: str,
|
|
209
|
+
file_id: str,
|
|
210
|
+
correlation_id: Optional[str] = None,
|
|
211
|
+
api_version: str = ApiVersion.V1.value,
|
|
212
|
+
):
|
|
213
|
+
"""
|
|
214
|
+
Prepare request data for delete file endpoint.
|
|
215
|
+
|
|
216
|
+
This internal method constructs the URL for file deletion requests.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
project_id: ID of the project
|
|
220
|
+
file_id: ID of the file to delete
|
|
221
|
+
correlation_id: Optional correlation ID for tracing
|
|
222
|
+
api_version: API version to use for the request
|
|
223
|
+
|
|
224
|
+
Returns:
|
|
225
|
+
RequestData: Prepared request data for the delete file endpoint
|
|
226
|
+
|
|
227
|
+
Raises:
|
|
228
|
+
ValueError: If an invalid API version is provided
|
|
229
|
+
"""
|
|
230
|
+
if api_version not in ApiVersion.as_list():
|
|
231
|
+
raise ValueError(
|
|
232
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
233
|
+
)
|
|
234
|
+
url = urljoin(
|
|
235
|
+
self._request_handler.base_url,
|
|
236
|
+
f"{api_version}/Store/DeleteFile/{project_id}/{file_id}",
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
request_data = self._request_handler.prepare_request(
|
|
240
|
+
url, payload=None, correlation_id=correlation_id
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
return request_data
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.store import File, GetFileResponse, GetFilesResponse
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_store import BaseStore
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Store(BaseStore):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def upload_file(
|
|
14
|
+
self,
|
|
15
|
+
store_connector_id: str,
|
|
16
|
+
project_id: str,
|
|
17
|
+
file_path: str,
|
|
18
|
+
folder_id: Optional[str] = None,
|
|
19
|
+
pending_ingestion: bool = True,
|
|
20
|
+
correlation_id: Optional[str] = None,
|
|
21
|
+
) -> File:
|
|
22
|
+
"""
|
|
23
|
+
Upload a file to the Airia store.
|
|
24
|
+
|
|
25
|
+
This method uploads a file to the specified store connector and project,
|
|
26
|
+
with optional folder organization and ingestion settings.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
30
|
+
project_id: The unique identifier of the project (GUID format)
|
|
31
|
+
file_path: Path to the file on disk
|
|
32
|
+
folder_id: Optional folder identifier for organizing the file (GUID format)
|
|
33
|
+
pending_ingestion: Whether the file should be marked as pending ingestion. Default is True.
|
|
34
|
+
correlation_id: Optional correlation ID for request tracing
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
File: object containing details about the uploaded file.
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
41
|
+
- The store_connector_id doesn't exist (404)
|
|
42
|
+
- The project_id doesn't exist (404)
|
|
43
|
+
- The folder_id is invalid (400)
|
|
44
|
+
- Authentication fails (401)
|
|
45
|
+
- Access is forbidden (403)
|
|
46
|
+
- Server errors (5xx)
|
|
47
|
+
ValueError: If required parameters are missing or invalid
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
```python
|
|
51
|
+
from airia import AiriaClient
|
|
52
|
+
|
|
53
|
+
client = AiriaClient(api_key="your_api_key")
|
|
54
|
+
|
|
55
|
+
# Upload file
|
|
56
|
+
uploaded_file = client.store.upload_file(
|
|
57
|
+
store_connector_id="your_store_connector_id",
|
|
58
|
+
project_id="your_project_id",
|
|
59
|
+
file_path="document.pdf"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Upload with folder organization
|
|
63
|
+
uploaded_file = client.store.upload_file(
|
|
64
|
+
store_connector_id="your_store_connector_id",
|
|
65
|
+
project_id="your_project_id",
|
|
66
|
+
file_path="document.pdf",
|
|
67
|
+
folder_id="your_folder_id",
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
"""
|
|
71
|
+
request_data = self._pre_upload_file(
|
|
72
|
+
store_connector_id=store_connector_id,
|
|
73
|
+
project_id=project_id,
|
|
74
|
+
file_path=file_path,
|
|
75
|
+
folder_id=folder_id,
|
|
76
|
+
pending_ingestion=pending_ingestion,
|
|
77
|
+
correlation_id=correlation_id,
|
|
78
|
+
api_version=ApiVersion.V1.value,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
response = self._request_handler.make_request_multipart(
|
|
83
|
+
"POST", request_data
|
|
84
|
+
)
|
|
85
|
+
return File(**response)
|
|
86
|
+
finally:
|
|
87
|
+
request_data.files["File"][1].close()
|
|
88
|
+
|
|
89
|
+
def update_file(
|
|
90
|
+
self,
|
|
91
|
+
store_connector_id: str,
|
|
92
|
+
store_file_id: str,
|
|
93
|
+
project_id: str,
|
|
94
|
+
file_path: str,
|
|
95
|
+
pending_ingestion: bool = True,
|
|
96
|
+
correlation_id: Optional[str] = None,
|
|
97
|
+
) -> str:
|
|
98
|
+
"""
|
|
99
|
+
Update an existing file in the Airia store.
|
|
100
|
+
|
|
101
|
+
This method updates an existing file in the specified store connector and project,
|
|
102
|
+
with optional ingestion settings.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
106
|
+
store_file_id: The unique identifier of the file to update (GUID format)
|
|
107
|
+
project_id: The unique identifier of the project (GUID format)
|
|
108
|
+
file_path: Path to the file on disk
|
|
109
|
+
pending_ingestion: Whether the file should be marked as pending ingestion. Default is True.
|
|
110
|
+
correlation_id: Optional correlation ID for request tracing
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
The File ID of the updated file.
|
|
114
|
+
|
|
115
|
+
Raises:
|
|
116
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
117
|
+
- The store_connector_id doesn't exist (404)
|
|
118
|
+
- The store_file_id doesn't exist (404)
|
|
119
|
+
- The project_id doesn't exist (404)
|
|
120
|
+
- Authentication fails (401)
|
|
121
|
+
- Access is forbidden (403)
|
|
122
|
+
- Server errors (5xx)
|
|
123
|
+
ValueError: If required parameters are missing or invalid
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
```python
|
|
127
|
+
from airia import AiriaClient
|
|
128
|
+
|
|
129
|
+
client = AiriaClient(api_key="your_api_key")
|
|
130
|
+
|
|
131
|
+
# Update existing file
|
|
132
|
+
updated_file_id = client.store.update_file(
|
|
133
|
+
store_connector_id="your_store_connector_id",
|
|
134
|
+
store_file_id="your_store_file_id",
|
|
135
|
+
project_id="your_project_id",
|
|
136
|
+
file_path="document.pdf"
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
"""
|
|
140
|
+
request_data = self._pre_update_file(
|
|
141
|
+
store_connector_id=store_connector_id,
|
|
142
|
+
store_file_id=store_file_id,
|
|
143
|
+
project_id=project_id,
|
|
144
|
+
file_path=file_path,
|
|
145
|
+
pending_ingestion=pending_ingestion,
|
|
146
|
+
correlation_id=correlation_id,
|
|
147
|
+
api_version=ApiVersion.V1.value,
|
|
148
|
+
)
|
|
149
|
+
try:
|
|
150
|
+
response = self._request_handler.make_request_multipart("PUT", request_data)
|
|
151
|
+
return response["fileId"]
|
|
152
|
+
finally:
|
|
153
|
+
request_data.files["File"][1].close()
|
|
154
|
+
|
|
155
|
+
def get_file(
|
|
156
|
+
self,
|
|
157
|
+
project_id: str,
|
|
158
|
+
file_id: str,
|
|
159
|
+
correlation_id: Optional[str] = None,
|
|
160
|
+
) -> GetFileResponse:
|
|
161
|
+
"""
|
|
162
|
+
Retrieve a file from the Airia store.
|
|
163
|
+
|
|
164
|
+
This method retrieves file information, download URL, and preview information
|
|
165
|
+
for a specific file in the given project.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
project_id: The unique identifier of the project (GUID format)
|
|
169
|
+
file_id: The unique identifier of the file (GUID format)
|
|
170
|
+
correlation_id: Optional correlation ID for request tracing
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
GetFileResponse: File information including metadata, download info, and preview info
|
|
174
|
+
|
|
175
|
+
Raises:
|
|
176
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
177
|
+
- The project_id doesn't exist (404)
|
|
178
|
+
- The file_id doesn't exist (404)
|
|
179
|
+
- Authentication fails (401)
|
|
180
|
+
- Access is forbidden (403)
|
|
181
|
+
- Server errors (5xx)
|
|
182
|
+
ValueError: If required parameters are missing or invalid
|
|
183
|
+
|
|
184
|
+
Example:
|
|
185
|
+
```python
|
|
186
|
+
from airia import AiriaClient
|
|
187
|
+
|
|
188
|
+
client = AiriaClient(api_key="your_api_key")
|
|
189
|
+
|
|
190
|
+
# Get file information
|
|
191
|
+
file_info = client.store.get_file(
|
|
192
|
+
project_id="your_project_id",
|
|
193
|
+
file_id="your_file_id"
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# Access file metadata
|
|
197
|
+
if file_info.file:
|
|
198
|
+
print(f"File name: {file_info.file.name}")
|
|
199
|
+
print(f"File size: {file_info.file.size}")
|
|
200
|
+
print(f"Status: {file_info.file.status}")
|
|
201
|
+
|
|
202
|
+
# Access download URL
|
|
203
|
+
if file_info.downloadInfo:
|
|
204
|
+
print(f"Download URL: {file_info.download_info.url}")
|
|
205
|
+
|
|
206
|
+
# Access preview information
|
|
207
|
+
if file_info.previewInfo:
|
|
208
|
+
print(f"Preview URL: {file_info.preview_info.preview_url}")
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Note:
|
|
212
|
+
The response includes three optional components:
|
|
213
|
+
- file: File metadata and processing status
|
|
214
|
+
- downloadInfo: Direct download URL for the file
|
|
215
|
+
- previewInfo: Preview URL and connector information
|
|
216
|
+
"""
|
|
217
|
+
request_data = self._pre_get_file(
|
|
218
|
+
project_id=project_id,
|
|
219
|
+
file_id=file_id,
|
|
220
|
+
correlation_id=correlation_id,
|
|
221
|
+
api_version=ApiVersion.V1.value,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
response = self._request_handler.make_request(
|
|
225
|
+
"GET", request_data, return_json=True
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return GetFileResponse(**response)
|
|
229
|
+
|
|
230
|
+
def get_files(
|
|
231
|
+
self,
|
|
232
|
+
project_id: str,
|
|
233
|
+
store_connector_id: str,
|
|
234
|
+
correlation_id: Optional[str] = None,
|
|
235
|
+
) -> GetFilesResponse:
|
|
236
|
+
"""
|
|
237
|
+
Retrieve all files from a store connector in the Airia store.
|
|
238
|
+
|
|
239
|
+
This method retrieves information about all files in the specified store connector
|
|
240
|
+
and project, including file metadata, download URLs, and processing status.
|
|
241
|
+
|
|
242
|
+
Args:
|
|
243
|
+
project_id: The unique identifier of the project (GUID format)
|
|
244
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
245
|
+
correlation_id: Optional correlation ID for request tracing
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
GetFilesResponse: List of files with metadata, download info, and total count
|
|
249
|
+
|
|
250
|
+
Raises:
|
|
251
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
252
|
+
- The project_id doesn't exist (404)
|
|
253
|
+
- The store_connector_id doesn't exist (404)
|
|
254
|
+
- Authentication fails (401)
|
|
255
|
+
- Access is forbidden (403)
|
|
256
|
+
- Server errors (5xx)
|
|
257
|
+
ValueError: If required parameters are missing or invalid
|
|
258
|
+
|
|
259
|
+
Example:
|
|
260
|
+
```python
|
|
261
|
+
from airia import AiriaClient
|
|
262
|
+
|
|
263
|
+
client = AiriaClient(api_key="your_api_key")
|
|
264
|
+
|
|
265
|
+
# Get all files from a store connector
|
|
266
|
+
files_response = client.store.get_files(
|
|
267
|
+
project_id="your_project_id",
|
|
268
|
+
store_connector_id="your_store_connector_id"
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
# Access files list
|
|
272
|
+
if files_response.files:
|
|
273
|
+
for file in files_response.files:
|
|
274
|
+
print(f"File: {file.name}, Status: {file.status}, Size: {file.size}")
|
|
275
|
+
|
|
276
|
+
# Access download URLs
|
|
277
|
+
if files_response.downloadInfos:
|
|
278
|
+
for download_info in files_response.downloadInfos:
|
|
279
|
+
print(f"File ID: {download_info.fileId}, URL: {download_info.url}")
|
|
280
|
+
|
|
281
|
+
# Access total count
|
|
282
|
+
print(f"Total files: {files_response.totalCount}")
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Note:
|
|
286
|
+
The response includes:
|
|
287
|
+
- files: List of file metadata and processing status
|
|
288
|
+
- downloadInfos: List of direct download URLs for files
|
|
289
|
+
- totalCount: Total number of files in the store connector
|
|
290
|
+
"""
|
|
291
|
+
request_data = self._pre_get_files(
|
|
292
|
+
project_id=project_id,
|
|
293
|
+
store_connector_id=store_connector_id,
|
|
294
|
+
correlation_id=correlation_id,
|
|
295
|
+
api_version=ApiVersion.V1.value,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
response = self._request_handler.make_request(
|
|
299
|
+
"GET", request_data, return_json=True
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
return GetFilesResponse(**response)
|
|
303
|
+
|
|
304
|
+
def delete_file(
|
|
305
|
+
self,
|
|
306
|
+
project_id: str,
|
|
307
|
+
file_id: str,
|
|
308
|
+
correlation_id: Optional[str] = None,
|
|
309
|
+
) -> None:
|
|
310
|
+
"""
|
|
311
|
+
Delete a file from the Airia store.
|
|
312
|
+
|
|
313
|
+
This method deletes a specific file from the given project.
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
project_id: The unique identifier of the project (GUID format)
|
|
317
|
+
file_id: The unique identifier of the file to delete (GUID format)
|
|
318
|
+
correlation_id: Optional correlation ID for request tracing
|
|
319
|
+
|
|
320
|
+
Returns:
|
|
321
|
+
None
|
|
322
|
+
|
|
323
|
+
Raises:
|
|
324
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
325
|
+
- The project_id doesn't exist (404)
|
|
326
|
+
- The file_id doesn't exist (404)
|
|
327
|
+
- Authentication fails (401)
|
|
328
|
+
- Access is forbidden (403)
|
|
329
|
+
- Server errors (5xx)
|
|
330
|
+
ValueError: If required parameters are missing or invalid
|
|
331
|
+
|
|
332
|
+
Example:
|
|
333
|
+
```python
|
|
334
|
+
from airia import AiriaClient
|
|
335
|
+
|
|
336
|
+
client = AiriaClient(api_key="your_api_key")
|
|
337
|
+
|
|
338
|
+
# Delete a file
|
|
339
|
+
client.store.delete_file(
|
|
340
|
+
project_id="your_project_id",
|
|
341
|
+
file_id="your_file_id"
|
|
342
|
+
)
|
|
343
|
+
```
|
|
344
|
+
"""
|
|
345
|
+
request_data = self._pre_delete_file(
|
|
346
|
+
project_id=project_id,
|
|
347
|
+
file_id=file_id,
|
|
348
|
+
correlation_id=correlation_id,
|
|
349
|
+
api_version=ApiVersion.V1.value,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
self._request_handler.make_request("DELETE", request_data, return_json=False)
|