letta-client 0.1.266__py3-none-any.whl → 0.1.268__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 letta-client might be problematic. Click here for more details.
- letta_client/__init__.py +59 -14
- letta_client/agents/__init__.py +1 -3
- letta_client/agents/templates/__init__.py +2 -2
- letta_client/agents/templates/client.py +52 -134
- letta_client/agents/templates/raw_client.py +50 -300
- letta_client/agents/templates/types/__init__.py +1 -3
- letta_client/core/client_wrapper.py +2 -2
- letta_client/errors/__init__.py +1 -9
- letta_client/templates/__init__.py +56 -1
- letta_client/templates/client.py +774 -2
- letta_client/templates/raw_client.py +1016 -21
- letta_client/templates/types/__init__.py +84 -1
- letta_client/templates/types/templates_create_template_response.py +37 -0
- letta_client/{types/internal_server_error_body.py → templates/types/templates_delete_template_response.py} +4 -4
- letta_client/templates/types/templates_fork_template_response.py +37 -0
- letta_client/templates/types/templates_get_template_snapshot_response.py +28 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item.py +56 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_memory_variables.py +24 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_memory_variables_data_item.py +24 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_properties.py +25 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item.py +39 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_child_output_mapping.py +25 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_five.py +22 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_four.py +22 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_max_count_limit.py +23 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_one.py +22 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_seven.py +23 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_two.py +22 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_rules_item_zero.py +23 -0
- letta_client/templates/types/templates_get_template_snapshot_response_agents_item_tool_variables.py +24 -0
- letta_client/{agents/templates/types/templates_create_response.py → templates/types/templates_get_template_snapshot_response_agents_item_tool_variables_data_item.py} +7 -6
- letta_client/templates/types/templates_get_template_snapshot_response_blocks_item.py +29 -0
- letta_client/templates/types/templates_get_template_snapshot_response_configuration.py +34 -0
- letta_client/templates/types/templates_get_template_snapshot_response_type.py +8 -0
- letta_client/templates/types/templates_list_response_templates_item.py +11 -1
- letta_client/templates/types/templates_list_template_versions_response.py +23 -0
- letta_client/templates/types/templates_list_template_versions_response_versions_item.py +38 -0
- letta_client/templates/types/templates_rename_template_response.py +20 -0
- letta_client/templates/types/templates_save_template_version_response.py +37 -0
- letta_client/types/__init__.py +2 -4
- letta_client/types/conflict_error_body.py +1 -3
- letta_client/types/llm_config.py +6 -0
- letta_client/types/llm_config_verbosity.py +5 -0
- letta_client/types/not_found_error_body.py +1 -1
- {letta_client-0.1.266.dist-info → letta_client-0.1.268.dist-info}/METADATA +1 -1
- {letta_client-0.1.266.dist-info → letta_client-0.1.268.dist-info}/RECORD +47 -25
- letta_client/agents/templates/types/templates_create_version_request_return_agent_state.py +0 -5
- letta_client/errors/internal_server_error.py +0 -10
- letta_client/types/not_found_error_body_message.py +0 -11
- {letta_client-0.1.266.dist-info → letta_client-0.1.268.dist-info}/WHEEL +0 -0
|
@@ -6,9 +6,24 @@ from json.decoder import JSONDecodeError
|
|
|
6
6
|
from ..core.api_error import ApiError
|
|
7
7
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
8
|
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
10
|
from ..core.request_options import RequestOptions
|
|
10
11
|
from ..core.unchecked_base_model import construct_type
|
|
12
|
+
from ..errors.bad_request_error import BadRequestError
|
|
13
|
+
from ..errors.conflict_error import ConflictError
|
|
14
|
+
from ..errors.not_found_error import NotFoundError
|
|
15
|
+
from ..types.conflict_error_body import ConflictErrorBody
|
|
16
|
+
from .types.templates_create_template_response import TemplatesCreateTemplateResponse
|
|
17
|
+
from .types.templates_delete_template_response import TemplatesDeleteTemplateResponse
|
|
18
|
+
from .types.templates_fork_template_response import TemplatesForkTemplateResponse
|
|
19
|
+
from .types.templates_get_template_snapshot_response import TemplatesGetTemplateSnapshotResponse
|
|
11
20
|
from .types.templates_list_response import TemplatesListResponse
|
|
21
|
+
from .types.templates_list_template_versions_response import TemplatesListTemplateVersionsResponse
|
|
22
|
+
from .types.templates_rename_template_response import TemplatesRenameTemplateResponse
|
|
23
|
+
from .types.templates_save_template_version_response import TemplatesSaveTemplateVersionResponse
|
|
24
|
+
|
|
25
|
+
# this is used as the default value for optional parameters
|
|
26
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
12
27
|
|
|
13
28
|
|
|
14
29
|
class RawTemplatesClient:
|
|
@@ -20,7 +35,10 @@ class RawTemplatesClient:
|
|
|
20
35
|
*,
|
|
21
36
|
offset: typing.Optional[str] = None,
|
|
22
37
|
limit: typing.Optional[str] = None,
|
|
38
|
+
template_id: typing.Optional[str] = None,
|
|
23
39
|
name: typing.Optional[str] = None,
|
|
40
|
+
search: typing.Optional[str] = None,
|
|
41
|
+
project_slug: typing.Optional[str] = None,
|
|
24
42
|
project_id: typing.Optional[str] = None,
|
|
25
43
|
request_options: typing.Optional[RequestOptions] = None,
|
|
26
44
|
) -> HttpResponse[TemplatesListResponse]:
|
|
@@ -33,8 +51,14 @@ class RawTemplatesClient:
|
|
|
33
51
|
|
|
34
52
|
limit : typing.Optional[str]
|
|
35
53
|
|
|
54
|
+
template_id : typing.Optional[str]
|
|
55
|
+
|
|
36
56
|
name : typing.Optional[str]
|
|
37
57
|
|
|
58
|
+
search : typing.Optional[str]
|
|
59
|
+
|
|
60
|
+
project_slug : typing.Optional[str]
|
|
61
|
+
|
|
38
62
|
project_id : typing.Optional[str]
|
|
39
63
|
|
|
40
64
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -51,8 +75,11 @@ class RawTemplatesClient:
|
|
|
51
75
|
params={
|
|
52
76
|
"offset": offset,
|
|
53
77
|
"limit": limit,
|
|
78
|
+
"template_id": template_id,
|
|
54
79
|
"name": name,
|
|
55
|
-
"
|
|
80
|
+
"search": search,
|
|
81
|
+
"project_slug": project_slug,
|
|
82
|
+
"project_id": project_id,
|
|
56
83
|
},
|
|
57
84
|
request_options=request_options,
|
|
58
85
|
)
|
|
@@ -71,62 +98,1030 @@ class RawTemplatesClient:
|
|
|
71
98
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
72
99
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
73
100
|
|
|
101
|
+
def savetemplateversion(
|
|
102
|
+
self,
|
|
103
|
+
project: str,
|
|
104
|
+
template_name: str,
|
|
105
|
+
*,
|
|
106
|
+
preserve_environment_variables_on_migration: typing.Optional[bool] = OMIT,
|
|
107
|
+
preserve_core_memories_on_migration: typing.Optional[bool] = OMIT,
|
|
108
|
+
migrate_agents: typing.Optional[bool] = OMIT,
|
|
109
|
+
message: typing.Optional[str] = OMIT,
|
|
110
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
111
|
+
) -> HttpResponse[TemplatesSaveTemplateVersionResponse]:
|
|
112
|
+
"""
|
|
113
|
+
Saves the current version of the template as a new version
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
project : str
|
|
118
|
+
The project slug
|
|
74
119
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
self._client_wrapper = client_wrapper
|
|
120
|
+
template_name : str
|
|
121
|
+
The template version, formatted as {template-name}, any version appended will be ignored
|
|
78
122
|
|
|
79
|
-
|
|
123
|
+
preserve_environment_variables_on_migration : typing.Optional[bool]
|
|
124
|
+
If true, the environment variables will be preserved in the template version when migrating agents
|
|
125
|
+
|
|
126
|
+
preserve_core_memories_on_migration : typing.Optional[bool]
|
|
127
|
+
If true, the core memories will be preserved in the template version when migrating agents
|
|
128
|
+
|
|
129
|
+
migrate_agents : typing.Optional[bool]
|
|
130
|
+
If true, existing agents attached to this template will be migrated to the new template version
|
|
131
|
+
|
|
132
|
+
message : typing.Optional[str]
|
|
133
|
+
A message to describe the changes made in this template version
|
|
134
|
+
|
|
135
|
+
request_options : typing.Optional[RequestOptions]
|
|
136
|
+
Request-specific configuration.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
HttpResponse[TemplatesSaveTemplateVersionResponse]
|
|
141
|
+
200
|
|
142
|
+
"""
|
|
143
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
144
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}",
|
|
145
|
+
method="POST",
|
|
146
|
+
json={
|
|
147
|
+
"preserve_environment_variables_on_migration": preserve_environment_variables_on_migration,
|
|
148
|
+
"preserve_core_memories_on_migration": preserve_core_memories_on_migration,
|
|
149
|
+
"migrate_agents": migrate_agents,
|
|
150
|
+
"message": message,
|
|
151
|
+
},
|
|
152
|
+
headers={
|
|
153
|
+
"content-type": "application/json",
|
|
154
|
+
},
|
|
155
|
+
request_options=request_options,
|
|
156
|
+
omit=OMIT,
|
|
157
|
+
)
|
|
158
|
+
try:
|
|
159
|
+
if 200 <= _response.status_code < 300:
|
|
160
|
+
_data = typing.cast(
|
|
161
|
+
TemplatesSaveTemplateVersionResponse,
|
|
162
|
+
construct_type(
|
|
163
|
+
type_=TemplatesSaveTemplateVersionResponse, # type: ignore
|
|
164
|
+
object_=_response.json(),
|
|
165
|
+
),
|
|
166
|
+
)
|
|
167
|
+
return HttpResponse(response=_response, data=_data)
|
|
168
|
+
if _response.status_code == 400:
|
|
169
|
+
raise BadRequestError(
|
|
170
|
+
headers=dict(_response.headers),
|
|
171
|
+
body=typing.cast(
|
|
172
|
+
typing.Optional[typing.Any],
|
|
173
|
+
construct_type(
|
|
174
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
175
|
+
object_=_response.json(),
|
|
176
|
+
),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
_response_json = _response.json()
|
|
180
|
+
except JSONDecodeError:
|
|
181
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
182
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
183
|
+
|
|
184
|
+
def deletetemplate(
|
|
185
|
+
self, project: str, template_name: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
186
|
+
) -> HttpResponse[TemplatesDeleteTemplateResponse]:
|
|
187
|
+
"""
|
|
188
|
+
Deletes all versions of a template with the specified name
|
|
189
|
+
|
|
190
|
+
Parameters
|
|
191
|
+
----------
|
|
192
|
+
project : str
|
|
193
|
+
The project slug
|
|
194
|
+
|
|
195
|
+
template_name : str
|
|
196
|
+
The template name (without version)
|
|
197
|
+
|
|
198
|
+
request_options : typing.Optional[RequestOptions]
|
|
199
|
+
Request-specific configuration.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
HttpResponse[TemplatesDeleteTemplateResponse]
|
|
204
|
+
200
|
|
205
|
+
"""
|
|
206
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
207
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}",
|
|
208
|
+
method="DELETE",
|
|
209
|
+
json={},
|
|
210
|
+
headers={
|
|
211
|
+
"content-type": "application/json",
|
|
212
|
+
},
|
|
213
|
+
request_options=request_options,
|
|
214
|
+
omit=OMIT,
|
|
215
|
+
)
|
|
216
|
+
try:
|
|
217
|
+
if 200 <= _response.status_code < 300:
|
|
218
|
+
_data = typing.cast(
|
|
219
|
+
TemplatesDeleteTemplateResponse,
|
|
220
|
+
construct_type(
|
|
221
|
+
type_=TemplatesDeleteTemplateResponse, # type: ignore
|
|
222
|
+
object_=_response.json(),
|
|
223
|
+
),
|
|
224
|
+
)
|
|
225
|
+
return HttpResponse(response=_response, data=_data)
|
|
226
|
+
if _response.status_code == 404:
|
|
227
|
+
raise NotFoundError(
|
|
228
|
+
headers=dict(_response.headers),
|
|
229
|
+
body=typing.cast(
|
|
230
|
+
typing.Optional[typing.Any],
|
|
231
|
+
construct_type(
|
|
232
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
233
|
+
object_=_response.json(),
|
|
234
|
+
),
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
_response_json = _response.json()
|
|
238
|
+
except JSONDecodeError:
|
|
239
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
240
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
241
|
+
|
|
242
|
+
def gettemplatesnapshot(
|
|
243
|
+
self, project: str, template_version: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
244
|
+
) -> HttpResponse[TemplatesGetTemplateSnapshotResponse]:
|
|
245
|
+
"""
|
|
246
|
+
Get a snapshot of the template version, this will return the template state at a specific version
|
|
247
|
+
|
|
248
|
+
Parameters
|
|
249
|
+
----------
|
|
250
|
+
project : str
|
|
251
|
+
The project slug
|
|
252
|
+
|
|
253
|
+
template_version : str
|
|
254
|
+
The template version, formatted as {template-name}:{version-number} or {template-name}:latest
|
|
255
|
+
|
|
256
|
+
request_options : typing.Optional[RequestOptions]
|
|
257
|
+
Request-specific configuration.
|
|
258
|
+
|
|
259
|
+
Returns
|
|
260
|
+
-------
|
|
261
|
+
HttpResponse[TemplatesGetTemplateSnapshotResponse]
|
|
262
|
+
200
|
|
263
|
+
"""
|
|
264
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
265
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_version)}/snapshot",
|
|
266
|
+
method="GET",
|
|
267
|
+
request_options=request_options,
|
|
268
|
+
)
|
|
269
|
+
try:
|
|
270
|
+
if 200 <= _response.status_code < 300:
|
|
271
|
+
_data = typing.cast(
|
|
272
|
+
TemplatesGetTemplateSnapshotResponse,
|
|
273
|
+
construct_type(
|
|
274
|
+
type_=TemplatesGetTemplateSnapshotResponse, # type: ignore
|
|
275
|
+
object_=_response.json(),
|
|
276
|
+
),
|
|
277
|
+
)
|
|
278
|
+
return HttpResponse(response=_response, data=_data)
|
|
279
|
+
_response_json = _response.json()
|
|
280
|
+
except JSONDecodeError:
|
|
281
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
282
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
283
|
+
|
|
284
|
+
def forktemplate(
|
|
285
|
+
self,
|
|
286
|
+
project: str,
|
|
287
|
+
template_version: str,
|
|
288
|
+
*,
|
|
289
|
+
name: typing.Optional[str] = OMIT,
|
|
290
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
291
|
+
) -> HttpResponse[TemplatesForkTemplateResponse]:
|
|
292
|
+
"""
|
|
293
|
+
Forks a template version into a new template
|
|
294
|
+
|
|
295
|
+
Parameters
|
|
296
|
+
----------
|
|
297
|
+
project : str
|
|
298
|
+
The project slug
|
|
299
|
+
|
|
300
|
+
template_version : str
|
|
301
|
+
The template version, formatted as {template-name}:{version-number} or {template-name}:latest
|
|
302
|
+
|
|
303
|
+
name : typing.Optional[str]
|
|
304
|
+
Optional custom name for the forked template. If not provided, a random name will be generated.
|
|
305
|
+
|
|
306
|
+
request_options : typing.Optional[RequestOptions]
|
|
307
|
+
Request-specific configuration.
|
|
308
|
+
|
|
309
|
+
Returns
|
|
310
|
+
-------
|
|
311
|
+
HttpResponse[TemplatesForkTemplateResponse]
|
|
312
|
+
200
|
|
313
|
+
"""
|
|
314
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
315
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_version)}/fork",
|
|
316
|
+
method="POST",
|
|
317
|
+
json={
|
|
318
|
+
"name": name,
|
|
319
|
+
},
|
|
320
|
+
headers={
|
|
321
|
+
"content-type": "application/json",
|
|
322
|
+
},
|
|
323
|
+
request_options=request_options,
|
|
324
|
+
omit=OMIT,
|
|
325
|
+
)
|
|
326
|
+
try:
|
|
327
|
+
if 200 <= _response.status_code < 300:
|
|
328
|
+
_data = typing.cast(
|
|
329
|
+
TemplatesForkTemplateResponse,
|
|
330
|
+
construct_type(
|
|
331
|
+
type_=TemplatesForkTemplateResponse, # type: ignore
|
|
332
|
+
object_=_response.json(),
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
return HttpResponse(response=_response, data=_data)
|
|
336
|
+
if _response.status_code == 400:
|
|
337
|
+
raise BadRequestError(
|
|
338
|
+
headers=dict(_response.headers),
|
|
339
|
+
body=typing.cast(
|
|
340
|
+
typing.Optional[typing.Any],
|
|
341
|
+
construct_type(
|
|
342
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
343
|
+
object_=_response.json(),
|
|
344
|
+
),
|
|
345
|
+
),
|
|
346
|
+
)
|
|
347
|
+
_response_json = _response.json()
|
|
348
|
+
except JSONDecodeError:
|
|
349
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
350
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
351
|
+
|
|
352
|
+
def createtemplate(
|
|
353
|
+
self,
|
|
354
|
+
project: str,
|
|
355
|
+
*,
|
|
356
|
+
agent_id: str,
|
|
357
|
+
name: typing.Optional[str] = OMIT,
|
|
358
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
359
|
+
) -> HttpResponse[TemplatesCreateTemplateResponse]:
|
|
360
|
+
"""
|
|
361
|
+
Creates a new template from an existing agent
|
|
362
|
+
|
|
363
|
+
Parameters
|
|
364
|
+
----------
|
|
365
|
+
project : str
|
|
366
|
+
The project slug
|
|
367
|
+
|
|
368
|
+
agent_id : str
|
|
369
|
+
The ID of the agent to use as a template, can be from any project
|
|
370
|
+
|
|
371
|
+
name : typing.Optional[str]
|
|
372
|
+
Optional custom name for the template. If not provided, a random name will be generated.
|
|
373
|
+
|
|
374
|
+
request_options : typing.Optional[RequestOptions]
|
|
375
|
+
Request-specific configuration.
|
|
376
|
+
|
|
377
|
+
Returns
|
|
378
|
+
-------
|
|
379
|
+
HttpResponse[TemplatesCreateTemplateResponse]
|
|
380
|
+
201
|
|
381
|
+
"""
|
|
382
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
383
|
+
f"v1/templates/{jsonable_encoder(project)}",
|
|
384
|
+
method="POST",
|
|
385
|
+
json={
|
|
386
|
+
"agent_id": agent_id,
|
|
387
|
+
"name": name,
|
|
388
|
+
"type": "agent",
|
|
389
|
+
},
|
|
390
|
+
headers={
|
|
391
|
+
"content-type": "application/json",
|
|
392
|
+
},
|
|
393
|
+
request_options=request_options,
|
|
394
|
+
omit=OMIT,
|
|
395
|
+
)
|
|
396
|
+
try:
|
|
397
|
+
if 200 <= _response.status_code < 300:
|
|
398
|
+
_data = typing.cast(
|
|
399
|
+
TemplatesCreateTemplateResponse,
|
|
400
|
+
construct_type(
|
|
401
|
+
type_=TemplatesCreateTemplateResponse, # type: ignore
|
|
402
|
+
object_=_response.json(),
|
|
403
|
+
),
|
|
404
|
+
)
|
|
405
|
+
return HttpResponse(response=_response, data=_data)
|
|
406
|
+
if _response.status_code == 400:
|
|
407
|
+
raise BadRequestError(
|
|
408
|
+
headers=dict(_response.headers),
|
|
409
|
+
body=typing.cast(
|
|
410
|
+
typing.Optional[typing.Any],
|
|
411
|
+
construct_type(
|
|
412
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
413
|
+
object_=_response.json(),
|
|
414
|
+
),
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
_response_json = _response.json()
|
|
418
|
+
except JSONDecodeError:
|
|
419
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
420
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
421
|
+
|
|
422
|
+
def renametemplate(
|
|
423
|
+
self,
|
|
424
|
+
project: str,
|
|
425
|
+
template_name: str,
|
|
426
|
+
*,
|
|
427
|
+
new_name: str,
|
|
428
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
429
|
+
) -> HttpResponse[TemplatesRenameTemplateResponse]:
|
|
430
|
+
"""
|
|
431
|
+
Renames all versions of a template with the specified name. Versions are automatically stripped from the current template name if accidentally included.
|
|
432
|
+
|
|
433
|
+
Parameters
|
|
434
|
+
----------
|
|
435
|
+
project : str
|
|
436
|
+
The project slug
|
|
437
|
+
|
|
438
|
+
template_name : str
|
|
439
|
+
The current template name (version will be automatically stripped if included)
|
|
440
|
+
|
|
441
|
+
new_name : str
|
|
442
|
+
The new name for the template
|
|
443
|
+
|
|
444
|
+
request_options : typing.Optional[RequestOptions]
|
|
445
|
+
Request-specific configuration.
|
|
446
|
+
|
|
447
|
+
Returns
|
|
448
|
+
-------
|
|
449
|
+
HttpResponse[TemplatesRenameTemplateResponse]
|
|
450
|
+
200
|
|
451
|
+
"""
|
|
452
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
453
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}/name",
|
|
454
|
+
method="PATCH",
|
|
455
|
+
json={
|
|
456
|
+
"new_name": new_name,
|
|
457
|
+
},
|
|
458
|
+
headers={
|
|
459
|
+
"content-type": "application/json",
|
|
460
|
+
},
|
|
461
|
+
request_options=request_options,
|
|
462
|
+
omit=OMIT,
|
|
463
|
+
)
|
|
464
|
+
try:
|
|
465
|
+
if 200 <= _response.status_code < 300:
|
|
466
|
+
_data = typing.cast(
|
|
467
|
+
TemplatesRenameTemplateResponse,
|
|
468
|
+
construct_type(
|
|
469
|
+
type_=TemplatesRenameTemplateResponse, # type: ignore
|
|
470
|
+
object_=_response.json(),
|
|
471
|
+
),
|
|
472
|
+
)
|
|
473
|
+
return HttpResponse(response=_response, data=_data)
|
|
474
|
+
if _response.status_code == 400:
|
|
475
|
+
raise BadRequestError(
|
|
476
|
+
headers=dict(_response.headers),
|
|
477
|
+
body=typing.cast(
|
|
478
|
+
typing.Optional[typing.Any],
|
|
479
|
+
construct_type(
|
|
480
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
481
|
+
object_=_response.json(),
|
|
482
|
+
),
|
|
483
|
+
),
|
|
484
|
+
)
|
|
485
|
+
if _response.status_code == 404:
|
|
486
|
+
raise NotFoundError(
|
|
487
|
+
headers=dict(_response.headers),
|
|
488
|
+
body=typing.cast(
|
|
489
|
+
typing.Optional[typing.Any],
|
|
490
|
+
construct_type(
|
|
491
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
492
|
+
object_=_response.json(),
|
|
493
|
+
),
|
|
494
|
+
),
|
|
495
|
+
)
|
|
496
|
+
if _response.status_code == 409:
|
|
497
|
+
raise ConflictError(
|
|
498
|
+
headers=dict(_response.headers),
|
|
499
|
+
body=typing.cast(
|
|
500
|
+
ConflictErrorBody,
|
|
501
|
+
construct_type(
|
|
502
|
+
type_=ConflictErrorBody, # type: ignore
|
|
503
|
+
object_=_response.json(),
|
|
504
|
+
),
|
|
505
|
+
),
|
|
506
|
+
)
|
|
507
|
+
_response_json = _response.json()
|
|
508
|
+
except JSONDecodeError:
|
|
509
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
510
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
511
|
+
|
|
512
|
+
def listtemplateversions(
|
|
80
513
|
self,
|
|
514
|
+
project_slug: str,
|
|
515
|
+
name: str,
|
|
81
516
|
*,
|
|
82
517
|
offset: typing.Optional[str] = None,
|
|
83
518
|
limit: typing.Optional[str] = None,
|
|
84
|
-
name: typing.Optional[str] = None,
|
|
85
|
-
project_id: typing.Optional[str] = None,
|
|
86
519
|
request_options: typing.Optional[RequestOptions] = None,
|
|
87
|
-
) ->
|
|
520
|
+
) -> HttpResponse[TemplatesListTemplateVersionsResponse]:
|
|
88
521
|
"""
|
|
89
|
-
List all
|
|
522
|
+
List all versions of a specific template
|
|
90
523
|
|
|
91
524
|
Parameters
|
|
92
525
|
----------
|
|
93
|
-
|
|
526
|
+
project_slug : str
|
|
527
|
+
The project slug
|
|
94
528
|
|
|
95
|
-
|
|
529
|
+
name : str
|
|
530
|
+
The template name (without version)
|
|
96
531
|
|
|
97
|
-
|
|
532
|
+
offset : typing.Optional[str]
|
|
98
533
|
|
|
99
|
-
|
|
534
|
+
limit : typing.Optional[str]
|
|
100
535
|
|
|
101
536
|
request_options : typing.Optional[RequestOptions]
|
|
102
537
|
Request-specific configuration.
|
|
103
538
|
|
|
104
539
|
Returns
|
|
105
540
|
-------
|
|
106
|
-
|
|
541
|
+
HttpResponse[TemplatesListTemplateVersionsResponse]
|
|
107
542
|
200
|
|
108
543
|
"""
|
|
109
|
-
_response =
|
|
110
|
-
"v1/templates",
|
|
544
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
545
|
+
f"v1/templates/{jsonable_encoder(project_slug)}/{jsonable_encoder(name)}/versions",
|
|
111
546
|
method="GET",
|
|
112
547
|
params={
|
|
113
548
|
"offset": offset,
|
|
114
549
|
"limit": limit,
|
|
115
|
-
"name": name,
|
|
116
|
-
"projectId": project_id,
|
|
117
550
|
},
|
|
118
551
|
request_options=request_options,
|
|
119
552
|
)
|
|
120
553
|
try:
|
|
121
554
|
if 200 <= _response.status_code < 300:
|
|
122
555
|
_data = typing.cast(
|
|
123
|
-
|
|
556
|
+
TemplatesListTemplateVersionsResponse,
|
|
124
557
|
construct_type(
|
|
125
|
-
type_=
|
|
558
|
+
type_=TemplatesListTemplateVersionsResponse, # type: ignore
|
|
126
559
|
object_=_response.json(),
|
|
127
560
|
),
|
|
128
561
|
)
|
|
129
|
-
return
|
|
562
|
+
return HttpResponse(response=_response, data=_data)
|
|
563
|
+
if _response.status_code == 404:
|
|
564
|
+
raise NotFoundError(
|
|
565
|
+
headers=dict(_response.headers),
|
|
566
|
+
body=typing.cast(
|
|
567
|
+
typing.Optional[typing.Any],
|
|
568
|
+
construct_type(
|
|
569
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
570
|
+
object_=_response.json(),
|
|
571
|
+
),
|
|
572
|
+
),
|
|
573
|
+
)
|
|
574
|
+
_response_json = _response.json()
|
|
575
|
+
except JSONDecodeError:
|
|
576
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
577
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
class AsyncRawTemplatesClient:
|
|
581
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
582
|
+
self._client_wrapper = client_wrapper
|
|
583
|
+
|
|
584
|
+
async def list(
|
|
585
|
+
self,
|
|
586
|
+
*,
|
|
587
|
+
offset: typing.Optional[str] = None,
|
|
588
|
+
limit: typing.Optional[str] = None,
|
|
589
|
+
template_id: typing.Optional[str] = None,
|
|
590
|
+
name: typing.Optional[str] = None,
|
|
591
|
+
search: typing.Optional[str] = None,
|
|
592
|
+
project_slug: typing.Optional[str] = None,
|
|
593
|
+
project_id: typing.Optional[str] = None,
|
|
594
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
595
|
+
) -> AsyncHttpResponse[TemplatesListResponse]:
|
|
596
|
+
"""
|
|
597
|
+
List all templates
|
|
598
|
+
|
|
599
|
+
Parameters
|
|
600
|
+
----------
|
|
601
|
+
offset : typing.Optional[str]
|
|
602
|
+
|
|
603
|
+
limit : typing.Optional[str]
|
|
604
|
+
|
|
605
|
+
template_id : typing.Optional[str]
|
|
606
|
+
|
|
607
|
+
name : typing.Optional[str]
|
|
608
|
+
|
|
609
|
+
search : typing.Optional[str]
|
|
610
|
+
|
|
611
|
+
project_slug : typing.Optional[str]
|
|
612
|
+
|
|
613
|
+
project_id : typing.Optional[str]
|
|
614
|
+
|
|
615
|
+
request_options : typing.Optional[RequestOptions]
|
|
616
|
+
Request-specific configuration.
|
|
617
|
+
|
|
618
|
+
Returns
|
|
619
|
+
-------
|
|
620
|
+
AsyncHttpResponse[TemplatesListResponse]
|
|
621
|
+
200
|
|
622
|
+
"""
|
|
623
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
624
|
+
"v1/templates",
|
|
625
|
+
method="GET",
|
|
626
|
+
params={
|
|
627
|
+
"offset": offset,
|
|
628
|
+
"limit": limit,
|
|
629
|
+
"template_id": template_id,
|
|
630
|
+
"name": name,
|
|
631
|
+
"search": search,
|
|
632
|
+
"project_slug": project_slug,
|
|
633
|
+
"project_id": project_id,
|
|
634
|
+
},
|
|
635
|
+
request_options=request_options,
|
|
636
|
+
)
|
|
637
|
+
try:
|
|
638
|
+
if 200 <= _response.status_code < 300:
|
|
639
|
+
_data = typing.cast(
|
|
640
|
+
TemplatesListResponse,
|
|
641
|
+
construct_type(
|
|
642
|
+
type_=TemplatesListResponse, # type: ignore
|
|
643
|
+
object_=_response.json(),
|
|
644
|
+
),
|
|
645
|
+
)
|
|
646
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
647
|
+
_response_json = _response.json()
|
|
648
|
+
except JSONDecodeError:
|
|
649
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
650
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
651
|
+
|
|
652
|
+
async def savetemplateversion(
|
|
653
|
+
self,
|
|
654
|
+
project: str,
|
|
655
|
+
template_name: str,
|
|
656
|
+
*,
|
|
657
|
+
preserve_environment_variables_on_migration: typing.Optional[bool] = OMIT,
|
|
658
|
+
preserve_core_memories_on_migration: typing.Optional[bool] = OMIT,
|
|
659
|
+
migrate_agents: typing.Optional[bool] = OMIT,
|
|
660
|
+
message: typing.Optional[str] = OMIT,
|
|
661
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
662
|
+
) -> AsyncHttpResponse[TemplatesSaveTemplateVersionResponse]:
|
|
663
|
+
"""
|
|
664
|
+
Saves the current version of the template as a new version
|
|
665
|
+
|
|
666
|
+
Parameters
|
|
667
|
+
----------
|
|
668
|
+
project : str
|
|
669
|
+
The project slug
|
|
670
|
+
|
|
671
|
+
template_name : str
|
|
672
|
+
The template version, formatted as {template-name}, any version appended will be ignored
|
|
673
|
+
|
|
674
|
+
preserve_environment_variables_on_migration : typing.Optional[bool]
|
|
675
|
+
If true, the environment variables will be preserved in the template version when migrating agents
|
|
676
|
+
|
|
677
|
+
preserve_core_memories_on_migration : typing.Optional[bool]
|
|
678
|
+
If true, the core memories will be preserved in the template version when migrating agents
|
|
679
|
+
|
|
680
|
+
migrate_agents : typing.Optional[bool]
|
|
681
|
+
If true, existing agents attached to this template will be migrated to the new template version
|
|
682
|
+
|
|
683
|
+
message : typing.Optional[str]
|
|
684
|
+
A message to describe the changes made in this template version
|
|
685
|
+
|
|
686
|
+
request_options : typing.Optional[RequestOptions]
|
|
687
|
+
Request-specific configuration.
|
|
688
|
+
|
|
689
|
+
Returns
|
|
690
|
+
-------
|
|
691
|
+
AsyncHttpResponse[TemplatesSaveTemplateVersionResponse]
|
|
692
|
+
200
|
|
693
|
+
"""
|
|
694
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
695
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}",
|
|
696
|
+
method="POST",
|
|
697
|
+
json={
|
|
698
|
+
"preserve_environment_variables_on_migration": preserve_environment_variables_on_migration,
|
|
699
|
+
"preserve_core_memories_on_migration": preserve_core_memories_on_migration,
|
|
700
|
+
"migrate_agents": migrate_agents,
|
|
701
|
+
"message": message,
|
|
702
|
+
},
|
|
703
|
+
headers={
|
|
704
|
+
"content-type": "application/json",
|
|
705
|
+
},
|
|
706
|
+
request_options=request_options,
|
|
707
|
+
omit=OMIT,
|
|
708
|
+
)
|
|
709
|
+
try:
|
|
710
|
+
if 200 <= _response.status_code < 300:
|
|
711
|
+
_data = typing.cast(
|
|
712
|
+
TemplatesSaveTemplateVersionResponse,
|
|
713
|
+
construct_type(
|
|
714
|
+
type_=TemplatesSaveTemplateVersionResponse, # type: ignore
|
|
715
|
+
object_=_response.json(),
|
|
716
|
+
),
|
|
717
|
+
)
|
|
718
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
719
|
+
if _response.status_code == 400:
|
|
720
|
+
raise BadRequestError(
|
|
721
|
+
headers=dict(_response.headers),
|
|
722
|
+
body=typing.cast(
|
|
723
|
+
typing.Optional[typing.Any],
|
|
724
|
+
construct_type(
|
|
725
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
726
|
+
object_=_response.json(),
|
|
727
|
+
),
|
|
728
|
+
),
|
|
729
|
+
)
|
|
730
|
+
_response_json = _response.json()
|
|
731
|
+
except JSONDecodeError:
|
|
732
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
733
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
734
|
+
|
|
735
|
+
async def deletetemplate(
|
|
736
|
+
self, project: str, template_name: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
737
|
+
) -> AsyncHttpResponse[TemplatesDeleteTemplateResponse]:
|
|
738
|
+
"""
|
|
739
|
+
Deletes all versions of a template with the specified name
|
|
740
|
+
|
|
741
|
+
Parameters
|
|
742
|
+
----------
|
|
743
|
+
project : str
|
|
744
|
+
The project slug
|
|
745
|
+
|
|
746
|
+
template_name : str
|
|
747
|
+
The template name (without version)
|
|
748
|
+
|
|
749
|
+
request_options : typing.Optional[RequestOptions]
|
|
750
|
+
Request-specific configuration.
|
|
751
|
+
|
|
752
|
+
Returns
|
|
753
|
+
-------
|
|
754
|
+
AsyncHttpResponse[TemplatesDeleteTemplateResponse]
|
|
755
|
+
200
|
|
756
|
+
"""
|
|
757
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
758
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}",
|
|
759
|
+
method="DELETE",
|
|
760
|
+
json={},
|
|
761
|
+
headers={
|
|
762
|
+
"content-type": "application/json",
|
|
763
|
+
},
|
|
764
|
+
request_options=request_options,
|
|
765
|
+
omit=OMIT,
|
|
766
|
+
)
|
|
767
|
+
try:
|
|
768
|
+
if 200 <= _response.status_code < 300:
|
|
769
|
+
_data = typing.cast(
|
|
770
|
+
TemplatesDeleteTemplateResponse,
|
|
771
|
+
construct_type(
|
|
772
|
+
type_=TemplatesDeleteTemplateResponse, # type: ignore
|
|
773
|
+
object_=_response.json(),
|
|
774
|
+
),
|
|
775
|
+
)
|
|
776
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
777
|
+
if _response.status_code == 404:
|
|
778
|
+
raise NotFoundError(
|
|
779
|
+
headers=dict(_response.headers),
|
|
780
|
+
body=typing.cast(
|
|
781
|
+
typing.Optional[typing.Any],
|
|
782
|
+
construct_type(
|
|
783
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
784
|
+
object_=_response.json(),
|
|
785
|
+
),
|
|
786
|
+
),
|
|
787
|
+
)
|
|
788
|
+
_response_json = _response.json()
|
|
789
|
+
except JSONDecodeError:
|
|
790
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
791
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
792
|
+
|
|
793
|
+
async def gettemplatesnapshot(
|
|
794
|
+
self, project: str, template_version: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
795
|
+
) -> AsyncHttpResponse[TemplatesGetTemplateSnapshotResponse]:
|
|
796
|
+
"""
|
|
797
|
+
Get a snapshot of the template version, this will return the template state at a specific version
|
|
798
|
+
|
|
799
|
+
Parameters
|
|
800
|
+
----------
|
|
801
|
+
project : str
|
|
802
|
+
The project slug
|
|
803
|
+
|
|
804
|
+
template_version : str
|
|
805
|
+
The template version, formatted as {template-name}:{version-number} or {template-name}:latest
|
|
806
|
+
|
|
807
|
+
request_options : typing.Optional[RequestOptions]
|
|
808
|
+
Request-specific configuration.
|
|
809
|
+
|
|
810
|
+
Returns
|
|
811
|
+
-------
|
|
812
|
+
AsyncHttpResponse[TemplatesGetTemplateSnapshotResponse]
|
|
813
|
+
200
|
|
814
|
+
"""
|
|
815
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
816
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_version)}/snapshot",
|
|
817
|
+
method="GET",
|
|
818
|
+
request_options=request_options,
|
|
819
|
+
)
|
|
820
|
+
try:
|
|
821
|
+
if 200 <= _response.status_code < 300:
|
|
822
|
+
_data = typing.cast(
|
|
823
|
+
TemplatesGetTemplateSnapshotResponse,
|
|
824
|
+
construct_type(
|
|
825
|
+
type_=TemplatesGetTemplateSnapshotResponse, # type: ignore
|
|
826
|
+
object_=_response.json(),
|
|
827
|
+
),
|
|
828
|
+
)
|
|
829
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
830
|
+
_response_json = _response.json()
|
|
831
|
+
except JSONDecodeError:
|
|
832
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
833
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
834
|
+
|
|
835
|
+
async def forktemplate(
|
|
836
|
+
self,
|
|
837
|
+
project: str,
|
|
838
|
+
template_version: str,
|
|
839
|
+
*,
|
|
840
|
+
name: typing.Optional[str] = OMIT,
|
|
841
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
842
|
+
) -> AsyncHttpResponse[TemplatesForkTemplateResponse]:
|
|
843
|
+
"""
|
|
844
|
+
Forks a template version into a new template
|
|
845
|
+
|
|
846
|
+
Parameters
|
|
847
|
+
----------
|
|
848
|
+
project : str
|
|
849
|
+
The project slug
|
|
850
|
+
|
|
851
|
+
template_version : str
|
|
852
|
+
The template version, formatted as {template-name}:{version-number} or {template-name}:latest
|
|
853
|
+
|
|
854
|
+
name : typing.Optional[str]
|
|
855
|
+
Optional custom name for the forked template. If not provided, a random name will be generated.
|
|
856
|
+
|
|
857
|
+
request_options : typing.Optional[RequestOptions]
|
|
858
|
+
Request-specific configuration.
|
|
859
|
+
|
|
860
|
+
Returns
|
|
861
|
+
-------
|
|
862
|
+
AsyncHttpResponse[TemplatesForkTemplateResponse]
|
|
863
|
+
200
|
|
864
|
+
"""
|
|
865
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
866
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_version)}/fork",
|
|
867
|
+
method="POST",
|
|
868
|
+
json={
|
|
869
|
+
"name": name,
|
|
870
|
+
},
|
|
871
|
+
headers={
|
|
872
|
+
"content-type": "application/json",
|
|
873
|
+
},
|
|
874
|
+
request_options=request_options,
|
|
875
|
+
omit=OMIT,
|
|
876
|
+
)
|
|
877
|
+
try:
|
|
878
|
+
if 200 <= _response.status_code < 300:
|
|
879
|
+
_data = typing.cast(
|
|
880
|
+
TemplatesForkTemplateResponse,
|
|
881
|
+
construct_type(
|
|
882
|
+
type_=TemplatesForkTemplateResponse, # type: ignore
|
|
883
|
+
object_=_response.json(),
|
|
884
|
+
),
|
|
885
|
+
)
|
|
886
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
887
|
+
if _response.status_code == 400:
|
|
888
|
+
raise BadRequestError(
|
|
889
|
+
headers=dict(_response.headers),
|
|
890
|
+
body=typing.cast(
|
|
891
|
+
typing.Optional[typing.Any],
|
|
892
|
+
construct_type(
|
|
893
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
894
|
+
object_=_response.json(),
|
|
895
|
+
),
|
|
896
|
+
),
|
|
897
|
+
)
|
|
898
|
+
_response_json = _response.json()
|
|
899
|
+
except JSONDecodeError:
|
|
900
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
901
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
902
|
+
|
|
903
|
+
async def createtemplate(
|
|
904
|
+
self,
|
|
905
|
+
project: str,
|
|
906
|
+
*,
|
|
907
|
+
agent_id: str,
|
|
908
|
+
name: typing.Optional[str] = OMIT,
|
|
909
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
910
|
+
) -> AsyncHttpResponse[TemplatesCreateTemplateResponse]:
|
|
911
|
+
"""
|
|
912
|
+
Creates a new template from an existing agent
|
|
913
|
+
|
|
914
|
+
Parameters
|
|
915
|
+
----------
|
|
916
|
+
project : str
|
|
917
|
+
The project slug
|
|
918
|
+
|
|
919
|
+
agent_id : str
|
|
920
|
+
The ID of the agent to use as a template, can be from any project
|
|
921
|
+
|
|
922
|
+
name : typing.Optional[str]
|
|
923
|
+
Optional custom name for the template. If not provided, a random name will be generated.
|
|
924
|
+
|
|
925
|
+
request_options : typing.Optional[RequestOptions]
|
|
926
|
+
Request-specific configuration.
|
|
927
|
+
|
|
928
|
+
Returns
|
|
929
|
+
-------
|
|
930
|
+
AsyncHttpResponse[TemplatesCreateTemplateResponse]
|
|
931
|
+
201
|
|
932
|
+
"""
|
|
933
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
934
|
+
f"v1/templates/{jsonable_encoder(project)}",
|
|
935
|
+
method="POST",
|
|
936
|
+
json={
|
|
937
|
+
"agent_id": agent_id,
|
|
938
|
+
"name": name,
|
|
939
|
+
"type": "agent",
|
|
940
|
+
},
|
|
941
|
+
headers={
|
|
942
|
+
"content-type": "application/json",
|
|
943
|
+
},
|
|
944
|
+
request_options=request_options,
|
|
945
|
+
omit=OMIT,
|
|
946
|
+
)
|
|
947
|
+
try:
|
|
948
|
+
if 200 <= _response.status_code < 300:
|
|
949
|
+
_data = typing.cast(
|
|
950
|
+
TemplatesCreateTemplateResponse,
|
|
951
|
+
construct_type(
|
|
952
|
+
type_=TemplatesCreateTemplateResponse, # type: ignore
|
|
953
|
+
object_=_response.json(),
|
|
954
|
+
),
|
|
955
|
+
)
|
|
956
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
957
|
+
if _response.status_code == 400:
|
|
958
|
+
raise BadRequestError(
|
|
959
|
+
headers=dict(_response.headers),
|
|
960
|
+
body=typing.cast(
|
|
961
|
+
typing.Optional[typing.Any],
|
|
962
|
+
construct_type(
|
|
963
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
964
|
+
object_=_response.json(),
|
|
965
|
+
),
|
|
966
|
+
),
|
|
967
|
+
)
|
|
968
|
+
_response_json = _response.json()
|
|
969
|
+
except JSONDecodeError:
|
|
970
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
971
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
972
|
+
|
|
973
|
+
async def renametemplate(
|
|
974
|
+
self,
|
|
975
|
+
project: str,
|
|
976
|
+
template_name: str,
|
|
977
|
+
*,
|
|
978
|
+
new_name: str,
|
|
979
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
980
|
+
) -> AsyncHttpResponse[TemplatesRenameTemplateResponse]:
|
|
981
|
+
"""
|
|
982
|
+
Renames all versions of a template with the specified name. Versions are automatically stripped from the current template name if accidentally included.
|
|
983
|
+
|
|
984
|
+
Parameters
|
|
985
|
+
----------
|
|
986
|
+
project : str
|
|
987
|
+
The project slug
|
|
988
|
+
|
|
989
|
+
template_name : str
|
|
990
|
+
The current template name (version will be automatically stripped if included)
|
|
991
|
+
|
|
992
|
+
new_name : str
|
|
993
|
+
The new name for the template
|
|
994
|
+
|
|
995
|
+
request_options : typing.Optional[RequestOptions]
|
|
996
|
+
Request-specific configuration.
|
|
997
|
+
|
|
998
|
+
Returns
|
|
999
|
+
-------
|
|
1000
|
+
AsyncHttpResponse[TemplatesRenameTemplateResponse]
|
|
1001
|
+
200
|
|
1002
|
+
"""
|
|
1003
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1004
|
+
f"v1/templates/{jsonable_encoder(project)}/{jsonable_encoder(template_name)}/name",
|
|
1005
|
+
method="PATCH",
|
|
1006
|
+
json={
|
|
1007
|
+
"new_name": new_name,
|
|
1008
|
+
},
|
|
1009
|
+
headers={
|
|
1010
|
+
"content-type": "application/json",
|
|
1011
|
+
},
|
|
1012
|
+
request_options=request_options,
|
|
1013
|
+
omit=OMIT,
|
|
1014
|
+
)
|
|
1015
|
+
try:
|
|
1016
|
+
if 200 <= _response.status_code < 300:
|
|
1017
|
+
_data = typing.cast(
|
|
1018
|
+
TemplatesRenameTemplateResponse,
|
|
1019
|
+
construct_type(
|
|
1020
|
+
type_=TemplatesRenameTemplateResponse, # type: ignore
|
|
1021
|
+
object_=_response.json(),
|
|
1022
|
+
),
|
|
1023
|
+
)
|
|
1024
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1025
|
+
if _response.status_code == 400:
|
|
1026
|
+
raise BadRequestError(
|
|
1027
|
+
headers=dict(_response.headers),
|
|
1028
|
+
body=typing.cast(
|
|
1029
|
+
typing.Optional[typing.Any],
|
|
1030
|
+
construct_type(
|
|
1031
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1032
|
+
object_=_response.json(),
|
|
1033
|
+
),
|
|
1034
|
+
),
|
|
1035
|
+
)
|
|
1036
|
+
if _response.status_code == 404:
|
|
1037
|
+
raise NotFoundError(
|
|
1038
|
+
headers=dict(_response.headers),
|
|
1039
|
+
body=typing.cast(
|
|
1040
|
+
typing.Optional[typing.Any],
|
|
1041
|
+
construct_type(
|
|
1042
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1043
|
+
object_=_response.json(),
|
|
1044
|
+
),
|
|
1045
|
+
),
|
|
1046
|
+
)
|
|
1047
|
+
if _response.status_code == 409:
|
|
1048
|
+
raise ConflictError(
|
|
1049
|
+
headers=dict(_response.headers),
|
|
1050
|
+
body=typing.cast(
|
|
1051
|
+
ConflictErrorBody,
|
|
1052
|
+
construct_type(
|
|
1053
|
+
type_=ConflictErrorBody, # type: ignore
|
|
1054
|
+
object_=_response.json(),
|
|
1055
|
+
),
|
|
1056
|
+
),
|
|
1057
|
+
)
|
|
1058
|
+
_response_json = _response.json()
|
|
1059
|
+
except JSONDecodeError:
|
|
1060
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1061
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1062
|
+
|
|
1063
|
+
async def listtemplateversions(
|
|
1064
|
+
self,
|
|
1065
|
+
project_slug: str,
|
|
1066
|
+
name: str,
|
|
1067
|
+
*,
|
|
1068
|
+
offset: typing.Optional[str] = None,
|
|
1069
|
+
limit: typing.Optional[str] = None,
|
|
1070
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1071
|
+
) -> AsyncHttpResponse[TemplatesListTemplateVersionsResponse]:
|
|
1072
|
+
"""
|
|
1073
|
+
List all versions of a specific template
|
|
1074
|
+
|
|
1075
|
+
Parameters
|
|
1076
|
+
----------
|
|
1077
|
+
project_slug : str
|
|
1078
|
+
The project slug
|
|
1079
|
+
|
|
1080
|
+
name : str
|
|
1081
|
+
The template name (without version)
|
|
1082
|
+
|
|
1083
|
+
offset : typing.Optional[str]
|
|
1084
|
+
|
|
1085
|
+
limit : typing.Optional[str]
|
|
1086
|
+
|
|
1087
|
+
request_options : typing.Optional[RequestOptions]
|
|
1088
|
+
Request-specific configuration.
|
|
1089
|
+
|
|
1090
|
+
Returns
|
|
1091
|
+
-------
|
|
1092
|
+
AsyncHttpResponse[TemplatesListTemplateVersionsResponse]
|
|
1093
|
+
200
|
|
1094
|
+
"""
|
|
1095
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1096
|
+
f"v1/templates/{jsonable_encoder(project_slug)}/{jsonable_encoder(name)}/versions",
|
|
1097
|
+
method="GET",
|
|
1098
|
+
params={
|
|
1099
|
+
"offset": offset,
|
|
1100
|
+
"limit": limit,
|
|
1101
|
+
},
|
|
1102
|
+
request_options=request_options,
|
|
1103
|
+
)
|
|
1104
|
+
try:
|
|
1105
|
+
if 200 <= _response.status_code < 300:
|
|
1106
|
+
_data = typing.cast(
|
|
1107
|
+
TemplatesListTemplateVersionsResponse,
|
|
1108
|
+
construct_type(
|
|
1109
|
+
type_=TemplatesListTemplateVersionsResponse, # type: ignore
|
|
1110
|
+
object_=_response.json(),
|
|
1111
|
+
),
|
|
1112
|
+
)
|
|
1113
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1114
|
+
if _response.status_code == 404:
|
|
1115
|
+
raise NotFoundError(
|
|
1116
|
+
headers=dict(_response.headers),
|
|
1117
|
+
body=typing.cast(
|
|
1118
|
+
typing.Optional[typing.Any],
|
|
1119
|
+
construct_type(
|
|
1120
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1121
|
+
object_=_response.json(),
|
|
1122
|
+
),
|
|
1123
|
+
),
|
|
1124
|
+
)
|
|
130
1125
|
_response_json = _response.json()
|
|
131
1126
|
except JSONDecodeError:
|
|
132
1127
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|