agenta 0.27.0a9__py3-none-any.whl → 0.27.0a13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- agenta/__init__.py +21 -3
- agenta/client/backend/__init__.py +14 -0
- agenta/client/backend/apps/client.py +28 -20
- agenta/client/backend/client.py +25 -2
- agenta/client/backend/containers/client.py +5 -1
- agenta/client/backend/core/__init__.py +2 -1
- agenta/client/backend/core/client_wrapper.py +6 -6
- agenta/client/backend/core/file.py +33 -11
- agenta/client/backend/core/http_client.py +24 -18
- agenta/client/backend/core/pydantic_utilities.py +144 -29
- agenta/client/backend/core/request_options.py +3 -0
- agenta/client/backend/core/serialization.py +139 -42
- agenta/client/backend/evaluations/client.py +7 -2
- agenta/client/backend/evaluators/client.py +349 -1
- agenta/client/backend/observability/client.py +11 -2
- agenta/client/backend/testsets/client.py +10 -10
- agenta/client/backend/types/__init__.py +14 -0
- agenta/client/backend/types/app.py +1 -0
- agenta/client/backend/types/app_variant_response.py +3 -1
- agenta/client/backend/types/config_dto.py +32 -0
- agenta/client/backend/types/config_response_model.py +32 -0
- agenta/client/backend/types/create_span.py +3 -2
- agenta/client/backend/types/environment_output.py +1 -0
- agenta/client/backend/types/environment_output_extended.py +1 -0
- agenta/client/backend/types/evaluation.py +1 -2
- agenta/client/backend/types/evaluator.py +2 -0
- agenta/client/backend/types/evaluator_config.py +1 -0
- agenta/client/backend/types/evaluator_mapping_output_interface.py +21 -0
- agenta/client/backend/types/evaluator_output_interface.py +21 -0
- agenta/client/backend/types/human_evaluation.py +1 -2
- agenta/client/backend/types/lifecycle_dto.py +24 -0
- agenta/client/backend/types/llm_tokens.py +2 -2
- agenta/client/backend/types/reference_dto.py +23 -0
- agenta/client/backend/types/reference_request_model.py +23 -0
- agenta/client/backend/types/span.py +1 -0
- agenta/client/backend/types/span_detail.py +7 -1
- agenta/client/backend/types/test_set_output_response.py +5 -2
- agenta/client/backend/types/trace_detail.py +7 -1
- agenta/client/backend/types/with_pagination.py +4 -2
- agenta/client/backend/variants/client.py +1565 -272
- agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
- agenta/sdk/__init__.py +19 -5
- agenta/sdk/agenta_init.py +21 -7
- agenta/sdk/context/routing.py +6 -5
- agenta/sdk/decorators/routing.py +16 -5
- agenta/sdk/decorators/tracing.py +16 -9
- agenta/sdk/litellm/litellm.py +47 -36
- agenta/sdk/managers/__init__.py +6 -0
- agenta/sdk/managers/config.py +318 -0
- agenta/sdk/managers/deployment.py +45 -0
- agenta/sdk/managers/shared.py +639 -0
- agenta/sdk/managers/variant.py +182 -0
- agenta/sdk/tracing/exporters.py +0 -1
- agenta/sdk/tracing/inline.py +46 -1
- agenta/sdk/tracing/processors.py +0 -1
- agenta/sdk/types.py +47 -2
- agenta/sdk/utils/exceptions.py +31 -1
- {agenta-0.27.0a9.dist-info → agenta-0.27.0a13.dist-info}/METADATA +1 -1
- {agenta-0.27.0a9.dist-info → agenta-0.27.0a13.dist-info}/RECORD +61 -50
- agenta/sdk/config_manager.py +0 -205
- {agenta-0.27.0a9.dist-info → agenta-0.27.0a13.dist-info}/WHEEL +0 -0
- {agenta-0.27.0a9.dist-info → agenta-0.27.0a13.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional, Dict, Any
|
|
3
|
+
|
|
4
|
+
from agenta.sdk.utils.exceptions import handle_exceptions
|
|
5
|
+
|
|
6
|
+
from agenta.sdk.types import (
|
|
7
|
+
ConfigurationResponse,
|
|
8
|
+
DeploymentResponse,
|
|
9
|
+
)
|
|
10
|
+
from agenta.client.backend.types.config_dto import ConfigDto as ConfigRequest
|
|
11
|
+
from agenta.client.backend.types.config_response_model import ConfigResponseModel
|
|
12
|
+
from agenta.client.backend.types.reference_request_model import ReferenceRequestModel
|
|
13
|
+
|
|
14
|
+
import agenta as ag
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SharedManager:
|
|
21
|
+
"""
|
|
22
|
+
SharedManager is a utility class that serves as an interface for managing
|
|
23
|
+
application configurations, variants, and deployments through the Agenta API.
|
|
24
|
+
It provides both synchronous and asynchronous methods, allowing flexibility
|
|
25
|
+
depending on the context of use (e.g., blocking or non-blocking environments).
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
client (AgentaApi): Synchronous client for interacting with the Agenta API.
|
|
29
|
+
aclient (AsyncAgentaApi): Asynchronous client for interacting with the Agenta API.
|
|
30
|
+
|
|
31
|
+
Notes:
|
|
32
|
+
- The class manages both synchronous and asynchronous interactions with the API, allowing users to
|
|
33
|
+
select the method that best fits their needs.
|
|
34
|
+
- Methods prefixed with 'a' (e.g., aadd, afetch) are designed to be used in asynchronous environments.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def _parse_fetch_request(
|
|
39
|
+
cls,
|
|
40
|
+
app_id: Optional[str] = None,
|
|
41
|
+
app_slug: Optional[str] = None,
|
|
42
|
+
variant_id: Optional[str] = None,
|
|
43
|
+
variant_slug: Optional[str] = None,
|
|
44
|
+
variant_version: Optional[int] = None,
|
|
45
|
+
environment_id: Optional[str] = None,
|
|
46
|
+
environment_slug: Optional[str] = None,
|
|
47
|
+
environment_version: Optional[int] = None,
|
|
48
|
+
):
|
|
49
|
+
if variant_slug and not (app_id or app_slug):
|
|
50
|
+
raise ValueError("`variant_slug` requires `app_id` or `app_slug`")
|
|
51
|
+
if variant_version and not variant_slug:
|
|
52
|
+
raise ValueError("`variant_version` requires `variant_slug`")
|
|
53
|
+
if environment_slug and not (app_id or app_slug):
|
|
54
|
+
raise ValueError("`environment_slug` requires `app_id` or `app_slug`")
|
|
55
|
+
if environment_version and not environment_slug:
|
|
56
|
+
raise ValueError("`environment_version` requires `environment_slug`")
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
"app_id": app_id,
|
|
60
|
+
"app_slug": app_slug,
|
|
61
|
+
"variant_id": variant_id,
|
|
62
|
+
"variant_slug": variant_slug,
|
|
63
|
+
"variant_version": variant_version,
|
|
64
|
+
"environment_id": environment_id,
|
|
65
|
+
"environment_slug": environment_slug,
|
|
66
|
+
"environment_version": environment_version,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def _parse_config_response(
|
|
71
|
+
cls,
|
|
72
|
+
model: ConfigResponseModel,
|
|
73
|
+
) -> Dict[str, Any]:
|
|
74
|
+
flattened: Dict[str, Any] = {}
|
|
75
|
+
|
|
76
|
+
# Process application_ref
|
|
77
|
+
if model.application_ref:
|
|
78
|
+
flattened["app_id"] = model.application_ref.id
|
|
79
|
+
flattened["app_slug"] = model.application_ref.slug
|
|
80
|
+
|
|
81
|
+
# Process variant_ref
|
|
82
|
+
if model.variant_ref:
|
|
83
|
+
flattened["variant_id"] = model.variant_ref.id
|
|
84
|
+
flattened["variant_slug"] = model.variant_ref.slug
|
|
85
|
+
flattened["variant_version"] = model.variant_ref.version
|
|
86
|
+
|
|
87
|
+
# Process environment_ref
|
|
88
|
+
if model.environment_ref:
|
|
89
|
+
flattened["environment_id"] = model.environment_ref.id
|
|
90
|
+
flattened["environment_slug"] = model.environment_ref.slug
|
|
91
|
+
flattened["environment_version"] = model.environment_ref.version
|
|
92
|
+
|
|
93
|
+
# Process variant_lifecycle
|
|
94
|
+
if model.variant_lifecycle:
|
|
95
|
+
flattened["committed_at"] = model.variant_lifecycle.updated_at
|
|
96
|
+
flattened["committed_by"] = model.variant_lifecycle.updated_by
|
|
97
|
+
flattened["committed_by_id"] = model.variant_lifecycle.updated_by_id
|
|
98
|
+
|
|
99
|
+
# Process environment_lifecycle
|
|
100
|
+
if model.environment_lifecycle:
|
|
101
|
+
flattened["deployed_at"] = model.environment_lifecycle.created_at
|
|
102
|
+
flattened["deployed_by"] = model.environment_lifecycle.updated_by
|
|
103
|
+
flattened["deployed_by_id"] = model.environment_lifecycle.updated_by_id
|
|
104
|
+
|
|
105
|
+
# Add parameters
|
|
106
|
+
flattened["params"] = model.params or {}
|
|
107
|
+
|
|
108
|
+
return flattened
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def _ref_or_none(
|
|
112
|
+
cls,
|
|
113
|
+
*,
|
|
114
|
+
id: Optional[str] = None,
|
|
115
|
+
slug: Optional[str] = None,
|
|
116
|
+
version: Optional[int] = None,
|
|
117
|
+
) -> Optional[ReferenceRequestModel]:
|
|
118
|
+
if not id and not slug and not version:
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
return ReferenceRequestModel(id=id, slug=slug, version=version)
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
@handle_exceptions()
|
|
125
|
+
def add(
|
|
126
|
+
cls,
|
|
127
|
+
*,
|
|
128
|
+
variant_slug: str,
|
|
129
|
+
#
|
|
130
|
+
app_id: Optional[str] = None,
|
|
131
|
+
app_slug: Optional[str] = None,
|
|
132
|
+
):
|
|
133
|
+
config_response = ag.api.variants.configs_add( # type: ignore
|
|
134
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
135
|
+
slug=variant_slug,
|
|
136
|
+
version=None,
|
|
137
|
+
id=None,
|
|
138
|
+
),
|
|
139
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
140
|
+
slug=app_slug,
|
|
141
|
+
version=None,
|
|
142
|
+
id=app_id,
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
response = SharedManager._parse_config_response(config_response)
|
|
146
|
+
return ConfigurationResponse(**response)
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
@handle_exceptions()
|
|
150
|
+
async def aadd(
|
|
151
|
+
cls,
|
|
152
|
+
*,
|
|
153
|
+
variant_slug: str,
|
|
154
|
+
#
|
|
155
|
+
app_id: Optional[str] = None,
|
|
156
|
+
app_slug: Optional[str] = None,
|
|
157
|
+
):
|
|
158
|
+
config_response = await ag.async_api.variants.configs_add( # type: ignore
|
|
159
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
160
|
+
slug=variant_slug,
|
|
161
|
+
version=None,
|
|
162
|
+
id=None,
|
|
163
|
+
),
|
|
164
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
165
|
+
slug=app_slug,
|
|
166
|
+
version=None,
|
|
167
|
+
id=app_id,
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
response = SharedManager._parse_config_response(config_response)
|
|
171
|
+
|
|
172
|
+
return ConfigurationResponse(**response)
|
|
173
|
+
|
|
174
|
+
@classmethod
|
|
175
|
+
@handle_exceptions()
|
|
176
|
+
def fetch(
|
|
177
|
+
cls,
|
|
178
|
+
*,
|
|
179
|
+
app_id: Optional[str] = None,
|
|
180
|
+
app_slug: Optional[str] = None,
|
|
181
|
+
variant_id: Optional[str] = None,
|
|
182
|
+
variant_slug: Optional[str] = None,
|
|
183
|
+
variant_version: Optional[int] = None,
|
|
184
|
+
environment_id: Optional[str] = None,
|
|
185
|
+
environment_slug: Optional[str] = None,
|
|
186
|
+
environment_version: Optional[int] = None,
|
|
187
|
+
) -> ConfigurationResponse:
|
|
188
|
+
fetch_signatures = SharedManager._parse_fetch_request(
|
|
189
|
+
app_id=app_id,
|
|
190
|
+
app_slug=app_slug,
|
|
191
|
+
variant_id=variant_id,
|
|
192
|
+
variant_slug=variant_slug,
|
|
193
|
+
variant_version=variant_version,
|
|
194
|
+
environment_id=environment_id,
|
|
195
|
+
environment_slug=environment_slug,
|
|
196
|
+
environment_version=environment_version,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
config_response = ag.api.variants.configs_fetch( # type: ignore
|
|
200
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
201
|
+
slug=fetch_signatures["variant_slug"],
|
|
202
|
+
version=fetch_signatures["variant_version"],
|
|
203
|
+
id=fetch_signatures["variant_id"],
|
|
204
|
+
),
|
|
205
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
206
|
+
slug=fetch_signatures["environment_slug"],
|
|
207
|
+
version=fetch_signatures["environment_version"],
|
|
208
|
+
id=fetch_signatures["environment_id"],
|
|
209
|
+
),
|
|
210
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
211
|
+
slug=fetch_signatures["app_slug"],
|
|
212
|
+
version=None,
|
|
213
|
+
id=fetch_signatures["app_id"],
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
response = SharedManager._parse_config_response(config_response)
|
|
218
|
+
|
|
219
|
+
return ConfigurationResponse(**response)
|
|
220
|
+
|
|
221
|
+
@classmethod
|
|
222
|
+
@handle_exceptions()
|
|
223
|
+
async def afetch(
|
|
224
|
+
cls,
|
|
225
|
+
*,
|
|
226
|
+
app_id: Optional[str] = None,
|
|
227
|
+
app_slug: Optional[str] = None,
|
|
228
|
+
variant_id: Optional[str] = None,
|
|
229
|
+
variant_slug: Optional[str] = None,
|
|
230
|
+
variant_version: Optional[int] = None,
|
|
231
|
+
environment_id: Optional[str] = None,
|
|
232
|
+
environment_slug: Optional[str] = None,
|
|
233
|
+
environment_version: Optional[int] = None,
|
|
234
|
+
):
|
|
235
|
+
fetch_signatures = SharedManager._parse_fetch_request(
|
|
236
|
+
app_id=app_id,
|
|
237
|
+
app_slug=app_slug,
|
|
238
|
+
variant_id=variant_id,
|
|
239
|
+
variant_slug=variant_slug,
|
|
240
|
+
variant_version=variant_version,
|
|
241
|
+
environment_id=environment_id,
|
|
242
|
+
environment_slug=environment_slug,
|
|
243
|
+
environment_version=environment_version,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
config_response = await ag.async_api.variants.configs_fetch( # type: ignore
|
|
247
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
248
|
+
slug=fetch_signatures["variant_slug"],
|
|
249
|
+
version=fetch_signatures["variant_version"],
|
|
250
|
+
id=fetch_signatures["variant_id"],
|
|
251
|
+
),
|
|
252
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
253
|
+
slug=fetch_signatures["environment_slug"],
|
|
254
|
+
version=fetch_signatures["environment_version"],
|
|
255
|
+
id=fetch_signatures["environment_id"],
|
|
256
|
+
),
|
|
257
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
258
|
+
slug=fetch_signatures["app_slug"],
|
|
259
|
+
version=None,
|
|
260
|
+
id=fetch_signatures["app_id"],
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
response = SharedManager._parse_config_response(config_response)
|
|
265
|
+
|
|
266
|
+
return ConfigurationResponse(**response)
|
|
267
|
+
|
|
268
|
+
@classmethod
|
|
269
|
+
@handle_exceptions()
|
|
270
|
+
def list(
|
|
271
|
+
cls,
|
|
272
|
+
*,
|
|
273
|
+
app_id: Optional[str] = None,
|
|
274
|
+
app_slug: Optional[str] = None,
|
|
275
|
+
):
|
|
276
|
+
configs_response = ag.api.variants.configs_list( # type: ignore
|
|
277
|
+
application_ref=SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
278
|
+
slug=app_slug,
|
|
279
|
+
version=None,
|
|
280
|
+
id=app_id,
|
|
281
|
+
),
|
|
282
|
+
) # type: ignore
|
|
283
|
+
|
|
284
|
+
transformed_response = [
|
|
285
|
+
SharedManager._parse_config_response(config_response)
|
|
286
|
+
for config_response in configs_response
|
|
287
|
+
]
|
|
288
|
+
|
|
289
|
+
return [
|
|
290
|
+
ConfigurationResponse(**response) # type: ignore
|
|
291
|
+
for response in transformed_response
|
|
292
|
+
]
|
|
293
|
+
|
|
294
|
+
@classmethod
|
|
295
|
+
@handle_exceptions()
|
|
296
|
+
async def alist(
|
|
297
|
+
cls,
|
|
298
|
+
*,
|
|
299
|
+
app_id: Optional[str] = None,
|
|
300
|
+
app_slug: Optional[str] = None,
|
|
301
|
+
):
|
|
302
|
+
configs_response = await ag.async_api.variants.configs_list( # type: ignore
|
|
303
|
+
application_ref=SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
304
|
+
slug=app_slug,
|
|
305
|
+
version=None,
|
|
306
|
+
id=app_id,
|
|
307
|
+
),
|
|
308
|
+
) # type: ignore
|
|
309
|
+
|
|
310
|
+
transformed_response = [
|
|
311
|
+
SharedManager._parse_config_response(config_response)
|
|
312
|
+
for config_response in configs_response
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
return [
|
|
316
|
+
ConfigurationResponse(**response) # type: ignore
|
|
317
|
+
for response in transformed_response
|
|
318
|
+
]
|
|
319
|
+
|
|
320
|
+
@classmethod
|
|
321
|
+
@handle_exceptions()
|
|
322
|
+
def history(
|
|
323
|
+
cls,
|
|
324
|
+
*,
|
|
325
|
+
app_id: Optional[str] = None,
|
|
326
|
+
app_slug: Optional[str] = None,
|
|
327
|
+
variant_id: Optional[str] = None,
|
|
328
|
+
variant_slug: Optional[str] = None,
|
|
329
|
+
):
|
|
330
|
+
configs_response = ag.api.variants.configs_history( # type: ignore
|
|
331
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
332
|
+
slug=variant_slug,
|
|
333
|
+
version=None,
|
|
334
|
+
id=variant_id,
|
|
335
|
+
),
|
|
336
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
337
|
+
slug=app_slug,
|
|
338
|
+
version=None,
|
|
339
|
+
id=app_id,
|
|
340
|
+
),
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
transformed_response = [
|
|
344
|
+
SharedManager._parse_config_response(config_response)
|
|
345
|
+
for config_response in configs_response
|
|
346
|
+
]
|
|
347
|
+
|
|
348
|
+
return [
|
|
349
|
+
ConfigurationResponse(**response) # type: ignore
|
|
350
|
+
for response in transformed_response
|
|
351
|
+
]
|
|
352
|
+
|
|
353
|
+
@classmethod
|
|
354
|
+
@handle_exceptions()
|
|
355
|
+
async def ahistory(
|
|
356
|
+
cls,
|
|
357
|
+
*,
|
|
358
|
+
app_id: Optional[str] = None,
|
|
359
|
+
app_slug: Optional[str] = None,
|
|
360
|
+
variant_id: Optional[str] = None,
|
|
361
|
+
variant_slug: Optional[str] = None,
|
|
362
|
+
):
|
|
363
|
+
configs_response = await ag.async_api.variants.configs_history( # type: ignore
|
|
364
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
365
|
+
slug=variant_slug,
|
|
366
|
+
version=None,
|
|
367
|
+
id=variant_id,
|
|
368
|
+
),
|
|
369
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
370
|
+
slug=app_slug,
|
|
371
|
+
version=None,
|
|
372
|
+
id=app_id,
|
|
373
|
+
),
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
transformed_response = [
|
|
377
|
+
SharedManager._parse_config_response(config_response)
|
|
378
|
+
for config_response in configs_response
|
|
379
|
+
]
|
|
380
|
+
|
|
381
|
+
return [
|
|
382
|
+
ConfigurationResponse(**response) # type: ignore
|
|
383
|
+
for response in transformed_response
|
|
384
|
+
]
|
|
385
|
+
|
|
386
|
+
@classmethod
|
|
387
|
+
@handle_exceptions()
|
|
388
|
+
def fork(
|
|
389
|
+
cls,
|
|
390
|
+
*,
|
|
391
|
+
app_id: Optional[str] = None,
|
|
392
|
+
app_slug: Optional[str] = None,
|
|
393
|
+
variant_id: Optional[str] = None,
|
|
394
|
+
variant_slug: Optional[str] = None,
|
|
395
|
+
variant_version: Optional[int] = None,
|
|
396
|
+
environment_id: Optional[str] = None,
|
|
397
|
+
environment_slug: Optional[str] = None,
|
|
398
|
+
environment_version: Optional[int] = None,
|
|
399
|
+
):
|
|
400
|
+
config_response = ag.api.variants.configs_fork( # type: ignore
|
|
401
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
402
|
+
slug=variant_slug,
|
|
403
|
+
version=variant_version,
|
|
404
|
+
id=variant_id,
|
|
405
|
+
),
|
|
406
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
407
|
+
slug=environment_slug,
|
|
408
|
+
version=environment_version,
|
|
409
|
+
id=environment_id,
|
|
410
|
+
),
|
|
411
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
412
|
+
slug=app_slug,
|
|
413
|
+
version=None,
|
|
414
|
+
id=app_id,
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
response = SharedManager._parse_config_response(config_response)
|
|
419
|
+
|
|
420
|
+
return ConfigurationResponse(**response)
|
|
421
|
+
|
|
422
|
+
@classmethod
|
|
423
|
+
@handle_exceptions()
|
|
424
|
+
async def afork(
|
|
425
|
+
cls,
|
|
426
|
+
*,
|
|
427
|
+
app_id: Optional[str] = None,
|
|
428
|
+
app_slug: Optional[str] = None,
|
|
429
|
+
variant_id: Optional[str] = None,
|
|
430
|
+
variant_slug: Optional[str] = None,
|
|
431
|
+
variant_version: Optional[int] = None,
|
|
432
|
+
environment_id: Optional[str] = None,
|
|
433
|
+
environment_slug: Optional[str] = None,
|
|
434
|
+
environment_version: Optional[int] = None,
|
|
435
|
+
):
|
|
436
|
+
config_response = await ag.async_api.variants.configs_fork( # type: ignore
|
|
437
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
438
|
+
slug=variant_slug,
|
|
439
|
+
version=variant_version,
|
|
440
|
+
id=variant_id,
|
|
441
|
+
),
|
|
442
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
443
|
+
slug=environment_slug,
|
|
444
|
+
version=environment_version,
|
|
445
|
+
id=environment_id,
|
|
446
|
+
),
|
|
447
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
448
|
+
slug=app_slug,
|
|
449
|
+
version=None,
|
|
450
|
+
id=app_id,
|
|
451
|
+
),
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
response = SharedManager._parse_config_response(config_response)
|
|
455
|
+
return ConfigurationResponse(**response)
|
|
456
|
+
|
|
457
|
+
@classmethod
|
|
458
|
+
@handle_exceptions()
|
|
459
|
+
def commit(
|
|
460
|
+
cls,
|
|
461
|
+
*,
|
|
462
|
+
parameters: dict,
|
|
463
|
+
variant_slug: str,
|
|
464
|
+
#
|
|
465
|
+
app_id: Optional[str] = None,
|
|
466
|
+
app_slug: Optional[str] = None,
|
|
467
|
+
):
|
|
468
|
+
variant_ref = SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
469
|
+
slug=variant_slug,
|
|
470
|
+
version=None,
|
|
471
|
+
id=None,
|
|
472
|
+
)
|
|
473
|
+
application_ref = SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
474
|
+
slug=app_slug,
|
|
475
|
+
version=None,
|
|
476
|
+
id=app_id,
|
|
477
|
+
)
|
|
478
|
+
config_response = ag.api.variants.configs_commit( # type: ignore
|
|
479
|
+
config=ConfigRequest(
|
|
480
|
+
params=parameters,
|
|
481
|
+
variant_ref=variant_ref.model_dump() if variant_ref else None, # type: ignore
|
|
482
|
+
application_ref=application_ref.model_dump() if application_ref else None, # type: ignore
|
|
483
|
+
)
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
response = SharedManager._parse_config_response(config_response)
|
|
487
|
+
|
|
488
|
+
return ConfigurationResponse(**response)
|
|
489
|
+
|
|
490
|
+
@classmethod
|
|
491
|
+
@handle_exceptions()
|
|
492
|
+
async def acommit(
|
|
493
|
+
cls,
|
|
494
|
+
*,
|
|
495
|
+
parameters: dict,
|
|
496
|
+
variant_slug: str,
|
|
497
|
+
#
|
|
498
|
+
app_id: Optional[str] = None,
|
|
499
|
+
app_slug: Optional[str] = None,
|
|
500
|
+
):
|
|
501
|
+
config_response = await ag.async_api.variants.configs_commit( # type: ignore
|
|
502
|
+
config=ConfigRequest(
|
|
503
|
+
params=parameters,
|
|
504
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
505
|
+
slug=variant_slug,
|
|
506
|
+
version=None,
|
|
507
|
+
id=None,
|
|
508
|
+
),
|
|
509
|
+
application_ref=SharedManager._ref_or_none( # type: ignore # type: ignore
|
|
510
|
+
slug=app_slug,
|
|
511
|
+
version=None,
|
|
512
|
+
id=app_id,
|
|
513
|
+
),
|
|
514
|
+
)
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
response = SharedManager._parse_config_response(config_response)
|
|
518
|
+
|
|
519
|
+
return ConfigurationResponse(**response)
|
|
520
|
+
|
|
521
|
+
@classmethod
|
|
522
|
+
@handle_exceptions()
|
|
523
|
+
def deploy(
|
|
524
|
+
cls,
|
|
525
|
+
*,
|
|
526
|
+
variant_slug: str,
|
|
527
|
+
environment_slug: str,
|
|
528
|
+
#
|
|
529
|
+
app_id: Optional[str] = None,
|
|
530
|
+
app_slug: Optional[str] = None,
|
|
531
|
+
variant_version: Optional[int] = None,
|
|
532
|
+
):
|
|
533
|
+
config_response = ag.api.variants.configs_deploy( # type: ignore
|
|
534
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
535
|
+
slug=variant_slug,
|
|
536
|
+
version=variant_version,
|
|
537
|
+
id=None,
|
|
538
|
+
),
|
|
539
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
540
|
+
slug=environment_slug,
|
|
541
|
+
version=None,
|
|
542
|
+
id=None,
|
|
543
|
+
),
|
|
544
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
545
|
+
slug=app_slug,
|
|
546
|
+
version=None,
|
|
547
|
+
id=app_id,
|
|
548
|
+
),
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
response = SharedManager._parse_config_response(config_response)
|
|
552
|
+
|
|
553
|
+
return DeploymentResponse(**response)
|
|
554
|
+
|
|
555
|
+
@classmethod
|
|
556
|
+
@handle_exceptions()
|
|
557
|
+
async def adeploy(
|
|
558
|
+
cls,
|
|
559
|
+
*,
|
|
560
|
+
variant_slug: str,
|
|
561
|
+
environment_slug: str,
|
|
562
|
+
#
|
|
563
|
+
app_id: Optional[str] = None,
|
|
564
|
+
app_slug: Optional[str] = None,
|
|
565
|
+
variant_version: Optional[int] = None,
|
|
566
|
+
):
|
|
567
|
+
config_response = await ag.async_api.variants.configs_deploy( # type: ignore
|
|
568
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
569
|
+
slug=variant_slug,
|
|
570
|
+
version=variant_version,
|
|
571
|
+
id=None,
|
|
572
|
+
),
|
|
573
|
+
environment_ref=SharedManager._ref_or_none( # type: ignore
|
|
574
|
+
slug=environment_slug,
|
|
575
|
+
version=None,
|
|
576
|
+
id=None,
|
|
577
|
+
),
|
|
578
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
579
|
+
slug=app_slug,
|
|
580
|
+
version=None,
|
|
581
|
+
id=app_id,
|
|
582
|
+
),
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
response = SharedManager._parse_config_response(config_response)
|
|
586
|
+
|
|
587
|
+
return DeploymentResponse(**response)
|
|
588
|
+
|
|
589
|
+
@classmethod
|
|
590
|
+
@handle_exceptions()
|
|
591
|
+
def delete(
|
|
592
|
+
cls,
|
|
593
|
+
*,
|
|
594
|
+
app_id: Optional[str] = None,
|
|
595
|
+
app_slug: Optional[str] = None,
|
|
596
|
+
variant_id: Optional[str] = None,
|
|
597
|
+
variant_slug: Optional[str] = None,
|
|
598
|
+
variant_version: Optional[int] = None,
|
|
599
|
+
):
|
|
600
|
+
config_response = ag.api.variants.configs_delete( # type: ignore
|
|
601
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
602
|
+
slug=variant_slug,
|
|
603
|
+
version=variant_version,
|
|
604
|
+
id=variant_id,
|
|
605
|
+
),
|
|
606
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
607
|
+
slug=app_slug,
|
|
608
|
+
version=None,
|
|
609
|
+
id=app_id,
|
|
610
|
+
),
|
|
611
|
+
) # type: ignore
|
|
612
|
+
|
|
613
|
+
return config_response
|
|
614
|
+
|
|
615
|
+
@classmethod
|
|
616
|
+
@handle_exceptions()
|
|
617
|
+
async def adelete(
|
|
618
|
+
cls,
|
|
619
|
+
*,
|
|
620
|
+
app_id: Optional[str] = None,
|
|
621
|
+
app_slug: Optional[str] = None,
|
|
622
|
+
variant_id: Optional[str] = None,
|
|
623
|
+
variant_slug: Optional[str] = None,
|
|
624
|
+
variant_version: Optional[int] = None,
|
|
625
|
+
):
|
|
626
|
+
config_response = await ag.async_api.variants.configs_delete( # type: ignore
|
|
627
|
+
variant_ref=SharedManager._ref_or_none( # type: ignore
|
|
628
|
+
slug=variant_slug,
|
|
629
|
+
version=variant_version,
|
|
630
|
+
id=variant_id,
|
|
631
|
+
),
|
|
632
|
+
application_ref=SharedManager._ref_or_none( # type: ignore
|
|
633
|
+
slug=app_slug,
|
|
634
|
+
version=None,
|
|
635
|
+
id=app_id,
|
|
636
|
+
),
|
|
637
|
+
) # type: ignore
|
|
638
|
+
|
|
639
|
+
return config_response
|