# Manage role

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 identifier
  • description <string> description

# Example

code ='code'
role = management_client.roles.create(code=code)

# Delete role

RolesManagementClient().delete(code)

Delete role

# Parameters

  • code <string> unique character identifier

# Example

data = management_client.roles.delete(code='code')
code = data['code'] # 200 means success

# Delete roles in batch

RolesManagementClient().delete_many(codeList)

Batch delete roles

# Parameters

  • codeList <string[]> Character unique identifier list

# Example

data = management_client.roles.delete_many([
  'ROLE1',
  'ROLE2'
])
totalCount = data['totalCount']
_list = data['list']

# Modify role

RolesManagementClient().update(code, input)

Modify role

# Parameters

  • code <string> unique character identifier
  • input <Object>
  • input.description <string> description information
  • input.newCode <string> New unique identifier

# Example


# Modify basic information
code ='code'
desc ='Description'
role = management_client.roles.update(code=code, description=desc)

# Modify new code
role = management_client.roles.update(code='old', newCode="new")

# Get role details

RolesManagementClient().detail(code)

Get role details

# Parameters

  • code <string> unique character identifier

# Example

code ='code'
management_client.roles.create(code=code)

# 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 is 10.

# Example

data = management_client.roles.list()
totalCount = data['totalCount']
_list = data['list']

# Get the list of role users

RolesManagementClient().list_users(code)

Get the list of role users

# Parameters

  • code <string> unique character identifier

# Example

data = management_client.roles.list_users('ROLE')
totalCount = data['totalCount']
_list = data['list']

# Add user

RolesManagementClient().add_users(code, userIds)

Add user

# Parameters

  • code <string> unique character identifier
  • userIds <string[]> list of user IDs

# Example

data = management_client.roles.add_users('ROLE', [
  'USERID1',
  'USERID2'
])
totalCount = data['totalCount']
_list = data['list']

# Remove user

RolesManagementClient().remove_users(code, userIds)

Remove user

# Parameters

  • code <string> unique character identifier
  • userIds <string[]> list of user IDs

# Example

data = management_client.roles.remove_users('ROLE', [
  'USERID1',
  'USERID2'
])
totalCount = data['totalCount']
_list = data['list']

# Get a list of role policies

RolesManagementClient().list_policies(code, page, limit)

Get a list of role policies

# Parameters

  • code <string> unique character identifier
  • page <number> Page number The default value is: 1.
  • limit <number> Number of page numbers The default value is 10.

# Example

data = management_client.roles.list_policies('ROLE')
totalCount = data['totalCount']
_list = data['list']

# Authorization Policy

RolesManagementClient().add_policies(code, policies)

Grant role authorization strategy

# Parameters

  • code <string> unique character identifier
  • policies <string[]> policy list

# Example

data = management_client.roles.add_policies('ROLE', [
  'Policy1',
  'Policy2'
])
totalCount = data['totalCount']
_list = data['list']

# Role removal strategy

RolesManagementClient().remove_policies(code, policies)

Role removal strategy

# Parameters

  • code <string> unique character identifier
  • policies <string[]> policy list

# Example

data = management_client.roles.remove_policies('ROLE', [
  'Policy1',
  'Policy2'
])
totalCount = data['totalCount']
_list = data['list']