本篇主要介绍角色授权相关接口。
请求参数中的 options: IPDSRequestConfig 基于 axios 的 request config 封装,详情请看:AxiosRequestConfig。
assignRole 方法
需要Admin权限。
分配角色,当前支持将用户设置为团队管理员角色。
const result = await client.assignRole(params, options)
举例
const user_id = 'xxx';
const group_id = 'xxxx';
await client.assignRole({
identity: {
identity_type: 'IT_User',
identity_id: user_id,
},
role_id: 'SystemGroupAdmin',
manage_resource_type: 'RT_Group',
manage_resource_id: group_id,
});
参数
字段 | 类型 | 必选 | 说明 |
params | IAssignRoleReq | 是 | 授权角色请求参数 |
options | IPDSRequestConfig | 请求参数 |
IAssignRoleReq
字段 | 类型 | 必选 | 说明 |
identity | IIDentity | 是 | 被授权者的唯一标识,一般为用户ID或者分组ID |
role_id | string | 是 | 角色ID,目前仅支持: "SystemGroupAdmin" |
manage_resource_type | string | 是 | 管理资源的类型。目前仅支持: "RT_Group" |
manage_resource_id | string | 是 | 管理的资源ID,比如分组的ID。 |
IIDentity
字段 | 类型 | 必选 | 说明 |
identity_type | string | 是 | 管理资源的类型。目前仅支持:"IT_User" | "IT_Group" |
identity_id | string | 是 | 唯一标识 user_id 或者 group_id。 |
返回
无
cancelAssignRole 方法
需要Admin权限。
取消分配角色,当前仅支持取消团队管理员角色。
const result = await client.cancelAssignRole(params, options)
举例
const user_id = 'xxx';
const group_id = 'xxxx';
await client.cancelAssignRole({
identity: {
identity_type: 'IT_User',
identity_id: user_id,
},
role_id: 'SystemGroupAdmin',
manage_resource_type: 'RT_Group',
manage_resource_id: group_id,
});
参数
字段 | 类型 | 必选 | 说明 |
params | ICancelAssignRoleReq | 是 | 授权角色请求参数 |
options | IPDSRequestConfig | 请求参数 |
ICancelAssignRoleReq
字段 | 类型 | 必选 | 说明 |
identity | IIDentity | 是 | 被授权者的唯一标识,一般为用户ID或者分组ID |
role_id | string | 是 | 角色ID,目前仅支持: "SystemGroupAdmin" |
manage_resource_type | string | 是 | 管理资源的类型。目前仅支持: "RT_Group" |
manage_resource_id | string | 是 | 管理的资源ID,比如分组的ID。 |
返回
无
listAssignments 方法
需要Admin权限或者分组管理员权限。
列举已分配的角色列表,比如可通过团队ID获取分组管理员角色列表。
const result = await client.listAssignments(params, options)
举例
const group_id = 'xxxx';
await client.listAssignments({
manage_resource_type: 'RT_Group',
manage_resource_id: group_id,
limit: 100,
});
参数
字段 | 类型 | 必选 | 说明 |
params | IListAssignmentsReq | 是 | 授权角色请求参数 |
options | IPDSRequestConfig | 请求参数 |
IListAssignmentsReq
字段 | 类型 | 必选 | 说明 |
limit | long | 限定此次返回资源的数量,取值范围[1,100]。 返回结果可以小于指定的数量,但不能多于指定的数量。 | |
marker | string | 分页开始标识。 | |
manage_resource_type | string | 管理的资源类型,当前仅支持: RT_Group,查询某分组的管理员授权列表 | |
manage_resource_id | string | 管理的资源ID,比如分组的ID |
返回
字段 | 类型 | 说明 |
assignment_list | IAssignment[] | null | 返回授权信息列表 |
next_marker | string | 下一页起始资源标识符, 最后一页该值为空 |
IAssignment
字段 | 类型 | 说明 |
domain_id | string | domain ID |
identity | IIDentity | 被授权者的唯一标识,一般为用户ID或者分组ID |
role_id | string | 被授权的角色ID |
manage_resource_type | string | 管理的资源类型,比如: RT_Group,表示分组类型 |
manage_resource_id | string | 管理的资源ID,比如分组的ID |
creator | string | 创建者ID |
created_at | number | 创建时间,从1970年1月1日0点到当前的毫秒时间戳 |
- 本页导读 (0)