Skip to content

Get the role list

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If the description of this document is incorrect, please refer to the V3 API.

Get the role list, support paging, support filtering by permission group (permission space)

Method name

ManagementClient.listRoles

Request parameters

NameTypeRequiredDefault valueDescriptionSample value
pagenumberNo1Current page number, starting from 11
limitnumberNo10Number per page, maximum cannot exceed 50, default is 1010
keywordsstringNo-Used for fuzzy search based on role code or name, optional.admin
namespacestringNodefaultThe code of the permission group (permission space). If not passed, the default permission group is obtained.default

Sample code

ts
import { ManagementClient, Models } from "authing-node-sdk";

// Initialize ManagementClient
const managementClient = new ManagementClient({
  // Need to be replaced with your GenAuth Access Key ID
  accessKeyId: "GEN_AUTH_ACCESS_KEY_ID",
  // Need to be replaced with your GenAuth Access Key Secret
  accessKeySecret: "GEN_AUTH_ACCESS_KEY_SECRET",
  // If it is a private deployment customer, you need to set the GenAuth service domain name
  // host: 'https://api.your-authing-service.com'
});

(async () => {
  const result = await managementClient.listRoles({
    keywords: "admin",
    namespace: "default",
    page: 1,
    limit: 10,
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: RolePaginatedRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegmented error code, which can be used to get the specific error type (successful request does not return). For a detailed list of error codes, see: API Code List
requestIdstringRequest ID. Returned when the request fails.
data<a RolePagingDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "list": {
      "id": "60b49eb83fd80adb96f26e68",
      "code": "role1",
      "name": "role1",
      "description": "this is role description",
      "namespace": "default",
      "namespaceName": "Sample permission name",
      "status": "ENABLE",
      "disableTime": "1669881887852"
    }
  }
}

Data structure

RolePagingDto

NameTypeIs it required?DescriptionSample value
totalCountnumberYesTotal number of records
listarrayYesResponse data Nested type: <a RoleDto.

RoleDto

NameTypeIs it required?DescriptionSample value
idstringYesRole ID60b49eb83fd80adb96f26e68
codestringYesUnique identifier of the role in the permission group (permission space) Coderole1
namestringYesRole name in the permission group (permission space)role1
descriptionstringYesRole descriptionthis is role description
namespacestringYesThe name of the permission group (permission space) to which it belongs Code, if not passed, the default permission group is obtained.default
namespaceNamestringyesThe name of the permission group (permission space)Sample permission name
statusstringnoRole status, ENABLE- means normal, DISABLE- means disabledENABLE
disableTimenumbernoRole automatic disable time, in milliseconds, if null is passed, it means permanent1669881887852

Agent infrastructure for identity, memory, and web action.