# 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.
# Creating a Role
RolesManagementClient().create(code, description)
Create role
# Parameters
code
<string> unique character identifierdescription
<string> description
# Example
Role role = managementClient.roles().create(new CreateRoleParam("code")).execute();
# Delete role
RolesManagementClient().delete(code)
Delete role
# Parameters
code
<string> unique character identifier
# Example
CommonMessage message = managementClient.roles().delete("code").execute();
# Delete roles in batch
RolesManagementClient().deleteMany(codeList)
Batch delete roles
# Parameters
codeList
<string[]> Character unique identifier list
# Example
ArrayList<String> list = new ArrayList<String>();
list.add("code");
CommonMessage result = managementClient.roles().deleteMany(list).execute();
# 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
Role role = rolesManagementClient.roles().update(new UpdateRoleParam("code").withDescription("desc")).execute();
# Get role details
RolesManagementClient().detail(code)
Get role details
# Parameters
code
<string> unique character identifier
# Example
Role role = managementClient.roles().detail("code").execute();
# 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
PaginatedRoles roles = managementClient.roles().list().execute();
# Get the list of role users
RolesManagementClient().listUsers(code)
Get the list of role users
# Parameters
code
<string> unique character identifier
# Example
PaginatedUsers users = managementClient.roles().listUsers("code").execute();
# Add user
RolesManagementClient().addUsers(code, userIds)
Add user
# Parameters
code
<string> unique character identifieruserIds
<string[]> list of user IDs
# Example
ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
CommonMessage message = managementClient.roles().addUsers("code", userIds).execute();
# Remove user
RolesManagementClient().removeUsers(code, userIds)
Remove user
# Parameters
code
<string> unique character identifieruserIds
<string[]> list of user IDs
# Example
ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
CommonMessage message = managementClient.roles().removeUsers("code", userIds).execute();
# 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
PaginatedPolicyAssignments result = managementClient.roles().listPolicies("code").execute();
# Authorization Policy
RolesManagementClient().addPolicies(code, policies)
Grant role authorization strategy
# Parameters
code
<string> unique character identifierpolicies
<string[]> policy list
# Example
ArrayList<String> policies = new ArrayList<>();
policies.add("policy id");
CommonMessage message = managementClient.roles().addPolicies("code", policies).execute();
# Role removal strategy
RolesManagementClient().removePolicies(code, policies)
Role removal strategy
# Parameters
code
<string> unique character identifierpolicies
<string[]> policy list
# Example
ArrayList<String> policies = new ArrayList<>();
policies.add("policy id");
CommonMessage message = managementClient.roles().removePolicies("code", policies).execute();