# Manage Groups

This module is used to manage Authing groups, and can perform operations such as group addition, deletion, modification, group addition/deleting users, group addition/deletion strategies, etc.

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.groups.list // Get group list
managementClient.groups.create // Create group
managementClient.groups.listUsers // Get the list of grouped users

# Create group

GroupsManagementClient().create(code, name, description)

Create group

# Parameters

  • code <string> group unique identifier
  • name <string> group name
  • description <string> description

# Example

managementClient.groups.create('group','group xxx')

# return value

  • Promise<DeepPartial<Group>>

# Delete group

GroupsManagementClient().delete(code)

Delete group

# Parameters

  • code <string> group unique identifier

# Example

managementClient.groups.delete('rolea')

# return value

  • Promise<CommonMessage>

# Modify group

GroupsManagementClient().update(code, input)

Modify group

# Parameters

  • code <string> group unique identifier
  • input <Object>
  • input.name <string> new name
  • input.description <string> new description information
  • input.newCode <string> New unique identifier

# Example

managementClient.groups.update('group', {newCode:'newcode'})

# return value

  • Promise<DeepPartial<Group>>

# Get group details

GroupsManagementClient().detail(code)

Get group details

# Parameters

  • code <string> group unique identifier

# Example

managementClient.groups.detail('manager')

# return value

  • Promise<DeepPartial<Group>> group details

# Get group list

GroupsManagementClient().list(page, limit)

Get group list

# Parameters

  • page <number> Page number The default value is: 1.
  • limit <number> Number per page The default value is 10.

# Example

managementClient.groups.list(1, 10)

# return value

  • Promise<DeepPartial<PaginatedGroups>>

# Batch delete groups

GroupsManagementClient().deleteMany(codeList)

Batch delete groups

# Parameters

  • codeList <string[]> group unique identifier list

# Example

managementClient.groups.deleteMany(['groupa','groupb'])

# return value

  • Promise<CommonMessage>

# Get the list of grouped users

GroupsManagementClient().listUsers(code, page, limit)

Get grouped user list

# Parameters

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

# Example

managementClient.groups.listUsers(code)

# return value

  • Promise<DeepPartial<PaginatedUsers>>

# Add user

GroupsManagementClient().addUsers(code, userIds)

Add user

# Parameters

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

# Example

managementClient.groups.addUsers(code, ['USERID1','USERID2'])

# return value

  • Promise<CommonMessage>

# Remove user

GroupsManagementClient().removeUsers(code, userIds)

Remove user

# Parameters

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

# Example

managementClient.groups.removeUsers(code, ['USERID1','USERID2'])

# return value

  • Promise<CommonMessage>