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