# Manage Roles
This module is used to manage Authing roles, and can perform operations such as adding, deleting, modifying, and checking roles, adding/deleting users, and adding/deleting roles.
Please use the module in the following way instead of initializing the module directly:
import {ManagementClient} from "authing-js-sdk"
const managementClient = new ManagementClient({
userPoolId: "YOUR_USERPOOL_ID",
secret: "YOUR_USERPOOL_SECRET",
})
managementClient.roles.list // Get the list of roles
managementClient.roles.create // Create roles
managementClient.roles.listUsers // Get the list of role users
# Creating a Role
RolesManagementClient().create(code, description)
Create role
# Parameters
code
<string> Character unique identifierdescription
<string> description
# Example
managementClient.roles.create('rolea','RoleA')
# return value
Promise<DeepPartial<Role>>
# Delete role
RolesManagementClient().delete(code)
Delete role
# Parameters
code
<string> Character unique identifier
# Example
managementClient.roles.delete('rolea')
# return value
Promise<CommonMessage>
# Delete roles in batch
RolesManagementClient().deleteMany(codeList)
Batch delete roles
# Parameters
codeList
<string[]> Character unique identifier list
# Example
managementClient.roles.delete(['rolea'])
# return value
Promise<CommonMessage>
# Modify role
RolesManagementClient().update(code, input)
Modify role
# Parameters
code
<string> unique character identifierinput
<Object>input.description
<string> description informationinput.newCode
<string> New unique identifier
# Example
managementClient.roles.update('rolea', {newCode:'newcode'})
# return value
Promise<DeepPartial<Role>>
# Get role details
RolesManagementClient().detail(code)
Get role details
# Parameters
code
<string> unique character identifier
# Example
managementClient.roles.detail('manager')
# return value
Promise<DeepPartial<Role>>
role details
# Get a list of roles
RolesManagementClient().list(page, limit)
Get a list of roles
# Parameters
page
<number> Page number The default value is:1
.limit
<number> Number per page The default value is10
.
# Example
managementClient.roles.list(2, 10)
# return value
Promise<DeepPartial<PaginatedRoles>>
# Get the list of role users
RolesManagementClient().listUsers(code)
Get the list of role users
# Parameters
code
<string> unique character identifier
# Example
managementClient.roles.listUsers(code)
# return value
Promise<DeepPartial<PaginatedUsers>>
# Add user
RolesManagementClient().addUsers(code, userIds)
Add user
# Parameters
code
<string> unique character identifieruserIds
<string[]> list of user IDs
# Example
managementClient.roles.addUsers(code, ['USERID1','USERID2'])
# return value
Promise<CommonMessage>
# Remove user
RolesManagementClient().removeUsers(code, userIds)
Remove user
# Parameters
code
<string> Character unique identifieruserIds
<string[]> User ID list
# Example
managementClient.roles.removeUsers(code, ['USERID1','USERID2'])
# return value
Promise<CommonMessage>
# Get a list of role policies
RolesManagementClient().listPolicies(code, page, limit)
Get a list of role policies
# Parameters
code
<string> unique character identifierpage
<number> Page number The default value is:1
.limit
<number> Number of page numbers The default value is10
.
# Example
managementClient.roles.listPolicies('codea', 1, 10)
# return value
Promise<PaginatedPolicyAssignments>
# Authorization Policy
RolesManagementClient().addPolicies(code, policies)
Grant role authorization strategy
# Parameters
code
<string> unique character identifierpolicies
<string[]> policy list
# Example
managementClient.roles.addPolicies('rolea', ['PolicyA','PolicyB'])
# return value
Promise<CommonMessage>
# Role removal strategy
RolesManagementClient().removePolicies(code, policies)
Role removal strategy
# Parameters
code
<string> unique character identifierpolicies
<string[]> policy list
# Example
managementClient.roles.removePolicies('rolea', ['PolicyA','PolicyB'])
# return value
Promise<CommonMessage>
â Manage users Manage Strategy â