agentkit-sdk-python 0.9.2__py3-none-any.whl → 0.9.5__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.
- agentkit/__init__.py +5 -5
- agentkit/apps/a2a_app/a2a_app.py +108 -11
- agentkit/client/base_service_client.py +102 -8
- agentkit/frameworks/_agentsentry.py +5 -0
- agentkit/sdk/organizations/__init__.py +63 -0
- agentkit/sdk/organizations/client.py +175 -0
- agentkit/sdk/organizations/types.py +368 -0
- agentkit/sdk/users/__init__.py +73 -0
- agentkit/sdk/users/client.py +181 -0
- agentkit/sdk/users/types.py +548 -0
- agentkit/sdk/workspaces/__init__.py +91 -0
- agentkit/sdk/workspaces/client.py +272 -0
- agentkit/sdk/workspaces/types.py +539 -0
- agentkit/toolkit/resources/samples/a2a.py +14 -2
- agentkit/version.py +1 -1
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/METADATA +2 -2
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/RECORD +21 -12
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/WHEEL +0 -0
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/entry_points.txt +0 -0
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/licenses/LICENSE +0 -0
- {agentkit_sdk_python-0.9.2.dist-info → agentkit_sdk_python-0.9.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Pydantic models for the AgentKit Organizations OpenAPI (amon
|
|
16
|
+
organization service, signing service ``agentkit``).
|
|
17
|
+
|
|
18
|
+
All actions resolve the organization from the signed account, so request
|
|
19
|
+
bodies only carry the business identifiers below. GET-declared actions
|
|
20
|
+
(``GetOrganization``, ``ListOrganizationMembers``) carry business params in
|
|
21
|
+
the query string with PascalCase keys; POST-style actions carry them in a
|
|
22
|
+
JSON body.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from typing import List, Optional
|
|
28
|
+
|
|
29
|
+
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
30
|
+
|
|
31
|
+
# The only organization role the OpenAPI supports today.
|
|
32
|
+
ORGANIZATION_ADMIN_ROLE = "organization_admin"
|
|
33
|
+
|
|
34
|
+
MAX_LIST_ORGANIZATION_MEMBERS_RESULTS = 100
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class OrganizationsBaseModel(BaseModel):
|
|
38
|
+
"""AgentKit Organizations base model"""
|
|
39
|
+
|
|
40
|
+
model_config = {"populate_by_name": True, "arbitrary_types_allowed": True}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Data Types
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class OrganizationEndpointData(OrganizationsBaseModel):
|
|
47
|
+
"""An Endpoint bound to an organization (``UpdateOrganization``, read-
|
|
48
|
+
only elsewhere)."""
|
|
49
|
+
|
|
50
|
+
id: Optional[str] = Field(default=None, alias="Id")
|
|
51
|
+
base_url: Optional[str] = Field(default=None, alias="BaseUrl")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class OrganizationData(OrganizationsBaseModel):
|
|
55
|
+
"""One organization as returned by ``CreateOrganization`` /
|
|
56
|
+
``GetOrganization``."""
|
|
57
|
+
|
|
58
|
+
org_id: Optional[str] = Field(default=None, alias="OrgId")
|
|
59
|
+
name: Optional[str] = Field(default=None, alias="Name")
|
|
60
|
+
status: Optional[str] = Field(default=None, alias="Status")
|
|
61
|
+
user_pool_id: Optional[str] = Field(default=None, alias="UserPoolId")
|
|
62
|
+
workload_pool_id: Optional[str] = Field(default=None, alias="WorkloadPoolId")
|
|
63
|
+
idp_id: Optional[str] = Field(default=None, alias="IdpId")
|
|
64
|
+
default_user_pool_client_id: Optional[str] = Field(
|
|
65
|
+
default=None, alias="DefaultUserPoolClientId"
|
|
66
|
+
)
|
|
67
|
+
default_user_pool_cli_client_id: Optional[str] = Field(
|
|
68
|
+
default=None, alias="DefaultUserPoolCliClientId"
|
|
69
|
+
)
|
|
70
|
+
endpoint: Optional[OrganizationEndpointData] = Field(
|
|
71
|
+
default=None, alias="Endpoint"
|
|
72
|
+
)
|
|
73
|
+
default_workspace_id: Optional[str] = Field(
|
|
74
|
+
default=None, alias="DefaultWorkspaceId"
|
|
75
|
+
)
|
|
76
|
+
project_name: Optional[str] = Field(default=None, alias="ProjectName")
|
|
77
|
+
create_time: Optional[str] = Field(default=None, alias="CreateTime")
|
|
78
|
+
update_time: Optional[str] = Field(default=None, alias="UpdateTime")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class OrganizationMemberData(OrganizationsBaseModel):
|
|
82
|
+
"""One organization member as returned by the member actions."""
|
|
83
|
+
|
|
84
|
+
binding_id: Optional[str] = Field(default=None, alias="BindingId")
|
|
85
|
+
user_id: Optional[str] = Field(default=None, alias="UserId")
|
|
86
|
+
role: Optional[str] = Field(default=None, alias="Role")
|
|
87
|
+
preferred_username: Optional[str] = Field(
|
|
88
|
+
default=None, alias="PreferredUsername"
|
|
89
|
+
)
|
|
90
|
+
name: Optional[str] = Field(default=None, alias="Name")
|
|
91
|
+
email: Optional[str] = Field(default=None, alias="Email")
|
|
92
|
+
phone: Optional[str] = Field(default=None, alias="Phone")
|
|
93
|
+
create_time: Optional[str] = Field(default=None, alias="CreateTime")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class UpdateOrganizationEndpointData(OrganizationsBaseModel):
|
|
97
|
+
"""The Endpoint binding accepted by ``UpdateOrganization``; ``Id`` and
|
|
98
|
+
``BaseUrl`` must be provided together."""
|
|
99
|
+
|
|
100
|
+
id: str = Field(..., alias="Id")
|
|
101
|
+
base_url: str = Field(..., alias="BaseUrl")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# CreateOrganization - Request / Response
|
|
105
|
+
class CreateOrganizationRequest(OrganizationsBaseModel):
|
|
106
|
+
# Project name for the default workspace (also used as its name).
|
|
107
|
+
project_name: Optional[str] = Field(default=None, alias="ProjectName")
|
|
108
|
+
# Skip auto-creating the default user pool and its clients.
|
|
109
|
+
skip_create_user_pool: Optional[bool] = Field(
|
|
110
|
+
default=None, alias="SkipCreateUserPool"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
@field_validator("project_name")
|
|
114
|
+
@classmethod
|
|
115
|
+
def _validate_project_name(cls, v: Optional[str]) -> Optional[str]:
|
|
116
|
+
if v is not None and not v.strip():
|
|
117
|
+
raise ValueError("project_name must not be empty when provided.")
|
|
118
|
+
return v
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class CreateOrganizationResponse(OrganizationsBaseModel):
|
|
122
|
+
"""``created=False`` means an active organization already existed and
|
|
123
|
+
was reused (provisioning is idempotent)."""
|
|
124
|
+
|
|
125
|
+
organization: Optional[OrganizationData] = Field(
|
|
126
|
+
default=None, alias="Organization"
|
|
127
|
+
)
|
|
128
|
+
created: Optional[bool] = Field(default=None, alias="Created")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# GetOrganization - Request / Response
|
|
132
|
+
class GetOrganizationRequest(OrganizationsBaseModel):
|
|
133
|
+
# Optional: when omitted the server looks up the current account's
|
|
134
|
+
# organization.
|
|
135
|
+
org_id: Optional[str] = Field(default=None, alias="OrgId")
|
|
136
|
+
|
|
137
|
+
@field_validator("org_id")
|
|
138
|
+
@classmethod
|
|
139
|
+
def _validate_org_id(cls, v: Optional[str]) -> Optional[str]:
|
|
140
|
+
if v is not None and not v.strip():
|
|
141
|
+
raise ValueError(
|
|
142
|
+
"org_id must not be empty when provided; omit it to probe "
|
|
143
|
+
"the current account."
|
|
144
|
+
)
|
|
145
|
+
return v
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class GetOrganizationResponse(OrganizationsBaseModel):
|
|
149
|
+
"""An empty result is a legal "account not provisioned yet" answer (no
|
|
150
|
+
error), surfaced as ``organization=None``."""
|
|
151
|
+
|
|
152
|
+
organization: Optional[OrganizationData] = Field(
|
|
153
|
+
default=None, alias="Organization"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# UpdateOrganization - Request / Response
|
|
158
|
+
class UpdateOrganizationRequest(OrganizationsBaseModel):
|
|
159
|
+
org_id: str = Field(..., alias="OrgId")
|
|
160
|
+
name: Optional[str] = Field(default=None, alias="Name")
|
|
161
|
+
idp_id: Optional[str] = Field(default=None, alias="IdpId")
|
|
162
|
+
user_pool_id: Optional[str] = Field(default=None, alias="UserPoolId")
|
|
163
|
+
user_pool_client_id: Optional[str] = Field(
|
|
164
|
+
default=None, alias="UserPoolClientId"
|
|
165
|
+
)
|
|
166
|
+
user_pool_client_secret: Optional[str] = Field(
|
|
167
|
+
default=None, alias="UserPoolClientSecret"
|
|
168
|
+
)
|
|
169
|
+
user_pool_cli_client_id: Optional[str] = Field(
|
|
170
|
+
default=None, alias="UserPoolCliClientId"
|
|
171
|
+
)
|
|
172
|
+
endpoint: Optional[UpdateOrganizationEndpointData] = Field(
|
|
173
|
+
default=None, alias="Endpoint"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
@field_validator("org_id")
|
|
177
|
+
@classmethod
|
|
178
|
+
def _validate_org_id(cls, v: str) -> str:
|
|
179
|
+
if not v.strip():
|
|
180
|
+
raise ValueError("org_id is required to update an organization.")
|
|
181
|
+
return v
|
|
182
|
+
|
|
183
|
+
@field_validator(
|
|
184
|
+
"name",
|
|
185
|
+
"idp_id",
|
|
186
|
+
"user_pool_id",
|
|
187
|
+
"user_pool_client_id",
|
|
188
|
+
"user_pool_client_secret",
|
|
189
|
+
"user_pool_cli_client_id",
|
|
190
|
+
)
|
|
191
|
+
@classmethod
|
|
192
|
+
def _validate_non_empty(cls, v: Optional[str]) -> Optional[str]:
|
|
193
|
+
# Empty values do not update server-side.
|
|
194
|
+
if v is not None and not v.strip():
|
|
195
|
+
raise ValueError(
|
|
196
|
+
"update fields must not be empty; omit them to keep the "
|
|
197
|
+
"current values."
|
|
198
|
+
)
|
|
199
|
+
return v
|
|
200
|
+
|
|
201
|
+
@model_validator(mode="after")
|
|
202
|
+
def _validate_has_change(self) -> "UpdateOrganizationRequest":
|
|
203
|
+
fields = (
|
|
204
|
+
self.name,
|
|
205
|
+
self.idp_id,
|
|
206
|
+
self.user_pool_id,
|
|
207
|
+
self.user_pool_client_id,
|
|
208
|
+
self.user_pool_client_secret,
|
|
209
|
+
self.user_pool_cli_client_id,
|
|
210
|
+
)
|
|
211
|
+
if all(value is None for value in fields) and self.endpoint is None:
|
|
212
|
+
raise ValueError(
|
|
213
|
+
"Nothing to update. Pass at least one of name/idp_id/"
|
|
214
|
+
"user_pool_id/user_pool_client_id/user_pool_client_secret/"
|
|
215
|
+
"user_pool_cli_client_id/endpoint."
|
|
216
|
+
)
|
|
217
|
+
return self
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class UpdateOrganizationResponse(OrganizationsBaseModel):
|
|
221
|
+
org_id: Optional[str] = Field(default=None, alias="OrgId")
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
# DeleteOrganization - Request / Response
|
|
225
|
+
class DeleteOrganizationRequest(OrganizationsBaseModel):
|
|
226
|
+
org_id: str = Field(..., alias="OrgId")
|
|
227
|
+
# Also delete the organization's default user pool (default server
|
|
228
|
+
# behavior).
|
|
229
|
+
delete_user_pool: Optional[bool] = Field(
|
|
230
|
+
default=None, alias="DeleteUserPool"
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
@field_validator("org_id")
|
|
234
|
+
@classmethod
|
|
235
|
+
def _validate_org_id(cls, v: str) -> str:
|
|
236
|
+
if not v.strip():
|
|
237
|
+
raise ValueError("org_id is required to delete an organization.")
|
|
238
|
+
return v
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class DeleteOrganizationResponse(OrganizationsBaseModel):
|
|
242
|
+
"""The deletion is synchronous and cascades to all workspaces and
|
|
243
|
+
member bindings; the response reports the final status (``DELETED``)."""
|
|
244
|
+
|
|
245
|
+
status: Optional[str] = Field(default=None, alias="Status")
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
# AddOrganizationMember - Request / Response
|
|
249
|
+
class AddOrganizationMemberRequest(OrganizationsBaseModel):
|
|
250
|
+
# Both resolve the organization from the signed account -- there is no
|
|
251
|
+
# OrgId param.
|
|
252
|
+
user_id: str = Field(..., alias="UserId")
|
|
253
|
+
role: str = Field(..., alias="Role")
|
|
254
|
+
|
|
255
|
+
@field_validator("user_id", "role")
|
|
256
|
+
@classmethod
|
|
257
|
+
def _validate_required(cls, v: str) -> str:
|
|
258
|
+
if not v.strip():
|
|
259
|
+
raise ValueError(
|
|
260
|
+
"userId and role are required for organization member "
|
|
261
|
+
"operations."
|
|
262
|
+
)
|
|
263
|
+
return v
|
|
264
|
+
|
|
265
|
+
@field_validator("role")
|
|
266
|
+
@classmethod
|
|
267
|
+
def _validate_role(cls, v: str) -> str:
|
|
268
|
+
if v != ORGANIZATION_ADMIN_ROLE:
|
|
269
|
+
raise ValueError(
|
|
270
|
+
f"role {v!r} is invalid; only "
|
|
271
|
+
f"{ORGANIZATION_ADMIN_ROLE!r} is supported."
|
|
272
|
+
)
|
|
273
|
+
return v
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
class AddOrganizationMemberResponse(OrganizationsBaseModel):
|
|
277
|
+
"""Idempotent server-side: re-granting the same UserId+Role
|
|
278
|
+
restores/reuses the existing binding."""
|
|
279
|
+
|
|
280
|
+
member: Optional[OrganizationMemberData] = Field(
|
|
281
|
+
default=None, alias="Member"
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# RemoveOrganizationMember - Request / Response
|
|
286
|
+
class RemoveOrganizationMemberRequest(OrganizationsBaseModel):
|
|
287
|
+
user_id: str = Field(..., alias="UserId")
|
|
288
|
+
role: str = Field(..., alias="Role")
|
|
289
|
+
|
|
290
|
+
@field_validator("user_id", "role")
|
|
291
|
+
@classmethod
|
|
292
|
+
def _validate_required(cls, v: str) -> str:
|
|
293
|
+
if not v.strip():
|
|
294
|
+
raise ValueError(
|
|
295
|
+
"userId and role are required for organization member "
|
|
296
|
+
"operations."
|
|
297
|
+
)
|
|
298
|
+
return v
|
|
299
|
+
|
|
300
|
+
@field_validator("role")
|
|
301
|
+
@classmethod
|
|
302
|
+
def _validate_role(cls, v: str) -> str:
|
|
303
|
+
if v != ORGANIZATION_ADMIN_ROLE:
|
|
304
|
+
raise ValueError(
|
|
305
|
+
f"role {v!r} is invalid; only "
|
|
306
|
+
f"{ORGANIZATION_ADMIN_ROLE!r} is supported."
|
|
307
|
+
)
|
|
308
|
+
return v
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class RemoveOrganizationMemberResponse(OrganizationsBaseModel):
|
|
312
|
+
"""Idempotent: revoking a missing binding still succeeds with
|
|
313
|
+
``revoked=True``."""
|
|
314
|
+
|
|
315
|
+
revoked: Optional[bool] = Field(default=None, alias="Revoked")
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# ListOrganizationMembers - Request / Response
|
|
319
|
+
class ListOrganizationMembersRequest(OrganizationsBaseModel):
|
|
320
|
+
user_id: Optional[str] = Field(default=None, alias="UserId")
|
|
321
|
+
role: Optional[str] = Field(default=None, alias="Role")
|
|
322
|
+
# 0 means "unspecified" and lets the server default (10, max 100).
|
|
323
|
+
max_results: Optional[int] = Field(
|
|
324
|
+
default=None,
|
|
325
|
+
alias="MaxResults",
|
|
326
|
+
ge=0,
|
|
327
|
+
le=MAX_LIST_ORGANIZATION_MEMBERS_RESULTS,
|
|
328
|
+
)
|
|
329
|
+
next_token: Optional[str] = Field(default=None, alias="NextToken")
|
|
330
|
+
|
|
331
|
+
@field_validator("user_id")
|
|
332
|
+
@classmethod
|
|
333
|
+
def _validate_user_id(cls, v: Optional[str]) -> Optional[str]:
|
|
334
|
+
if v is not None and not v.strip():
|
|
335
|
+
raise ValueError("user_id must not be empty when provided.")
|
|
336
|
+
return v
|
|
337
|
+
|
|
338
|
+
@field_validator("role")
|
|
339
|
+
@classmethod
|
|
340
|
+
def _validate_role(cls, v: Optional[str]) -> Optional[str]:
|
|
341
|
+
if v is not None:
|
|
342
|
+
if not v.strip():
|
|
343
|
+
raise ValueError("role must not be empty when provided.")
|
|
344
|
+
if v != ORGANIZATION_ADMIN_ROLE:
|
|
345
|
+
raise ValueError(
|
|
346
|
+
f"role {v!r} is invalid; only "
|
|
347
|
+
f"{ORGANIZATION_ADMIN_ROLE!r} is supported."
|
|
348
|
+
)
|
|
349
|
+
return v
|
|
350
|
+
|
|
351
|
+
@field_validator("next_token")
|
|
352
|
+
@classmethod
|
|
353
|
+
def _validate_next_token(cls, v: Optional[str]) -> Optional[str]:
|
|
354
|
+
if v is not None and not v.strip():
|
|
355
|
+
raise ValueError("next_token must not be empty when provided.")
|
|
356
|
+
return v
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class ListOrganizationMembersResponse(OrganizationsBaseModel):
|
|
360
|
+
members: Optional[List[OrganizationMemberData]] = Field(
|
|
361
|
+
default=None, alias="Members"
|
|
362
|
+
)
|
|
363
|
+
next_token: Optional[str] = Field(default=None, alias="NextToken")
|
|
364
|
+
|
|
365
|
+
@field_validator("next_token")
|
|
366
|
+
@classmethod
|
|
367
|
+
def _empty_token_is_none(cls, v: Optional[str]) -> Optional[str]:
|
|
368
|
+
return v or None
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from .client import AgentkitUsersClient
|
|
16
|
+
from .types import (
|
|
17
|
+
AddUsersToGroupRequest,
|
|
18
|
+
AddUsersToGroupResponse,
|
|
19
|
+
ChangeUsersGroupRequest,
|
|
20
|
+
ChangeUsersGroupResponse,
|
|
21
|
+
CreateUsersRequest,
|
|
22
|
+
CreateUsersResponse,
|
|
23
|
+
CreateUserResultItem,
|
|
24
|
+
DeleteUserRequest,
|
|
25
|
+
DeleteUserResponse,
|
|
26
|
+
ErrorForCreateUserResultItem,
|
|
27
|
+
ErrorForGroupUserResultItem,
|
|
28
|
+
GetUserRequest,
|
|
29
|
+
GetUserResponse,
|
|
30
|
+
GroupUserResultItem,
|
|
31
|
+
ImportUserErrorItem,
|
|
32
|
+
ImportUsersRequest,
|
|
33
|
+
ImportUsersResponse,
|
|
34
|
+
ListUsersRequest,
|
|
35
|
+
ListUsersResponse,
|
|
36
|
+
RemoveUsersFromGroupRequest,
|
|
37
|
+
RemoveUsersFromGroupResponse,
|
|
38
|
+
UpdateUserRequest,
|
|
39
|
+
UpdateUserResponse,
|
|
40
|
+
UserForCreateUsers,
|
|
41
|
+
UsersItemForListUsers,
|
|
42
|
+
UsersBaseModel,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"AgentkitUsersClient",
|
|
47
|
+
"AddUsersToGroupRequest",
|
|
48
|
+
"AddUsersToGroupResponse",
|
|
49
|
+
"ChangeUsersGroupRequest",
|
|
50
|
+
"ChangeUsersGroupResponse",
|
|
51
|
+
"CreateUsersRequest",
|
|
52
|
+
"CreateUsersResponse",
|
|
53
|
+
"CreateUserResultItem",
|
|
54
|
+
"DeleteUserRequest",
|
|
55
|
+
"DeleteUserResponse",
|
|
56
|
+
"ErrorForCreateUserResultItem",
|
|
57
|
+
"ErrorForGroupUserResultItem",
|
|
58
|
+
"GetUserRequest",
|
|
59
|
+
"GetUserResponse",
|
|
60
|
+
"GroupUserResultItem",
|
|
61
|
+
"ImportUserErrorItem",
|
|
62
|
+
"ImportUsersRequest",
|
|
63
|
+
"ImportUsersResponse",
|
|
64
|
+
"ListUsersRequest",
|
|
65
|
+
"ListUsersResponse",
|
|
66
|
+
"RemoveUsersFromGroupRequest",
|
|
67
|
+
"RemoveUsersFromGroupResponse",
|
|
68
|
+
"UpdateUserRequest",
|
|
69
|
+
"UpdateUserResponse",
|
|
70
|
+
"UserForCreateUsers",
|
|
71
|
+
"UsersItemForListUsers",
|
|
72
|
+
"UsersBaseModel",
|
|
73
|
+
]
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""AgentKit Users (user pool) Management Service client.
|
|
16
|
+
|
|
17
|
+
Mirrors the AgentKit OpenAPI ``ListUsers``/``GetUser``/``CreateUsers``/
|
|
18
|
+
``UpdateUser``/``DeleteUser``/``ImportUsers``/group-membership actions on
|
|
19
|
+
the ``agentkit`` signing service. ``ListUsers`` and ``GetUser`` are
|
|
20
|
+
declared as HTTP GET in the OpenAPI definition, so their business params
|
|
21
|
+
travel in the query string (see ``_invoke_get_api``); every other action
|
|
22
|
+
is a JSON-body POST.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from typing import Dict, Union
|
|
28
|
+
|
|
29
|
+
from agentkit.client import BaseAgentkitClient
|
|
30
|
+
from agentkit.client.base_service_client import ApiConfig
|
|
31
|
+
|
|
32
|
+
from .types import (
|
|
33
|
+
AddUsersToGroupRequest,
|
|
34
|
+
AddUsersToGroupResponse,
|
|
35
|
+
ChangeUsersGroupRequest,
|
|
36
|
+
ChangeUsersGroupResponse,
|
|
37
|
+
CreateUsersRequest,
|
|
38
|
+
CreateUsersResponse,
|
|
39
|
+
DeleteUserRequest,
|
|
40
|
+
DeleteUserResponse,
|
|
41
|
+
GetUserRequest,
|
|
42
|
+
GetUserResponse,
|
|
43
|
+
ImportUsersRequest,
|
|
44
|
+
ImportUsersResponse,
|
|
45
|
+
ListUsersRequest,
|
|
46
|
+
ListUsersResponse,
|
|
47
|
+
RemoveUsersFromGroupRequest,
|
|
48
|
+
RemoveUsersFromGroupResponse,
|
|
49
|
+
UpdateUserRequest,
|
|
50
|
+
UpdateUserResponse,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class AgentkitUsersClient(BaseAgentkitClient):
|
|
55
|
+
"""AgentKit Users (user pool) Management Service.
|
|
56
|
+
|
|
57
|
+
``user_pool_id`` is optional on every action: when omitted the server
|
|
58
|
+
falls back to the current account's default user pool.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
API_ACTIONS: Dict[str, Union[str, ApiConfig]] = {
|
|
62
|
+
# GET-declared actions: business params are signed in the query
|
|
63
|
+
# string and no JSON body is sent.
|
|
64
|
+
"ListUsers": ApiConfig(action="ListUsers", method="GET"),
|
|
65
|
+
"GetUser": ApiConfig(action="GetUser", method="GET"),
|
|
66
|
+
# POST-declared actions: business params travel in the JSON body.
|
|
67
|
+
"CreateUsers": "CreateUsers",
|
|
68
|
+
"UpdateUser": "UpdateUser",
|
|
69
|
+
"DeleteUser": "DeleteUser",
|
|
70
|
+
"AddUsersToGroup": "AddUsersToGroup",
|
|
71
|
+
"RemoveUsersFromGroup": "RemoveUsersFromGroup",
|
|
72
|
+
"ChangeUsersGroup": "ChangeUsersGroup",
|
|
73
|
+
"ImportUsers": "ImportUsers",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
def __init__(
|
|
77
|
+
self,
|
|
78
|
+
access_key: str = "",
|
|
79
|
+
secret_key: str = "",
|
|
80
|
+
region: str = "",
|
|
81
|
+
session_token: str = "",
|
|
82
|
+
) -> None:
|
|
83
|
+
super().__init__(
|
|
84
|
+
access_key=access_key,
|
|
85
|
+
secret_key=secret_key,
|
|
86
|
+
region=region,
|
|
87
|
+
session_token=session_token,
|
|
88
|
+
service_name="users",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
@staticmethod
|
|
92
|
+
def _query_params(request) -> Dict[str, object]:
|
|
93
|
+
"""Dump a GET request into query params (PascalCase keys, None
|
|
94
|
+
dropped). Int/bool values are stringified by
|
|
95
|
+
``Service.prepare_request`` before signing."""
|
|
96
|
+
return request.model_dump(by_alias=True, exclude_none=True)
|
|
97
|
+
|
|
98
|
+
def create_users(self, request: CreateUsersRequest) -> CreateUsersResponse:
|
|
99
|
+
"""Create 1-1000 users in a user pool. ``results[i]`` keeps request
|
|
100
|
+
order; a present ``error`` marks that user as failed without
|
|
101
|
+
affecting the others."""
|
|
102
|
+
return self._invoke_api(
|
|
103
|
+
api_action="CreateUsers",
|
|
104
|
+
request=request,
|
|
105
|
+
response_type=CreateUsersResponse,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
def update_user(self, request: UpdateUserRequest) -> UpdateUserResponse:
|
|
109
|
+
"""Update one user; omitted fields are kept, empty strings clear
|
|
110
|
+
them server-side."""
|
|
111
|
+
return self._invoke_api(
|
|
112
|
+
api_action="UpdateUser",
|
|
113
|
+
request=request,
|
|
114
|
+
response_type=UpdateUserResponse,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
def delete_user(self, request: DeleteUserRequest) -> DeleteUserResponse:
|
|
118
|
+
"""Delete one user from a user pool (irreversible)."""
|
|
119
|
+
return self._invoke_api(
|
|
120
|
+
api_action="DeleteUser",
|
|
121
|
+
request=request,
|
|
122
|
+
response_type=DeleteUserResponse,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def list_users(self, request: ListUsersRequest) -> ListUsersResponse:
|
|
126
|
+
"""List users in a user pool. Filters are exact matches;
|
|
127
|
+
``max_results=0`` means "unspecified" and lets the server default
|
|
128
|
+
(10, max 100). ``next_token`` is None on the last page."""
|
|
129
|
+
return self._invoke_get_api(
|
|
130
|
+
api_action="ListUsers",
|
|
131
|
+
params=self._query_params(request),
|
|
132
|
+
response_type=ListUsersResponse,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def get_user(self, request: GetUserRequest) -> GetUserResponse:
|
|
136
|
+
"""Fetch one user (carries WorkspaceIds, no phone/updatedAt)."""
|
|
137
|
+
return self._invoke_get_api(
|
|
138
|
+
api_action="GetUser",
|
|
139
|
+
params=self._query_params(request),
|
|
140
|
+
response_type=GetUserResponse,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
def add_users_to_group(
|
|
144
|
+
self, request: AddUsersToGroupRequest
|
|
145
|
+
) -> AddUsersToGroupResponse:
|
|
146
|
+
"""Add 1-100 users to a group; results keep request order."""
|
|
147
|
+
return self._invoke_api(
|
|
148
|
+
api_action="AddUsersToGroup",
|
|
149
|
+
request=request,
|
|
150
|
+
response_type=AddUsersToGroupResponse,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def remove_users_from_group(
|
|
154
|
+
self, request: RemoveUsersFromGroupRequest
|
|
155
|
+
) -> RemoveUsersFromGroupResponse:
|
|
156
|
+
"""Remove 1-100 users from a group; results keep request order."""
|
|
157
|
+
return self._invoke_api(
|
|
158
|
+
api_action="RemoveUsersFromGroup",
|
|
159
|
+
request=request,
|
|
160
|
+
response_type=RemoveUsersFromGroupResponse,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def change_users_group(
|
|
164
|
+
self, request: ChangeUsersGroupRequest
|
|
165
|
+
) -> ChangeUsersGroupResponse:
|
|
166
|
+
"""Move 1-100 users from one group to another; results keep
|
|
167
|
+
request order."""
|
|
168
|
+
return self._invoke_api(
|
|
169
|
+
api_action="ChangeUsersGroup",
|
|
170
|
+
request=request,
|
|
171
|
+
response_type=ChangeUsersGroupResponse,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
def import_users(self, request: ImportUsersRequest) -> ImportUsersResponse:
|
|
175
|
+
"""Bulk-import users from a base64-encoded CSV (header row + one
|
|
176
|
+
user per row; only CSV is supported)."""
|
|
177
|
+
return self._invoke_api(
|
|
178
|
+
api_action="ImportUsers",
|
|
179
|
+
request=request,
|
|
180
|
+
response_type=ImportUsersResponse,
|
|
181
|
+
)
|