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.

Files changed (132) hide show
  1. agenta/cli/variant_commands.py +15 -10
  2. agenta/client/Readme.md +72 -64
  3. agenta/client/api.py +1 -1
  4. agenta/client/backend/__init__.py +14 -9
  5. agenta/client/backend/apps/client.py +1669 -0
  6. agenta/client/backend/bases/client.py +190 -0
  7. agenta/client/backend/client.py +2102 -868
  8. agenta/client/backend/configs/client.py +598 -0
  9. agenta/client/backend/containers/client.py +638 -0
  10. agenta/client/backend/{resources/containers → containers}/types/container_templates_response.py +1 -2
  11. agenta/client/backend/core/__init__.py +29 -0
  12. agenta/client/backend/core/client_wrapper.py +42 -9
  13. agenta/client/backend/core/datetime_utils.py +1 -1
  14. agenta/client/backend/core/file.py +43 -0
  15. agenta/client/backend/core/http_client.py +553 -0
  16. agenta/client/backend/core/jsonable_encoder.py +33 -39
  17. agenta/client/backend/core/pydantic_utilities.py +212 -0
  18. agenta/client/backend/core/query_encoder.py +60 -0
  19. agenta/client/backend/core/remove_none_from_dict.py +2 -2
  20. agenta/client/backend/core/request_options.py +32 -0
  21. agenta/client/backend/core/serialization.py +179 -0
  22. agenta/client/backend/environments/client.py +190 -0
  23. agenta/client/backend/evaluations/client.py +1462 -0
  24. agenta/client/backend/evaluators/client.py +911 -0
  25. agenta/client/backend/observability/client.py +1271 -0
  26. agenta/client/backend/testsets/client.py +1132 -0
  27. agenta/client/backend/types/__init__.py +8 -6
  28. agenta/client/backend/types/aggregated_result.py +14 -29
  29. agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -2
  30. agenta/client/backend/types/app.py +13 -28
  31. agenta/client/backend/types/app_variant_response.py +21 -37
  32. agenta/client/backend/types/app_variant_revision.py +17 -32
  33. agenta/client/backend/types/base_output.py +13 -28
  34. agenta/client/backend/types/body_import_testset.py +16 -31
  35. agenta/client/backend/types/config_db.py +16 -31
  36. agenta/client/backend/types/correct_answer.py +22 -0
  37. agenta/client/backend/types/create_app_output.py +13 -28
  38. agenta/client/backend/types/create_span.py +33 -50
  39. agenta/client/backend/types/create_trace_response.py +16 -31
  40. agenta/client/backend/types/docker_env_vars.py +13 -28
  41. agenta/client/backend/types/environment_output.py +21 -36
  42. agenta/client/backend/types/environment_output_extended.py +21 -36
  43. agenta/client/backend/types/environment_revision.py +18 -33
  44. agenta/client/backend/types/error.py +16 -31
  45. agenta/client/backend/types/evaluation.py +20 -34
  46. agenta/client/backend/types/evaluation_scenario.py +18 -33
  47. agenta/client/backend/types/evaluation_scenario_input.py +16 -31
  48. agenta/client/backend/types/evaluation_scenario_output.py +18 -33
  49. agenta/client/backend/types/evaluation_scenario_result.py +14 -29
  50. agenta/client/backend/types/evaluation_scenario_score_update.py +13 -28
  51. agenta/client/backend/types/evaluation_status_enum.py +11 -33
  52. agenta/client/backend/types/evaluation_type.py +3 -21
  53. agenta/client/backend/types/evaluator.py +18 -32
  54. agenta/client/backend/types/evaluator_config.py +20 -33
  55. agenta/client/backend/types/get_config_response.py +16 -31
  56. agenta/client/backend/types/http_validation_error.py +14 -29
  57. agenta/client/backend/types/human_evaluation.py +17 -32
  58. agenta/client/backend/types/human_evaluation_scenario.py +21 -37
  59. agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
  60. agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
  61. agenta/client/backend/types/human_evaluation_scenario_update.py +26 -41
  62. agenta/client/backend/types/human_evaluation_update.py +14 -29
  63. agenta/client/backend/types/image.py +18 -33
  64. agenta/client/backend/types/invite_request.py +13 -28
  65. agenta/client/backend/types/list_api_keys_response.py +18 -33
  66. agenta/client/backend/types/llm_run_rate_limit.py +13 -28
  67. agenta/client/backend/types/llm_tokens.py +16 -31
  68. agenta/client/backend/types/lm_providers_enum.py +21 -0
  69. agenta/client/backend/types/new_human_evaluation.py +13 -28
  70. agenta/client/backend/types/new_testset.py +16 -31
  71. agenta/client/backend/types/organization.py +22 -36
  72. agenta/client/backend/types/organization_output.py +13 -28
  73. agenta/client/backend/types/outputs.py +5 -0
  74. agenta/client/backend/types/permission.py +36 -137
  75. agenta/client/backend/types/result.py +17 -32
  76. agenta/client/backend/types/simple_evaluation_output.py +13 -28
  77. agenta/client/backend/types/span.py +23 -38
  78. agenta/client/backend/types/span_detail.py +26 -40
  79. agenta/client/backend/types/span_status_code.py +1 -25
  80. agenta/client/backend/types/span_variant.py +16 -31
  81. agenta/client/backend/types/template.py +14 -29
  82. agenta/client/backend/types/template_image_info.py +21 -35
  83. agenta/client/backend/types/test_set_output_response.py +16 -32
  84. agenta/client/backend/types/test_set_simple_response.py +13 -28
  85. agenta/client/backend/types/trace_detail.py +26 -40
  86. agenta/client/backend/types/update_app_output.py +22 -0
  87. agenta/client/backend/types/uri.py +13 -28
  88. agenta/client/backend/types/validation_error.py +13 -28
  89. agenta/client/backend/types/variant_action.py +14 -29
  90. agenta/client/backend/types/variant_action_enum.py +1 -19
  91. agenta/client/backend/types/with_pagination.py +14 -30
  92. agenta/client/backend/types/workspace_member_response.py +14 -29
  93. agenta/client/backend/types/workspace_permission.py +18 -33
  94. agenta/client/backend/types/workspace_response.py +20 -35
  95. agenta/client/backend/types/workspace_role.py +11 -37
  96. agenta/client/backend/types/workspace_role_response.py +17 -32
  97. agenta/client/backend/variants/client.py +1447 -0
  98. agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
  99. agenta/sdk/decorators/llm_entrypoint.py +8 -13
  100. agenta/sdk/tracing/llm_tracing.py +10 -12
  101. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/METADATA +1 -1
  102. agenta-0.24.2.dist-info/RECORD +175 -0
  103. agenta/client/backend/resources/__init__.py +0 -31
  104. agenta/client/backend/resources/apps/client.py +0 -977
  105. agenta/client/backend/resources/bases/client.py +0 -127
  106. agenta/client/backend/resources/configs/client.py +0 -377
  107. agenta/client/backend/resources/containers/client.py +0 -383
  108. agenta/client/backend/resources/environments/client.py +0 -131
  109. agenta/client/backend/resources/evaluations/client.py +0 -1008
  110. agenta/client/backend/resources/evaluators/client.py +0 -594
  111. agenta/client/backend/resources/observability/client.py +0 -1187
  112. agenta/client/backend/resources/testsets/client.py +0 -689
  113. agenta/client/backend/resources/variants/client.py +0 -796
  114. agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -7
  115. agenta/client/backend/types/evaluation_webhook.py +0 -36
  116. agenta/client/backend/types/feedback.py +0 -40
  117. agenta/client/backend/types/span_kind.py +0 -49
  118. agenta-0.24.1a0.dist-info/RECORD +0 -169
  119. /agenta/client/backend/{resources/apps → apps}/__init__.py +0 -0
  120. /agenta/client/backend/{resources/bases → bases}/__init__.py +0 -0
  121. /agenta/client/backend/{resources/configs → configs}/__init__.py +0 -0
  122. /agenta/client/backend/{resources/containers → containers}/__init__.py +0 -0
  123. /agenta/client/backend/{resources/containers → containers}/types/__init__.py +0 -0
  124. /agenta/client/backend/{resources/environments → environments}/__init__.py +0 -0
  125. /agenta/client/backend/{resources/evaluations → evaluations}/__init__.py +0 -0
  126. /agenta/client/backend/{resources/evaluators → evaluators}/__init__.py +0 -0
  127. /agenta/client/backend/{resources/observability → observability}/__init__.py +0 -0
  128. /agenta/client/backend/{resources/testsets → testsets}/__init__.py +0 -0
  129. /agenta/client/backend/{resources/variants → variants}/__init__.py +0 -0
  130. /agenta/client/backend/{resources/variants → variants}/types/__init__.py +0 -0
  131. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/WHEEL +0 -0
  132. {agenta-0.24.1a0.dist-info → agenta-0.24.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,1669 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from ..core.request_options import RequestOptions
6
+ from ..types.app_variant_response import AppVariantResponse
7
+ from ..core.jsonable_encoder import jsonable_encoder
8
+ from ..core.pydantic_utilities import parse_obj_as
9
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
10
+ from ..types.http_validation_error import HttpValidationError
11
+ from json.decoder import JSONDecodeError
12
+ from ..core.api_error import ApiError
13
+ from ..types.app import App
14
+ from ..types.create_app_output import CreateAppOutput
15
+ from ..types.update_app_output import UpdateAppOutput
16
+ from ..types.environment_output import EnvironmentOutput
17
+ from ..types.environment_output_extended import EnvironmentOutputExtended
18
+ from ..core.client_wrapper import AsyncClientWrapper
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class AppsClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+
28
+ def list_app_variants(
29
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
30
+ ) -> typing.List[AppVariantResponse]:
31
+ """
32
+ Retrieve a list of app variants for a given app ID.
33
+
34
+ Args:
35
+ app_id (str): The ID of the app to retrieve variants for.
36
+ stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
37
+
38
+ Returns:
39
+ List[AppVariantResponse]: A list of app variants for the given app ID.
40
+
41
+ Parameters
42
+ ----------
43
+ app_id : str
44
+
45
+ request_options : typing.Optional[RequestOptions]
46
+ Request-specific configuration.
47
+
48
+ Returns
49
+ -------
50
+ typing.List[AppVariantResponse]
51
+ Successful Response
52
+
53
+ Examples
54
+ --------
55
+ from agenta import AgentaApi
56
+
57
+ client = AgentaApi(
58
+ api_key="YOUR_API_KEY",
59
+ base_url="https://yourhost.com/path/to/api",
60
+ )
61
+ client.apps.list_app_variants(
62
+ app_id="app_id",
63
+ )
64
+ """
65
+ _response = self._client_wrapper.httpx_client.request(
66
+ f"apps/{jsonable_encoder(app_id)}/variants",
67
+ method="GET",
68
+ request_options=request_options,
69
+ )
70
+ try:
71
+ if 200 <= _response.status_code < 300:
72
+ return typing.cast(
73
+ typing.List[AppVariantResponse],
74
+ parse_obj_as(
75
+ type_=typing.List[AppVariantResponse], # type: ignore
76
+ object_=_response.json(),
77
+ ),
78
+ )
79
+ if _response.status_code == 422:
80
+ raise UnprocessableEntityError(
81
+ typing.cast(
82
+ HttpValidationError,
83
+ parse_obj_as(
84
+ type_=HttpValidationError, # type: ignore
85
+ object_=_response.json(),
86
+ ),
87
+ )
88
+ )
89
+ _response_json = _response.json()
90
+ except JSONDecodeError:
91
+ raise ApiError(status_code=_response.status_code, body=_response.text)
92
+ raise ApiError(status_code=_response.status_code, body=_response_json)
93
+
94
+ def get_variant_by_env(
95
+ self,
96
+ *,
97
+ app_id: str,
98
+ environment: str,
99
+ request_options: typing.Optional[RequestOptions] = None,
100
+ ) -> AppVariantResponse:
101
+ """
102
+ Retrieve the app variant based on the provided app_id and environment.
103
+
104
+ Args:
105
+ app_id (str): The ID of the app to retrieve the variant for.
106
+ environment (str): The environment of the app variant to retrieve.
107
+ stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
108
+
109
+ Raises:
110
+ 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).
111
+
112
+ Returns:
113
+ AppVariantResponse: The retrieved app variant.
114
+
115
+ Parameters
116
+ ----------
117
+ app_id : str
118
+
119
+ environment : str
120
+
121
+ request_options : typing.Optional[RequestOptions]
122
+ Request-specific configuration.
123
+
124
+ Returns
125
+ -------
126
+ AppVariantResponse
127
+ Successful Response
128
+
129
+ Examples
130
+ --------
131
+ from agenta import AgentaApi
132
+
133
+ client = AgentaApi(
134
+ api_key="YOUR_API_KEY",
135
+ base_url="https://yourhost.com/path/to/api",
136
+ )
137
+ client.apps.get_variant_by_env(
138
+ app_id="app_id",
139
+ environment="environment",
140
+ )
141
+ """
142
+ _response = self._client_wrapper.httpx_client.request(
143
+ "apps/get_variant_by_env",
144
+ method="GET",
145
+ params={
146
+ "app_id": app_id,
147
+ "environment": environment,
148
+ },
149
+ request_options=request_options,
150
+ )
151
+ try:
152
+ if 200 <= _response.status_code < 300:
153
+ return typing.cast(
154
+ AppVariantResponse,
155
+ parse_obj_as(
156
+ type_=AppVariantResponse, # type: ignore
157
+ object_=_response.json(),
158
+ ),
159
+ )
160
+ if _response.status_code == 422:
161
+ raise UnprocessableEntityError(
162
+ typing.cast(
163
+ HttpValidationError,
164
+ parse_obj_as(
165
+ type_=HttpValidationError, # type: ignore
166
+ object_=_response.json(),
167
+ ),
168
+ )
169
+ )
170
+ _response_json = _response.json()
171
+ except JSONDecodeError:
172
+ raise ApiError(status_code=_response.status_code, body=_response.text)
173
+ raise ApiError(status_code=_response.status_code, body=_response_json)
174
+
175
+ def list_apps(
176
+ self,
177
+ *,
178
+ app_name: typing.Optional[str] = None,
179
+ org_id: typing.Optional[str] = None,
180
+ workspace_id: typing.Optional[str] = None,
181
+ request_options: typing.Optional[RequestOptions] = None,
182
+ ) -> typing.List[App]:
183
+ """
184
+ Retrieve a list of apps filtered by app_name and org_id.
185
+
186
+ Args:
187
+ app_name (Optional[str]): The name of the app to filter by.
188
+ org_id (Optional[str]): The ID of the organization to filter by.
189
+ stoken_session (SessionContainer): The session container.
190
+
191
+ Returns:
192
+ List[App]: A list of apps filtered by app_name and org_id.
193
+
194
+ Raises:
195
+ HTTPException: If there was an error retrieving the list of apps.
196
+
197
+ Parameters
198
+ ----------
199
+ app_name : typing.Optional[str]
200
+
201
+ org_id : typing.Optional[str]
202
+
203
+ workspace_id : typing.Optional[str]
204
+
205
+ request_options : typing.Optional[RequestOptions]
206
+ Request-specific configuration.
207
+
208
+ Returns
209
+ -------
210
+ typing.List[App]
211
+ Successful Response
212
+
213
+ Examples
214
+ --------
215
+ from agenta import AgentaApi
216
+
217
+ client = AgentaApi(
218
+ api_key="YOUR_API_KEY",
219
+ base_url="https://yourhost.com/path/to/api",
220
+ )
221
+ client.apps.list_apps()
222
+ """
223
+ _response = self._client_wrapper.httpx_client.request(
224
+ "apps",
225
+ method="GET",
226
+ params={
227
+ "app_name": app_name,
228
+ "org_id": org_id,
229
+ "workspace_id": workspace_id,
230
+ },
231
+ request_options=request_options,
232
+ )
233
+ try:
234
+ if 200 <= _response.status_code < 300:
235
+ return typing.cast(
236
+ typing.List[App],
237
+ parse_obj_as(
238
+ type_=typing.List[App], # type: ignore
239
+ object_=_response.json(),
240
+ ),
241
+ )
242
+ if _response.status_code == 422:
243
+ raise UnprocessableEntityError(
244
+ typing.cast(
245
+ HttpValidationError,
246
+ parse_obj_as(
247
+ type_=HttpValidationError, # type: ignore
248
+ object_=_response.json(),
249
+ ),
250
+ )
251
+ )
252
+ _response_json = _response.json()
253
+ except JSONDecodeError:
254
+ raise ApiError(status_code=_response.status_code, body=_response.text)
255
+ raise ApiError(status_code=_response.status_code, body=_response_json)
256
+
257
+ def create_app(
258
+ self,
259
+ *,
260
+ app_name: str,
261
+ organization_id: typing.Optional[str] = OMIT,
262
+ workspace_id: typing.Optional[str] = OMIT,
263
+ request_options: typing.Optional[RequestOptions] = None,
264
+ ) -> CreateAppOutput:
265
+ """
266
+ Create a new app for a user or organization.
267
+
268
+ Args:
269
+ payload (CreateApp): The payload containing the app name and organization ID (optional).
270
+ stoken_session (SessionContainer): The session container containing the user's session token.
271
+
272
+ Returns:
273
+ CreateAppOutput: The output containing the newly created app's ID and name.
274
+
275
+ Raises:
276
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
277
+
278
+ Parameters
279
+ ----------
280
+ app_name : str
281
+
282
+ organization_id : typing.Optional[str]
283
+
284
+ workspace_id : typing.Optional[str]
285
+
286
+ request_options : typing.Optional[RequestOptions]
287
+ Request-specific configuration.
288
+
289
+ Returns
290
+ -------
291
+ CreateAppOutput
292
+ Successful Response
293
+
294
+ Examples
295
+ --------
296
+ from agenta import AgentaApi
297
+
298
+ client = AgentaApi(
299
+ api_key="YOUR_API_KEY",
300
+ base_url="https://yourhost.com/path/to/api",
301
+ )
302
+ client.apps.create_app(
303
+ app_name="app_name",
304
+ )
305
+ """
306
+ _response = self._client_wrapper.httpx_client.request(
307
+ "apps",
308
+ method="POST",
309
+ json={
310
+ "app_name": app_name,
311
+ "organization_id": organization_id,
312
+ "workspace_id": workspace_id,
313
+ },
314
+ request_options=request_options,
315
+ omit=OMIT,
316
+ )
317
+ try:
318
+ if 200 <= _response.status_code < 300:
319
+ return typing.cast(
320
+ CreateAppOutput,
321
+ parse_obj_as(
322
+ type_=CreateAppOutput, # type: ignore
323
+ object_=_response.json(),
324
+ ),
325
+ )
326
+ if _response.status_code == 422:
327
+ raise UnprocessableEntityError(
328
+ typing.cast(
329
+ HttpValidationError,
330
+ parse_obj_as(
331
+ type_=HttpValidationError, # type: ignore
332
+ object_=_response.json(),
333
+ ),
334
+ )
335
+ )
336
+ _response_json = _response.json()
337
+ except JSONDecodeError:
338
+ raise ApiError(status_code=_response.status_code, body=_response.text)
339
+ raise ApiError(status_code=_response.status_code, body=_response_json)
340
+
341
+ def remove_app(
342
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
343
+ ) -> typing.Optional[typing.Any]:
344
+ """
345
+ Remove app, all its variant, containers and images
346
+
347
+ Arguments:
348
+ app -- App to remove
349
+
350
+ Parameters
351
+ ----------
352
+ app_id : str
353
+
354
+ request_options : typing.Optional[RequestOptions]
355
+ Request-specific configuration.
356
+
357
+ Returns
358
+ -------
359
+ typing.Optional[typing.Any]
360
+ Successful Response
361
+
362
+ Examples
363
+ --------
364
+ from agenta import AgentaApi
365
+
366
+ client = AgentaApi(
367
+ api_key="YOUR_API_KEY",
368
+ base_url="https://yourhost.com/path/to/api",
369
+ )
370
+ client.apps.remove_app(
371
+ app_id="app_id",
372
+ )
373
+ """
374
+ _response = self._client_wrapper.httpx_client.request(
375
+ f"apps/{jsonable_encoder(app_id)}",
376
+ method="DELETE",
377
+ request_options=request_options,
378
+ )
379
+ try:
380
+ if 200 <= _response.status_code < 300:
381
+ return typing.cast(
382
+ typing.Optional[typing.Any],
383
+ parse_obj_as(
384
+ type_=typing.Optional[typing.Any], # type: ignore
385
+ object_=_response.json(),
386
+ ),
387
+ )
388
+ if _response.status_code == 422:
389
+ raise UnprocessableEntityError(
390
+ typing.cast(
391
+ HttpValidationError,
392
+ parse_obj_as(
393
+ type_=HttpValidationError, # type: ignore
394
+ object_=_response.json(),
395
+ ),
396
+ )
397
+ )
398
+ _response_json = _response.json()
399
+ except JSONDecodeError:
400
+ raise ApiError(status_code=_response.status_code, body=_response.text)
401
+ raise ApiError(status_code=_response.status_code, body=_response_json)
402
+
403
+ def update_app(
404
+ self,
405
+ app_id: str,
406
+ *,
407
+ app_name: str,
408
+ request_options: typing.Optional[RequestOptions] = None,
409
+ ) -> UpdateAppOutput:
410
+ """
411
+ Update an app for a user or organization.
412
+
413
+ Args:
414
+ app_id (str): The ID of the app.
415
+ payload (UpdateApp): The payload containing the app name.
416
+ stoken_session (SessionContainer): The session container containing the user's session token.
417
+
418
+ Returns:
419
+ UpdateAppOuput: The output containing the newly created app's ID and name.
420
+
421
+ Raises:
422
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
423
+
424
+ Parameters
425
+ ----------
426
+ app_id : str
427
+
428
+ app_name : str
429
+
430
+ request_options : typing.Optional[RequestOptions]
431
+ Request-specific configuration.
432
+
433
+ Returns
434
+ -------
435
+ UpdateAppOutput
436
+ Successful Response
437
+
438
+ Examples
439
+ --------
440
+ from agenta import AgentaApi
441
+
442
+ client = AgentaApi(
443
+ api_key="YOUR_API_KEY",
444
+ base_url="https://yourhost.com/path/to/api",
445
+ )
446
+ client.apps.update_app(
447
+ app_id="app_id",
448
+ app_name="app_name",
449
+ )
450
+ """
451
+ _response = self._client_wrapper.httpx_client.request(
452
+ f"apps/{jsonable_encoder(app_id)}",
453
+ method="PATCH",
454
+ json={
455
+ "app_name": app_name,
456
+ },
457
+ request_options=request_options,
458
+ omit=OMIT,
459
+ )
460
+ try:
461
+ if 200 <= _response.status_code < 300:
462
+ return typing.cast(
463
+ UpdateAppOutput,
464
+ parse_obj_as(
465
+ type_=UpdateAppOutput, # type: ignore
466
+ object_=_response.json(),
467
+ ),
468
+ )
469
+ if _response.status_code == 422:
470
+ raise UnprocessableEntityError(
471
+ typing.cast(
472
+ HttpValidationError,
473
+ parse_obj_as(
474
+ type_=HttpValidationError, # type: ignore
475
+ object_=_response.json(),
476
+ ),
477
+ )
478
+ )
479
+ _response_json = _response.json()
480
+ except JSONDecodeError:
481
+ raise ApiError(status_code=_response.status_code, body=_response.text)
482
+ raise ApiError(status_code=_response.status_code, body=_response_json)
483
+
484
+ def add_variant_from_image(
485
+ self,
486
+ app_id: str,
487
+ *,
488
+ variant_name: str,
489
+ docker_id: str,
490
+ tags: str,
491
+ base_name: typing.Optional[str] = OMIT,
492
+ config_name: typing.Optional[str] = OMIT,
493
+ request_options: typing.Optional[RequestOptions] = None,
494
+ ) -> typing.Optional[typing.Any]:
495
+ """
496
+ Add a new variant to an app based on a Docker image.
497
+
498
+ Args:
499
+ app_id (str): The ID of the app to add the variant to.
500
+ payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
501
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
502
+
503
+ Raises:
504
+ 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.
505
+
506
+ Returns:
507
+ dict: The newly added variant.
508
+
509
+ Parameters
510
+ ----------
511
+ app_id : str
512
+
513
+ variant_name : str
514
+
515
+ docker_id : str
516
+
517
+ tags : str
518
+
519
+ base_name : typing.Optional[str]
520
+
521
+ config_name : typing.Optional[str]
522
+
523
+ request_options : typing.Optional[RequestOptions]
524
+ Request-specific configuration.
525
+
526
+ Returns
527
+ -------
528
+ typing.Optional[typing.Any]
529
+ Successful Response
530
+
531
+ Examples
532
+ --------
533
+ from agenta import AgentaApi
534
+
535
+ client = AgentaApi(
536
+ api_key="YOUR_API_KEY",
537
+ base_url="https://yourhost.com/path/to/api",
538
+ )
539
+ client.apps.add_variant_from_image(
540
+ app_id="app_id",
541
+ variant_name="variant_name",
542
+ docker_id="docker_id",
543
+ tags="tags",
544
+ )
545
+ """
546
+ _response = self._client_wrapper.httpx_client.request(
547
+ f"apps/{jsonable_encoder(app_id)}/variant/from-image",
548
+ method="POST",
549
+ json={
550
+ "variant_name": variant_name,
551
+ "docker_id": docker_id,
552
+ "tags": tags,
553
+ "base_name": base_name,
554
+ "config_name": config_name,
555
+ },
556
+ request_options=request_options,
557
+ omit=OMIT,
558
+ )
559
+ try:
560
+ if 200 <= _response.status_code < 300:
561
+ return typing.cast(
562
+ typing.Optional[typing.Any],
563
+ parse_obj_as(
564
+ type_=typing.Optional[typing.Any], # type: ignore
565
+ object_=_response.json(),
566
+ ),
567
+ )
568
+ if _response.status_code == 422:
569
+ raise UnprocessableEntityError(
570
+ typing.cast(
571
+ HttpValidationError,
572
+ parse_obj_as(
573
+ type_=HttpValidationError, # type: ignore
574
+ object_=_response.json(),
575
+ ),
576
+ )
577
+ )
578
+ _response_json = _response.json()
579
+ except JSONDecodeError:
580
+ raise ApiError(status_code=_response.status_code, body=_response.text)
581
+ raise ApiError(status_code=_response.status_code, body=_response_json)
582
+
583
+ def create_app_and_variant_from_template(
584
+ self,
585
+ *,
586
+ app_name: str,
587
+ template_id: str,
588
+ env_vars: typing.Dict[str, str],
589
+ organization_id: typing.Optional[str] = OMIT,
590
+ workspace_id: typing.Optional[str] = OMIT,
591
+ request_options: typing.Optional[RequestOptions] = None,
592
+ ) -> AppVariantResponse:
593
+ """
594
+ Create an app and variant from a template.
595
+
596
+ Args:
597
+ payload (CreateAppVariant): The payload containing the app and variant information.
598
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
599
+
600
+ Raises:
601
+ HTTPException: If the user has reached the app limit or if an app with the same name already exists.
602
+
603
+ Returns:
604
+ AppVariantResponse: The output of the created app variant.
605
+
606
+ Parameters
607
+ ----------
608
+ app_name : str
609
+
610
+ template_id : str
611
+
612
+ env_vars : typing.Dict[str, str]
613
+
614
+ organization_id : typing.Optional[str]
615
+
616
+ workspace_id : typing.Optional[str]
617
+
618
+ request_options : typing.Optional[RequestOptions]
619
+ Request-specific configuration.
620
+
621
+ Returns
622
+ -------
623
+ AppVariantResponse
624
+ Successful Response
625
+
626
+ Examples
627
+ --------
628
+ from agenta import AgentaApi
629
+
630
+ client = AgentaApi(
631
+ api_key="YOUR_API_KEY",
632
+ base_url="https://yourhost.com/path/to/api",
633
+ )
634
+ client.apps.create_app_and_variant_from_template(
635
+ app_name="app_name",
636
+ template_id="template_id",
637
+ env_vars={"key": "value"},
638
+ )
639
+ """
640
+ _response = self._client_wrapper.httpx_client.request(
641
+ "apps/app_and_variant_from_template",
642
+ method="POST",
643
+ json={
644
+ "app_name": app_name,
645
+ "template_id": template_id,
646
+ "env_vars": env_vars,
647
+ "organization_id": organization_id,
648
+ "workspace_id": workspace_id,
649
+ },
650
+ request_options=request_options,
651
+ omit=OMIT,
652
+ )
653
+ try:
654
+ if 200 <= _response.status_code < 300:
655
+ return typing.cast(
656
+ AppVariantResponse,
657
+ parse_obj_as(
658
+ type_=AppVariantResponse, # type: ignore
659
+ object_=_response.json(),
660
+ ),
661
+ )
662
+ if _response.status_code == 422:
663
+ raise UnprocessableEntityError(
664
+ typing.cast(
665
+ HttpValidationError,
666
+ parse_obj_as(
667
+ type_=HttpValidationError, # type: ignore
668
+ object_=_response.json(),
669
+ ),
670
+ )
671
+ )
672
+ _response_json = _response.json()
673
+ except JSONDecodeError:
674
+ raise ApiError(status_code=_response.status_code, body=_response.text)
675
+ raise ApiError(status_code=_response.status_code, body=_response_json)
676
+
677
+ def list_environments(
678
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
679
+ ) -> typing.List[EnvironmentOutput]:
680
+ """
681
+ Retrieve a list of environments for a given app ID.
682
+
683
+ Args:
684
+ app_id (str): The ID of the app to retrieve environments for.
685
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
686
+
687
+ Returns:
688
+ List[EnvironmentOutput]: A list of environment objects.
689
+
690
+ Parameters
691
+ ----------
692
+ app_id : str
693
+
694
+ request_options : typing.Optional[RequestOptions]
695
+ Request-specific configuration.
696
+
697
+ Returns
698
+ -------
699
+ typing.List[EnvironmentOutput]
700
+ Successful Response
701
+
702
+ Examples
703
+ --------
704
+ from agenta import AgentaApi
705
+
706
+ client = AgentaApi(
707
+ api_key="YOUR_API_KEY",
708
+ base_url="https://yourhost.com/path/to/api",
709
+ )
710
+ client.apps.list_environments(
711
+ app_id="app_id",
712
+ )
713
+ """
714
+ _response = self._client_wrapper.httpx_client.request(
715
+ f"apps/{jsonable_encoder(app_id)}/environments",
716
+ method="GET",
717
+ request_options=request_options,
718
+ )
719
+ try:
720
+ if 200 <= _response.status_code < 300:
721
+ return typing.cast(
722
+ typing.List[EnvironmentOutput],
723
+ parse_obj_as(
724
+ type_=typing.List[EnvironmentOutput], # type: ignore
725
+ object_=_response.json(),
726
+ ),
727
+ )
728
+ if _response.status_code == 422:
729
+ raise UnprocessableEntityError(
730
+ typing.cast(
731
+ HttpValidationError,
732
+ parse_obj_as(
733
+ type_=HttpValidationError, # type: ignore
734
+ object_=_response.json(),
735
+ ),
736
+ )
737
+ )
738
+ _response_json = _response.json()
739
+ except JSONDecodeError:
740
+ raise ApiError(status_code=_response.status_code, body=_response.text)
741
+ raise ApiError(status_code=_response.status_code, body=_response_json)
742
+
743
+ def environment_revisions(
744
+ self,
745
+ app_id: str,
746
+ environment_name: typing.Optional[typing.Any],
747
+ *,
748
+ request_options: typing.Optional[RequestOptions] = None,
749
+ ) -> EnvironmentOutputExtended:
750
+ """
751
+ Parameters
752
+ ----------
753
+ app_id : str
754
+
755
+ environment_name : typing.Optional[typing.Any]
756
+
757
+ request_options : typing.Optional[RequestOptions]
758
+ Request-specific configuration.
759
+
760
+ Returns
761
+ -------
762
+ EnvironmentOutputExtended
763
+ Successful Response
764
+
765
+ Examples
766
+ --------
767
+ from agenta import AgentaApi
768
+
769
+ client = AgentaApi(
770
+ api_key="YOUR_API_KEY",
771
+ base_url="https://yourhost.com/path/to/api",
772
+ )
773
+ client.apps.environment_revisions(
774
+ app_id="string",
775
+ environment_name={"key": "value"},
776
+ )
777
+ """
778
+ _response = self._client_wrapper.httpx_client.request(
779
+ f"apps/{jsonable_encoder(app_id)}/revisions/{jsonable_encoder(environment_name)}",
780
+ method="GET",
781
+ request_options=request_options,
782
+ )
783
+ try:
784
+ if 200 <= _response.status_code < 300:
785
+ return typing.cast(
786
+ EnvironmentOutputExtended,
787
+ parse_obj_as(
788
+ type_=EnvironmentOutputExtended, # type: ignore
789
+ object_=_response.json(),
790
+ ),
791
+ )
792
+ if _response.status_code == 422:
793
+ raise UnprocessableEntityError(
794
+ typing.cast(
795
+ HttpValidationError,
796
+ parse_obj_as(
797
+ type_=HttpValidationError, # type: ignore
798
+ object_=_response.json(),
799
+ ),
800
+ )
801
+ )
802
+ _response_json = _response.json()
803
+ except JSONDecodeError:
804
+ raise ApiError(status_code=_response.status_code, body=_response.text)
805
+ raise ApiError(status_code=_response.status_code, body=_response_json)
806
+
807
+
808
+ class AsyncAppsClient:
809
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
810
+ self._client_wrapper = client_wrapper
811
+
812
+ async def list_app_variants(
813
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
814
+ ) -> typing.List[AppVariantResponse]:
815
+ """
816
+ Retrieve a list of app variants for a given app ID.
817
+
818
+ Args:
819
+ app_id (str): The ID of the app to retrieve variants for.
820
+ stoken_session (SessionContainer, optional): The session container to verify the user's session. Defaults to Depends(verify_session()).
821
+
822
+ Returns:
823
+ List[AppVariantResponse]: A list of app variants for the given app ID.
824
+
825
+ Parameters
826
+ ----------
827
+ app_id : str
828
+
829
+ request_options : typing.Optional[RequestOptions]
830
+ Request-specific configuration.
831
+
832
+ Returns
833
+ -------
834
+ typing.List[AppVariantResponse]
835
+ Successful Response
836
+
837
+ Examples
838
+ --------
839
+ import asyncio
840
+
841
+ from agenta import AsyncAgentaApi
842
+
843
+ client = AsyncAgentaApi(
844
+ api_key="YOUR_API_KEY",
845
+ base_url="https://yourhost.com/path/to/api",
846
+ )
847
+
848
+
849
+ async def main() -> None:
850
+ await client.apps.list_app_variants(
851
+ app_id="app_id",
852
+ )
853
+
854
+
855
+ asyncio.run(main())
856
+ """
857
+ _response = await self._client_wrapper.httpx_client.request(
858
+ f"apps/{jsonable_encoder(app_id)}/variants",
859
+ method="GET",
860
+ request_options=request_options,
861
+ )
862
+ try:
863
+ if 200 <= _response.status_code < 300:
864
+ return typing.cast(
865
+ typing.List[AppVariantResponse],
866
+ parse_obj_as(
867
+ type_=typing.List[AppVariantResponse], # type: ignore
868
+ object_=_response.json(),
869
+ ),
870
+ )
871
+ if _response.status_code == 422:
872
+ raise UnprocessableEntityError(
873
+ typing.cast(
874
+ HttpValidationError,
875
+ parse_obj_as(
876
+ type_=HttpValidationError, # type: ignore
877
+ object_=_response.json(),
878
+ ),
879
+ )
880
+ )
881
+ _response_json = _response.json()
882
+ except JSONDecodeError:
883
+ raise ApiError(status_code=_response.status_code, body=_response.text)
884
+ raise ApiError(status_code=_response.status_code, body=_response_json)
885
+
886
+ async def get_variant_by_env(
887
+ self,
888
+ *,
889
+ app_id: str,
890
+ environment: str,
891
+ request_options: typing.Optional[RequestOptions] = None,
892
+ ) -> AppVariantResponse:
893
+ """
894
+ Retrieve the app variant based on the provided app_id and environment.
895
+
896
+ Args:
897
+ app_id (str): The ID of the app to retrieve the variant for.
898
+ environment (str): The environment of the app variant to retrieve.
899
+ stoken_session (SessionContainer, optional): The session token container. Defaults to Depends(verify_session()).
900
+
901
+ Raises:
902
+ 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).
903
+
904
+ Returns:
905
+ AppVariantResponse: The retrieved app variant.
906
+
907
+ Parameters
908
+ ----------
909
+ app_id : str
910
+
911
+ environment : str
912
+
913
+ request_options : typing.Optional[RequestOptions]
914
+ Request-specific configuration.
915
+
916
+ Returns
917
+ -------
918
+ AppVariantResponse
919
+ Successful Response
920
+
921
+ Examples
922
+ --------
923
+ import asyncio
924
+
925
+ from agenta import AsyncAgentaApi
926
+
927
+ client = AsyncAgentaApi(
928
+ api_key="YOUR_API_KEY",
929
+ base_url="https://yourhost.com/path/to/api",
930
+ )
931
+
932
+
933
+ async def main() -> None:
934
+ await client.apps.get_variant_by_env(
935
+ app_id="app_id",
936
+ environment="environment",
937
+ )
938
+
939
+
940
+ asyncio.run(main())
941
+ """
942
+ _response = await self._client_wrapper.httpx_client.request(
943
+ "apps/get_variant_by_env",
944
+ method="GET",
945
+ params={
946
+ "app_id": app_id,
947
+ "environment": environment,
948
+ },
949
+ request_options=request_options,
950
+ )
951
+ try:
952
+ if 200 <= _response.status_code < 300:
953
+ return typing.cast(
954
+ AppVariantResponse,
955
+ parse_obj_as(
956
+ type_=AppVariantResponse, # type: ignore
957
+ object_=_response.json(),
958
+ ),
959
+ )
960
+ if _response.status_code == 422:
961
+ raise UnprocessableEntityError(
962
+ typing.cast(
963
+ HttpValidationError,
964
+ parse_obj_as(
965
+ type_=HttpValidationError, # type: ignore
966
+ object_=_response.json(),
967
+ ),
968
+ )
969
+ )
970
+ _response_json = _response.json()
971
+ except JSONDecodeError:
972
+ raise ApiError(status_code=_response.status_code, body=_response.text)
973
+ raise ApiError(status_code=_response.status_code, body=_response_json)
974
+
975
+ async def list_apps(
976
+ self,
977
+ *,
978
+ app_name: typing.Optional[str] = None,
979
+ org_id: typing.Optional[str] = None,
980
+ workspace_id: typing.Optional[str] = None,
981
+ request_options: typing.Optional[RequestOptions] = None,
982
+ ) -> typing.List[App]:
983
+ """
984
+ Retrieve a list of apps filtered by app_name and org_id.
985
+
986
+ Args:
987
+ app_name (Optional[str]): The name of the app to filter by.
988
+ org_id (Optional[str]): The ID of the organization to filter by.
989
+ stoken_session (SessionContainer): The session container.
990
+
991
+ Returns:
992
+ List[App]: A list of apps filtered by app_name and org_id.
993
+
994
+ Raises:
995
+ HTTPException: If there was an error retrieving the list of apps.
996
+
997
+ Parameters
998
+ ----------
999
+ app_name : typing.Optional[str]
1000
+
1001
+ org_id : typing.Optional[str]
1002
+
1003
+ workspace_id : typing.Optional[str]
1004
+
1005
+ request_options : typing.Optional[RequestOptions]
1006
+ Request-specific configuration.
1007
+
1008
+ Returns
1009
+ -------
1010
+ typing.List[App]
1011
+ Successful Response
1012
+
1013
+ Examples
1014
+ --------
1015
+ import asyncio
1016
+
1017
+ from agenta import AsyncAgentaApi
1018
+
1019
+ client = AsyncAgentaApi(
1020
+ api_key="YOUR_API_KEY",
1021
+ base_url="https://yourhost.com/path/to/api",
1022
+ )
1023
+
1024
+
1025
+ async def main() -> None:
1026
+ await client.apps.list_apps()
1027
+
1028
+
1029
+ asyncio.run(main())
1030
+ """
1031
+ _response = await self._client_wrapper.httpx_client.request(
1032
+ "apps",
1033
+ method="GET",
1034
+ params={
1035
+ "app_name": app_name,
1036
+ "org_id": org_id,
1037
+ "workspace_id": workspace_id,
1038
+ },
1039
+ request_options=request_options,
1040
+ )
1041
+ try:
1042
+ if 200 <= _response.status_code < 300:
1043
+ return typing.cast(
1044
+ typing.List[App],
1045
+ parse_obj_as(
1046
+ type_=typing.List[App], # type: ignore
1047
+ object_=_response.json(),
1048
+ ),
1049
+ )
1050
+ if _response.status_code == 422:
1051
+ raise UnprocessableEntityError(
1052
+ typing.cast(
1053
+ HttpValidationError,
1054
+ parse_obj_as(
1055
+ type_=HttpValidationError, # type: ignore
1056
+ object_=_response.json(),
1057
+ ),
1058
+ )
1059
+ )
1060
+ _response_json = _response.json()
1061
+ except JSONDecodeError:
1062
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1063
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1064
+
1065
+ async def create_app(
1066
+ self,
1067
+ *,
1068
+ app_name: str,
1069
+ organization_id: typing.Optional[str] = OMIT,
1070
+ workspace_id: typing.Optional[str] = OMIT,
1071
+ request_options: typing.Optional[RequestOptions] = None,
1072
+ ) -> CreateAppOutput:
1073
+ """
1074
+ Create a new app for a user or organization.
1075
+
1076
+ Args:
1077
+ payload (CreateApp): The payload containing the app name and organization ID (optional).
1078
+ stoken_session (SessionContainer): The session container containing the user's session token.
1079
+
1080
+ Returns:
1081
+ CreateAppOutput: The output containing the newly created app's ID and name.
1082
+
1083
+ Raises:
1084
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1085
+
1086
+ Parameters
1087
+ ----------
1088
+ app_name : str
1089
+
1090
+ organization_id : typing.Optional[str]
1091
+
1092
+ workspace_id : typing.Optional[str]
1093
+
1094
+ request_options : typing.Optional[RequestOptions]
1095
+ Request-specific configuration.
1096
+
1097
+ Returns
1098
+ -------
1099
+ CreateAppOutput
1100
+ Successful Response
1101
+
1102
+ Examples
1103
+ --------
1104
+ import asyncio
1105
+
1106
+ from agenta import AsyncAgentaApi
1107
+
1108
+ client = AsyncAgentaApi(
1109
+ api_key="YOUR_API_KEY",
1110
+ base_url="https://yourhost.com/path/to/api",
1111
+ )
1112
+
1113
+
1114
+ async def main() -> None:
1115
+ await client.apps.create_app(
1116
+ app_name="app_name",
1117
+ )
1118
+
1119
+
1120
+ asyncio.run(main())
1121
+ """
1122
+ _response = await self._client_wrapper.httpx_client.request(
1123
+ "apps",
1124
+ method="POST",
1125
+ json={
1126
+ "app_name": app_name,
1127
+ "organization_id": organization_id,
1128
+ "workspace_id": workspace_id,
1129
+ },
1130
+ request_options=request_options,
1131
+ omit=OMIT,
1132
+ )
1133
+ try:
1134
+ if 200 <= _response.status_code < 300:
1135
+ return typing.cast(
1136
+ CreateAppOutput,
1137
+ parse_obj_as(
1138
+ type_=CreateAppOutput, # type: ignore
1139
+ object_=_response.json(),
1140
+ ),
1141
+ )
1142
+ if _response.status_code == 422:
1143
+ raise UnprocessableEntityError(
1144
+ typing.cast(
1145
+ HttpValidationError,
1146
+ parse_obj_as(
1147
+ type_=HttpValidationError, # type: ignore
1148
+ object_=_response.json(),
1149
+ ),
1150
+ )
1151
+ )
1152
+ _response_json = _response.json()
1153
+ except JSONDecodeError:
1154
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1155
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1156
+
1157
+ async def remove_app(
1158
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
1159
+ ) -> typing.Optional[typing.Any]:
1160
+ """
1161
+ Remove app, all its variant, containers and images
1162
+
1163
+ Arguments:
1164
+ app -- App to remove
1165
+
1166
+ Parameters
1167
+ ----------
1168
+ app_id : str
1169
+
1170
+ request_options : typing.Optional[RequestOptions]
1171
+ Request-specific configuration.
1172
+
1173
+ Returns
1174
+ -------
1175
+ typing.Optional[typing.Any]
1176
+ Successful Response
1177
+
1178
+ Examples
1179
+ --------
1180
+ import asyncio
1181
+
1182
+ from agenta import AsyncAgentaApi
1183
+
1184
+ client = AsyncAgentaApi(
1185
+ api_key="YOUR_API_KEY",
1186
+ base_url="https://yourhost.com/path/to/api",
1187
+ )
1188
+
1189
+
1190
+ async def main() -> None:
1191
+ await client.apps.remove_app(
1192
+ app_id="app_id",
1193
+ )
1194
+
1195
+
1196
+ asyncio.run(main())
1197
+ """
1198
+ _response = await self._client_wrapper.httpx_client.request(
1199
+ f"apps/{jsonable_encoder(app_id)}",
1200
+ method="DELETE",
1201
+ request_options=request_options,
1202
+ )
1203
+ try:
1204
+ if 200 <= _response.status_code < 300:
1205
+ return typing.cast(
1206
+ typing.Optional[typing.Any],
1207
+ parse_obj_as(
1208
+ type_=typing.Optional[typing.Any], # type: ignore
1209
+ object_=_response.json(),
1210
+ ),
1211
+ )
1212
+ if _response.status_code == 422:
1213
+ raise UnprocessableEntityError(
1214
+ typing.cast(
1215
+ HttpValidationError,
1216
+ parse_obj_as(
1217
+ type_=HttpValidationError, # type: ignore
1218
+ object_=_response.json(),
1219
+ ),
1220
+ )
1221
+ )
1222
+ _response_json = _response.json()
1223
+ except JSONDecodeError:
1224
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1225
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1226
+
1227
+ async def update_app(
1228
+ self,
1229
+ app_id: str,
1230
+ *,
1231
+ app_name: str,
1232
+ request_options: typing.Optional[RequestOptions] = None,
1233
+ ) -> UpdateAppOutput:
1234
+ """
1235
+ Update an app for a user or organization.
1236
+
1237
+ Args:
1238
+ app_id (str): The ID of the app.
1239
+ payload (UpdateApp): The payload containing the app name.
1240
+ stoken_session (SessionContainer): The session container containing the user's session token.
1241
+
1242
+ Returns:
1243
+ UpdateAppOuput: The output containing the newly created app's ID and name.
1244
+
1245
+ Raises:
1246
+ HTTPException: If there is an error creating the app or the user does not have permission to access the app.
1247
+
1248
+ Parameters
1249
+ ----------
1250
+ app_id : str
1251
+
1252
+ app_name : str
1253
+
1254
+ request_options : typing.Optional[RequestOptions]
1255
+ Request-specific configuration.
1256
+
1257
+ Returns
1258
+ -------
1259
+ UpdateAppOutput
1260
+ Successful Response
1261
+
1262
+ Examples
1263
+ --------
1264
+ import asyncio
1265
+
1266
+ from agenta import AsyncAgentaApi
1267
+
1268
+ client = AsyncAgentaApi(
1269
+ api_key="YOUR_API_KEY",
1270
+ base_url="https://yourhost.com/path/to/api",
1271
+ )
1272
+
1273
+
1274
+ async def main() -> None:
1275
+ await client.apps.update_app(
1276
+ app_id="app_id",
1277
+ app_name="app_name",
1278
+ )
1279
+
1280
+
1281
+ asyncio.run(main())
1282
+ """
1283
+ _response = await self._client_wrapper.httpx_client.request(
1284
+ f"apps/{jsonable_encoder(app_id)}",
1285
+ method="PATCH",
1286
+ json={
1287
+ "app_name": app_name,
1288
+ },
1289
+ request_options=request_options,
1290
+ omit=OMIT,
1291
+ )
1292
+ try:
1293
+ if 200 <= _response.status_code < 300:
1294
+ return typing.cast(
1295
+ UpdateAppOutput,
1296
+ parse_obj_as(
1297
+ type_=UpdateAppOutput, # type: ignore
1298
+ object_=_response.json(),
1299
+ ),
1300
+ )
1301
+ if _response.status_code == 422:
1302
+ raise UnprocessableEntityError(
1303
+ typing.cast(
1304
+ HttpValidationError,
1305
+ parse_obj_as(
1306
+ type_=HttpValidationError, # type: ignore
1307
+ object_=_response.json(),
1308
+ ),
1309
+ )
1310
+ )
1311
+ _response_json = _response.json()
1312
+ except JSONDecodeError:
1313
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1314
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1315
+
1316
+ async def add_variant_from_image(
1317
+ self,
1318
+ app_id: str,
1319
+ *,
1320
+ variant_name: str,
1321
+ docker_id: str,
1322
+ tags: str,
1323
+ base_name: typing.Optional[str] = OMIT,
1324
+ config_name: typing.Optional[str] = OMIT,
1325
+ request_options: typing.Optional[RequestOptions] = None,
1326
+ ) -> typing.Optional[typing.Any]:
1327
+ """
1328
+ Add a new variant to an app based on a Docker image.
1329
+
1330
+ Args:
1331
+ app_id (str): The ID of the app to add the variant to.
1332
+ payload (AddVariantFromImagePayload): The payload containing information about the variant to add.
1333
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1334
+
1335
+ Raises:
1336
+ 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.
1337
+
1338
+ Returns:
1339
+ dict: The newly added variant.
1340
+
1341
+ Parameters
1342
+ ----------
1343
+ app_id : str
1344
+
1345
+ variant_name : str
1346
+
1347
+ docker_id : str
1348
+
1349
+ tags : str
1350
+
1351
+ base_name : typing.Optional[str]
1352
+
1353
+ config_name : typing.Optional[str]
1354
+
1355
+ request_options : typing.Optional[RequestOptions]
1356
+ Request-specific configuration.
1357
+
1358
+ Returns
1359
+ -------
1360
+ typing.Optional[typing.Any]
1361
+ Successful Response
1362
+
1363
+ Examples
1364
+ --------
1365
+ import asyncio
1366
+
1367
+ from agenta import AsyncAgentaApi
1368
+
1369
+ client = AsyncAgentaApi(
1370
+ api_key="YOUR_API_KEY",
1371
+ base_url="https://yourhost.com/path/to/api",
1372
+ )
1373
+
1374
+
1375
+ async def main() -> None:
1376
+ await client.apps.add_variant_from_image(
1377
+ app_id="app_id",
1378
+ variant_name="variant_name",
1379
+ docker_id="docker_id",
1380
+ tags="tags",
1381
+ )
1382
+
1383
+
1384
+ asyncio.run(main())
1385
+ """
1386
+ _response = await self._client_wrapper.httpx_client.request(
1387
+ f"apps/{jsonable_encoder(app_id)}/variant/from-image",
1388
+ method="POST",
1389
+ json={
1390
+ "variant_name": variant_name,
1391
+ "docker_id": docker_id,
1392
+ "tags": tags,
1393
+ "base_name": base_name,
1394
+ "config_name": config_name,
1395
+ },
1396
+ request_options=request_options,
1397
+ omit=OMIT,
1398
+ )
1399
+ try:
1400
+ if 200 <= _response.status_code < 300:
1401
+ return typing.cast(
1402
+ typing.Optional[typing.Any],
1403
+ parse_obj_as(
1404
+ type_=typing.Optional[typing.Any], # type: ignore
1405
+ object_=_response.json(),
1406
+ ),
1407
+ )
1408
+ if _response.status_code == 422:
1409
+ raise UnprocessableEntityError(
1410
+ typing.cast(
1411
+ HttpValidationError,
1412
+ parse_obj_as(
1413
+ type_=HttpValidationError, # type: ignore
1414
+ object_=_response.json(),
1415
+ ),
1416
+ )
1417
+ )
1418
+ _response_json = _response.json()
1419
+ except JSONDecodeError:
1420
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1421
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1422
+
1423
+ async def create_app_and_variant_from_template(
1424
+ self,
1425
+ *,
1426
+ app_name: str,
1427
+ template_id: str,
1428
+ env_vars: typing.Dict[str, str],
1429
+ organization_id: typing.Optional[str] = OMIT,
1430
+ workspace_id: typing.Optional[str] = OMIT,
1431
+ request_options: typing.Optional[RequestOptions] = None,
1432
+ ) -> AppVariantResponse:
1433
+ """
1434
+ Create an app and variant from a template.
1435
+
1436
+ Args:
1437
+ payload (CreateAppVariant): The payload containing the app and variant information.
1438
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1439
+
1440
+ Raises:
1441
+ HTTPException: If the user has reached the app limit or if an app with the same name already exists.
1442
+
1443
+ Returns:
1444
+ AppVariantResponse: The output of the created app variant.
1445
+
1446
+ Parameters
1447
+ ----------
1448
+ app_name : str
1449
+
1450
+ template_id : str
1451
+
1452
+ env_vars : typing.Dict[str, str]
1453
+
1454
+ organization_id : typing.Optional[str]
1455
+
1456
+ workspace_id : typing.Optional[str]
1457
+
1458
+ request_options : typing.Optional[RequestOptions]
1459
+ Request-specific configuration.
1460
+
1461
+ Returns
1462
+ -------
1463
+ AppVariantResponse
1464
+ Successful Response
1465
+
1466
+ Examples
1467
+ --------
1468
+ import asyncio
1469
+
1470
+ from agenta import AsyncAgentaApi
1471
+
1472
+ client = AsyncAgentaApi(
1473
+ api_key="YOUR_API_KEY",
1474
+ base_url="https://yourhost.com/path/to/api",
1475
+ )
1476
+
1477
+
1478
+ async def main() -> None:
1479
+ await client.apps.create_app_and_variant_from_template(
1480
+ app_name="app_name",
1481
+ template_id="template_id",
1482
+ env_vars={"key": "value"},
1483
+ )
1484
+
1485
+
1486
+ asyncio.run(main())
1487
+ """
1488
+ _response = await self._client_wrapper.httpx_client.request(
1489
+ "apps/app_and_variant_from_template",
1490
+ method="POST",
1491
+ json={
1492
+ "app_name": app_name,
1493
+ "template_id": template_id,
1494
+ "env_vars": env_vars,
1495
+ "organization_id": organization_id,
1496
+ "workspace_id": workspace_id,
1497
+ },
1498
+ request_options=request_options,
1499
+ omit=OMIT,
1500
+ )
1501
+ try:
1502
+ if 200 <= _response.status_code < 300:
1503
+ return typing.cast(
1504
+ AppVariantResponse,
1505
+ parse_obj_as(
1506
+ type_=AppVariantResponse, # type: ignore
1507
+ object_=_response.json(),
1508
+ ),
1509
+ )
1510
+ if _response.status_code == 422:
1511
+ raise UnprocessableEntityError(
1512
+ typing.cast(
1513
+ HttpValidationError,
1514
+ parse_obj_as(
1515
+ type_=HttpValidationError, # type: ignore
1516
+ object_=_response.json(),
1517
+ ),
1518
+ )
1519
+ )
1520
+ _response_json = _response.json()
1521
+ except JSONDecodeError:
1522
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1523
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1524
+
1525
+ async def list_environments(
1526
+ self, app_id: str, *, request_options: typing.Optional[RequestOptions] = None
1527
+ ) -> typing.List[EnvironmentOutput]:
1528
+ """
1529
+ Retrieve a list of environments for a given app ID.
1530
+
1531
+ Args:
1532
+ app_id (str): The ID of the app to retrieve environments for.
1533
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1534
+
1535
+ Returns:
1536
+ List[EnvironmentOutput]: A list of environment objects.
1537
+
1538
+ Parameters
1539
+ ----------
1540
+ app_id : str
1541
+
1542
+ request_options : typing.Optional[RequestOptions]
1543
+ Request-specific configuration.
1544
+
1545
+ Returns
1546
+ -------
1547
+ typing.List[EnvironmentOutput]
1548
+ Successful Response
1549
+
1550
+ Examples
1551
+ --------
1552
+ import asyncio
1553
+
1554
+ from agenta import AsyncAgentaApi
1555
+
1556
+ client = AsyncAgentaApi(
1557
+ api_key="YOUR_API_KEY",
1558
+ base_url="https://yourhost.com/path/to/api",
1559
+ )
1560
+
1561
+
1562
+ async def main() -> None:
1563
+ await client.apps.list_environments(
1564
+ app_id="app_id",
1565
+ )
1566
+
1567
+
1568
+ asyncio.run(main())
1569
+ """
1570
+ _response = await self._client_wrapper.httpx_client.request(
1571
+ f"apps/{jsonable_encoder(app_id)}/environments",
1572
+ method="GET",
1573
+ request_options=request_options,
1574
+ )
1575
+ try:
1576
+ if 200 <= _response.status_code < 300:
1577
+ return typing.cast(
1578
+ typing.List[EnvironmentOutput],
1579
+ parse_obj_as(
1580
+ type_=typing.List[EnvironmentOutput], # type: ignore
1581
+ object_=_response.json(),
1582
+ ),
1583
+ )
1584
+ if _response.status_code == 422:
1585
+ raise UnprocessableEntityError(
1586
+ typing.cast(
1587
+ HttpValidationError,
1588
+ parse_obj_as(
1589
+ type_=HttpValidationError, # type: ignore
1590
+ object_=_response.json(),
1591
+ ),
1592
+ )
1593
+ )
1594
+ _response_json = _response.json()
1595
+ except JSONDecodeError:
1596
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1597
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1598
+
1599
+ async def environment_revisions(
1600
+ self,
1601
+ app_id: str,
1602
+ environment_name: typing.Optional[typing.Any],
1603
+ *,
1604
+ request_options: typing.Optional[RequestOptions] = None,
1605
+ ) -> EnvironmentOutputExtended:
1606
+ """
1607
+ Parameters
1608
+ ----------
1609
+ app_id : str
1610
+
1611
+ environment_name : typing.Optional[typing.Any]
1612
+
1613
+ request_options : typing.Optional[RequestOptions]
1614
+ Request-specific configuration.
1615
+
1616
+ Returns
1617
+ -------
1618
+ EnvironmentOutputExtended
1619
+ Successful Response
1620
+
1621
+ Examples
1622
+ --------
1623
+ import asyncio
1624
+
1625
+ from agenta import AsyncAgentaApi
1626
+
1627
+ client = AsyncAgentaApi(
1628
+ api_key="YOUR_API_KEY",
1629
+ base_url="https://yourhost.com/path/to/api",
1630
+ )
1631
+
1632
+
1633
+ async def main() -> None:
1634
+ await client.apps.environment_revisions(
1635
+ app_id="string",
1636
+ environment_name={"key": "value"},
1637
+ )
1638
+
1639
+
1640
+ asyncio.run(main())
1641
+ """
1642
+ _response = await self._client_wrapper.httpx_client.request(
1643
+ f"apps/{jsonable_encoder(app_id)}/revisions/{jsonable_encoder(environment_name)}",
1644
+ method="GET",
1645
+ request_options=request_options,
1646
+ )
1647
+ try:
1648
+ if 200 <= _response.status_code < 300:
1649
+ return typing.cast(
1650
+ EnvironmentOutputExtended,
1651
+ parse_obj_as(
1652
+ type_=EnvironmentOutputExtended, # type: ignore
1653
+ object_=_response.json(),
1654
+ ),
1655
+ )
1656
+ if _response.status_code == 422:
1657
+ raise UnprocessableEntityError(
1658
+ typing.cast(
1659
+ HttpValidationError,
1660
+ parse_obj_as(
1661
+ type_=HttpValidationError, # type: ignore
1662
+ object_=_response.json(),
1663
+ ),
1664
+ )
1665
+ )
1666
+ _response_json = _response.json()
1667
+ except JSONDecodeError:
1668
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1669
+ raise ApiError(status_code=_response.status_code, body=_response_json)