User

Updated at:

Note

A User has a unique ID within a Domain. An Account is the logon credential for a User. A single User can have multiple logon accounts, such as a mobile phone number or an email address.

Note

The system has three built-in roles: user, admin, and superadmin.

The Admin permission mentioned in this document requires a caller token with the admin or superadmin role.

createUser method

Important

Admin permission is required.

Creates a user.

This method only creates a user. To use the logon methods provided by PDS, you also need to call the LinkAccount - Attach an account API.

If the user is integrated using JSON Web Token (JWT), you do not need to call linkAccount.

const result = await client.createUser(params, options)

Example

const userInfo = await client.createUser({
  user_id: 'id_123',
  phone: '135****8888',
  email:'username@aliyundoc.com',
  nick_name: 'Nickname',
  user_name: 'Username',
  role: 'user'
})

Parameters

Parameter

Type

Required

Description

params

ICreateUserReq

Yes

The parameters to create a user.

options

AxiosRequestConfig

Other configuration items.

ICreateUserReq

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

role

string

The role of the user. Valid values: "user", "admin", and "superadmin". Default value: "user". If the current domain supports subdomains, "subdomain_super_admin" and "subdomain_admin" are also supported.

user_name

string

The username.

nick_name

string

The nickname.

description

string

Note

email

string

The email address.

phone

string

Mobile phone

status

string

The status. Valid values: disabled, enabled.

avatar

string

The profile picture information. It must start with http:// or be a base64 data URI.

Returns

Parameter

Type

Required

Description

result

IUserItem

Yes

The result.

IUserItem

Name

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address.

role

string

The user role.

description

string

The description.

phone

string

Mobile phone

nick_name

string

The nickname.

user_name

string

The username.

status

string

The status. Valid values: enabled, disabled.

avatar

string

The profile picture.

created_at

long

The time when the user was created.

updated_at

long

The time when the user was last modified.

default_drive_id

string

The default drive ID.

listUsers method

Important

Admin permission is required.

Lists users.

const result = await client.listUsers(params, options)

Example

const {items=[],next_marker} = await client.listUsers({
  limit: 100,
  marker: ''
})

Parameters

Parameter

Type

Required

Description

params

IListReq

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IListReq

Parameter

Type

Required

Description

marker

string

The start marker for the query.

limit

string

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

Returns

Parameter

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Parameter

Type

Required

Description

items

IUserItem[]

Yes

The list of users.

getUser method

Important

Users with Admin permission can query information about any user. Users with User permission can only query their own information.

Queries user information.

const result = await client.getUser(params, options)

Example

const userInfo = await client.getUser({
   user_id: 'id_123'
})

Parameters

Parameter

Type

Required

Description

params

Object

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

params

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

Returns

Parameter

Type

Required

Description

result

IUserItem

Yes

The result.

IUserItem

Name

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address.

role

string

The user role.

description

string

The description.

phone

string

Mobile phone

nick_name

string

The nickname.

user_name

string

The username.

status

string

The status. Valid values: enabled, disabled.

avatar

string

The profile picture.

created_at

long

The time when the user was created.

updated_at

long

The time when the user was last modified.

default_drive_id

string

The default drive ID.

generalGetUser method

Queries a single user.

const result = await client.generalGetUser(params, options)

Example

const userInfo = await client.generalGetUser({
  user_id: 'id_123',
  extra_return_info: ['drive', 'group']
})

Parameters

Parameter

Type

Required

Description

params

Object

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

params

Parameter

Type

Required

Description

user_id

string

Yes

The user ID. If you do not specify this parameter, the information of the currently logged-on user is queried.

extra_return_info

string[]

Only administrators can specify this parameter.

Optional enumeration: drive, group. This indicates whether to return the user's drive or group information.

If you include group in this field, the query speed will be significantly reduced. The value of limit cannot exceed 30.

Returns

Parameter

Type

Required

Description

result

IUserItem

Yes

The result.

IUserItem

Name

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address.

role

string

The user role.

description

string

The description.

phone

string

Mobile phone

nick_name

string

The nickname.

user_name

string

The username.

status

string

The status. Valid values: enabled, disabled.

avatar

string

The profile picture.

created_at

long

The time when the user was created.

updated_at

long

The time when the user was last modified.

default_drive_id

string

The default drive ID.

updateUser method

Important

Admin permission is required.

Modifies user information, such as the nickname and profile picture.

await client.updateUser(params, options)

Example

// Disable the user
await client.updateUser({  
  user_id: 'id_123',
  status : 'disabled'
})

Parameters

Parameter

Type

Required

Description

params

IUpdateUserReq

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IUpdateUserReq

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

role

string

The role of the user. Valid values: "user", "admin", and "superadmin". Default value: "user".

nick_name

string

The nickname.

description

string

Note

email

string

The email address.

phone

string

Mobile phone

status

string

The status. Valid values: disabled, enabled.

avatar

string

The profile picture information. It must start with http:// or be a base64 data URI.

Returns

Parameter

Type

Required

Description

result

IUserItem

Yes

The result.

deleteUser method

Important

Admin permission is required.

Deletes a user and their associated AccountLink.

await client.deleteUser(params, options)

Example

await client.deleteUser({
  user_id: 'id_123'
})

Parameters

Parameter

Type

Required

Description

params

Object

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

params

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

Returns

None

searchUsers method

Important

Admin permission is required.

Searches for users.

const result = await client.searchUsers(params, options)

Example

const {items=[]} = await client.searchUsers({  
  nick_name_for_fuzzy: 'test'
})

Parameters

Parameter

Type

Required

Description

params

ISearchUsersReq

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

ISearchUsersReq

Parameter

Type

Required

Description

nick_name

string

The nickname. This parameter supports prefix matching. Pinyin and first-letter Pinyin search for Chinese characters are not supported.

nick_name_for_fuzzy

string

Fuzzy search for the user nickname.

user_name

string

The username. This parameter supports prefix matching. Pinyin and first-letter Pinyin search for Chinese characters are not supported.

email

string

The email address. This parameter supports prefix matching.

phone

string

The phone number. This parameter supports prefix matching.

role

string

The role. This parameter supports exact matching.

status

string

Status, exact match

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker for the query.

Returns

Parameter

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Name

Type

Description

items

IUserItem[]

An array of users.

next_marker

string

The marker for the next page.

generalSearchUsers method

Searches for users.

const result = await client.generalSearchUsers(params, options)

Example

const {items=[], next_marker} = await client.generalSearchUsers({  
  nick_name_for_fuzzy: 'test',
  direct_parent_group_id: '123456',
  extra_return_info: ['drive', 'group'],
  limit: 30,
  marker: ''
})

Parameters

Parameter

Type

Required

Description

params

IUserGeneralSearchReq

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IUserGeneralSearchReq

Parameter

Type

Required

Description

nick_name

string

The nickname. This parameter supports prefix matching. Pinyin and first-letter Pinyin search for Chinese characters are not supported.

nick_name_for_fuzzy

string

Fuzzy search for the user nickname.

parent_group_id_list

string[]

Returns data for the specified group, including matching members in subgroups.

direct_parent_group_id

string

Returns data only for the specified group, not including subgroups.

extra_return_info

string[]

Only administrators can specify this parameter.

Optional enumeration: drive, group. This indicates whether to return the user's drive or group information.

If you include group in this field, the query speed will be significantly reduced. The value of limit cannot exceed 30.

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker for the query.

Returns

Parameter

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Name

Type

Description

items

IUserItem[]

An array of users.

next_marker

string

The marker for the next page.

listGroupUsers method

Lists the direct members of a group.

Regular users can also call this method.

const result = await client.listGroupUsers(params, options)

Example

const params = {
  group_id: "abc"
}
const {items=[], next_marker} = await client.listGroupUsers(params)

Parameters

Parameter

Type

Required

Description

params

IListGroupUserReq

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IListGroupUserReq

Parameter

Type

Required

Description

group_id

string

Queries the users and groups within a specific group.

member_type

string

The member type. Optional parameters: user, group. If you do not specify this parameter, both users and groups are returned by default.

extra_return_info

string[]

Optional values: group, drive.

Only administrators can specify this parameter. This indicates whether to return the user's drive or group information. If you include group in this field, the query speed will be significantly reduced. A single call cannot retrieve more than 30 records.

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker for the query.

Returns

Parameter

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Name

Type

Description

items

IGroupItem[] or

IUserItem[]

An array.

next_marker

string

The marker for the next page.

importUser method

Important

Admin permission is required.

Imports a user using a mobile phone number or an email address.

This method is equivalent to calling createAccountLink after a successful call to createUser.

const result = await client.importUser(params, options)

Example

Import a user by mobile phone number

await client.importUser({
  authentication_type: 'mobile',
  auto_create_drive: true,
  identity:'135****8888',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

Import a user by email address

await client.importUser({
  authentication_type: 'email',
  auto_create_drive: true,
  identity:'username@example.com',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

Parameters

Parameter

Type

Required

Description

params

IImportUserReq

Yes

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IImportUserReq

Parameter

Type

Required

Description

auto_create_drive

boolean

Automatically creates a disk.

drive_total_size

number

The size of the disk space.

authentication_type

string

Valid values: mobile, email, ldap, custom.

identity

string

Yes

The unique identity. If authentication_type is set to mobile, specify the mobile phone number. If it is set to email, specify the email address. If it is set to ldap, specify the ldap_dn. If it is set to custom, specify a custom unique ID.

plain_password

string

The user's password in plaintext.

deny_change_password_by_self

boolean

Prevents the user from changing their own password.

need_change_password_next_login

boolean

Specifies whether the user must change their password at the next logon.

parent_group_id

string

nick_name

string

The nickname.

Returns

Parameter

Type

Required

Description

result

IUserItem

Yes

The result.