This topic describes the methods that are used to manage role assignments.
The options parameter of the IPDSRequestConfig type is encapsulated based on the request config options of axios. For more information, see AxiosRequestConfig.
assignRole method
To use this method, you must have the admin permission.
Assigns a role. You can use this method to assign the team administrator role to a user.
const result = await client.assignRole(params, options)Example
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,
});Request parameters
Parameter | Type | Required | Description |
params | IAssignRoleReq | Yes | The parameters that are used to assign a role. |
options | IPDSRequestConfig | Other request parameters. |
IAssignRoleReq parameters
Parameter | Type | Required | Description |
identity | IIDentity | Yes | The unique identifier of the user or group to be assigned with the role. |
role_id | string | Yes | The role ID. Set the value to SystemGroupAdmin. |
manage_resource_type | string | Yes | The type of the resource that can be managed by the role. Set the value to RT_Group. |
manage_resource_id | string | Yes | The ID of the resource that can be managed by the role, such as a group ID. |
IIDentity parameters
Parameter | Type | Required | Description |
identity_type | string | Yes | The type of the object to be assigned with the role. Valid values: IT_User and IT_Group. |
identity_id | string | Yes | The ID of the user or group to be assigned with the role. |
Response parameters
None.
cancelAssignRole method
To use this method, you must have the admin permission.
Cancels the assignment of a role. You can use this method to cancel the assignment of the team administrator role.
const result = await client.cancelAssignRole(params, options)Example
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,
});Request parameters
Parameter | Type | Required | Description |
params | ICancelAssignRoleReq | Yes | The request parameters that are used to cancel the assignment of a role. |
options | IPDSRequestConfig | Other request parameters. |
ICancelAssignRoleReq parameters
Parameter | Type | Required | Description |
identity | IIDentity | Yes | The ID of the user or group from which you want to cancel the assignment of the role. |
role_id | string | Yes | The role ID. Set the value to SystemGroupAdmin. |
manage_resource_type | string | Yes | The type of the resource that can be managed by the role. Set the value to RT_Group. |
manage_resource_id | string | Yes | The ID of the resource that can be managed by the role, such as a group ID. |
Response parameters
None.
listAssignments method
To use this method, you must have the admin permission or group administrator permissions.
Queries the roles that are assigned. For example, you can query the administrators of a group by using the ID of the group.
const result = await client.listAssignments(params, options)Example
const group_id = 'xxxx';
await client.listAssignments({
manage_resource_type: 'RT_Group',
manage_resource_id: group_id,
limit: 100,
});Request parameters
Parameter | Type | Required | Description |
params | IListAssignmentsReq | Yes | The request parameters that are used to query the roles that are assigned. |
options | IPDSRequestConfig | Other request parameters. |
IListAssignmentsReq parameters
Parameter | Type | Required | Description |
limit | long | The maximum number of entries to return. Valid values: 1 to 100. The number of returned entries is less than or equal to the specified number. | |
marker | string | The start marker of the pagination. | |
manage_resource_type | string | The type of the resource that is managed. Set the value to RT_Group. This value indicates that the administrators of a group are queried. | |
manage_resource_id | string | The ID of the resource that is managed, such as a group ID. |
Response parameters
Parameter | Type | Description |
assignment_list | IAssignment[] | null | The roles that are assigned. |
next_marker | string | The pagination token. It can be used in the next request to retrieve a new page of results. If next_marker is empty, no next page exists. |
IAssignment parameters
Parameter | Type | Description |
domain_id | string | The domain ID. |
identity | IIDentity | The ID of the user or group that is assigned with the role. |
role_id | string | The role ID. |
manage_resource_type | string | The type of the resource that is managed by the role. Only RT_Group may be returned, which indicates that a group is managed by the role. |
manage_resource_id | string | The ID of the resource that is managed by the role, such as a group ID. |
creator | string | The ID of the user who assigned the role. |
created_at | number | The time when the role was assigned. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC. |