agenta 0.24.1a0__py3-none-any.whl → 0.24.2__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.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- agenta/cli/variant_commands.py +15 -10
- agenta/client/Readme.md +72 -64
- agenta/client/api.py +1 -1
- agenta/client/backend/__init__.py +14 -9
- agenta/client/backend/apps/client.py +1669 -0
- agenta/client/backend/bases/client.py +190 -0
- agenta/client/backend/client.py +2102 -868
- agenta/client/backend/configs/client.py +598 -0
- agenta/client/backend/containers/client.py +638 -0
- agenta/client/backend/{resources/containers → containers}/types/container_templates_response.py +1 -2
- agenta/client/backend/core/__init__.py +29 -0
- agenta/client/backend/core/client_wrapper.py +42 -9
- agenta/client/backend/core/datetime_utils.py +1 -1
- agenta/client/backend/core/file.py +43 -0
- agenta/client/backend/core/http_client.py +553 -0
- agenta/client/backend/core/jsonable_encoder.py +33 -39
- agenta/client/backend/core/pydantic_utilities.py +212 -0
- agenta/client/backend/core/query_encoder.py +60 -0
- agenta/client/backend/core/remove_none_from_dict.py +2 -2
- agenta/client/backend/core/request_options.py +32 -0
- agenta/client/backend/core/serialization.py +179 -0
- agenta/client/backend/environments/client.py +190 -0
- agenta/client/backend/evaluations/client.py +1462 -0
- agenta/client/backend/evaluators/client.py +911 -0
- agenta/client/backend/observability/client.py +1271 -0
- agenta/client/backend/testsets/client.py +1132 -0
- agenta/client/backend/types/__init__.py +8 -6
- agenta/client/backend/types/aggregated_result.py +14 -29
- agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -2
- agenta/client/backend/types/app.py +13 -28
- agenta/client/backend/types/app_variant_response.py +21 -37
- agenta/client/backend/types/app_variant_revision.py +17 -32
- agenta/client/backend/types/base_output.py +13 -28
- agenta/client/backend/types/body_import_testset.py +16 -31
- agenta/client/backend/types/config_db.py +16 -31
- agenta/client/backend/types/correct_answer.py +22 -0
- agenta/client/backend/types/create_app_output.py +13 -28
- agenta/client/backend/types/create_span.py +33 -50
- agenta/client/backend/types/create_trace_response.py +16 -31
- agenta/client/backend/types/docker_env_vars.py +13 -28
- agenta/client/backend/types/environment_output.py +21 -36
- agenta/client/backend/types/environment_output_extended.py +21 -36
- agenta/client/backend/types/environment_revision.py +18 -33
- agenta/client/backend/types/error.py +16 -31
- agenta/client/backend/types/evaluation.py +20 -34
- agenta/client/backend/types/evaluation_scenario.py +18 -33
- agenta/client/backend/types/evaluation_scenario_input.py +16 -31
- agenta/client/backend/types/evaluation_scenario_output.py +18 -33
- agenta/client/backend/types/evaluation_scenario_result.py +14 -29
- agenta/client/backend/types/evaluation_scenario_score_update.py +13 -28
- agenta/client/backend/types/evaluation_status_enum.py +11 -33
- agenta/client/backend/types/evaluation_type.py +3 -21
- agenta/client/backend/types/evaluator.py +18 -32
- agenta/client/backend/types/evaluator_config.py +20 -33
- agenta/client/backend/types/get_config_response.py +16 -31
- agenta/client/backend/types/http_validation_error.py +14 -29
- agenta/client/backend/types/human_evaluation.py +17 -32
- agenta/client/backend/types/human_evaluation_scenario.py +21 -37
- agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
- agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
- agenta/client/backend/types/human_evaluation_scenario_update.py +26 -41
- agenta/client/backend/types/human_evaluation_update.py +14 -29
- agenta/client/backend/types/image.py +18 -33
- agenta/client/backend/types/invite_request.py +13 -28
- agenta/client/backend/types/list_api_keys_response.py +18 -33
- agenta/client/backend/types/llm_run_rate_limit.py +13 -28
- agenta/client/backend/types/llm_tokens.py +16 -31
- agenta/client/backend/types/lm_providers_enum.py +21 -0
- agenta/client/backend/types/new_human_evaluation.py +13 -28
- agenta/client/backend/types/new_testset.py +16 -31
- agenta/client/backend/types/organization.py +22 -36
- agenta/client/backend/types/organization_output.py +13 -28
- agenta/client/backend/types/outputs.py +5 -0
- agenta/client/backend/types/permission.py +36 -137
- agenta/client/backend/types/result.py +17 -32
- agenta/client/backend/types/simple_evaluation_output.py +13 -28
- agenta/client/backend/types/span.py +23 -38
- agenta/client/backend/types/span_detail.py +26 -40
- agenta/client/backend/types/span_status_code.py +1 -25
- agenta/client/backend/types/span_variant.py +16 -31
- agenta/client/backend/types/template.py +14 -29
- agenta/client/backend/types/template_image_info.py +21 -35
- agenta/client/backend/types/test_set_output_response.py +16 -32
- agenta/client/backend/types/test_set_simple_response.py +13 -28
- agenta/client/backend/types/trace_detail.py +26 -40
- agenta/client/backend/types/update_app_output.py +22 -0
- agenta/client/backend/types/uri.py +13 -28
- agenta/client/backend/types/validation_error.py +13 -28
- agenta/client/backend/types/variant_action.py +14 -29
- agenta/client/backend/types/variant_action_enum.py +1 -19
- agenta/client/backend/types/with_pagination.py +14 -30
- agenta/client/backend/types/workspace_member_response.py +14 -29
- agenta/client/backend/types/workspace_permission.py +18 -33
- agenta/client/backend/types/workspace_response.py +20 -35
- agenta/client/backend/types/workspace_role.py +11 -37
- agenta/client/backend/types/workspace_role_response.py +17 -32
- agenta/client/backend/variants/client.py +1447 -0
- agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
- agenta/sdk/decorators/llm_entrypoint.py +8 -13
- agenta/sdk/tracing/llm_tracing.py +10 -12
- {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/METADATA +1 -1
- agenta-0.24.2.dist-info/RECORD +175 -0
- agenta/client/backend/resources/__init__.py +0 -31
- agenta/client/backend/resources/apps/client.py +0 -977
- agenta/client/backend/resources/bases/client.py +0 -127
- agenta/client/backend/resources/configs/client.py +0 -377
- agenta/client/backend/resources/containers/client.py +0 -383
- agenta/client/backend/resources/environments/client.py +0 -131
- agenta/client/backend/resources/evaluations/client.py +0 -1008
- agenta/client/backend/resources/evaluators/client.py +0 -594
- agenta/client/backend/resources/observability/client.py +0 -1187
- agenta/client/backend/resources/testsets/client.py +0 -689
- agenta/client/backend/resources/variants/client.py +0 -796
- agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -7
- agenta/client/backend/types/evaluation_webhook.py +0 -36
- agenta/client/backend/types/feedback.py +0 -40
- agenta/client/backend/types/span_kind.py +0 -49
- agenta-0.24.1a0.dist-info/RECORD +0 -169
- /agenta/client/backend/{resources/apps → apps}/__init__.py +0 -0
- /agenta/client/backend/{resources/bases → bases}/__init__.py +0 -0
- /agenta/client/backend/{resources/configs → configs}/__init__.py +0 -0
- /agenta/client/backend/{resources/containers → containers}/__init__.py +0 -0
- /agenta/client/backend/{resources/containers → containers}/types/__init__.py +0 -0
- /agenta/client/backend/{resources/environments → environments}/__init__.py +0 -0
- /agenta/client/backend/{resources/evaluations → evaluations}/__init__.py +0 -0
- /agenta/client/backend/{resources/evaluators → evaluators}/__init__.py +0 -0
- /agenta/client/backend/{resources/observability → observability}/__init__.py +0 -0
- /agenta/client/backend/{resources/testsets → testsets}/__init__.py +0 -0
- /agenta/client/backend/{resources/variants → variants}/__init__.py +0 -0
- /agenta/client/backend/{resources/variants → variants}/types/__init__.py +0 -0
- {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/WHEEL +0 -0
- {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,977 +0,0 @@
|
|
|
1
|
-
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
import urllib.parse
|
|
5
|
-
from json.decoder import JSONDecodeError
|
|
6
|
-
|
|
7
|
-
from ...core.api_error import ApiError
|
|
8
|
-
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
-
from ...core.jsonable_encoder import jsonable_encoder
|
|
10
|
-
from ...core.remove_none_from_dict import remove_none_from_dict
|
|
11
|
-
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
12
|
-
from ...types.app import App
|
|
13
|
-
from ...types.app_variant_response import AppVariantResponse
|
|
14
|
-
from ...types.create_app_output import CreateAppOutput
|
|
15
|
-
from ...types.environment_output import EnvironmentOutput
|
|
16
|
-
from ...types.environment_output_extended import EnvironmentOutputExtended
|
|
17
|
-
from ...types.http_validation_error import HttpValidationError
|
|
18
|
-
|
|
19
|
-
try:
|
|
20
|
-
import pydantic.v1 as pydantic # type: ignore
|
|
21
|
-
except ImportError:
|
|
22
|
-
import pydantic # type: ignore
|
|
23
|
-
|
|
24
|
-
# this is used as the default value for optional parameters
|
|
25
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class AppsClient:
|
|
29
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
30
|
-
self._client_wrapper = client_wrapper
|
|
31
|
-
|
|
32
|
-
def list_app_variants(self, app_id: str) -> typing.List[AppVariantResponse]:
|
|
33
|
-
"""
|
|
34
|
-
Retrieve a list of app variants for a given app ID.
|
|
35
|
-
|
|
36
|
-
Args:
|
|
37
|
-
app_id (str): The ID of the app to retrieve variants for.
|
|
38
|
-
stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
List[AppVariantResponse]: A list of app variants for the given app ID.
|
|
42
|
-
|
|
43
|
-
Parameters:
|
|
44
|
-
- app_id: str.
|
|
45
|
-
---
|
|
46
|
-
from agenta.client import AgentaApi
|
|
47
|
-
|
|
48
|
-
client = AgentaApi(
|
|
49
|
-
api_key="YOUR_API_KEY",
|
|
50
|
-
base_url="https://yourhost.com/path/to/api",
|
|
51
|
-
)
|
|
52
|
-
client.apps.list_app_variants(
|
|
53
|
-
app_id="app_id",
|
|
54
|
-
)
|
|
55
|
-
"""
|
|
56
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
57
|
-
"GET",
|
|
58
|
-
urllib.parse.urljoin(
|
|
59
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}/variants"
|
|
60
|
-
),
|
|
61
|
-
headers=self._client_wrapper.get_headers(),
|
|
62
|
-
timeout=60,
|
|
63
|
-
)
|
|
64
|
-
if 200 <= _response.status_code < 300:
|
|
65
|
-
return pydantic.parse_obj_as(typing.List[AppVariantResponse], _response.json()) # type: ignore
|
|
66
|
-
if _response.status_code == 422:
|
|
67
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
68
|
-
try:
|
|
69
|
-
_response_json = _response.json()
|
|
70
|
-
except JSONDecodeError:
|
|
71
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
72
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
73
|
-
|
|
74
|
-
def get_variant_by_env(
|
|
75
|
-
self, *, app_id: str, environment: str
|
|
76
|
-
) -> AppVariantResponse:
|
|
77
|
-
"""
|
|
78
|
-
Retrieve the app variant based on the provided app_id and environment.
|
|
79
|
-
|
|
80
|
-
Args:
|
|
81
|
-
app_id (str): The ID of the app to retrieve the variant for.
|
|
82
|
-
environment (str): The environment of the app variant to retrieve.
|
|
83
|
-
stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
|
|
84
|
-
|
|
85
|
-
Raises:
|
|
86
|
-
HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
|
|
87
|
-
|
|
88
|
-
Returns:
|
|
89
|
-
AppVariantResponse: The retrieved app variant.
|
|
90
|
-
|
|
91
|
-
Parameters:
|
|
92
|
-
- app_id: str.
|
|
93
|
-
|
|
94
|
-
- environment: str.
|
|
95
|
-
---
|
|
96
|
-
from agenta.client import AgentaApi
|
|
97
|
-
|
|
98
|
-
client = AgentaApi(
|
|
99
|
-
api_key="YOUR_API_KEY",
|
|
100
|
-
base_url="https://yourhost.com/path/to/api",
|
|
101
|
-
)
|
|
102
|
-
client.apps.get_variant_by_env(
|
|
103
|
-
app_id="app_id",
|
|
104
|
-
environment="environment",
|
|
105
|
-
)
|
|
106
|
-
"""
|
|
107
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
108
|
-
"GET",
|
|
109
|
-
urllib.parse.urljoin(
|
|
110
|
-
f"{self._client_wrapper.get_base_url()}/", "apps/get_variant_by_env"
|
|
111
|
-
),
|
|
112
|
-
params=remove_none_from_dict(
|
|
113
|
-
{"app_id": app_id, "environment": environment}
|
|
114
|
-
),
|
|
115
|
-
headers=self._client_wrapper.get_headers(),
|
|
116
|
-
timeout=60,
|
|
117
|
-
)
|
|
118
|
-
if 200 <= _response.status_code < 300:
|
|
119
|
-
return pydantic.parse_obj_as(AppVariantResponse, _response.json()) # type: ignore
|
|
120
|
-
if _response.status_code == 422:
|
|
121
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
122
|
-
try:
|
|
123
|
-
_response_json = _response.json()
|
|
124
|
-
except JSONDecodeError:
|
|
125
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
126
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
127
|
-
|
|
128
|
-
def list_apps(
|
|
129
|
-
self,
|
|
130
|
-
*,
|
|
131
|
-
app_name: typing.Optional[str] = None,
|
|
132
|
-
org_id: typing.Optional[str] = None,
|
|
133
|
-
workspace_id: typing.Optional[str] = None,
|
|
134
|
-
) -> typing.List[App]:
|
|
135
|
-
"""
|
|
136
|
-
Retrieve a list of apps filtered by app_name and org_id.
|
|
137
|
-
|
|
138
|
-
Args:
|
|
139
|
-
app_name (Optional[str]): The name of the app to filter by.
|
|
140
|
-
org_id (Optional[str]): The ID of the organization to filter by.
|
|
141
|
-
stoken_session (SessionContainer): The session container.
|
|
142
|
-
|
|
143
|
-
Returns:
|
|
144
|
-
List[App]: A list of apps filtered by app_name and org_id.
|
|
145
|
-
|
|
146
|
-
Raises:
|
|
147
|
-
HTTPException: If there was an error retrieving the list of apps.
|
|
148
|
-
|
|
149
|
-
Parameters:
|
|
150
|
-
- app_name: typing.Optional[str].
|
|
151
|
-
|
|
152
|
-
- org_id: typing.Optional[str].
|
|
153
|
-
|
|
154
|
-
- workspace_id: typing.Optional[str].
|
|
155
|
-
---
|
|
156
|
-
from agenta.client import AgentaApi
|
|
157
|
-
|
|
158
|
-
client = AgentaApi(
|
|
159
|
-
api_key="YOUR_API_KEY",
|
|
160
|
-
base_url="https://yourhost.com/path/to/api",
|
|
161
|
-
)
|
|
162
|
-
client.apps.list_apps()
|
|
163
|
-
"""
|
|
164
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
165
|
-
"GET",
|
|
166
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "apps"),
|
|
167
|
-
params=remove_none_from_dict(
|
|
168
|
-
{"app_name": app_name, "org_id": org_id, "workspace_id": workspace_id}
|
|
169
|
-
),
|
|
170
|
-
headers=self._client_wrapper.get_headers(),
|
|
171
|
-
timeout=60,
|
|
172
|
-
)
|
|
173
|
-
if 200 <= _response.status_code < 300:
|
|
174
|
-
return pydantic.parse_obj_as(typing.List[App], _response.json()) # type: ignore
|
|
175
|
-
if _response.status_code == 422:
|
|
176
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
177
|
-
try:
|
|
178
|
-
_response_json = _response.json()
|
|
179
|
-
except JSONDecodeError:
|
|
180
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
181
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
182
|
-
|
|
183
|
-
def create_app(
|
|
184
|
-
self,
|
|
185
|
-
*,
|
|
186
|
-
app_name: str,
|
|
187
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
188
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
189
|
-
) -> CreateAppOutput:
|
|
190
|
-
"""
|
|
191
|
-
Create a new app for a user or organization.
|
|
192
|
-
|
|
193
|
-
Args:
|
|
194
|
-
payload (CreateApp): The payload containing the app name and organization ID (optional).
|
|
195
|
-
stoken_session (SessionContainer): The session container containing the user's session token.
|
|
196
|
-
|
|
197
|
-
Returns:
|
|
198
|
-
CreateAppOutput: The output containing the newly created app's ID and name.
|
|
199
|
-
|
|
200
|
-
Raises:
|
|
201
|
-
HTTPException: If there is an error creating the app or the user does not have permission to access the app.
|
|
202
|
-
|
|
203
|
-
Parameters:
|
|
204
|
-
- app_name: str.
|
|
205
|
-
|
|
206
|
-
- organization_id: typing.Optional[str].
|
|
207
|
-
|
|
208
|
-
- workspace_id: typing.Optional[str].
|
|
209
|
-
---
|
|
210
|
-
from agenta.client import AgentaApi
|
|
211
|
-
|
|
212
|
-
client = AgentaApi(
|
|
213
|
-
api_key="YOUR_API_KEY",
|
|
214
|
-
base_url="https://yourhost.com/path/to/api",
|
|
215
|
-
)
|
|
216
|
-
client.apps.create_app(
|
|
217
|
-
app_name="app_name",
|
|
218
|
-
)
|
|
219
|
-
"""
|
|
220
|
-
_request: typing.Dict[str, typing.Any] = {"app_name": app_name}
|
|
221
|
-
if organization_id is not OMIT:
|
|
222
|
-
_request["organization_id"] = organization_id
|
|
223
|
-
if workspace_id is not OMIT:
|
|
224
|
-
_request["workspace_id"] = workspace_id
|
|
225
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
226
|
-
"POST",
|
|
227
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "apps"),
|
|
228
|
-
json=jsonable_encoder(_request),
|
|
229
|
-
headers=self._client_wrapper.get_headers(),
|
|
230
|
-
timeout=60,
|
|
231
|
-
)
|
|
232
|
-
if 200 <= _response.status_code < 300:
|
|
233
|
-
return pydantic.parse_obj_as(CreateAppOutput, _response.json()) # type: ignore
|
|
234
|
-
if _response.status_code == 422:
|
|
235
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
236
|
-
try:
|
|
237
|
-
_response_json = _response.json()
|
|
238
|
-
except JSONDecodeError:
|
|
239
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
240
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
241
|
-
|
|
242
|
-
def add_variant_from_image(
|
|
243
|
-
self,
|
|
244
|
-
app_id: str,
|
|
245
|
-
*,
|
|
246
|
-
variant_name: str,
|
|
247
|
-
docker_id: str,
|
|
248
|
-
tags: str,
|
|
249
|
-
base_name: typing.Optional[str] = OMIT,
|
|
250
|
-
config_name: typing.Optional[str] = OMIT,
|
|
251
|
-
) -> typing.Any:
|
|
252
|
-
"""
|
|
253
|
-
Add a new variant to an app based on a Docker image.
|
|
254
|
-
|
|
255
|
-
Args:
|
|
256
|
-
app_id (str): The ID of the app to add the variant to.
|
|
257
|
-
payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
|
|
258
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
259
|
-
|
|
260
|
-
Raises:
|
|
261
|
-
HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
|
|
262
|
-
|
|
263
|
-
Returns:
|
|
264
|
-
dict: The newly added variant.
|
|
265
|
-
|
|
266
|
-
Parameters:
|
|
267
|
-
- app_id: str.
|
|
268
|
-
|
|
269
|
-
- variant_name: str.
|
|
270
|
-
|
|
271
|
-
- docker_id: str.
|
|
272
|
-
|
|
273
|
-
- tags: str.
|
|
274
|
-
|
|
275
|
-
- base_name: typing.Optional[str].
|
|
276
|
-
|
|
277
|
-
- config_name: typing.Optional[str].
|
|
278
|
-
---
|
|
279
|
-
from agenta.client import AgentaApi
|
|
280
|
-
|
|
281
|
-
client = AgentaApi(
|
|
282
|
-
api_key="YOUR_API_KEY",
|
|
283
|
-
base_url="https://yourhost.com/path/to/api",
|
|
284
|
-
)
|
|
285
|
-
client.apps.add_variant_from_image(
|
|
286
|
-
app_id="app_id",
|
|
287
|
-
variant_name="variant_name",
|
|
288
|
-
docker_id="docker_id",
|
|
289
|
-
tags="tags",
|
|
290
|
-
)
|
|
291
|
-
"""
|
|
292
|
-
_request: typing.Dict[str, typing.Any] = {
|
|
293
|
-
"variant_name": variant_name,
|
|
294
|
-
"docker_id": docker_id,
|
|
295
|
-
"tags": tags,
|
|
296
|
-
}
|
|
297
|
-
if base_name is not OMIT:
|
|
298
|
-
_request["base_name"] = base_name
|
|
299
|
-
if config_name is not OMIT:
|
|
300
|
-
_request["config_name"] = config_name
|
|
301
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
302
|
-
"POST",
|
|
303
|
-
urllib.parse.urljoin(
|
|
304
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
305
|
-
f"apps/{app_id}/variant/from-image",
|
|
306
|
-
),
|
|
307
|
-
json=jsonable_encoder(_request),
|
|
308
|
-
headers=self._client_wrapper.get_headers(),
|
|
309
|
-
timeout=60,
|
|
310
|
-
)
|
|
311
|
-
if 200 <= _response.status_code < 300:
|
|
312
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
313
|
-
if _response.status_code == 422:
|
|
314
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
315
|
-
try:
|
|
316
|
-
_response_json = _response.json()
|
|
317
|
-
except JSONDecodeError:
|
|
318
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
319
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
320
|
-
|
|
321
|
-
def remove_app(self, app_id: str) -> typing.Any:
|
|
322
|
-
"""
|
|
323
|
-
Remove app, all its variant, containers and images
|
|
324
|
-
|
|
325
|
-
Arguments:
|
|
326
|
-
app -- App to remove
|
|
327
|
-
|
|
328
|
-
Parameters:
|
|
329
|
-
- app_id: str.
|
|
330
|
-
---
|
|
331
|
-
from agenta.client import AgentaApi
|
|
332
|
-
|
|
333
|
-
client = AgentaApi(
|
|
334
|
-
api_key="YOUR_API_KEY",
|
|
335
|
-
base_url="https://yourhost.com/path/to/api",
|
|
336
|
-
)
|
|
337
|
-
client.apps.remove_app(
|
|
338
|
-
app_id="app_id",
|
|
339
|
-
)
|
|
340
|
-
"""
|
|
341
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
342
|
-
"DELETE",
|
|
343
|
-
urllib.parse.urljoin(
|
|
344
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}"
|
|
345
|
-
),
|
|
346
|
-
headers=self._client_wrapper.get_headers(),
|
|
347
|
-
timeout=60,
|
|
348
|
-
)
|
|
349
|
-
if 200 <= _response.status_code < 300:
|
|
350
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
351
|
-
if _response.status_code == 422:
|
|
352
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
353
|
-
try:
|
|
354
|
-
_response_json = _response.json()
|
|
355
|
-
except JSONDecodeError:
|
|
356
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
357
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
358
|
-
|
|
359
|
-
def create_app_and_variant_from_template(
|
|
360
|
-
self,
|
|
361
|
-
*,
|
|
362
|
-
app_name: str,
|
|
363
|
-
template_id: str,
|
|
364
|
-
env_vars: typing.Dict[str, str],
|
|
365
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
366
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
367
|
-
) -> AppVariantResponse:
|
|
368
|
-
"""
|
|
369
|
-
Create an app and variant from a template.
|
|
370
|
-
|
|
371
|
-
Args:
|
|
372
|
-
payload (CreateAppVariant): The payload containing the app and variant information.
|
|
373
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
374
|
-
|
|
375
|
-
Raises:
|
|
376
|
-
HTTPException: If the user has reached the app limit or if an app with the same name already exists.
|
|
377
|
-
|
|
378
|
-
Returns:
|
|
379
|
-
AppVariantResponse: The output of the created app variant.
|
|
380
|
-
|
|
381
|
-
Parameters:
|
|
382
|
-
- app_name: str.
|
|
383
|
-
|
|
384
|
-
- template_id: str.
|
|
385
|
-
|
|
386
|
-
- env_vars: typing.Dict[str, str].
|
|
387
|
-
|
|
388
|
-
- organization_id: typing.Optional[str].
|
|
389
|
-
|
|
390
|
-
- workspace_id: typing.Optional[str].
|
|
391
|
-
---
|
|
392
|
-
from agenta.client import AgentaApi
|
|
393
|
-
|
|
394
|
-
client = AgentaApi(
|
|
395
|
-
api_key="YOUR_API_KEY",
|
|
396
|
-
base_url="https://yourhost.com/path/to/api",
|
|
397
|
-
)
|
|
398
|
-
client.apps.create_app_and_variant_from_template(
|
|
399
|
-
app_name="app_name",
|
|
400
|
-
template_id="template_id",
|
|
401
|
-
env_vars={"env_vars": "env_vars"},
|
|
402
|
-
)
|
|
403
|
-
"""
|
|
404
|
-
_request: typing.Dict[str, typing.Any] = {
|
|
405
|
-
"app_name": app_name,
|
|
406
|
-
"template_id": template_id,
|
|
407
|
-
"env_vars": env_vars,
|
|
408
|
-
}
|
|
409
|
-
if organization_id is not OMIT:
|
|
410
|
-
_request["organization_id"] = organization_id
|
|
411
|
-
if workspace_id is not OMIT:
|
|
412
|
-
_request["workspace_id"] = workspace_id
|
|
413
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
414
|
-
"POST",
|
|
415
|
-
urllib.parse.urljoin(
|
|
416
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
417
|
-
"apps/app_and_variant_from_template",
|
|
418
|
-
),
|
|
419
|
-
json=jsonable_encoder(_request),
|
|
420
|
-
headers=self._client_wrapper.get_headers(),
|
|
421
|
-
timeout=60,
|
|
422
|
-
)
|
|
423
|
-
if 200 <= _response.status_code < 300:
|
|
424
|
-
return pydantic.parse_obj_as(AppVariantResponse, _response.json()) # type: ignore
|
|
425
|
-
if _response.status_code == 422:
|
|
426
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
427
|
-
try:
|
|
428
|
-
_response_json = _response.json()
|
|
429
|
-
except JSONDecodeError:
|
|
430
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
431
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
432
|
-
|
|
433
|
-
def list_environments(self, app_id: str) -> typing.List[EnvironmentOutput]:
|
|
434
|
-
"""
|
|
435
|
-
Retrieve a list of environments for a given app ID.
|
|
436
|
-
|
|
437
|
-
Args:
|
|
438
|
-
app_id (str): The ID of the app to retrieve environments for.
|
|
439
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
440
|
-
|
|
441
|
-
Returns:
|
|
442
|
-
List[EnvironmentOutput]: A list of environment objects.
|
|
443
|
-
|
|
444
|
-
Parameters:
|
|
445
|
-
- app_id: str.
|
|
446
|
-
---
|
|
447
|
-
from agenta.client import AgentaApi
|
|
448
|
-
|
|
449
|
-
client = AgentaApi(
|
|
450
|
-
api_key="YOUR_API_KEY",
|
|
451
|
-
base_url="https://yourhost.com/path/to/api",
|
|
452
|
-
)
|
|
453
|
-
client.apps.list_environments(
|
|
454
|
-
app_id="app_id",
|
|
455
|
-
)
|
|
456
|
-
"""
|
|
457
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
458
|
-
"GET",
|
|
459
|
-
urllib.parse.urljoin(
|
|
460
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}/environments"
|
|
461
|
-
),
|
|
462
|
-
headers=self._client_wrapper.get_headers(),
|
|
463
|
-
timeout=60,
|
|
464
|
-
)
|
|
465
|
-
if 200 <= _response.status_code < 300:
|
|
466
|
-
return pydantic.parse_obj_as(typing.List[EnvironmentOutput], _response.json()) # type: ignore
|
|
467
|
-
if _response.status_code == 422:
|
|
468
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
469
|
-
try:
|
|
470
|
-
_response_json = _response.json()
|
|
471
|
-
except JSONDecodeError:
|
|
472
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
473
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
474
|
-
|
|
475
|
-
def environment_revisions(
|
|
476
|
-
self, app_id: str, environment_name: typing.Any
|
|
477
|
-
) -> EnvironmentOutputExtended:
|
|
478
|
-
"""
|
|
479
|
-
Parameters:
|
|
480
|
-
- app_id: str.
|
|
481
|
-
|
|
482
|
-
- environment_name: typing.Any.
|
|
483
|
-
"""
|
|
484
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
485
|
-
"GET",
|
|
486
|
-
urllib.parse.urljoin(
|
|
487
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
488
|
-
f"apps/{app_id}/revisions/{environment_name}",
|
|
489
|
-
),
|
|
490
|
-
headers=self._client_wrapper.get_headers(),
|
|
491
|
-
timeout=60,
|
|
492
|
-
)
|
|
493
|
-
if 200 <= _response.status_code < 300:
|
|
494
|
-
return pydantic.parse_obj_as(EnvironmentOutputExtended, _response.json()) # type: ignore
|
|
495
|
-
if _response.status_code == 422:
|
|
496
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
497
|
-
try:
|
|
498
|
-
_response_json = _response.json()
|
|
499
|
-
except JSONDecodeError:
|
|
500
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
501
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
class AsyncAppsClient:
|
|
505
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
506
|
-
self._client_wrapper = client_wrapper
|
|
507
|
-
|
|
508
|
-
async def list_app_variants(self, app_id: str) -> typing.List[AppVariantResponse]:
|
|
509
|
-
"""
|
|
510
|
-
Retrieve a list of app variants for a given app ID.
|
|
511
|
-
|
|
512
|
-
Args:
|
|
513
|
-
app_id (str): The ID of the app to retrieve variants for.
|
|
514
|
-
stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
|
|
515
|
-
|
|
516
|
-
Returns:
|
|
517
|
-
List[AppVariantResponse]: A list of app variants for the given app ID.
|
|
518
|
-
|
|
519
|
-
Parameters:
|
|
520
|
-
- app_id: str.
|
|
521
|
-
---
|
|
522
|
-
from agenta.client import AsyncAgentaApi
|
|
523
|
-
|
|
524
|
-
client = AsyncAgentaApi(
|
|
525
|
-
api_key="YOUR_API_KEY",
|
|
526
|
-
base_url="https://yourhost.com/path/to/api",
|
|
527
|
-
)
|
|
528
|
-
await client.apps.list_app_variants(
|
|
529
|
-
app_id="app_id",
|
|
530
|
-
)
|
|
531
|
-
"""
|
|
532
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
533
|
-
"GET",
|
|
534
|
-
urllib.parse.urljoin(
|
|
535
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}/variants"
|
|
536
|
-
),
|
|
537
|
-
headers=self._client_wrapper.get_headers(),
|
|
538
|
-
timeout=60,
|
|
539
|
-
)
|
|
540
|
-
if 200 <= _response.status_code < 300:
|
|
541
|
-
return pydantic.parse_obj_as(typing.List[AppVariantResponse], _response.json()) # type: ignore
|
|
542
|
-
if _response.status_code == 422:
|
|
543
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
544
|
-
try:
|
|
545
|
-
_response_json = _response.json()
|
|
546
|
-
except JSONDecodeError:
|
|
547
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
548
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
549
|
-
|
|
550
|
-
async def get_variant_by_env(
|
|
551
|
-
self, *, app_id: str, environment: str
|
|
552
|
-
) -> AppVariantResponse:
|
|
553
|
-
"""
|
|
554
|
-
Retrieve the app variant based on the provided app_id and environment.
|
|
555
|
-
|
|
556
|
-
Args:
|
|
557
|
-
app_id (str): The ID of the app to retrieve the variant for.
|
|
558
|
-
environment (str): The environment of the app variant to retrieve.
|
|
559
|
-
stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
|
|
560
|
-
|
|
561
|
-
Raises:
|
|
562
|
-
HTTPException: If the app variant is not found (status_code=500), or if a ValueError is raised (status_code=400), or if any other exception is raised (status_code=500).
|
|
563
|
-
|
|
564
|
-
Returns:
|
|
565
|
-
AppVariantResponse: The retrieved app variant.
|
|
566
|
-
|
|
567
|
-
Parameters:
|
|
568
|
-
- app_id: str.
|
|
569
|
-
|
|
570
|
-
- environment: str.
|
|
571
|
-
---
|
|
572
|
-
from agenta.client import AsyncAgentaApi
|
|
573
|
-
|
|
574
|
-
client = AsyncAgentaApi(
|
|
575
|
-
api_key="YOUR_API_KEY",
|
|
576
|
-
base_url="https://yourhost.com/path/to/api",
|
|
577
|
-
)
|
|
578
|
-
await client.apps.get_variant_by_env(
|
|
579
|
-
app_id="app_id",
|
|
580
|
-
environment="environment",
|
|
581
|
-
)
|
|
582
|
-
"""
|
|
583
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
584
|
-
"GET",
|
|
585
|
-
urllib.parse.urljoin(
|
|
586
|
-
f"{self._client_wrapper.get_base_url()}/", "apps/get_variant_by_env"
|
|
587
|
-
),
|
|
588
|
-
params=remove_none_from_dict(
|
|
589
|
-
{"app_id": app_id, "environment": environment}
|
|
590
|
-
),
|
|
591
|
-
headers=self._client_wrapper.get_headers(),
|
|
592
|
-
timeout=60,
|
|
593
|
-
)
|
|
594
|
-
if 200 <= _response.status_code < 300:
|
|
595
|
-
return pydantic.parse_obj_as(AppVariantResponse, _response.json()) # type: ignore
|
|
596
|
-
if _response.status_code == 422:
|
|
597
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
598
|
-
try:
|
|
599
|
-
_response_json = _response.json()
|
|
600
|
-
except JSONDecodeError:
|
|
601
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
602
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
603
|
-
|
|
604
|
-
async def list_apps(
|
|
605
|
-
self,
|
|
606
|
-
*,
|
|
607
|
-
app_name: typing.Optional[str] = None,
|
|
608
|
-
org_id: typing.Optional[str] = None,
|
|
609
|
-
workspace_id: typing.Optional[str] = None,
|
|
610
|
-
) -> typing.List[App]:
|
|
611
|
-
"""
|
|
612
|
-
Retrieve a list of apps filtered by app_name and org_id.
|
|
613
|
-
|
|
614
|
-
Args:
|
|
615
|
-
app_name (Optional[str]): The name of the app to filter by.
|
|
616
|
-
org_id (Optional[str]): The ID of the organization to filter by.
|
|
617
|
-
stoken_session (SessionContainer): The session container.
|
|
618
|
-
|
|
619
|
-
Returns:
|
|
620
|
-
List[App]: A list of apps filtered by app_name and org_id.
|
|
621
|
-
|
|
622
|
-
Raises:
|
|
623
|
-
HTTPException: If there was an error retrieving the list of apps.
|
|
624
|
-
|
|
625
|
-
Parameters:
|
|
626
|
-
- app_name: typing.Optional[str].
|
|
627
|
-
|
|
628
|
-
- org_id: typing.Optional[str].
|
|
629
|
-
|
|
630
|
-
- workspace_id: typing.Optional[str].
|
|
631
|
-
---
|
|
632
|
-
from agenta.client import AsyncAgentaApi
|
|
633
|
-
|
|
634
|
-
client = AsyncAgentaApi(
|
|
635
|
-
api_key="YOUR_API_KEY",
|
|
636
|
-
base_url="https://yourhost.com/path/to/api",
|
|
637
|
-
)
|
|
638
|
-
await client.apps.list_apps()
|
|
639
|
-
"""
|
|
640
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
641
|
-
"GET",
|
|
642
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "apps"),
|
|
643
|
-
params=remove_none_from_dict(
|
|
644
|
-
{"app_name": app_name, "org_id": org_id, "workspace_id": workspace_id}
|
|
645
|
-
),
|
|
646
|
-
headers=self._client_wrapper.get_headers(),
|
|
647
|
-
timeout=60,
|
|
648
|
-
)
|
|
649
|
-
if 200 <= _response.status_code < 300:
|
|
650
|
-
return pydantic.parse_obj_as(typing.List[App], _response.json()) # type: ignore
|
|
651
|
-
if _response.status_code == 422:
|
|
652
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
653
|
-
try:
|
|
654
|
-
_response_json = _response.json()
|
|
655
|
-
except JSONDecodeError:
|
|
656
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
657
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
658
|
-
|
|
659
|
-
async def create_app(
|
|
660
|
-
self,
|
|
661
|
-
*,
|
|
662
|
-
app_name: str,
|
|
663
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
664
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
665
|
-
) -> CreateAppOutput:
|
|
666
|
-
"""
|
|
667
|
-
Create a new app for a user or organization.
|
|
668
|
-
|
|
669
|
-
Args:
|
|
670
|
-
payload (CreateApp): The payload containing the app name and organization ID (optional).
|
|
671
|
-
stoken_session (SessionContainer): The session container containing the user's session token.
|
|
672
|
-
|
|
673
|
-
Returns:
|
|
674
|
-
CreateAppOutput: The output containing the newly created app's ID and name.
|
|
675
|
-
|
|
676
|
-
Raises:
|
|
677
|
-
HTTPException: If there is an error creating the app or the user does not have permission to access the app.
|
|
678
|
-
|
|
679
|
-
Parameters:
|
|
680
|
-
- app_name: str.
|
|
681
|
-
|
|
682
|
-
- organization_id: typing.Optional[str].
|
|
683
|
-
|
|
684
|
-
- workspace_id: typing.Optional[str].
|
|
685
|
-
---
|
|
686
|
-
from agenta.client import AsyncAgentaApi
|
|
687
|
-
|
|
688
|
-
client = AsyncAgentaApi(
|
|
689
|
-
api_key="YOUR_API_KEY",
|
|
690
|
-
base_url="https://yourhost.com/path/to/api",
|
|
691
|
-
)
|
|
692
|
-
await client.apps.create_app(
|
|
693
|
-
app_name="app_name",
|
|
694
|
-
)
|
|
695
|
-
"""
|
|
696
|
-
_request: typing.Dict[str, typing.Any] = {"app_name": app_name}
|
|
697
|
-
if organization_id is not OMIT:
|
|
698
|
-
_request["organization_id"] = organization_id
|
|
699
|
-
if workspace_id is not OMIT:
|
|
700
|
-
_request["workspace_id"] = workspace_id
|
|
701
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
702
|
-
"POST",
|
|
703
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "apps"),
|
|
704
|
-
json=jsonable_encoder(_request),
|
|
705
|
-
headers=self._client_wrapper.get_headers(),
|
|
706
|
-
timeout=60,
|
|
707
|
-
)
|
|
708
|
-
if 200 <= _response.status_code < 300:
|
|
709
|
-
return pydantic.parse_obj_as(CreateAppOutput, _response.json()) # type: ignore
|
|
710
|
-
if _response.status_code == 422:
|
|
711
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
712
|
-
try:
|
|
713
|
-
_response_json = _response.json()
|
|
714
|
-
except JSONDecodeError:
|
|
715
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
716
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
717
|
-
|
|
718
|
-
async def add_variant_from_image(
|
|
719
|
-
self,
|
|
720
|
-
app_id: str,
|
|
721
|
-
*,
|
|
722
|
-
variant_name: str,
|
|
723
|
-
docker_id: str,
|
|
724
|
-
tags: str,
|
|
725
|
-
base_name: typing.Optional[str] = OMIT,
|
|
726
|
-
config_name: typing.Optional[str] = OMIT,
|
|
727
|
-
) -> typing.Any:
|
|
728
|
-
"""
|
|
729
|
-
Add a new variant to an app based on a Docker image.
|
|
730
|
-
|
|
731
|
-
Args:
|
|
732
|
-
app_id (str): The ID of the app to add the variant to.
|
|
733
|
-
payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
|
|
734
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
735
|
-
|
|
736
|
-
Raises:
|
|
737
|
-
HTTPException: If the feature flag is set to "demo" or if the image does not have a tag starting with the registry name (agenta-server) or if the image is not found or if the user does not have access to the app.
|
|
738
|
-
|
|
739
|
-
Returns:
|
|
740
|
-
dict: The newly added variant.
|
|
741
|
-
|
|
742
|
-
Parameters:
|
|
743
|
-
- app_id: str.
|
|
744
|
-
|
|
745
|
-
- variant_name: str.
|
|
746
|
-
|
|
747
|
-
- docker_id: str.
|
|
748
|
-
|
|
749
|
-
- tags: str.
|
|
750
|
-
|
|
751
|
-
- base_name: typing.Optional[str].
|
|
752
|
-
|
|
753
|
-
- config_name: typing.Optional[str].
|
|
754
|
-
---
|
|
755
|
-
from agenta.client import AsyncAgentaApi
|
|
756
|
-
|
|
757
|
-
client = AsyncAgentaApi(
|
|
758
|
-
api_key="YOUR_API_KEY",
|
|
759
|
-
base_url="https://yourhost.com/path/to/api",
|
|
760
|
-
)
|
|
761
|
-
await client.apps.add_variant_from_image(
|
|
762
|
-
app_id="app_id",
|
|
763
|
-
variant_name="variant_name",
|
|
764
|
-
docker_id="docker_id",
|
|
765
|
-
tags="tags",
|
|
766
|
-
)
|
|
767
|
-
"""
|
|
768
|
-
_request: typing.Dict[str, typing.Any] = {
|
|
769
|
-
"variant_name": variant_name,
|
|
770
|
-
"docker_id": docker_id,
|
|
771
|
-
"tags": tags,
|
|
772
|
-
}
|
|
773
|
-
if base_name is not OMIT:
|
|
774
|
-
_request["base_name"] = base_name
|
|
775
|
-
if config_name is not OMIT:
|
|
776
|
-
_request["config_name"] = config_name
|
|
777
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
778
|
-
"POST",
|
|
779
|
-
urllib.parse.urljoin(
|
|
780
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
781
|
-
f"apps/{app_id}/variant/from-image",
|
|
782
|
-
),
|
|
783
|
-
json=jsonable_encoder(_request),
|
|
784
|
-
headers=self._client_wrapper.get_headers(),
|
|
785
|
-
timeout=60,
|
|
786
|
-
)
|
|
787
|
-
if 200 <= _response.status_code < 300:
|
|
788
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
789
|
-
if _response.status_code == 422:
|
|
790
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
791
|
-
try:
|
|
792
|
-
_response_json = _response.json()
|
|
793
|
-
except JSONDecodeError:
|
|
794
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
795
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
796
|
-
|
|
797
|
-
async def remove_app(self, app_id: str) -> typing.Any:
|
|
798
|
-
"""
|
|
799
|
-
Remove app, all its variant, containers and images
|
|
800
|
-
|
|
801
|
-
Arguments:
|
|
802
|
-
app -- App to remove
|
|
803
|
-
|
|
804
|
-
Parameters:
|
|
805
|
-
- app_id: str.
|
|
806
|
-
---
|
|
807
|
-
from agenta.client import AsyncAgentaApi
|
|
808
|
-
|
|
809
|
-
client = AsyncAgentaApi(
|
|
810
|
-
api_key="YOUR_API_KEY",
|
|
811
|
-
base_url="https://yourhost.com/path/to/api",
|
|
812
|
-
)
|
|
813
|
-
await client.apps.remove_app(
|
|
814
|
-
app_id="app_id",
|
|
815
|
-
)
|
|
816
|
-
"""
|
|
817
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
818
|
-
"DELETE",
|
|
819
|
-
urllib.parse.urljoin(
|
|
820
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}"
|
|
821
|
-
),
|
|
822
|
-
headers=self._client_wrapper.get_headers(),
|
|
823
|
-
timeout=60,
|
|
824
|
-
)
|
|
825
|
-
if 200 <= _response.status_code < 300:
|
|
826
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
827
|
-
if _response.status_code == 422:
|
|
828
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
829
|
-
try:
|
|
830
|
-
_response_json = _response.json()
|
|
831
|
-
except JSONDecodeError:
|
|
832
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
833
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
834
|
-
|
|
835
|
-
async def create_app_and_variant_from_template(
|
|
836
|
-
self,
|
|
837
|
-
*,
|
|
838
|
-
app_name: str,
|
|
839
|
-
template_id: str,
|
|
840
|
-
env_vars: typing.Dict[str, str],
|
|
841
|
-
organization_id: typing.Optional[str] = OMIT,
|
|
842
|
-
workspace_id: typing.Optional[str] = OMIT,
|
|
843
|
-
) -> AppVariantResponse:
|
|
844
|
-
"""
|
|
845
|
-
Create an app and variant from a template.
|
|
846
|
-
|
|
847
|
-
Args:
|
|
848
|
-
payload (CreateAppVariant): The payload containing the app and variant information.
|
|
849
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
850
|
-
|
|
851
|
-
Raises:
|
|
852
|
-
HTTPException: If the user has reached the app limit or if an app with the same name already exists.
|
|
853
|
-
|
|
854
|
-
Returns:
|
|
855
|
-
AppVariantResponse: The output of the created app variant.
|
|
856
|
-
|
|
857
|
-
Parameters:
|
|
858
|
-
- app_name: str.
|
|
859
|
-
|
|
860
|
-
- template_id: str.
|
|
861
|
-
|
|
862
|
-
- env_vars: typing.Dict[str, str].
|
|
863
|
-
|
|
864
|
-
- organization_id: typing.Optional[str].
|
|
865
|
-
|
|
866
|
-
- workspace_id: typing.Optional[str].
|
|
867
|
-
---
|
|
868
|
-
from agenta.client import AsyncAgentaApi
|
|
869
|
-
|
|
870
|
-
client = AsyncAgentaApi(
|
|
871
|
-
api_key="YOUR_API_KEY",
|
|
872
|
-
base_url="https://yourhost.com/path/to/api",
|
|
873
|
-
)
|
|
874
|
-
await client.apps.create_app_and_variant_from_template(
|
|
875
|
-
app_name="app_name",
|
|
876
|
-
template_id="template_id",
|
|
877
|
-
env_vars={"env_vars": "env_vars"},
|
|
878
|
-
)
|
|
879
|
-
"""
|
|
880
|
-
_request: typing.Dict[str, typing.Any] = {
|
|
881
|
-
"app_name": app_name,
|
|
882
|
-
"template_id": template_id,
|
|
883
|
-
"env_vars": env_vars,
|
|
884
|
-
}
|
|
885
|
-
if organization_id is not OMIT:
|
|
886
|
-
_request["organization_id"] = organization_id
|
|
887
|
-
if workspace_id is not OMIT:
|
|
888
|
-
_request["workspace_id"] = workspace_id
|
|
889
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
890
|
-
"POST",
|
|
891
|
-
urllib.parse.urljoin(
|
|
892
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
893
|
-
"apps/app_and_variant_from_template",
|
|
894
|
-
),
|
|
895
|
-
json=jsonable_encoder(_request),
|
|
896
|
-
headers=self._client_wrapper.get_headers(),
|
|
897
|
-
timeout=60,
|
|
898
|
-
)
|
|
899
|
-
if 200 <= _response.status_code < 300:
|
|
900
|
-
return pydantic.parse_obj_as(AppVariantResponse, _response.json()) # type: ignore
|
|
901
|
-
if _response.status_code == 422:
|
|
902
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
903
|
-
try:
|
|
904
|
-
_response_json = _response.json()
|
|
905
|
-
except JSONDecodeError:
|
|
906
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
907
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
908
|
-
|
|
909
|
-
async def list_environments(self, app_id: str) -> typing.List[EnvironmentOutput]:
|
|
910
|
-
"""
|
|
911
|
-
Retrieve a list of environments for a given app ID.
|
|
912
|
-
|
|
913
|
-
Args:
|
|
914
|
-
app_id (str): The ID of the app to retrieve environments for.
|
|
915
|
-
stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
|
|
916
|
-
|
|
917
|
-
Returns:
|
|
918
|
-
List[EnvironmentOutput]: A list of environment objects.
|
|
919
|
-
|
|
920
|
-
Parameters:
|
|
921
|
-
- app_id: str.
|
|
922
|
-
---
|
|
923
|
-
from agenta.client import AsyncAgentaApi
|
|
924
|
-
|
|
925
|
-
client = AsyncAgentaApi(
|
|
926
|
-
api_key="YOUR_API_KEY",
|
|
927
|
-
base_url="https://yourhost.com/path/to/api",
|
|
928
|
-
)
|
|
929
|
-
await client.apps.list_environments(
|
|
930
|
-
app_id="app_id",
|
|
931
|
-
)
|
|
932
|
-
"""
|
|
933
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
934
|
-
"GET",
|
|
935
|
-
urllib.parse.urljoin(
|
|
936
|
-
f"{self._client_wrapper.get_base_url()}/", f"apps/{app_id}/environments"
|
|
937
|
-
),
|
|
938
|
-
headers=self._client_wrapper.get_headers(),
|
|
939
|
-
timeout=60,
|
|
940
|
-
)
|
|
941
|
-
if 200 <= _response.status_code < 300:
|
|
942
|
-
return pydantic.parse_obj_as(typing.List[EnvironmentOutput], _response.json()) # type: ignore
|
|
943
|
-
if _response.status_code == 422:
|
|
944
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
945
|
-
try:
|
|
946
|
-
_response_json = _response.json()
|
|
947
|
-
except JSONDecodeError:
|
|
948
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
949
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
950
|
-
|
|
951
|
-
async def environment_revisions(
|
|
952
|
-
self, app_id: str, environment_name: typing.Any
|
|
953
|
-
) -> EnvironmentOutputExtended:
|
|
954
|
-
"""
|
|
955
|
-
Parameters:
|
|
956
|
-
- app_id: str.
|
|
957
|
-
|
|
958
|
-
- environment_name: typing.Any.
|
|
959
|
-
"""
|
|
960
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
961
|
-
"GET",
|
|
962
|
-
urllib.parse.urljoin(
|
|
963
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
964
|
-
f"apps/{app_id}/revisions/{environment_name}",
|
|
965
|
-
),
|
|
966
|
-
headers=self._client_wrapper.get_headers(),
|
|
967
|
-
timeout=60,
|
|
968
|
-
)
|
|
969
|
-
if 200 <= _response.status_code < 300:
|
|
970
|
-
return pydantic.parse_obj_as(EnvironmentOutputExtended, _response.json()) # type: ignore
|
|
971
|
-
if _response.status_code == 422:
|
|
972
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
973
|
-
try:
|
|
974
|
-
_response_json = _response.json()
|
|
975
|
-
except JSONDecodeError:
|
|
976
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
977
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|