agentrun-inner-test 0.0.62__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 agentrun-inner-test might be problematic. Click here for more details.
- agentrun/__init__.py +358 -0
- agentrun/agent_runtime/__client_async_template.py +466 -0
- agentrun/agent_runtime/__endpoint_async_template.py +345 -0
- agentrun/agent_runtime/__init__.py +53 -0
- agentrun/agent_runtime/__runtime_async_template.py +477 -0
- agentrun/agent_runtime/api/__data_async_template.py +58 -0
- agentrun/agent_runtime/api/__init__.py +6 -0
- agentrun/agent_runtime/api/control.py +1362 -0
- agentrun/agent_runtime/api/data.py +98 -0
- agentrun/agent_runtime/client.py +868 -0
- agentrun/agent_runtime/endpoint.py +649 -0
- agentrun/agent_runtime/model.py +362 -0
- agentrun/agent_runtime/runtime.py +904 -0
- agentrun/credential/__client_async_template.py +177 -0
- agentrun/credential/__credential_async_template.py +216 -0
- agentrun/credential/__init__.py +28 -0
- agentrun/credential/api/__init__.py +5 -0
- agentrun/credential/api/control.py +606 -0
- agentrun/credential/client.py +319 -0
- agentrun/credential/credential.py +381 -0
- agentrun/credential/model.py +248 -0
- agentrun/integration/__init__.py +21 -0
- agentrun/integration/agentscope/__init__.py +13 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +88 -0
- agentrun/integration/agentscope/message_adapter.py +185 -0
- agentrun/integration/agentscope/model_adapter.py +60 -0
- agentrun/integration/agentscope/tool_adapter.py +59 -0
- agentrun/integration/builtin/__init__.py +18 -0
- agentrun/integration/builtin/knowledgebase.py +137 -0
- agentrun/integration/builtin/model.py +93 -0
- agentrun/integration/builtin/sandbox.py +1234 -0
- agentrun/integration/builtin/toolset.py +47 -0
- agentrun/integration/crewai/__init__.py +13 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +88 -0
- agentrun/integration/crewai/model_adapter.py +31 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +13 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +88 -0
- agentrun/integration/google_adk/message_adapter.py +144 -0
- agentrun/integration/google_adk/model_adapter.py +46 -0
- agentrun/integration/google_adk/tool_adapter.py +235 -0
- agentrun/integration/langchain/__init__.py +31 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +94 -0
- agentrun/integration/langchain/message_adapter.py +141 -0
- agentrun/integration/langchain/model_adapter.py +37 -0
- agentrun/integration/langchain/tool_adapter.py +50 -0
- agentrun/integration/langgraph/__init__.py +36 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/agent_converter.py +1073 -0
- agentrun/integration/langgraph/builtin.py +88 -0
- agentrun/integration/pydantic_ai/__init__.py +13 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +88 -0
- agentrun/integration/pydantic_ai/model_adapter.py +44 -0
- agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
- agentrun/integration/utils/__init__.py +112 -0
- agentrun/integration/utils/adapter.py +560 -0
- agentrun/integration/utils/canonical.py +164 -0
- agentrun/integration/utils/converter.py +134 -0
- agentrun/integration/utils/model.py +110 -0
- agentrun/integration/utils/tool.py +1759 -0
- agentrun/knowledgebase/__client_async_template.py +173 -0
- agentrun/knowledgebase/__init__.py +53 -0
- agentrun/knowledgebase/__knowledgebase_async_template.py +438 -0
- agentrun/knowledgebase/api/__data_async_template.py +414 -0
- agentrun/knowledgebase/api/__init__.py +19 -0
- agentrun/knowledgebase/api/control.py +606 -0
- agentrun/knowledgebase/api/data.py +624 -0
- agentrun/knowledgebase/client.py +311 -0
- agentrun/knowledgebase/knowledgebase.py +748 -0
- agentrun/knowledgebase/model.py +270 -0
- agentrun/memory_collection/__client_async_template.py +178 -0
- agentrun/memory_collection/__init__.py +37 -0
- agentrun/memory_collection/__memory_collection_async_template.py +457 -0
- agentrun/memory_collection/api/__init__.py +5 -0
- agentrun/memory_collection/api/control.py +610 -0
- agentrun/memory_collection/client.py +323 -0
- agentrun/memory_collection/memory_collection.py +844 -0
- agentrun/memory_collection/model.py +162 -0
- agentrun/model/__client_async_template.py +357 -0
- agentrun/model/__init__.py +57 -0
- agentrun/model/__model_proxy_async_template.py +270 -0
- agentrun/model/__model_service_async_template.py +267 -0
- agentrun/model/api/__init__.py +6 -0
- agentrun/model/api/control.py +1173 -0
- agentrun/model/api/data.py +196 -0
- agentrun/model/client.py +674 -0
- agentrun/model/model.py +235 -0
- agentrun/model/model_proxy.py +439 -0
- agentrun/model/model_service.py +438 -0
- agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
- agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
- agentrun/sandbox/__client_async_template.py +491 -0
- agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
- agentrun/sandbox/__init__.py +69 -0
- agentrun/sandbox/__sandbox_async_template.py +463 -0
- agentrun/sandbox/__template_async_template.py +152 -0
- agentrun/sandbox/aio_sandbox.py +912 -0
- agentrun/sandbox/api/__aio_data_async_template.py +335 -0
- agentrun/sandbox/api/__browser_data_async_template.py +140 -0
- agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
- agentrun/sandbox/api/__init__.py +19 -0
- agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
- agentrun/sandbox/api/aio_data.py +551 -0
- agentrun/sandbox/api/browser_data.py +172 -0
- agentrun/sandbox/api/code_interpreter_data.py +396 -0
- agentrun/sandbox/api/control.py +1051 -0
- agentrun/sandbox/api/playwright_async.py +492 -0
- agentrun/sandbox/api/playwright_sync.py +492 -0
- agentrun/sandbox/api/sandbox_data.py +154 -0
- agentrun/sandbox/browser_sandbox.py +185 -0
- agentrun/sandbox/client.py +925 -0
- agentrun/sandbox/code_interpreter_sandbox.py +823 -0
- agentrun/sandbox/model.py +384 -0
- agentrun/sandbox/sandbox.py +848 -0
- agentrun/sandbox/template.py +217 -0
- agentrun/server/__init__.py +191 -0
- agentrun/server/agui_normalizer.py +180 -0
- agentrun/server/agui_protocol.py +797 -0
- agentrun/server/invoker.py +309 -0
- agentrun/server/model.py +427 -0
- agentrun/server/openai_protocol.py +535 -0
- agentrun/server/protocol.py +140 -0
- agentrun/server/server.py +208 -0
- agentrun/toolset/__client_async_template.py +62 -0
- agentrun/toolset/__init__.py +51 -0
- agentrun/toolset/__toolset_async_template.py +204 -0
- agentrun/toolset/api/__init__.py +17 -0
- agentrun/toolset/api/control.py +262 -0
- agentrun/toolset/api/mcp.py +100 -0
- agentrun/toolset/api/openapi.py +1251 -0
- agentrun/toolset/client.py +102 -0
- agentrun/toolset/model.py +321 -0
- agentrun/toolset/toolset.py +271 -0
- agentrun/utils/__data_api_async_template.py +721 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +270 -0
- agentrun/utils/control_api.py +105 -0
- agentrun/utils/data_api.py +1121 -0
- agentrun/utils/exception.py +151 -0
- agentrun/utils/helper.py +108 -0
- agentrun/utils/log.py +77 -0
- agentrun/utils/model.py +168 -0
- agentrun/utils/resource.py +291 -0
- agentrun_inner_test-0.0.62.dist-info/METADATA +265 -0
- agentrun_inner_test-0.0.62.dist-info/RECORD +154 -0
- agentrun_inner_test-0.0.62.dist-info/WHEEL +5 -0
- agentrun_inner_test-0.0.62.dist-info/licenses/LICENSE +201 -0
- agentrun_inner_test-0.0.62.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1051 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file is auto generated by the code generation script.
|
|
3
|
+
Do not modify this file manually.
|
|
4
|
+
Use the `make codegen` command to regenerate.
|
|
5
|
+
|
|
6
|
+
当前文件为自动生成的控制 API 客户端代码。请勿手动修改此文件。
|
|
7
|
+
使用 `make codegen` 命令重新生成。
|
|
8
|
+
|
|
9
|
+
source: codegen/configs/sandbox_control_api.yaml
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Sandbox 管控链路 API
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from typing import Dict, Optional
|
|
16
|
+
|
|
17
|
+
from alibabacloud_agentrun20250910.models import (
|
|
18
|
+
CreateSandboxInput,
|
|
19
|
+
CreateSandboxRequest,
|
|
20
|
+
CreateTemplateInput,
|
|
21
|
+
CreateTemplateRequest,
|
|
22
|
+
ListSandboxesOutput,
|
|
23
|
+
ListSandboxesRequest,
|
|
24
|
+
ListTemplatesOutput,
|
|
25
|
+
ListTemplatesRequest,
|
|
26
|
+
Sandbox,
|
|
27
|
+
Template,
|
|
28
|
+
UpdateTemplateInput,
|
|
29
|
+
UpdateTemplateRequest,
|
|
30
|
+
)
|
|
31
|
+
from alibabacloud_tea_openapi.exceptions._client import ClientException
|
|
32
|
+
from alibabacloud_tea_openapi.exceptions._server import ServerException
|
|
33
|
+
from darabonba.runtime import RuntimeOptions
|
|
34
|
+
import pydash
|
|
35
|
+
|
|
36
|
+
from agentrun.utils.config import Config
|
|
37
|
+
from agentrun.utils.control_api import ControlAPI
|
|
38
|
+
from agentrun.utils.exception import ClientError, ServerError
|
|
39
|
+
from agentrun.utils.log import logger
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class SandboxControlAPI(ControlAPI):
|
|
43
|
+
"""Sandbox 管控链路 API"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, config: Optional[Config] = None):
|
|
46
|
+
"""初始化 API 客户端
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
config: 全局配置对象
|
|
50
|
+
"""
|
|
51
|
+
super().__init__(config)
|
|
52
|
+
|
|
53
|
+
def create_template(
|
|
54
|
+
self,
|
|
55
|
+
input: CreateTemplateInput,
|
|
56
|
+
headers: Optional[Dict[str, str]] = None,
|
|
57
|
+
config: Optional[Config] = None,
|
|
58
|
+
) -> Template:
|
|
59
|
+
"""创建 Sandbox Template
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
input: Template 配置
|
|
63
|
+
|
|
64
|
+
headers: 请求头
|
|
65
|
+
config: 配置
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Template: 创建的 Template 对象
|
|
69
|
+
|
|
70
|
+
Raises:
|
|
71
|
+
AgentRuntimeError: 调用失败时抛出
|
|
72
|
+
ClientError: 客户端错误
|
|
73
|
+
ServerError: 服务器错误
|
|
74
|
+
APIError: 运行时错误
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
client = self._get_client(config)
|
|
79
|
+
response = client.create_template_with_options(
|
|
80
|
+
CreateTemplateRequest(body=input),
|
|
81
|
+
headers=headers or {},
|
|
82
|
+
runtime=RuntimeOptions(),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
logger.debug(
|
|
86
|
+
"request api create_template, request Request ID:"
|
|
87
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
88
|
+
f" response: {response.body.data}"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return response.body.data
|
|
92
|
+
except ClientException as e:
|
|
93
|
+
raise ClientError(
|
|
94
|
+
e.status_code,
|
|
95
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
96
|
+
request_id=e.request_id,
|
|
97
|
+
request=[
|
|
98
|
+
input,
|
|
99
|
+
],
|
|
100
|
+
) from e
|
|
101
|
+
except ServerException as e:
|
|
102
|
+
raise ServerError(
|
|
103
|
+
e.status_code,
|
|
104
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
105
|
+
request_id=e.request_id,
|
|
106
|
+
) from e
|
|
107
|
+
|
|
108
|
+
async def create_template_async(
|
|
109
|
+
self,
|
|
110
|
+
input: CreateTemplateInput,
|
|
111
|
+
headers: Optional[Dict[str, str]] = None,
|
|
112
|
+
config: Optional[Config] = None,
|
|
113
|
+
) -> Template:
|
|
114
|
+
"""创建 Sandbox Template
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
input: Template 配置
|
|
118
|
+
|
|
119
|
+
headers: 请求头
|
|
120
|
+
config: 配置
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
Template: 创建的 Template 对象
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
AgentRuntimeError: 调用失败时抛出
|
|
127
|
+
ClientError: 客户端错误
|
|
128
|
+
ServerError: 服务器错误
|
|
129
|
+
APIError: 运行时错误
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
client = self._get_client(config)
|
|
134
|
+
response = await client.create_template_with_options_async(
|
|
135
|
+
CreateTemplateRequest(body=input),
|
|
136
|
+
headers=headers or {},
|
|
137
|
+
runtime=RuntimeOptions(),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
logger.debug(
|
|
141
|
+
"request api create_template, request Request ID:"
|
|
142
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
143
|
+
f" response: {response.body.data}"
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return response.body.data
|
|
147
|
+
except ClientException as e:
|
|
148
|
+
raise ClientError(
|
|
149
|
+
e.status_code,
|
|
150
|
+
e.data.get("message", e.message),
|
|
151
|
+
request_id=e.request_id,
|
|
152
|
+
request=[
|
|
153
|
+
input,
|
|
154
|
+
],
|
|
155
|
+
) from e
|
|
156
|
+
except ServerException as e:
|
|
157
|
+
raise ServerError(
|
|
158
|
+
e.status_code,
|
|
159
|
+
e.data.get("message", e.message),
|
|
160
|
+
request_id=e.request_id,
|
|
161
|
+
) from e
|
|
162
|
+
|
|
163
|
+
def delete_template(
|
|
164
|
+
self,
|
|
165
|
+
template_name: str,
|
|
166
|
+
headers: Optional[Dict[str, str]] = None,
|
|
167
|
+
config: Optional[Config] = None,
|
|
168
|
+
) -> Template:
|
|
169
|
+
"""删除 Sandbox Template
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
template_name: Template 名称
|
|
173
|
+
|
|
174
|
+
headers: 请求头
|
|
175
|
+
config: 配置
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
Template: 删除结果
|
|
179
|
+
|
|
180
|
+
Raises:
|
|
181
|
+
AgentRuntimeError: 调用失败时抛出
|
|
182
|
+
ClientError: 客户端错误
|
|
183
|
+
ServerError: 服务器错误
|
|
184
|
+
APIError: 运行时错误
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
client = self._get_client(config)
|
|
189
|
+
response = client.delete_template_with_options(
|
|
190
|
+
template_name,
|
|
191
|
+
headers=headers or {},
|
|
192
|
+
runtime=RuntimeOptions(),
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
logger.debug(
|
|
196
|
+
"request api delete_template, request Request ID:"
|
|
197
|
+
f" {response.body.request_id}\n request: {[template_name,]}\n "
|
|
198
|
+
f" response: {response.body.data}"
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return response.body.data
|
|
202
|
+
except ClientException as e:
|
|
203
|
+
raise ClientError(
|
|
204
|
+
e.status_code,
|
|
205
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
206
|
+
request_id=e.request_id,
|
|
207
|
+
request=[
|
|
208
|
+
template_name,
|
|
209
|
+
],
|
|
210
|
+
) from e
|
|
211
|
+
except ServerException as e:
|
|
212
|
+
raise ServerError(
|
|
213
|
+
e.status_code,
|
|
214
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
215
|
+
request_id=e.request_id,
|
|
216
|
+
) from e
|
|
217
|
+
|
|
218
|
+
async def delete_template_async(
|
|
219
|
+
self,
|
|
220
|
+
template_name: str,
|
|
221
|
+
headers: Optional[Dict[str, str]] = None,
|
|
222
|
+
config: Optional[Config] = None,
|
|
223
|
+
) -> Template:
|
|
224
|
+
"""删除 Sandbox Template
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
template_name: Template 名称
|
|
228
|
+
|
|
229
|
+
headers: 请求头
|
|
230
|
+
config: 配置
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
Template: 删除结果
|
|
234
|
+
|
|
235
|
+
Raises:
|
|
236
|
+
AgentRuntimeError: 调用失败时抛出
|
|
237
|
+
ClientError: 客户端错误
|
|
238
|
+
ServerError: 服务器错误
|
|
239
|
+
APIError: 运行时错误
|
|
240
|
+
"""
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
client = self._get_client(config)
|
|
244
|
+
response = await client.delete_template_with_options_async(
|
|
245
|
+
template_name,
|
|
246
|
+
headers=headers or {},
|
|
247
|
+
runtime=RuntimeOptions(),
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
logger.debug(
|
|
251
|
+
"request api delete_template, request Request ID:"
|
|
252
|
+
f" {response.body.request_id}\n request: {[template_name,]}\n "
|
|
253
|
+
f" response: {response.body.data}"
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return response.body.data
|
|
257
|
+
except ClientException as e:
|
|
258
|
+
raise ClientError(
|
|
259
|
+
e.status_code,
|
|
260
|
+
e.data.get("message", e.message),
|
|
261
|
+
request_id=e.request_id,
|
|
262
|
+
request=[
|
|
263
|
+
template_name,
|
|
264
|
+
],
|
|
265
|
+
) from e
|
|
266
|
+
except ServerException as e:
|
|
267
|
+
raise ServerError(
|
|
268
|
+
e.status_code,
|
|
269
|
+
e.data.get("message", e.message),
|
|
270
|
+
request_id=e.request_id,
|
|
271
|
+
) from e
|
|
272
|
+
|
|
273
|
+
def update_template(
|
|
274
|
+
self,
|
|
275
|
+
template_name: str,
|
|
276
|
+
input: UpdateTemplateInput,
|
|
277
|
+
headers: Optional[Dict[str, str]] = None,
|
|
278
|
+
config: Optional[Config] = None,
|
|
279
|
+
) -> Template:
|
|
280
|
+
"""更新 Sandbox Template
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
template_name: Template 名称
|
|
284
|
+
input: Template 配置
|
|
285
|
+
|
|
286
|
+
headers: 请求头
|
|
287
|
+
config: 配置
|
|
288
|
+
|
|
289
|
+
Returns:
|
|
290
|
+
Template: 更新的 Template 对象
|
|
291
|
+
|
|
292
|
+
Raises:
|
|
293
|
+
AgentRuntimeError: 调用失败时抛出
|
|
294
|
+
ClientError: 客户端错误
|
|
295
|
+
ServerError: 服务器错误
|
|
296
|
+
APIError: 运行时错误
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
try:
|
|
300
|
+
client = self._get_client(config)
|
|
301
|
+
response = client.update_template_with_options(
|
|
302
|
+
template_name,
|
|
303
|
+
UpdateTemplateRequest(body=input),
|
|
304
|
+
headers=headers or {},
|
|
305
|
+
runtime=RuntimeOptions(),
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
logger.debug(
|
|
309
|
+
"request api update_template, request Request ID:"
|
|
310
|
+
f" {response.body.request_id}\n request:"
|
|
311
|
+
f" {[template_name,input.to_map(),]}\n response:"
|
|
312
|
+
f" {response.body.data}"
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
return response.body.data
|
|
316
|
+
except ClientException as e:
|
|
317
|
+
raise ClientError(
|
|
318
|
+
e.status_code,
|
|
319
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
320
|
+
request_id=e.request_id,
|
|
321
|
+
request=[
|
|
322
|
+
template_name,
|
|
323
|
+
input,
|
|
324
|
+
],
|
|
325
|
+
) from e
|
|
326
|
+
except ServerException as e:
|
|
327
|
+
raise ServerError(
|
|
328
|
+
e.status_code,
|
|
329
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
330
|
+
request_id=e.request_id,
|
|
331
|
+
) from e
|
|
332
|
+
|
|
333
|
+
async def update_template_async(
|
|
334
|
+
self,
|
|
335
|
+
template_name: str,
|
|
336
|
+
input: UpdateTemplateInput,
|
|
337
|
+
headers: Optional[Dict[str, str]] = None,
|
|
338
|
+
config: Optional[Config] = None,
|
|
339
|
+
) -> Template:
|
|
340
|
+
"""更新 Sandbox Template
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
template_name: Template 名称
|
|
344
|
+
input: Template 配置
|
|
345
|
+
|
|
346
|
+
headers: 请求头
|
|
347
|
+
config: 配置
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
Template: 更新的 Template 对象
|
|
351
|
+
|
|
352
|
+
Raises:
|
|
353
|
+
AgentRuntimeError: 调用失败时抛出
|
|
354
|
+
ClientError: 客户端错误
|
|
355
|
+
ServerError: 服务器错误
|
|
356
|
+
APIError: 运行时错误
|
|
357
|
+
"""
|
|
358
|
+
|
|
359
|
+
try:
|
|
360
|
+
client = self._get_client(config)
|
|
361
|
+
response = await client.update_template_with_options_async(
|
|
362
|
+
template_name,
|
|
363
|
+
UpdateTemplateRequest(body=input),
|
|
364
|
+
headers=headers or {},
|
|
365
|
+
runtime=RuntimeOptions(),
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
logger.debug(
|
|
369
|
+
"request api update_template, request Request ID:"
|
|
370
|
+
f" {response.body.request_id}\n request:"
|
|
371
|
+
f" {[template_name,input.to_map(),]}\n response:"
|
|
372
|
+
f" {response.body.data}"
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
return response.body.data
|
|
376
|
+
except ClientException as e:
|
|
377
|
+
raise ClientError(
|
|
378
|
+
e.status_code,
|
|
379
|
+
e.data.get("message", e.message),
|
|
380
|
+
request_id=e.request_id,
|
|
381
|
+
request=[
|
|
382
|
+
template_name,
|
|
383
|
+
input,
|
|
384
|
+
],
|
|
385
|
+
) from e
|
|
386
|
+
except ServerException as e:
|
|
387
|
+
raise ServerError(
|
|
388
|
+
e.status_code,
|
|
389
|
+
e.data.get("message", e.message),
|
|
390
|
+
request_id=e.request_id,
|
|
391
|
+
) from e
|
|
392
|
+
|
|
393
|
+
def get_template(
|
|
394
|
+
self,
|
|
395
|
+
template_name: str,
|
|
396
|
+
headers: Optional[Dict[str, str]] = None,
|
|
397
|
+
config: Optional[Config] = None,
|
|
398
|
+
) -> Template:
|
|
399
|
+
"""获取 Sandbox Template
|
|
400
|
+
|
|
401
|
+
Args:
|
|
402
|
+
template_name: Template 名称
|
|
403
|
+
|
|
404
|
+
headers: 请求头
|
|
405
|
+
config: 配置
|
|
406
|
+
|
|
407
|
+
Returns:
|
|
408
|
+
Template: Template 对象
|
|
409
|
+
|
|
410
|
+
Raises:
|
|
411
|
+
AgentRuntimeError: 调用失败时抛出
|
|
412
|
+
ClientError: 客户端错误
|
|
413
|
+
ServerError: 服务器错误
|
|
414
|
+
APIError: 运行时错误
|
|
415
|
+
"""
|
|
416
|
+
|
|
417
|
+
try:
|
|
418
|
+
client = self._get_client(config)
|
|
419
|
+
response = client.get_template_with_options(
|
|
420
|
+
template_name,
|
|
421
|
+
headers=headers or {},
|
|
422
|
+
runtime=RuntimeOptions(),
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
logger.debug(
|
|
426
|
+
"request api get_template, request Request ID:"
|
|
427
|
+
f" {response.body.request_id}\n request: {[template_name,]}\n "
|
|
428
|
+
f" response: {response.body.data}"
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
return response.body.data
|
|
432
|
+
except ClientException as e:
|
|
433
|
+
raise ClientError(
|
|
434
|
+
e.status_code,
|
|
435
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
436
|
+
request_id=e.request_id,
|
|
437
|
+
request=[
|
|
438
|
+
template_name,
|
|
439
|
+
],
|
|
440
|
+
) from e
|
|
441
|
+
except ServerException as e:
|
|
442
|
+
raise ServerError(
|
|
443
|
+
e.status_code,
|
|
444
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
445
|
+
request_id=e.request_id,
|
|
446
|
+
) from e
|
|
447
|
+
|
|
448
|
+
async def get_template_async(
|
|
449
|
+
self,
|
|
450
|
+
template_name: str,
|
|
451
|
+
headers: Optional[Dict[str, str]] = None,
|
|
452
|
+
config: Optional[Config] = None,
|
|
453
|
+
) -> Template:
|
|
454
|
+
"""获取 Sandbox Template
|
|
455
|
+
|
|
456
|
+
Args:
|
|
457
|
+
template_name: Template 名称
|
|
458
|
+
|
|
459
|
+
headers: 请求头
|
|
460
|
+
config: 配置
|
|
461
|
+
|
|
462
|
+
Returns:
|
|
463
|
+
Template: Template 对象
|
|
464
|
+
|
|
465
|
+
Raises:
|
|
466
|
+
AgentRuntimeError: 调用失败时抛出
|
|
467
|
+
ClientError: 客户端错误
|
|
468
|
+
ServerError: 服务器错误
|
|
469
|
+
APIError: 运行时错误
|
|
470
|
+
"""
|
|
471
|
+
|
|
472
|
+
try:
|
|
473
|
+
client = self._get_client(config)
|
|
474
|
+
response = await client.get_template_with_options_async(
|
|
475
|
+
template_name,
|
|
476
|
+
headers=headers or {},
|
|
477
|
+
runtime=RuntimeOptions(),
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
logger.debug(
|
|
481
|
+
"request api get_template, request Request ID:"
|
|
482
|
+
f" {response.body.request_id}\n request: {[template_name,]}\n "
|
|
483
|
+
f" response: {response.body.data}"
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
return response.body.data
|
|
487
|
+
except ClientException as e:
|
|
488
|
+
raise ClientError(
|
|
489
|
+
e.status_code,
|
|
490
|
+
e.data.get("message", e.message),
|
|
491
|
+
request_id=e.request_id,
|
|
492
|
+
request=[
|
|
493
|
+
template_name,
|
|
494
|
+
],
|
|
495
|
+
) from e
|
|
496
|
+
except ServerException as e:
|
|
497
|
+
raise ServerError(
|
|
498
|
+
e.status_code,
|
|
499
|
+
e.data.get("message", e.message),
|
|
500
|
+
request_id=e.request_id,
|
|
501
|
+
) from e
|
|
502
|
+
|
|
503
|
+
def list_templates(
|
|
504
|
+
self,
|
|
505
|
+
input: ListTemplatesRequest,
|
|
506
|
+
headers: Optional[Dict[str, str]] = None,
|
|
507
|
+
config: Optional[Config] = None,
|
|
508
|
+
) -> ListTemplatesOutput:
|
|
509
|
+
"""枚举 Sandbox Templates
|
|
510
|
+
|
|
511
|
+
Args:
|
|
512
|
+
input: 枚举的配置
|
|
513
|
+
|
|
514
|
+
headers: 请求头
|
|
515
|
+
config: 配置
|
|
516
|
+
|
|
517
|
+
Returns:
|
|
518
|
+
ListTemplatesOutput: Template 列表
|
|
519
|
+
|
|
520
|
+
Raises:
|
|
521
|
+
AgentRuntimeError: 调用失败时抛出
|
|
522
|
+
ClientError: 客户端错误
|
|
523
|
+
ServerError: 服务器错误
|
|
524
|
+
APIError: 运行时错误
|
|
525
|
+
"""
|
|
526
|
+
|
|
527
|
+
try:
|
|
528
|
+
client = self._get_client(config)
|
|
529
|
+
response = client.list_templates_with_options(
|
|
530
|
+
input,
|
|
531
|
+
headers=headers or {},
|
|
532
|
+
runtime=RuntimeOptions(),
|
|
533
|
+
)
|
|
534
|
+
|
|
535
|
+
logger.debug(
|
|
536
|
+
"request api list_templates, request Request ID:"
|
|
537
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
538
|
+
f" response: {response.body.data}"
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
return response.body.data
|
|
542
|
+
except ClientException as e:
|
|
543
|
+
raise ClientError(
|
|
544
|
+
e.status_code,
|
|
545
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
546
|
+
request_id=e.request_id,
|
|
547
|
+
request=[
|
|
548
|
+
input,
|
|
549
|
+
],
|
|
550
|
+
) from e
|
|
551
|
+
except ServerException as e:
|
|
552
|
+
raise ServerError(
|
|
553
|
+
e.status_code,
|
|
554
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
555
|
+
request_id=e.request_id,
|
|
556
|
+
) from e
|
|
557
|
+
|
|
558
|
+
async def list_templates_async(
|
|
559
|
+
self,
|
|
560
|
+
input: ListTemplatesRequest,
|
|
561
|
+
headers: Optional[Dict[str, str]] = None,
|
|
562
|
+
config: Optional[Config] = None,
|
|
563
|
+
) -> ListTemplatesOutput:
|
|
564
|
+
"""枚举 Sandbox Templates
|
|
565
|
+
|
|
566
|
+
Args:
|
|
567
|
+
input: 枚举的配置
|
|
568
|
+
|
|
569
|
+
headers: 请求头
|
|
570
|
+
config: 配置
|
|
571
|
+
|
|
572
|
+
Returns:
|
|
573
|
+
ListTemplatesOutput: Template 列表
|
|
574
|
+
|
|
575
|
+
Raises:
|
|
576
|
+
AgentRuntimeError: 调用失败时抛出
|
|
577
|
+
ClientError: 客户端错误
|
|
578
|
+
ServerError: 服务器错误
|
|
579
|
+
APIError: 运行时错误
|
|
580
|
+
"""
|
|
581
|
+
|
|
582
|
+
try:
|
|
583
|
+
client = self._get_client(config)
|
|
584
|
+
response = await client.list_templates_with_options_async(
|
|
585
|
+
input,
|
|
586
|
+
headers=headers or {},
|
|
587
|
+
runtime=RuntimeOptions(),
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
logger.debug(
|
|
591
|
+
"request api list_templates, request Request ID:"
|
|
592
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
593
|
+
f" response: {response.body.data}"
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
return response.body.data
|
|
597
|
+
except ClientException as e:
|
|
598
|
+
raise ClientError(
|
|
599
|
+
e.status_code,
|
|
600
|
+
e.data.get("message", e.message),
|
|
601
|
+
request_id=e.request_id,
|
|
602
|
+
request=[
|
|
603
|
+
input,
|
|
604
|
+
],
|
|
605
|
+
) from e
|
|
606
|
+
except ServerException as e:
|
|
607
|
+
raise ServerError(
|
|
608
|
+
e.status_code,
|
|
609
|
+
e.data.get("message", e.message),
|
|
610
|
+
request_id=e.request_id,
|
|
611
|
+
) from e
|
|
612
|
+
|
|
613
|
+
def create_sandbox(
|
|
614
|
+
self,
|
|
615
|
+
input: CreateSandboxInput,
|
|
616
|
+
headers: Optional[Dict[str, str]] = None,
|
|
617
|
+
config: Optional[Config] = None,
|
|
618
|
+
) -> Sandbox:
|
|
619
|
+
"""创建 Sandbox
|
|
620
|
+
|
|
621
|
+
Args:
|
|
622
|
+
input: Sandbox 配置
|
|
623
|
+
|
|
624
|
+
headers: 请求头
|
|
625
|
+
config: 配置
|
|
626
|
+
|
|
627
|
+
Returns:
|
|
628
|
+
Sandbox: 创建的 Sandbox 对象
|
|
629
|
+
|
|
630
|
+
Raises:
|
|
631
|
+
AgentRuntimeError: 调用失败时抛出
|
|
632
|
+
ClientError: 客户端错误
|
|
633
|
+
ServerError: 服务器错误
|
|
634
|
+
APIError: 运行时错误
|
|
635
|
+
"""
|
|
636
|
+
|
|
637
|
+
try:
|
|
638
|
+
client = self._get_client(config)
|
|
639
|
+
response = client.create_sandbox_with_options(
|
|
640
|
+
CreateSandboxRequest(body=input),
|
|
641
|
+
headers=headers or {},
|
|
642
|
+
runtime=RuntimeOptions(),
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
logger.debug(
|
|
646
|
+
"request api create_sandbox, request Request ID:"
|
|
647
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
648
|
+
f" response: {response.body.data}"
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
return response.body.data
|
|
652
|
+
except ClientException as e:
|
|
653
|
+
raise ClientError(
|
|
654
|
+
e.status_code,
|
|
655
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
656
|
+
request_id=e.request_id,
|
|
657
|
+
request=[
|
|
658
|
+
input,
|
|
659
|
+
],
|
|
660
|
+
) from e
|
|
661
|
+
except ServerException as e:
|
|
662
|
+
raise ServerError(
|
|
663
|
+
e.status_code,
|
|
664
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
665
|
+
request_id=e.request_id,
|
|
666
|
+
) from e
|
|
667
|
+
|
|
668
|
+
async def create_sandbox_async(
|
|
669
|
+
self,
|
|
670
|
+
input: CreateSandboxInput,
|
|
671
|
+
headers: Optional[Dict[str, str]] = None,
|
|
672
|
+
config: Optional[Config] = None,
|
|
673
|
+
) -> Sandbox:
|
|
674
|
+
"""创建 Sandbox
|
|
675
|
+
|
|
676
|
+
Args:
|
|
677
|
+
input: Sandbox 配置
|
|
678
|
+
|
|
679
|
+
headers: 请求头
|
|
680
|
+
config: 配置
|
|
681
|
+
|
|
682
|
+
Returns:
|
|
683
|
+
Sandbox: 创建的 Sandbox 对象
|
|
684
|
+
|
|
685
|
+
Raises:
|
|
686
|
+
AgentRuntimeError: 调用失败时抛出
|
|
687
|
+
ClientError: 客户端错误
|
|
688
|
+
ServerError: 服务器错误
|
|
689
|
+
APIError: 运行时错误
|
|
690
|
+
"""
|
|
691
|
+
|
|
692
|
+
try:
|
|
693
|
+
client = self._get_client(config)
|
|
694
|
+
response = await client.create_sandbox_with_options_async(
|
|
695
|
+
CreateSandboxRequest(body=input),
|
|
696
|
+
headers=headers or {},
|
|
697
|
+
runtime=RuntimeOptions(),
|
|
698
|
+
)
|
|
699
|
+
|
|
700
|
+
logger.debug(
|
|
701
|
+
"request api create_sandbox, request Request ID:"
|
|
702
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
703
|
+
f" response: {response.body.data}"
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
return response.body.data
|
|
707
|
+
except ClientException as e:
|
|
708
|
+
raise ClientError(
|
|
709
|
+
e.status_code,
|
|
710
|
+
e.data.get("message", e.message),
|
|
711
|
+
request_id=e.request_id,
|
|
712
|
+
request=[
|
|
713
|
+
input,
|
|
714
|
+
],
|
|
715
|
+
) from e
|
|
716
|
+
except ServerException as e:
|
|
717
|
+
raise ServerError(
|
|
718
|
+
e.status_code,
|
|
719
|
+
e.data.get("message", e.message),
|
|
720
|
+
request_id=e.request_id,
|
|
721
|
+
) from e
|
|
722
|
+
|
|
723
|
+
def stop_sandbox(
|
|
724
|
+
self,
|
|
725
|
+
sandbox_id: str,
|
|
726
|
+
headers: Optional[Dict[str, str]] = None,
|
|
727
|
+
config: Optional[Config] = None,
|
|
728
|
+
) -> Sandbox:
|
|
729
|
+
"""停止 Sandbox
|
|
730
|
+
|
|
731
|
+
Args:
|
|
732
|
+
sandbox_id: Sandbox ID
|
|
733
|
+
|
|
734
|
+
headers: 请求头
|
|
735
|
+
config: 配置
|
|
736
|
+
|
|
737
|
+
Returns:
|
|
738
|
+
Sandbox: 停止结果
|
|
739
|
+
|
|
740
|
+
Raises:
|
|
741
|
+
AgentRuntimeError: 调用失败时抛出
|
|
742
|
+
ClientError: 客户端错误
|
|
743
|
+
ServerError: 服务器错误
|
|
744
|
+
APIError: 运行时错误
|
|
745
|
+
"""
|
|
746
|
+
|
|
747
|
+
try:
|
|
748
|
+
client = self._get_client(config)
|
|
749
|
+
response = client.stop_sandbox_with_options(
|
|
750
|
+
sandbox_id,
|
|
751
|
+
headers=headers or {},
|
|
752
|
+
runtime=RuntimeOptions(),
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
logger.debug(
|
|
756
|
+
"request api stop_sandbox, request Request ID:"
|
|
757
|
+
f" {response.body.request_id}\n request: {[sandbox_id,]}\n "
|
|
758
|
+
f" response: {response.body.data}"
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
return response.body.data
|
|
762
|
+
except ClientException as e:
|
|
763
|
+
raise ClientError(
|
|
764
|
+
e.status_code,
|
|
765
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
766
|
+
request_id=e.request_id,
|
|
767
|
+
request=[
|
|
768
|
+
sandbox_id,
|
|
769
|
+
],
|
|
770
|
+
) from e
|
|
771
|
+
except ServerException as e:
|
|
772
|
+
raise ServerError(
|
|
773
|
+
e.status_code,
|
|
774
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
775
|
+
request_id=e.request_id,
|
|
776
|
+
) from e
|
|
777
|
+
|
|
778
|
+
async def stop_sandbox_async(
|
|
779
|
+
self,
|
|
780
|
+
sandbox_id: str,
|
|
781
|
+
headers: Optional[Dict[str, str]] = None,
|
|
782
|
+
config: Optional[Config] = None,
|
|
783
|
+
) -> Sandbox:
|
|
784
|
+
"""停止 Sandbox
|
|
785
|
+
|
|
786
|
+
Args:
|
|
787
|
+
sandbox_id: Sandbox ID
|
|
788
|
+
|
|
789
|
+
headers: 请求头
|
|
790
|
+
config: 配置
|
|
791
|
+
|
|
792
|
+
Returns:
|
|
793
|
+
Sandbox: 停止结果
|
|
794
|
+
|
|
795
|
+
Raises:
|
|
796
|
+
AgentRuntimeError: 调用失败时抛出
|
|
797
|
+
ClientError: 客户端错误
|
|
798
|
+
ServerError: 服务器错误
|
|
799
|
+
APIError: 运行时错误
|
|
800
|
+
"""
|
|
801
|
+
|
|
802
|
+
try:
|
|
803
|
+
client = self._get_client(config)
|
|
804
|
+
response = await client.stop_sandbox_with_options_async(
|
|
805
|
+
sandbox_id,
|
|
806
|
+
headers=headers or {},
|
|
807
|
+
runtime=RuntimeOptions(),
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
logger.debug(
|
|
811
|
+
"request api stop_sandbox, request Request ID:"
|
|
812
|
+
f" {response.body.request_id}\n request: {[sandbox_id,]}\n "
|
|
813
|
+
f" response: {response.body.data}"
|
|
814
|
+
)
|
|
815
|
+
|
|
816
|
+
return response.body.data
|
|
817
|
+
except ClientException as e:
|
|
818
|
+
raise ClientError(
|
|
819
|
+
e.status_code,
|
|
820
|
+
e.data.get("message", e.message),
|
|
821
|
+
request_id=e.request_id,
|
|
822
|
+
request=[
|
|
823
|
+
sandbox_id,
|
|
824
|
+
],
|
|
825
|
+
) from e
|
|
826
|
+
except ServerException as e:
|
|
827
|
+
raise ServerError(
|
|
828
|
+
e.status_code,
|
|
829
|
+
e.data.get("message", e.message),
|
|
830
|
+
request_id=e.request_id,
|
|
831
|
+
) from e
|
|
832
|
+
|
|
833
|
+
def get_sandbox(
|
|
834
|
+
self,
|
|
835
|
+
sandbox_id: str,
|
|
836
|
+
headers: Optional[Dict[str, str]] = None,
|
|
837
|
+
config: Optional[Config] = None,
|
|
838
|
+
) -> Sandbox:
|
|
839
|
+
"""获取 Sandbox
|
|
840
|
+
|
|
841
|
+
Args:
|
|
842
|
+
sandbox_id: Sandbox ID
|
|
843
|
+
|
|
844
|
+
headers: 请求头
|
|
845
|
+
config: 配置
|
|
846
|
+
|
|
847
|
+
Returns:
|
|
848
|
+
Sandbox: Sandbox 对象
|
|
849
|
+
|
|
850
|
+
Raises:
|
|
851
|
+
AgentRuntimeError: 调用失败时抛出
|
|
852
|
+
ClientError: 客户端错误
|
|
853
|
+
ServerError: 服务器错误
|
|
854
|
+
APIError: 运行时错误
|
|
855
|
+
"""
|
|
856
|
+
|
|
857
|
+
try:
|
|
858
|
+
client = self._get_client(config)
|
|
859
|
+
response = client.get_sandbox_with_options(
|
|
860
|
+
sandbox_id,
|
|
861
|
+
headers=headers or {},
|
|
862
|
+
runtime=RuntimeOptions(),
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
logger.debug(
|
|
866
|
+
"request api get_sandbox, request Request ID:"
|
|
867
|
+
f" {response.body.request_id}\n request: {[sandbox_id,]}\n "
|
|
868
|
+
f" response: {response.body.data}"
|
|
869
|
+
)
|
|
870
|
+
|
|
871
|
+
return response.body.data
|
|
872
|
+
except ClientException as e:
|
|
873
|
+
raise ClientError(
|
|
874
|
+
e.status_code,
|
|
875
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
876
|
+
request_id=e.request_id,
|
|
877
|
+
request=[
|
|
878
|
+
sandbox_id,
|
|
879
|
+
],
|
|
880
|
+
) from e
|
|
881
|
+
except ServerException as e:
|
|
882
|
+
raise ServerError(
|
|
883
|
+
e.status_code,
|
|
884
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
885
|
+
request_id=e.request_id,
|
|
886
|
+
) from e
|
|
887
|
+
|
|
888
|
+
async def get_sandbox_async(
|
|
889
|
+
self,
|
|
890
|
+
sandbox_id: str,
|
|
891
|
+
headers: Optional[Dict[str, str]] = None,
|
|
892
|
+
config: Optional[Config] = None,
|
|
893
|
+
) -> Sandbox:
|
|
894
|
+
"""获取 Sandbox
|
|
895
|
+
|
|
896
|
+
Args:
|
|
897
|
+
sandbox_id: Sandbox ID
|
|
898
|
+
|
|
899
|
+
headers: 请求头
|
|
900
|
+
config: 配置
|
|
901
|
+
|
|
902
|
+
Returns:
|
|
903
|
+
Sandbox: Sandbox 对象
|
|
904
|
+
|
|
905
|
+
Raises:
|
|
906
|
+
AgentRuntimeError: 调用失败时抛出
|
|
907
|
+
ClientError: 客户端错误
|
|
908
|
+
ServerError: 服务器错误
|
|
909
|
+
APIError: 运行时错误
|
|
910
|
+
"""
|
|
911
|
+
|
|
912
|
+
try:
|
|
913
|
+
client = self._get_client(config)
|
|
914
|
+
response = await client.get_sandbox_with_options_async(
|
|
915
|
+
sandbox_id,
|
|
916
|
+
headers=headers or {},
|
|
917
|
+
runtime=RuntimeOptions(),
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
logger.debug(
|
|
921
|
+
"request api get_sandbox, request Request ID:"
|
|
922
|
+
f" {response.body.request_id}\n request: {[sandbox_id,]}\n "
|
|
923
|
+
f" response: {response.body.data}"
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
return response.body.data
|
|
927
|
+
except ClientException as e:
|
|
928
|
+
raise ClientError(
|
|
929
|
+
e.status_code,
|
|
930
|
+
e.data.get("message", e.message),
|
|
931
|
+
request_id=e.request_id,
|
|
932
|
+
request=[
|
|
933
|
+
sandbox_id,
|
|
934
|
+
],
|
|
935
|
+
) from e
|
|
936
|
+
except ServerException as e:
|
|
937
|
+
raise ServerError(
|
|
938
|
+
e.status_code,
|
|
939
|
+
e.data.get("message", e.message),
|
|
940
|
+
request_id=e.request_id,
|
|
941
|
+
) from e
|
|
942
|
+
|
|
943
|
+
def list_sandboxes(
|
|
944
|
+
self,
|
|
945
|
+
input: ListSandboxesRequest,
|
|
946
|
+
headers: Optional[Dict[str, str]] = None,
|
|
947
|
+
config: Optional[Config] = None,
|
|
948
|
+
) -> ListSandboxesOutput:
|
|
949
|
+
"""枚举 Sandboxes
|
|
950
|
+
|
|
951
|
+
Args:
|
|
952
|
+
input: 枚举的配置
|
|
953
|
+
|
|
954
|
+
headers: 请求头
|
|
955
|
+
config: 配置
|
|
956
|
+
|
|
957
|
+
Returns:
|
|
958
|
+
ListSandboxesOutput: Sandbox 列表
|
|
959
|
+
|
|
960
|
+
Raises:
|
|
961
|
+
AgentRuntimeError: 调用失败时抛出
|
|
962
|
+
ClientError: 客户端错误
|
|
963
|
+
ServerError: 服务器错误
|
|
964
|
+
APIError: 运行时错误
|
|
965
|
+
"""
|
|
966
|
+
|
|
967
|
+
try:
|
|
968
|
+
client = self._get_client(config)
|
|
969
|
+
response = client.list_sandboxes_with_options(
|
|
970
|
+
input,
|
|
971
|
+
headers=headers or {},
|
|
972
|
+
runtime=RuntimeOptions(),
|
|
973
|
+
)
|
|
974
|
+
|
|
975
|
+
logger.debug(
|
|
976
|
+
"request api list_sandboxes, request Request ID:"
|
|
977
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
978
|
+
f" response: {response.body.data}"
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
return response.body.data
|
|
982
|
+
except ClientException as e:
|
|
983
|
+
raise ClientError(
|
|
984
|
+
e.status_code,
|
|
985
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
986
|
+
request_id=e.request_id,
|
|
987
|
+
request=[
|
|
988
|
+
input,
|
|
989
|
+
],
|
|
990
|
+
) from e
|
|
991
|
+
except ServerException as e:
|
|
992
|
+
raise ServerError(
|
|
993
|
+
e.status_code,
|
|
994
|
+
pydash.get(e, "data.message", pydash.get(e, "message", "")),
|
|
995
|
+
request_id=e.request_id,
|
|
996
|
+
) from e
|
|
997
|
+
|
|
998
|
+
async def list_sandboxes_async(
|
|
999
|
+
self,
|
|
1000
|
+
input: ListSandboxesRequest,
|
|
1001
|
+
headers: Optional[Dict[str, str]] = None,
|
|
1002
|
+
config: Optional[Config] = None,
|
|
1003
|
+
) -> ListSandboxesOutput:
|
|
1004
|
+
"""枚举 Sandboxes
|
|
1005
|
+
|
|
1006
|
+
Args:
|
|
1007
|
+
input: 枚举的配置
|
|
1008
|
+
|
|
1009
|
+
headers: 请求头
|
|
1010
|
+
config: 配置
|
|
1011
|
+
|
|
1012
|
+
Returns:
|
|
1013
|
+
ListSandboxesOutput: Sandbox 列表
|
|
1014
|
+
|
|
1015
|
+
Raises:
|
|
1016
|
+
AgentRuntimeError: 调用失败时抛出
|
|
1017
|
+
ClientError: 客户端错误
|
|
1018
|
+
ServerError: 服务器错误
|
|
1019
|
+
APIError: 运行时错误
|
|
1020
|
+
"""
|
|
1021
|
+
|
|
1022
|
+
try:
|
|
1023
|
+
client = self._get_client(config)
|
|
1024
|
+
response = await client.list_sandboxes_with_options_async(
|
|
1025
|
+
input,
|
|
1026
|
+
headers=headers or {},
|
|
1027
|
+
runtime=RuntimeOptions(),
|
|
1028
|
+
)
|
|
1029
|
+
|
|
1030
|
+
logger.debug(
|
|
1031
|
+
"request api list_sandboxes, request Request ID:"
|
|
1032
|
+
f" {response.body.request_id}\n request: {[input.to_map(),]}\n"
|
|
1033
|
+
f" response: {response.body.data}"
|
|
1034
|
+
)
|
|
1035
|
+
|
|
1036
|
+
return response.body.data
|
|
1037
|
+
except ClientException as e:
|
|
1038
|
+
raise ClientError(
|
|
1039
|
+
e.status_code,
|
|
1040
|
+
e.data.get("message", e.message),
|
|
1041
|
+
request_id=e.request_id,
|
|
1042
|
+
request=[
|
|
1043
|
+
input,
|
|
1044
|
+
],
|
|
1045
|
+
) from e
|
|
1046
|
+
except ServerException as e:
|
|
1047
|
+
raise ServerError(
|
|
1048
|
+
e.status_code,
|
|
1049
|
+
e.data.get("message", e.message),
|
|
1050
|
+
request_id=e.request_id,
|
|
1051
|
+
) from e
|