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,122 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.project import ProjectItem
|
|
5
|
+
from .._request_handler import AsyncRequestHandler
|
|
6
|
+
from .base_project import BaseProject
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncProject(BaseProject):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async def get_projects(
|
|
14
|
+
self, correlation_id: Optional[str] = None
|
|
15
|
+
) -> List[ProjectItem]:
|
|
16
|
+
"""
|
|
17
|
+
Retrieve a list of all projects accessible to the authenticated user.
|
|
18
|
+
|
|
19
|
+
This method fetches comprehensive information about all projects that the
|
|
20
|
+
current user has access to, including project metadata, creation details,
|
|
21
|
+
and status information.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
25
|
+
and logging. If not provided, one will be automatically generated.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
List[ProjectItem]: A list of ProjectItem objects containing project
|
|
29
|
+
information. Returns an empty list if no projects are accessible
|
|
30
|
+
or found.
|
|
31
|
+
|
|
32
|
+
Raises:
|
|
33
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
34
|
+
- Authentication fails (401)
|
|
35
|
+
- Access is forbidden (403)
|
|
36
|
+
- Server errors (5xx)
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
```python
|
|
40
|
+
from airia import AiriaAsyncClient
|
|
41
|
+
|
|
42
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
43
|
+
|
|
44
|
+
# Get all accessible projects
|
|
45
|
+
projects = await client.project.get_projects()
|
|
46
|
+
|
|
47
|
+
for project in projects:
|
|
48
|
+
print(f"Project: {project.name}")
|
|
49
|
+
print(f"ID: {project.id}")
|
|
50
|
+
print(f"Description: {project.description}")
|
|
51
|
+
print(f"Created: {project.created_at}")
|
|
52
|
+
print("---")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note:
|
|
56
|
+
The returned projects are filtered based on the authenticated user's
|
|
57
|
+
permissions. Users will only see projects they have been granted
|
|
58
|
+
access to.
|
|
59
|
+
"""
|
|
60
|
+
request_data = self._pre_get_projects(
|
|
61
|
+
correlation_id=correlation_id, api_version=ApiVersion.V1.value
|
|
62
|
+
)
|
|
63
|
+
resp = await self._request_handler.make_request("GET", request_data)
|
|
64
|
+
|
|
65
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
66
|
+
return []
|
|
67
|
+
|
|
68
|
+
return [ProjectItem(**item) for item in resp["items"]]
|
|
69
|
+
|
|
70
|
+
async def get_project(
|
|
71
|
+
self, project_id: str, correlation_id: Optional[str] = None
|
|
72
|
+
) -> ProjectItem:
|
|
73
|
+
"""
|
|
74
|
+
Retrieve detailed information for a specific project.
|
|
75
|
+
|
|
76
|
+
This method fetches comprehensive information about a single project,
|
|
77
|
+
including all associated resources, metadata, and configuration details.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
project_id (str): The unique identifier (GUID) of the project to retrieve.
|
|
81
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
82
|
+
and logging. If not provided, one will be automatically generated.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
ProjectItem: A ProjectItem object containing complete project
|
|
86
|
+
information including pipelines, models, data sources, and metadata.
|
|
87
|
+
|
|
88
|
+
Raises:
|
|
89
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
90
|
+
- Project not found (404)
|
|
91
|
+
- Authentication fails (401)
|
|
92
|
+
- Access is forbidden (403)
|
|
93
|
+
- Server errors (5xx)
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
```python
|
|
97
|
+
from airia import AiriaAsyncClient
|
|
98
|
+
|
|
99
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
100
|
+
|
|
101
|
+
# Get a specific project by ID
|
|
102
|
+
project = await client.project.get_project("12345678-1234-1234-1234-123456789abc")
|
|
103
|
+
|
|
104
|
+
print(f"Project: {project.name}")
|
|
105
|
+
print(f"Description: {project.description}")
|
|
106
|
+
print(f"Pipelines: {len(project.pipelines)}")
|
|
107
|
+
print(f"Created: {project.created_at}")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Note:
|
|
111
|
+
The project must be accessible to the authenticated user.
|
|
112
|
+
Users will only be able to retrieve projects they have been granted
|
|
113
|
+
access to.
|
|
114
|
+
"""
|
|
115
|
+
request_data = self._pre_get_project(
|
|
116
|
+
project_id=project_id,
|
|
117
|
+
correlation_id=correlation_id,
|
|
118
|
+
api_version=ApiVersion.V1.value,
|
|
119
|
+
)
|
|
120
|
+
resp = await self._request_handler.make_request("GET", request_data)
|
|
121
|
+
|
|
122
|
+
return ProjectItem(**resp)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from ...types._api_version import ApiVersion
|
|
5
|
+
from .._request_handler import AsyncRequestHandler, RequestHandler
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseProject:
|
|
9
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
10
|
+
self._request_handler = request_handler
|
|
11
|
+
|
|
12
|
+
def _pre_get_projects(
|
|
13
|
+
self,
|
|
14
|
+
correlation_id: Optional[str] = None,
|
|
15
|
+
api_version: str = ApiVersion.V1.value,
|
|
16
|
+
):
|
|
17
|
+
"""
|
|
18
|
+
Prepare request data for getting projects endpoint.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
correlation_id: Optional correlation ID for tracing
|
|
22
|
+
api_version: API version to use for the request
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
RequestData: Prepared request data for the projects endpoint
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
ValueError: If an invalid API version is provided
|
|
29
|
+
"""
|
|
30
|
+
if api_version not in ApiVersion.as_list():
|
|
31
|
+
raise ValueError(
|
|
32
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
33
|
+
)
|
|
34
|
+
url = urljoin(
|
|
35
|
+
self._request_handler.base_url, f"{api_version}/Project/paginated"
|
|
36
|
+
)
|
|
37
|
+
request_data = self._request_handler.prepare_request(
|
|
38
|
+
url, correlation_id=correlation_id
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return request_data
|
|
42
|
+
|
|
43
|
+
def _pre_get_project(
|
|
44
|
+
self,
|
|
45
|
+
project_id: str,
|
|
46
|
+
correlation_id: Optional[str] = None,
|
|
47
|
+
api_version: str = ApiVersion.V1.value,
|
|
48
|
+
):
|
|
49
|
+
"""
|
|
50
|
+
Prepare request data for getting a single project endpoint.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
project_id: The project identifier (GUID format)
|
|
54
|
+
correlation_id: Optional correlation ID for tracing
|
|
55
|
+
api_version: API version to use for the request
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
RequestData: Prepared request data for the project endpoint
|
|
59
|
+
|
|
60
|
+
Raises:
|
|
61
|
+
ValueError: If an invalid API version is provided
|
|
62
|
+
"""
|
|
63
|
+
if api_version not in ApiVersion.as_list():
|
|
64
|
+
raise ValueError(
|
|
65
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
66
|
+
)
|
|
67
|
+
url = urljoin(
|
|
68
|
+
self._request_handler.base_url, f"{api_version}/Project/{project_id}"
|
|
69
|
+
)
|
|
70
|
+
request_data = self._request_handler.prepare_request(
|
|
71
|
+
url, correlation_id=correlation_id
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return request_data
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.project import ProjectItem
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_project import BaseProject
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Project(BaseProject):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def get_projects(self, correlation_id: Optional[str] = None) -> List[ProjectItem]:
|
|
14
|
+
"""
|
|
15
|
+
Retrieve a list of all projects accessible to the authenticated user.
|
|
16
|
+
|
|
17
|
+
This method fetches comprehensive information about all projects that the
|
|
18
|
+
current user has access to, including project metadata, creation details,
|
|
19
|
+
and status information.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
23
|
+
and logging. If not provided, one will be automatically generated.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
List[ProjectItem]: A list of ProjectItem objects containing project
|
|
27
|
+
information. Returns an empty list if no projects are accessible
|
|
28
|
+
or found.
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
32
|
+
- Authentication fails (401)
|
|
33
|
+
- Access is forbidden (403)
|
|
34
|
+
- Server errors (5xx)
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
```python
|
|
38
|
+
from airia import AiriaClient
|
|
39
|
+
|
|
40
|
+
client = AiriaClient(api_key="your_api_key")
|
|
41
|
+
|
|
42
|
+
# Get all accessible projects
|
|
43
|
+
projects = client.project.get_projects()
|
|
44
|
+
|
|
45
|
+
for project in projects:
|
|
46
|
+
print(f"Project: {project.name}")
|
|
47
|
+
print(f"ID: {project.id}")
|
|
48
|
+
print(f"Description: {project.description}")
|
|
49
|
+
print(f"Created: {project.created_at}")
|
|
50
|
+
print("---")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Note:
|
|
54
|
+
The returned projects are filtered based on the authenticated user's
|
|
55
|
+
permissions. Users will only see projects they have been granted
|
|
56
|
+
access to.
|
|
57
|
+
"""
|
|
58
|
+
request_data = self._pre_get_projects(
|
|
59
|
+
correlation_id=correlation_id, api_version=ApiVersion.V1.value
|
|
60
|
+
)
|
|
61
|
+
resp = self._request_handler.make_request("GET", request_data)
|
|
62
|
+
|
|
63
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
64
|
+
return []
|
|
65
|
+
|
|
66
|
+
return [ProjectItem(**item) for item in resp["items"]]
|
|
67
|
+
|
|
68
|
+
def get_project(
|
|
69
|
+
self, project_id: str, correlation_id: Optional[str] = None
|
|
70
|
+
) -> ProjectItem:
|
|
71
|
+
"""
|
|
72
|
+
Retrieve detailed information for a specific project.
|
|
73
|
+
|
|
74
|
+
This method fetches comprehensive information about a single project,
|
|
75
|
+
including all associated resources, metadata, and configuration details.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
project_id (str): The unique identifier (GUID) of the project to retrieve.
|
|
79
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
80
|
+
and logging. If not provided, one will be automatically generated.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
ProjectItem: A ProjectItem object containing complete project
|
|
84
|
+
information including pipelines, models, data sources, and metadata.
|
|
85
|
+
|
|
86
|
+
Raises:
|
|
87
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
88
|
+
- Project not found (404)
|
|
89
|
+
- Authentication fails (401)
|
|
90
|
+
- Access is forbidden (403)
|
|
91
|
+
- Server errors (5xx)
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
```python
|
|
95
|
+
from airia import AiriaClient
|
|
96
|
+
|
|
97
|
+
client = AiriaClient(api_key="your_api_key")
|
|
98
|
+
|
|
99
|
+
# Get a specific project by ID
|
|
100
|
+
project = client.project.get_project("12345678-1234-1234-1234-123456789abc")
|
|
101
|
+
|
|
102
|
+
print(f"Project: {project.name}")
|
|
103
|
+
print(f"Description: {project.description}")
|
|
104
|
+
print(f"Pipelines: {len(project.pipelines)}")
|
|
105
|
+
print(f"Created: {project.created_at}")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Note:
|
|
109
|
+
The project must be accessible to the authenticated user.
|
|
110
|
+
Users will only be able to retrieve projects they have been granted
|
|
111
|
+
access to.
|
|
112
|
+
"""
|
|
113
|
+
request_data = self._pre_get_project(
|
|
114
|
+
project_id=project_id,
|
|
115
|
+
correlation_id=correlation_id,
|
|
116
|
+
api_version=ApiVersion.V1.value,
|
|
117
|
+
)
|
|
118
|
+
resp = self._request_handler.make_request("GET", request_data)
|
|
119
|
+
|
|
120
|
+
return ProjectItem(**resp)
|
|
@@ -0,0 +1,377 @@
|
|
|
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 AsyncRequestHandler
|
|
6
|
+
from .base_store import BaseStore
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncStore(BaseStore):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async 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 asynchronously.
|
|
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
|
+
import asyncio
|
|
52
|
+
from airia import AiriaAsyncClient
|
|
53
|
+
|
|
54
|
+
async def main():
|
|
55
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
56
|
+
|
|
57
|
+
# Upload file
|
|
58
|
+
uploaded_file = await client.store.upload_file(
|
|
59
|
+
store_connector_id="your_store_connector_id",
|
|
60
|
+
project_id="your_project_id",
|
|
61
|
+
file_path="document.pdf"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Upload with folder organization
|
|
65
|
+
uploaded_file = await client.store.upload_file(
|
|
66
|
+
store_connector_id="your_store_connector_id",
|
|
67
|
+
project_id="your_project_id",
|
|
68
|
+
file_path="document.pdf",
|
|
69
|
+
folder_id="your_folder_id"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
asyncio.run(main())
|
|
73
|
+
```
|
|
74
|
+
"""
|
|
75
|
+
request_data = self._pre_upload_file(
|
|
76
|
+
store_connector_id=store_connector_id,
|
|
77
|
+
project_id=project_id,
|
|
78
|
+
file_path=file_path,
|
|
79
|
+
folder_id=folder_id,
|
|
80
|
+
pending_ingestion=pending_ingestion,
|
|
81
|
+
correlation_id=correlation_id,
|
|
82
|
+
api_version=ApiVersion.V1.value,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
response = await self._request_handler.make_request_multipart(
|
|
87
|
+
"POST", request_data
|
|
88
|
+
)
|
|
89
|
+
return File(**response)
|
|
90
|
+
finally:
|
|
91
|
+
request_data.files["File"][1].close()
|
|
92
|
+
|
|
93
|
+
async def update_file(
|
|
94
|
+
self,
|
|
95
|
+
store_connector_id: str,
|
|
96
|
+
store_file_id: str,
|
|
97
|
+
project_id: str,
|
|
98
|
+
file_path: str,
|
|
99
|
+
pending_ingestion: bool = True,
|
|
100
|
+
correlation_id: Optional[str] = None,
|
|
101
|
+
) -> str:
|
|
102
|
+
"""
|
|
103
|
+
Update an existing file in the Airia store asynchronously.
|
|
104
|
+
|
|
105
|
+
This method updates an existing file in the specified store connector and project,
|
|
106
|
+
with optional ingestion settings.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
110
|
+
store_file_id: The unique identifier of the file to update (GUID format)
|
|
111
|
+
project_id: The unique identifier of the project (GUID format)
|
|
112
|
+
file_path: Path to the file on disk
|
|
113
|
+
pending_ingestion: Whether the file should be marked as pending ingestion. Default is True.
|
|
114
|
+
correlation_id: Optional correlation ID for request tracing
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
The File ID of the updated file.
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
121
|
+
- The store_connector_id doesn't exist (404)
|
|
122
|
+
- The store_file_id doesn't exist (404)
|
|
123
|
+
- The project_id doesn't exist (404)
|
|
124
|
+
- Authentication fails (401)
|
|
125
|
+
- Access is forbidden (403)
|
|
126
|
+
- Server errors (5xx)
|
|
127
|
+
ValueError: If required parameters are missing or invalid
|
|
128
|
+
|
|
129
|
+
Example:
|
|
130
|
+
```python
|
|
131
|
+
import asyncio
|
|
132
|
+
from airia import AiriaAsyncClient
|
|
133
|
+
|
|
134
|
+
async def main():
|
|
135
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
136
|
+
|
|
137
|
+
# Update existing file
|
|
138
|
+
updated_file_id = await client.store.update_file(
|
|
139
|
+
store_connector_id="your_store_connector_id",
|
|
140
|
+
store_file_id="your_store_file_id",
|
|
141
|
+
project_id="your_project_id",
|
|
142
|
+
file_path="document.pdf"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
asyncio.run(main())
|
|
146
|
+
```
|
|
147
|
+
"""
|
|
148
|
+
request_data = self._pre_update_file(
|
|
149
|
+
store_connector_id=store_connector_id,
|
|
150
|
+
store_file_id=store_file_id,
|
|
151
|
+
project_id=project_id,
|
|
152
|
+
file_path=file_path,
|
|
153
|
+
pending_ingestion=pending_ingestion,
|
|
154
|
+
correlation_id=correlation_id,
|
|
155
|
+
api_version=ApiVersion.V1.value,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
response = await self._request_handler.make_request_multipart(
|
|
160
|
+
"PUT", request_data
|
|
161
|
+
)
|
|
162
|
+
return response["fileId"]
|
|
163
|
+
finally:
|
|
164
|
+
request_data.files["File"][1].close()
|
|
165
|
+
|
|
166
|
+
async def get_file(
|
|
167
|
+
self,
|
|
168
|
+
project_id: str,
|
|
169
|
+
file_id: str,
|
|
170
|
+
correlation_id: Optional[str] = None,
|
|
171
|
+
) -> GetFileResponse:
|
|
172
|
+
"""
|
|
173
|
+
Retrieve a file from the Airia store asynchronously.
|
|
174
|
+
|
|
175
|
+
This method retrieves file information, download URL, and preview information
|
|
176
|
+
for a specific file in the given project.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
project_id: The unique identifier of the project (GUID format)
|
|
180
|
+
file_id: The unique identifier of the file (GUID format)
|
|
181
|
+
correlation_id: Optional correlation ID for request tracing
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
GetFileResponse: File information including metadata, download info, and preview info
|
|
185
|
+
|
|
186
|
+
Raises:
|
|
187
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
188
|
+
- The project_id doesn't exist (404)
|
|
189
|
+
- The file_id doesn't exist (404)
|
|
190
|
+
- Authentication fails (401)
|
|
191
|
+
- Access is forbidden (403)
|
|
192
|
+
- Server errors (5xx)
|
|
193
|
+
ValueError: If required parameters are missing or invalid
|
|
194
|
+
|
|
195
|
+
Example:
|
|
196
|
+
```python
|
|
197
|
+
import asyncio
|
|
198
|
+
from airia import AiriaAsyncClient
|
|
199
|
+
|
|
200
|
+
async def main():
|
|
201
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
202
|
+
|
|
203
|
+
# Get file information
|
|
204
|
+
file_info = await client.store.get_file(
|
|
205
|
+
project_id="your_project_id",
|
|
206
|
+
file_id="your_file_id"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# Access file metadata
|
|
210
|
+
if file_info.file:
|
|
211
|
+
print(f"File name: {file_info.file.name}")
|
|
212
|
+
print(f"File size: {file_info.file.size}")
|
|
213
|
+
print(f"Status: {file_info.file.status}")
|
|
214
|
+
|
|
215
|
+
# Access download URL
|
|
216
|
+
if file_info.downloadInfo:
|
|
217
|
+
print(f"Download URL: {file_info.downloadInfo.url}")
|
|
218
|
+
|
|
219
|
+
# Access preview information
|
|
220
|
+
if file_info.previewInfo:
|
|
221
|
+
print(f"Preview URL: {file_info.previewInfo.previewUrl}")
|
|
222
|
+
|
|
223
|
+
asyncio.run(main())
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Note:
|
|
227
|
+
The response includes three optional components:
|
|
228
|
+
- file: File metadata and processing status
|
|
229
|
+
- downloadInfo: Direct download URL for the file
|
|
230
|
+
- previewInfo: Preview URL and connector information
|
|
231
|
+
"""
|
|
232
|
+
request_data = self._pre_get_file(
|
|
233
|
+
project_id=project_id,
|
|
234
|
+
file_id=file_id,
|
|
235
|
+
correlation_id=correlation_id,
|
|
236
|
+
api_version=ApiVersion.V1.value,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
response = await self._request_handler.make_request(
|
|
240
|
+
"GET", request_data, return_json=True
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
return GetFileResponse(**response)
|
|
244
|
+
|
|
245
|
+
async def get_files(
|
|
246
|
+
self,
|
|
247
|
+
project_id: str,
|
|
248
|
+
store_connector_id: str,
|
|
249
|
+
correlation_id: Optional[str] = None,
|
|
250
|
+
) -> GetFilesResponse:
|
|
251
|
+
"""
|
|
252
|
+
Retrieve all files from a store connector in the Airia store asynchronously.
|
|
253
|
+
|
|
254
|
+
This method retrieves information about all files in the specified store connector
|
|
255
|
+
and project, including file metadata, download URLs, and processing status.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
project_id: The unique identifier of the project (GUID format)
|
|
259
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
260
|
+
correlation_id: Optional correlation ID for request tracing
|
|
261
|
+
|
|
262
|
+
Returns:
|
|
263
|
+
GetFilesResponse: List of files with metadata, download info, and total count
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
267
|
+
- The project_id doesn't exist (404)
|
|
268
|
+
- The store_connector_id doesn't exist (404)
|
|
269
|
+
- Authentication fails (401)
|
|
270
|
+
- Access is forbidden (403)
|
|
271
|
+
- Server errors (5xx)
|
|
272
|
+
ValueError: If required parameters are missing or invalid
|
|
273
|
+
|
|
274
|
+
Example:
|
|
275
|
+
```python
|
|
276
|
+
import asyncio
|
|
277
|
+
from airia import AiriaAsyncClient
|
|
278
|
+
|
|
279
|
+
async def main():
|
|
280
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
281
|
+
|
|
282
|
+
# Get all files from a store connector
|
|
283
|
+
files_response = await client.store.get_files(
|
|
284
|
+
project_id="your_project_id",
|
|
285
|
+
store_connector_id="your_store_connector_id"
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# Access files list
|
|
289
|
+
if files_response.files:
|
|
290
|
+
for file in files_response.files:
|
|
291
|
+
print(f"File: {file.name}, Status: {file.status}, Size: {file.size}")
|
|
292
|
+
|
|
293
|
+
# Access download URLs
|
|
294
|
+
if files_response.downloadInfos:
|
|
295
|
+
for download_info in files_response.downloadInfos:
|
|
296
|
+
print(f"File ID: {download_info.fileId}, URL: {download_info.url}")
|
|
297
|
+
|
|
298
|
+
# Access total count
|
|
299
|
+
print(f"Total files: {files_response.totalCount}")
|
|
300
|
+
|
|
301
|
+
asyncio.run(main())
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Note:
|
|
305
|
+
The response includes:
|
|
306
|
+
- files: List of file metadata and processing status
|
|
307
|
+
- downloadInfos: List of direct download URLs for files
|
|
308
|
+
- totalCount: Total number of files in the store connector
|
|
309
|
+
"""
|
|
310
|
+
request_data = self._pre_get_files(
|
|
311
|
+
project_id=project_id,
|
|
312
|
+
store_connector_id=store_connector_id,
|
|
313
|
+
correlation_id=correlation_id,
|
|
314
|
+
api_version=ApiVersion.V1.value,
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
response = await self._request_handler.make_request(
|
|
318
|
+
"GET", request_data, return_json=True
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
return GetFilesResponse(**response)
|
|
322
|
+
|
|
323
|
+
async def delete_file(
|
|
324
|
+
self,
|
|
325
|
+
project_id: str,
|
|
326
|
+
file_id: str,
|
|
327
|
+
correlation_id: Optional[str] = None,
|
|
328
|
+
) -> None:
|
|
329
|
+
"""
|
|
330
|
+
Delete a file from the Airia store asynchronously.
|
|
331
|
+
|
|
332
|
+
This method deletes a specific file from the given project.
|
|
333
|
+
|
|
334
|
+
Args:
|
|
335
|
+
project_id: The unique identifier of the project (GUID format)
|
|
336
|
+
file_id: The unique identifier of the file to delete (GUID format)
|
|
337
|
+
correlation_id: Optional correlation ID for request tracing
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
None
|
|
341
|
+
|
|
342
|
+
Raises:
|
|
343
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
344
|
+
- The project_id doesn't exist (404)
|
|
345
|
+
- The file_id doesn't exist (404)
|
|
346
|
+
- Authentication fails (401)
|
|
347
|
+
- Access is forbidden (403)
|
|
348
|
+
- Server errors (5xx)
|
|
349
|
+
ValueError: If required parameters are missing or invalid
|
|
350
|
+
|
|
351
|
+
Example:
|
|
352
|
+
```python
|
|
353
|
+
import asyncio
|
|
354
|
+
from airia import AiriaAsyncClient
|
|
355
|
+
|
|
356
|
+
async def main():
|
|
357
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
358
|
+
|
|
359
|
+
# Delete a file
|
|
360
|
+
await client.store.delete_file(
|
|
361
|
+
project_id="your_project_id",
|
|
362
|
+
file_id="your_file_id"
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
asyncio.run(main())
|
|
366
|
+
```
|
|
367
|
+
"""
|
|
368
|
+
request_data = self._pre_delete_file(
|
|
369
|
+
project_id=project_id,
|
|
370
|
+
file_id=file_id,
|
|
371
|
+
correlation_id=correlation_id,
|
|
372
|
+
api_version=ApiVersion.V1.value,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
await self._request_handler.make_request(
|
|
376
|
+
"DELETE", request_data, return_json=False
|
|
377
|
+
)
|