airia 0.1.12__py3-none-any.whl → 0.1.14__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 +25 -584
- airia/client/base_client.py +2 -209
- 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/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 +127 -0
- airia/client/pipelines_config/base_pipelines_config.py +76 -0
- airia/client/pipelines_config/sync_pipelines_config.py +127 -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 +25 -563
- airia/constants.py +13 -2
- airia/exceptions.py +8 -8
- airia/logs.py +10 -32
- airia/types/__init__.py +0 -0
- airia/types/_request_data.py +29 -2
- airia/types/api/__init__.py +0 -19
- airia/types/api/conversations/__init__.py +3 -0
- airia/types/api/conversations/_conversations.py +115 -0
- airia/types/api/pipeline_execution/__init__.py +13 -0
- airia/types/api/pipeline_execution/_pipeline_execution.py +76 -0
- airia/types/api/pipelines_config/__init__.py +3 -0
- airia/types/api/pipelines_config/get_pipeline_config.py +401 -0
- airia/types/api/project/__init__.py +3 -0
- airia/types/api/project/get_projects.py +91 -0
- airia/types/api/store/__init__.py +4 -0
- airia/types/api/store/get_file.py +145 -0
- airia/types/api/store/get_files.py +21 -0
- airia/types/sse/__init__.py +8 -0
- airia/types/sse/sse_messages.py +209 -0
- airia/utils/sse_parser.py +40 -7
- airia-0.1.14.dist-info/METADATA +221 -0
- airia-0.1.14.dist-info/RECORD +55 -0
- airia/types/api/conversations.py +0 -14
- airia/types/api/get_pipeline_config.py +0 -183
- airia/types/api/get_projects.py +0 -35
- airia/types/api/pipeline_execution.py +0 -29
- airia-0.1.12.dist-info/METADATA +0 -705
- airia-0.1.12.dist-info/RECORD +0 -23
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/WHEEL +0 -0
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.pipelines_config import GetPipelineConfigResponse
|
|
5
|
+
from .._request_handler import AsyncRequestHandler
|
|
6
|
+
from .base_pipelines_config import BasePipelinesConfig
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncPipelinesConfig(BasePipelinesConfig):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async def get_active_pipelines_ids(
|
|
14
|
+
self, project_id: Optional[str] = None, correlation_id: Optional[str] = None
|
|
15
|
+
) -> List[str]:
|
|
16
|
+
"""
|
|
17
|
+
Retrieve a list of active pipeline IDs.
|
|
18
|
+
|
|
19
|
+
This method fetches the IDs of all active pipelines, optionally filtered by project.
|
|
20
|
+
Active pipelines are those that are currently deployed and available for execution.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
project_id (str, optional): The unique identifier of the project to filter
|
|
24
|
+
pipelines by. If not provided, returns active pipelines from all projects
|
|
25
|
+
accessible to the authenticated user.
|
|
26
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
27
|
+
and logging. If not provided, one will be automatically generated.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
List[str]: A list of pipeline IDs that are currently active. Returns an
|
|
31
|
+
empty list if no active pipelines are found.
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
35
|
+
- The project_id doesn't exist (404)
|
|
36
|
+
- Authentication fails (401)
|
|
37
|
+
- Access is forbidden (403)
|
|
38
|
+
- Server errors (5xx)
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
```python
|
|
42
|
+
from airia import AiriaAsyncClient
|
|
43
|
+
|
|
44
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
45
|
+
|
|
46
|
+
# Get all active pipeline IDs
|
|
47
|
+
pipeline_ids = await client.pipelines_config.get_active_pipelines_ids()
|
|
48
|
+
print(f"Found {len(pipeline_ids)} active pipelines")
|
|
49
|
+
|
|
50
|
+
# Get active pipeline IDs for a specific project
|
|
51
|
+
project_pipelines = await client.pipelines_config.get_active_pipelines_ids(
|
|
52
|
+
project_id="your_project_id"
|
|
53
|
+
)
|
|
54
|
+
print(f"Project has {len(project_pipelines)} active pipelines")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Note:
|
|
58
|
+
Only pipelines with active versions are returned. Inactive or archived
|
|
59
|
+
pipelines are not included in the results.
|
|
60
|
+
"""
|
|
61
|
+
request_data = self._pre_get_active_pipelines_ids(
|
|
62
|
+
project_id=project_id,
|
|
63
|
+
correlation_id=correlation_id,
|
|
64
|
+
api_version=ApiVersion.V1.value,
|
|
65
|
+
)
|
|
66
|
+
resp = await self._request_handler.make_request("GET", request_data)
|
|
67
|
+
|
|
68
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
69
|
+
return []
|
|
70
|
+
|
|
71
|
+
pipeline_ids = [r["activeVersion"]["pipelineId"] for r in resp["items"]]
|
|
72
|
+
|
|
73
|
+
return pipeline_ids
|
|
74
|
+
|
|
75
|
+
async def get_pipeline_config(
|
|
76
|
+
self, pipeline_id: str, correlation_id: Optional[str] = None
|
|
77
|
+
) -> GetPipelineConfigResponse:
|
|
78
|
+
"""
|
|
79
|
+
Retrieve configuration details for a specific pipeline.
|
|
80
|
+
|
|
81
|
+
This method fetches comprehensive information about a pipeline including its
|
|
82
|
+
deployment details, execution statistics, version information, and metadata.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
pipeline_id (str): The unique identifier of the pipeline to retrieve
|
|
86
|
+
configuration for.
|
|
87
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
88
|
+
and logging. If not provided, one will be automatically generated.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
GetPipelineConfigResponse: A response object containing the pipeline
|
|
92
|
+
configuration.
|
|
93
|
+
|
|
94
|
+
Raises:
|
|
95
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
96
|
+
- The pipeline_id doesn't exist (404)
|
|
97
|
+
- Authentication fails (401)
|
|
98
|
+
- Access is forbidden (403)
|
|
99
|
+
- Server errors (5xx)
|
|
100
|
+
|
|
101
|
+
Example:
|
|
102
|
+
```python
|
|
103
|
+
from airia import AiriaAsyncClient
|
|
104
|
+
|
|
105
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
106
|
+
|
|
107
|
+
# Get pipeline configuration
|
|
108
|
+
config = await client.pipelines_config.get_pipeline_config(
|
|
109
|
+
pipeline_id="your_pipeline_id"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
print(f"Pipeline: {config.agent.name}")
|
|
113
|
+
print(f"Description: {config.agent.agent_description}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Note:
|
|
117
|
+
This method only retrieves configuration information and does not
|
|
118
|
+
execute the pipeline. Use execute_pipeline() to run the pipeline.
|
|
119
|
+
"""
|
|
120
|
+
request_data = self._pre_get_pipeline_config(
|
|
121
|
+
pipeline_id=pipeline_id,
|
|
122
|
+
correlation_id=correlation_id,
|
|
123
|
+
api_version=ApiVersion.V1.value,
|
|
124
|
+
)
|
|
125
|
+
resp = await self._request_handler.make_request("GET", request_data)
|
|
126
|
+
|
|
127
|
+
return GetPipelineConfigResponse(**resp)
|
|
@@ -0,0 +1,76 @@
|
|
|
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 BasePipelinesConfig:
|
|
9
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
10
|
+
self._request_handler = request_handler
|
|
11
|
+
|
|
12
|
+
def _pre_get_active_pipelines_ids(
|
|
13
|
+
self,
|
|
14
|
+
project_id: Optional[str] = None,
|
|
15
|
+
correlation_id: Optional[str] = None,
|
|
16
|
+
api_version: str = ApiVersion.V1.value,
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
Prepare request data for getting active pipelines IDs.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
project_id: ID of the project to get configuration for
|
|
23
|
+
correlation_id: Optional correlation ID for tracing
|
|
24
|
+
api_version: API version to use for the request
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
RequestData: Prepared request data for the pipeline config endpoint
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
ValueError: If an invalid API version is provided
|
|
31
|
+
"""
|
|
32
|
+
if api_version not in ApiVersion.as_list():
|
|
33
|
+
raise ValueError(
|
|
34
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
35
|
+
)
|
|
36
|
+
url = urljoin(self._request_handler.base_url, f"{api_version}/PipelinesConfig")
|
|
37
|
+
params = {"projectId": project_id} if project_id is not None else None
|
|
38
|
+
request_data = self._request_handler.prepare_request(
|
|
39
|
+
url, params=params, correlation_id=correlation_id
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return request_data
|
|
43
|
+
|
|
44
|
+
def _pre_get_pipeline_config(
|
|
45
|
+
self,
|
|
46
|
+
pipeline_id: str,
|
|
47
|
+
correlation_id: Optional[str] = None,
|
|
48
|
+
api_version: str = ApiVersion.V1.value,
|
|
49
|
+
):
|
|
50
|
+
"""
|
|
51
|
+
Prepare request data for getting pipeline configuration endpoint.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
pipeline_id: ID of the pipeline to get configuration for
|
|
55
|
+
correlation_id: Optional correlation ID for tracing
|
|
56
|
+
api_version: API version to use for the request
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
RequestData: Prepared request data for the pipeline config endpoint
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
ValueError: If an invalid API version is provided
|
|
63
|
+
"""
|
|
64
|
+
if api_version not in ApiVersion.as_list():
|
|
65
|
+
raise ValueError(
|
|
66
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
67
|
+
)
|
|
68
|
+
url = urljoin(
|
|
69
|
+
self._request_handler.base_url,
|
|
70
|
+
f"{api_version}/PipelinesConfig/export/{pipeline_id}",
|
|
71
|
+
)
|
|
72
|
+
request_data = self._request_handler.prepare_request(
|
|
73
|
+
url, correlation_id=correlation_id
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return request_data
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.pipelines_config import GetPipelineConfigResponse
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_pipelines_config import BasePipelinesConfig
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PipelinesConfig(BasePipelinesConfig):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def get_active_pipelines_ids(
|
|
14
|
+
self, project_id: Optional[str] = None, correlation_id: Optional[str] = None
|
|
15
|
+
) -> List[str]:
|
|
16
|
+
"""
|
|
17
|
+
Retrieve a list of active pipeline IDs.
|
|
18
|
+
|
|
19
|
+
This method fetches the IDs of all active pipelines, optionally filtered by project.
|
|
20
|
+
Active pipelines are those that are currently deployed and available for execution.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
project_id (str, optional): The unique identifier of the project to filter
|
|
24
|
+
pipelines by. If not provided, returns active pipelines from all projects
|
|
25
|
+
accessible to the authenticated user.
|
|
26
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
27
|
+
and logging. If not provided, one will be automatically generated.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
List[str]: A list of pipeline IDs that are currently active. Returns an
|
|
31
|
+
empty list if no active pipelines are found.
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
35
|
+
- The project_id doesn't exist (404)
|
|
36
|
+
- Authentication fails (401)
|
|
37
|
+
- Access is forbidden (403)
|
|
38
|
+
- Server errors (5xx)
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
```python
|
|
42
|
+
from airia import AiriaClient
|
|
43
|
+
|
|
44
|
+
client = AiriaClient(api_key="your_api_key")
|
|
45
|
+
|
|
46
|
+
# Get all active pipeline IDs
|
|
47
|
+
pipeline_ids = client.pipelines_config.get_active_pipelines_ids()
|
|
48
|
+
print(f"Found {len(pipeline_ids)} active pipelines")
|
|
49
|
+
|
|
50
|
+
# Get active pipeline IDs for a specific project
|
|
51
|
+
project_pipelines = client.pipelines_config.get_active_pipelines_ids(
|
|
52
|
+
project_id="your_project_id"
|
|
53
|
+
)
|
|
54
|
+
print(f"Project has {len(project_pipelines)} active pipelines")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Note:
|
|
58
|
+
Only pipelines with active versions are returned. Inactive or archived
|
|
59
|
+
pipelines are not included in the results.
|
|
60
|
+
"""
|
|
61
|
+
request_data = self._pre_get_active_pipelines_ids(
|
|
62
|
+
project_id=project_id,
|
|
63
|
+
correlation_id=correlation_id,
|
|
64
|
+
api_version=ApiVersion.V1.value,
|
|
65
|
+
)
|
|
66
|
+
resp = self._request_handler.make_request("GET", request_data)
|
|
67
|
+
|
|
68
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
69
|
+
return []
|
|
70
|
+
|
|
71
|
+
pipeline_ids = [r["activeVersion"]["pipelineId"] for r in resp["items"]]
|
|
72
|
+
|
|
73
|
+
return pipeline_ids
|
|
74
|
+
|
|
75
|
+
def get_pipeline_config(
|
|
76
|
+
self, pipeline_id: str, correlation_id: Optional[str] = None
|
|
77
|
+
) -> GetPipelineConfigResponse:
|
|
78
|
+
"""
|
|
79
|
+
Retrieve configuration details for a specific pipeline.
|
|
80
|
+
|
|
81
|
+
This method fetches comprehensive information about a pipeline including its
|
|
82
|
+
deployment details, execution statistics, version information, and metadata.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
pipeline_id (str): The unique identifier of the pipeline to retrieve
|
|
86
|
+
configuration for.
|
|
87
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
88
|
+
and logging. If not provided, one will be automatically generated.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
GetPipelineConfigResponse: A response object containing the pipeline
|
|
92
|
+
configuration.
|
|
93
|
+
|
|
94
|
+
Raises:
|
|
95
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
96
|
+
- The pipeline_id doesn't exist (404)
|
|
97
|
+
- Authentication fails (401)
|
|
98
|
+
- Access is forbidden (403)
|
|
99
|
+
- Server errors (5xx)
|
|
100
|
+
|
|
101
|
+
Example:
|
|
102
|
+
```python
|
|
103
|
+
from airia import AiriaClient
|
|
104
|
+
|
|
105
|
+
client = AiriaClient(api_key="your_api_key")
|
|
106
|
+
|
|
107
|
+
# Get pipeline configuration
|
|
108
|
+
config = client.pipelines_config.get_pipeline_config(
|
|
109
|
+
pipeline_id="your_pipeline_id"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
print(f"Pipeline: {config.agent.name}")
|
|
113
|
+
print(f"Description: {config.agent.agent_description}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Note:
|
|
117
|
+
This method only retrieves configuration information and does not
|
|
118
|
+
execute the pipeline. Use execute_pipeline() to run the pipeline.
|
|
119
|
+
"""
|
|
120
|
+
request_data = self._pre_get_pipeline_config(
|
|
121
|
+
pipeline_id=pipeline_id,
|
|
122
|
+
correlation_id=correlation_id,
|
|
123
|
+
api_version=ApiVersion.V1.value,
|
|
124
|
+
)
|
|
125
|
+
resp = self._request_handler.make_request("GET", request_data)
|
|
126
|
+
|
|
127
|
+
return GetPipelineConfigResponse(**resp)
|
|
@@ -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)
|