agentrun-inner-test 0.0.46__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.
- agentrun/__init__.py +325 -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 +12 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +65 -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 +16 -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 +12 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +65 -0
- agentrun/integration/crewai/model_adapter.py +31 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +12 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +65 -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 +30 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +71 -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 +35 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/agent_converter.py +1073 -0
- agentrun/integration/langgraph/builtin.py +65 -0
- agentrun/integration/pydantic_ai/__init__.py +12 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +65 -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/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 +905 -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 +397 -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 +270 -0
- agentrun/utils/__data_api_async_template.py +720 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +258 -0
- agentrun/utils/control_api.py +78 -0
- agentrun/utils/data_api.py +1120 -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.46.dist-info/METADATA +263 -0
- agentrun_inner_test-0.0.46.dist-info/RECORD +135 -0
- agentrun_inner_test-0.0.46.dist-info/WHEEL +5 -0
- agentrun_inner_test-0.0.46.dist-info/licenses/LICENSE +201 -0
- agentrun_inner_test-0.0.46.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,319 @@
|
|
|
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: agentrun/credential/__client_async_template.py
|
|
10
|
+
|
|
11
|
+
Credential 客户端 / Credential Client
|
|
12
|
+
|
|
13
|
+
此模块提供凭证管理的客户端API。
|
|
14
|
+
This module provides the client API for credential management.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Optional
|
|
18
|
+
|
|
19
|
+
from alibabacloud_agentrun20250910.models import (
|
|
20
|
+
CreateCredentialInput,
|
|
21
|
+
ListCredentialsRequest,
|
|
22
|
+
UpdateCredentialInput,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from agentrun.utils.config import Config
|
|
26
|
+
from agentrun.utils.exception import HTTPError
|
|
27
|
+
|
|
28
|
+
from .api.control import CredentialControlAPI
|
|
29
|
+
from .credential import Credential
|
|
30
|
+
from .model import (
|
|
31
|
+
CredentialCreateInput,
|
|
32
|
+
CredentialListInput,
|
|
33
|
+
CredentialListOutput,
|
|
34
|
+
CredentialUpdateInput,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class CredentialClient:
|
|
39
|
+
"""Credential 客户端 / Credential Client
|
|
40
|
+
|
|
41
|
+
提供凭证的创建、删除、更新和查询功能。
|
|
42
|
+
Provides create, delete, update and query functions for credentials.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, config: Optional[Config] = None):
|
|
46
|
+
"""初始化客户端 / Initialize client
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
50
|
+
"""
|
|
51
|
+
self.__control_api = CredentialControlAPI(config)
|
|
52
|
+
|
|
53
|
+
async def create_async(
|
|
54
|
+
self, input: CredentialCreateInput, config: Optional[Config] = None
|
|
55
|
+
):
|
|
56
|
+
"""创建凭证(异步) / Create credential asynchronously
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
input: 凭证输入参数 / Credential input parameters
|
|
60
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Credential: 创建的凭证对象 / Created credential object
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
ResourceAlreadyExistError: 资源已存在 / Resource already exists
|
|
67
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
68
|
+
"""
|
|
69
|
+
try:
|
|
70
|
+
result = await self.__control_api.create_credential_async(
|
|
71
|
+
CreateCredentialInput().from_map({
|
|
72
|
+
**input.model_dump(),
|
|
73
|
+
**input.credential_config.model_dump(),
|
|
74
|
+
}),
|
|
75
|
+
config=config,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return Credential.from_inner_object(result)
|
|
79
|
+
except HTTPError as e:
|
|
80
|
+
raise e.to_resource_error(
|
|
81
|
+
"Credential", input.credential_name
|
|
82
|
+
) from e
|
|
83
|
+
|
|
84
|
+
def create(
|
|
85
|
+
self, input: CredentialCreateInput, config: Optional[Config] = None
|
|
86
|
+
):
|
|
87
|
+
"""创建凭证(同步) / Create credential asynchronously
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
input: 凭证输入参数 / Credential input parameters
|
|
91
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Credential: 创建的凭证对象 / Created credential object
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
ResourceAlreadyExistError: 资源已存在 / Resource already exists
|
|
98
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
99
|
+
"""
|
|
100
|
+
try:
|
|
101
|
+
result = self.__control_api.create_credential(
|
|
102
|
+
CreateCredentialInput().from_map({
|
|
103
|
+
**input.model_dump(),
|
|
104
|
+
**input.credential_config.model_dump(),
|
|
105
|
+
}),
|
|
106
|
+
config=config,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
return Credential.from_inner_object(result)
|
|
110
|
+
except HTTPError as e:
|
|
111
|
+
raise e.to_resource_error(
|
|
112
|
+
"Credential", input.credential_name
|
|
113
|
+
) from e
|
|
114
|
+
|
|
115
|
+
async def delete_async(
|
|
116
|
+
self, credential_name: str, config: Optional[Config] = None
|
|
117
|
+
):
|
|
118
|
+
"""删除凭证(异步)
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
credential_name: 凭证名称
|
|
122
|
+
config: 配置
|
|
123
|
+
|
|
124
|
+
Raises:
|
|
125
|
+
ResourceNotExistError: 凭证不存在
|
|
126
|
+
"""
|
|
127
|
+
try:
|
|
128
|
+
result = await self.__control_api.delete_credential_async(
|
|
129
|
+
credential_name, config=config
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
return Credential.from_inner_object(result)
|
|
133
|
+
|
|
134
|
+
except HTTPError as e:
|
|
135
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
136
|
+
|
|
137
|
+
def delete(self, credential_name: str, config: Optional[Config] = None):
|
|
138
|
+
"""删除凭证(同步)
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
credential_name: 凭证名称
|
|
142
|
+
config: 配置
|
|
143
|
+
|
|
144
|
+
Raises:
|
|
145
|
+
ResourceNotExistError: 凭证不存在
|
|
146
|
+
"""
|
|
147
|
+
try:
|
|
148
|
+
result = self.__control_api.delete_credential(
|
|
149
|
+
credential_name, config=config
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
return Credential.from_inner_object(result)
|
|
153
|
+
|
|
154
|
+
except HTTPError as e:
|
|
155
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
156
|
+
|
|
157
|
+
async def update_async(
|
|
158
|
+
self,
|
|
159
|
+
credential_name: str,
|
|
160
|
+
input: CredentialUpdateInput,
|
|
161
|
+
config: Optional[Config] = None,
|
|
162
|
+
):
|
|
163
|
+
"""更新凭证(异步)
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
credential_name: 凭证名称
|
|
167
|
+
input: 凭证更新输入参数
|
|
168
|
+
config: 配置
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Credential: 更新后的凭证对象
|
|
172
|
+
|
|
173
|
+
Raises:
|
|
174
|
+
ResourceNotExistError: 凭证不存在
|
|
175
|
+
"""
|
|
176
|
+
try:
|
|
177
|
+
result = await self.__control_api.update_credential_async(
|
|
178
|
+
credential_name,
|
|
179
|
+
UpdateCredentialInput().from_map({
|
|
180
|
+
**input.model_dump(),
|
|
181
|
+
**(
|
|
182
|
+
input.credential_config.model_dump()
|
|
183
|
+
if input.credential_config
|
|
184
|
+
else {}
|
|
185
|
+
),
|
|
186
|
+
}),
|
|
187
|
+
config=config,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
return Credential.from_inner_object(result)
|
|
191
|
+
except HTTPError as e:
|
|
192
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
193
|
+
|
|
194
|
+
def update(
|
|
195
|
+
self,
|
|
196
|
+
credential_name: str,
|
|
197
|
+
input: CredentialUpdateInput,
|
|
198
|
+
config: Optional[Config] = None,
|
|
199
|
+
):
|
|
200
|
+
"""更新凭证(同步)
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
credential_name: 凭证名称
|
|
204
|
+
input: 凭证更新输入参数
|
|
205
|
+
config: 配置
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
Credential: 更新后的凭证对象
|
|
209
|
+
|
|
210
|
+
Raises:
|
|
211
|
+
ResourceNotExistError: 凭证不存在
|
|
212
|
+
"""
|
|
213
|
+
try:
|
|
214
|
+
result = self.__control_api.update_credential(
|
|
215
|
+
credential_name,
|
|
216
|
+
UpdateCredentialInput().from_map({
|
|
217
|
+
**input.model_dump(),
|
|
218
|
+
**(
|
|
219
|
+
input.credential_config.model_dump()
|
|
220
|
+
if input.credential_config
|
|
221
|
+
else {}
|
|
222
|
+
),
|
|
223
|
+
}),
|
|
224
|
+
config=config,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
return Credential.from_inner_object(result)
|
|
228
|
+
except HTTPError as e:
|
|
229
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
230
|
+
|
|
231
|
+
async def get_async(
|
|
232
|
+
self, credential_name: str, config: Optional[Config] = None
|
|
233
|
+
):
|
|
234
|
+
"""获取凭证(异步)
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
credential_name: 凭证名称
|
|
238
|
+
config: 配置
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
Credential: 凭证对象
|
|
242
|
+
|
|
243
|
+
Raises:
|
|
244
|
+
ResourceNotExistError: 凭证不存在
|
|
245
|
+
"""
|
|
246
|
+
try:
|
|
247
|
+
result = await self.__control_api.get_credential_async(
|
|
248
|
+
credential_name, config=config
|
|
249
|
+
)
|
|
250
|
+
return Credential.from_inner_object(result)
|
|
251
|
+
except HTTPError as e:
|
|
252
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
253
|
+
|
|
254
|
+
def get(self, credential_name: str, config: Optional[Config] = None):
|
|
255
|
+
"""获取凭证(同步)
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
credential_name: 凭证名称
|
|
259
|
+
config: 配置
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
Credential: 凭证对象
|
|
263
|
+
|
|
264
|
+
Raises:
|
|
265
|
+
ResourceNotExistError: 凭证不存在
|
|
266
|
+
"""
|
|
267
|
+
try:
|
|
268
|
+
result = self.__control_api.get_credential(
|
|
269
|
+
credential_name, config=config
|
|
270
|
+
)
|
|
271
|
+
return Credential.from_inner_object(result)
|
|
272
|
+
except HTTPError as e:
|
|
273
|
+
raise e.to_resource_error("Credential", credential_name) from e
|
|
274
|
+
|
|
275
|
+
async def list_async(
|
|
276
|
+
self,
|
|
277
|
+
input: Optional[CredentialListInput] = None,
|
|
278
|
+
config: Optional[Config] = None,
|
|
279
|
+
):
|
|
280
|
+
"""列出凭证(异步)
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
input: 分页查询参数
|
|
284
|
+
config: 配置
|
|
285
|
+
|
|
286
|
+
Returns:
|
|
287
|
+
List[Credential]: 凭证列表
|
|
288
|
+
"""
|
|
289
|
+
if input is None:
|
|
290
|
+
input = CredentialListInput()
|
|
291
|
+
|
|
292
|
+
results = await self.__control_api.list_credentials_async(
|
|
293
|
+
ListCredentialsRequest().from_map(input.model_dump()),
|
|
294
|
+
config=config,
|
|
295
|
+
)
|
|
296
|
+
return [CredentialListOutput.from_inner_object(item) for item in results.items] # type: ignore
|
|
297
|
+
|
|
298
|
+
def list(
|
|
299
|
+
self,
|
|
300
|
+
input: Optional[CredentialListInput] = None,
|
|
301
|
+
config: Optional[Config] = None,
|
|
302
|
+
):
|
|
303
|
+
"""列出凭证(同步)
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
input: 分页查询参数
|
|
307
|
+
config: 配置
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
List[Credential]: 凭证列表
|
|
311
|
+
"""
|
|
312
|
+
if input is None:
|
|
313
|
+
input = CredentialListInput()
|
|
314
|
+
|
|
315
|
+
results = self.__control_api.list_credentials(
|
|
316
|
+
ListCredentialsRequest().from_map(input.model_dump()),
|
|
317
|
+
config=config,
|
|
318
|
+
)
|
|
319
|
+
return [CredentialListOutput.from_inner_object(item) for item in results.items] # type: ignore
|
|
@@ -0,0 +1,381 @@
|
|
|
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: agentrun/credential/__credential_async_template.py
|
|
10
|
+
|
|
11
|
+
Credential 高层 API / Credential High-Level API
|
|
12
|
+
|
|
13
|
+
此模块定义凭证资源的高级API。
|
|
14
|
+
This module defines the high-level API for credential resources.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import List, Optional
|
|
18
|
+
|
|
19
|
+
from agentrun.utils.config import Config
|
|
20
|
+
from agentrun.utils.model import PageableInput
|
|
21
|
+
from agentrun.utils.resource import ResourceBase
|
|
22
|
+
|
|
23
|
+
from .model import (
|
|
24
|
+
CredentialAuthType,
|
|
25
|
+
CredentialCreateInput,
|
|
26
|
+
CredentialImmutableProps,
|
|
27
|
+
CredentialListInput,
|
|
28
|
+
CredentialListOutput,
|
|
29
|
+
CredentialMutableProps,
|
|
30
|
+
CredentialSourceType,
|
|
31
|
+
CredentialSystemProps,
|
|
32
|
+
CredentialUpdateInput,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Credential(
|
|
37
|
+
CredentialMutableProps,
|
|
38
|
+
CredentialImmutableProps,
|
|
39
|
+
CredentialSystemProps,
|
|
40
|
+
ResourceBase,
|
|
41
|
+
):
|
|
42
|
+
"""凭证资源 / Credential Resource
|
|
43
|
+
|
|
44
|
+
提供凭证的完整生命周期管理,包括创建、删除、更新、查询。
|
|
45
|
+
Provides complete lifecycle management for credentials, including create, delete, update, and query.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def __get_client(cls):
|
|
50
|
+
"""获取客户端实例 / Get client instance
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
CredentialClient: 客户端实例 / Client instance
|
|
54
|
+
"""
|
|
55
|
+
from .client import CredentialClient
|
|
56
|
+
|
|
57
|
+
return CredentialClient()
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
async def create_async(
|
|
61
|
+
cls, input: CredentialCreateInput, config: Optional[Config] = None
|
|
62
|
+
):
|
|
63
|
+
"""创建凭证(异步)
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
input: 凭证输入参数
|
|
67
|
+
config: 配置
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Credential: 创建的凭证对象
|
|
71
|
+
"""
|
|
72
|
+
return await cls.__get_client().create_async(input, config=config)
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def create(
|
|
76
|
+
cls, input: CredentialCreateInput, config: Optional[Config] = None
|
|
77
|
+
):
|
|
78
|
+
"""创建凭证(同步)
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
input: 凭证输入参数
|
|
82
|
+
config: 配置
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
Credential: 创建的凭证对象
|
|
86
|
+
"""
|
|
87
|
+
return cls.__get_client().create(input, config=config)
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
async def delete_by_name_async(
|
|
91
|
+
cls, credential_name: str, config: Optional[Config] = None
|
|
92
|
+
):
|
|
93
|
+
"""根据名称删除凭证(异步)
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
credential_name: 凭证名称
|
|
97
|
+
config: 配置
|
|
98
|
+
"""
|
|
99
|
+
return await cls.__get_client().delete_async(
|
|
100
|
+
credential_name, config=config
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def delete_by_name(
|
|
105
|
+
cls, credential_name: str, config: Optional[Config] = None
|
|
106
|
+
):
|
|
107
|
+
"""根据名称删除凭证(同步)
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
credential_name: 凭证名称
|
|
111
|
+
config: 配置
|
|
112
|
+
"""
|
|
113
|
+
return cls.__get_client().delete(credential_name, config=config)
|
|
114
|
+
|
|
115
|
+
@classmethod
|
|
116
|
+
async def update_by_name_async(
|
|
117
|
+
cls,
|
|
118
|
+
credential_name: str,
|
|
119
|
+
input: CredentialUpdateInput,
|
|
120
|
+
config: Optional[Config] = None,
|
|
121
|
+
):
|
|
122
|
+
"""根据名称更新凭证(异步)
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
credential_name: 凭证名称
|
|
126
|
+
input: 凭证更新输入参数
|
|
127
|
+
config: 配置
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Credential: 更新后的凭证对象
|
|
131
|
+
"""
|
|
132
|
+
return await cls.__get_client().update_async(
|
|
133
|
+
credential_name, input, config=config
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def update_by_name(
|
|
138
|
+
cls,
|
|
139
|
+
credential_name: str,
|
|
140
|
+
input: CredentialUpdateInput,
|
|
141
|
+
config: Optional[Config] = None,
|
|
142
|
+
):
|
|
143
|
+
"""根据名称更新凭证(同步)
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
credential_name: 凭证名称
|
|
147
|
+
input: 凭证更新输入参数
|
|
148
|
+
config: 配置
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Credential: 更新后的凭证对象
|
|
152
|
+
"""
|
|
153
|
+
return cls.__get_client().update(credential_name, input, config=config)
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
async def get_by_name_async(
|
|
157
|
+
cls, credential_name: str, config: Optional[Config] = None
|
|
158
|
+
):
|
|
159
|
+
"""根据名称获取凭证(异步)
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
credential_name: 凭证名称
|
|
163
|
+
config: 配置
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
Credential: 凭证对象
|
|
167
|
+
"""
|
|
168
|
+
return await cls.__get_client().get_async(
|
|
169
|
+
credential_name, config=config
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
@classmethod
|
|
173
|
+
def get_by_name(cls, credential_name: str, config: Optional[Config] = None):
|
|
174
|
+
"""根据名称获取凭证(同步)
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
credential_name: 凭证名称
|
|
178
|
+
config: 配置
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
Credential: 凭证对象
|
|
182
|
+
"""
|
|
183
|
+
return cls.__get_client().get(credential_name, config=config)
|
|
184
|
+
|
|
185
|
+
@classmethod
|
|
186
|
+
async def _list_page_async(
|
|
187
|
+
cls, page_input: PageableInput, config: Config | None = None, **kwargs
|
|
188
|
+
):
|
|
189
|
+
return await cls.__get_client().list_async(
|
|
190
|
+
input=CredentialListInput(
|
|
191
|
+
**kwargs,
|
|
192
|
+
**page_input.model_dump(),
|
|
193
|
+
),
|
|
194
|
+
config=config,
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
@classmethod
|
|
198
|
+
def _list_page(
|
|
199
|
+
cls, page_input: PageableInput, config: Config | None = None, **kwargs
|
|
200
|
+
):
|
|
201
|
+
return cls.__get_client().list(
|
|
202
|
+
input=CredentialListInput(
|
|
203
|
+
**kwargs,
|
|
204
|
+
**page_input.model_dump(),
|
|
205
|
+
),
|
|
206
|
+
config=config,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
@classmethod
|
|
210
|
+
async def list_all_async(
|
|
211
|
+
cls,
|
|
212
|
+
*,
|
|
213
|
+
credential_auth_type: Optional[CredentialAuthType] = None,
|
|
214
|
+
credential_name: Optional[str] = None,
|
|
215
|
+
credential_source_type: Optional[CredentialSourceType] = None,
|
|
216
|
+
provider: Optional[str] = None,
|
|
217
|
+
config: Optional[Config] = None,
|
|
218
|
+
) -> List[CredentialListOutput]:
|
|
219
|
+
return await cls._list_all_async(
|
|
220
|
+
lambda cred: cred.credential_id or "",
|
|
221
|
+
config=config,
|
|
222
|
+
credential_auth_type=credential_auth_type,
|
|
223
|
+
credential_name=credential_name,
|
|
224
|
+
credential_source_type=credential_source_type,
|
|
225
|
+
provider=provider,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
@classmethod
|
|
229
|
+
def list_all(
|
|
230
|
+
cls,
|
|
231
|
+
*,
|
|
232
|
+
credential_auth_type: Optional[CredentialAuthType] = None,
|
|
233
|
+
credential_name: Optional[str] = None,
|
|
234
|
+
credential_source_type: Optional[CredentialSourceType] = None,
|
|
235
|
+
provider: Optional[str] = None,
|
|
236
|
+
config: Optional[Config] = None,
|
|
237
|
+
) -> List[CredentialListOutput]:
|
|
238
|
+
return cls._list_all(
|
|
239
|
+
lambda cred: cred.credential_id or "",
|
|
240
|
+
config=config,
|
|
241
|
+
credential_auth_type=credential_auth_type,
|
|
242
|
+
credential_name=credential_name,
|
|
243
|
+
credential_source_type=credential_source_type,
|
|
244
|
+
provider=provider,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
async def update_async(
|
|
248
|
+
self, input: CredentialUpdateInput, config: Optional[Config] = None
|
|
249
|
+
):
|
|
250
|
+
"""更新凭证(异步)
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
input: 凭证更新输入参数
|
|
254
|
+
config: 配置
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
Credential: 更新后的凭证对象
|
|
258
|
+
"""
|
|
259
|
+
if self.credential_name is None:
|
|
260
|
+
raise ValueError(
|
|
261
|
+
"credential_name is required to update a Credential"
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
result = await self.update_by_name_async(
|
|
265
|
+
self.credential_name, input, config=config
|
|
266
|
+
)
|
|
267
|
+
self.update_self(result)
|
|
268
|
+
|
|
269
|
+
return self
|
|
270
|
+
|
|
271
|
+
def update(
|
|
272
|
+
self, input: CredentialUpdateInput, config: Optional[Config] = None
|
|
273
|
+
):
|
|
274
|
+
"""更新凭证(同步)
|
|
275
|
+
|
|
276
|
+
Args:
|
|
277
|
+
input: 凭证更新输入参数
|
|
278
|
+
config: 配置
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
Credential: 更新后的凭证对象
|
|
282
|
+
"""
|
|
283
|
+
if self.credential_name is None:
|
|
284
|
+
raise ValueError(
|
|
285
|
+
"credential_name is required to update a Credential"
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
result = self.update_by_name(self.credential_name, input, config=config)
|
|
289
|
+
self.update_self(result)
|
|
290
|
+
|
|
291
|
+
return self
|
|
292
|
+
|
|
293
|
+
async def delete_async(self, config: Optional[Config] = None):
|
|
294
|
+
"""删除凭证(异步)
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
config: 配置
|
|
298
|
+
"""
|
|
299
|
+
if self.credential_name is None:
|
|
300
|
+
raise ValueError(
|
|
301
|
+
"credential_name is required to delete a Credential"
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
return await self.delete_by_name_async(
|
|
305
|
+
self.credential_name, config=config
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
def delete(self, config: Optional[Config] = None):
|
|
309
|
+
"""删除凭证(同步)
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
config: 配置
|
|
313
|
+
"""
|
|
314
|
+
if self.credential_name is None:
|
|
315
|
+
raise ValueError(
|
|
316
|
+
"credential_name is required to delete a Credential"
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
return self.delete_by_name(self.credential_name, config=config)
|
|
320
|
+
|
|
321
|
+
async def get_async(self, config: Optional[Config] = None):
|
|
322
|
+
"""刷新凭证信息(异步)
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
config: 配置
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
Credential: 刷新后的凭证对象
|
|
329
|
+
"""
|
|
330
|
+
if self.credential_name is None:
|
|
331
|
+
raise ValueError(
|
|
332
|
+
"credential_name is required to refresh a Credential"
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
result = await self.get_by_name_async(
|
|
336
|
+
self.credential_name, config=config
|
|
337
|
+
)
|
|
338
|
+
self.update_self(result)
|
|
339
|
+
|
|
340
|
+
return self
|
|
341
|
+
|
|
342
|
+
def get(self, config: Optional[Config] = None):
|
|
343
|
+
"""刷新凭证信息(同步)
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
config: 配置
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
Credential: 刷新后的凭证对象
|
|
350
|
+
"""
|
|
351
|
+
if self.credential_name is None:
|
|
352
|
+
raise ValueError(
|
|
353
|
+
"credential_name is required to refresh a Credential"
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
result = self.get_by_name(self.credential_name, config=config)
|
|
357
|
+
self.update_self(result)
|
|
358
|
+
|
|
359
|
+
return self
|
|
360
|
+
|
|
361
|
+
async def refresh_async(self, config: Optional[Config] = None):
|
|
362
|
+
"""刷新凭证信息(异步)
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
config: 配置
|
|
366
|
+
|
|
367
|
+
Returns:
|
|
368
|
+
Credential: 刷新后的凭证对象
|
|
369
|
+
"""
|
|
370
|
+
return await self.get_async(config=config)
|
|
371
|
+
|
|
372
|
+
def refresh(self, config: Optional[Config] = None):
|
|
373
|
+
"""刷新凭证信息(同步)
|
|
374
|
+
|
|
375
|
+
Args:
|
|
376
|
+
config: 配置
|
|
377
|
+
|
|
378
|
+
Returns:
|
|
379
|
+
Credential: 刷新后的凭证对象
|
|
380
|
+
"""
|
|
381
|
+
return self.get(config=config)
|