Skip to main content

User Management

Get User List

1. Interface Description

Function: Get the user list in the specified cloud environment.

Interface declaration: getEndUserList(options: Object): Promise<Object>

2. Input Parameters

FieldRequiredTypeDescription
limitYesNumberNumber of users to fetch
offsetYesNumberOffset

3. Response

FieldTypeDescription
TotalNumberTotal users
RequestIdStringRequest unique identifier
UsersArray<EndUserInfo>User information list

EndUserInfo

FieldTypeDescription
UUIdStringUser unique ID
WXOpenIdStringWeChat ID
QQOpenIdStringqq ID
PhoneStringPhone number
EmailStringEmail
NickNameStringNickname
GenderStringGender
AvatarUrlStringAvatar URL
UpdateTimeStringUpdate time
CreateTimeStringCreation time
IsAnonymousBooleanWhether the user is anonymous
IsDisabledBooleanWhether to disable the account
HasPasswordBooleanWhether the password has been set
UserNameStringUsername

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};
const app = new CloudBase(cloudBaseConfig);

async function main() {
const { Users } = await app.user.getEndUserList({
limit: 20,
offset: 0,
});

console.log(">>> Users are:", Users);
}

main();

Create New User

1. Interface Description

Function: Create username and password in the specified cloud environment.

Interface declaration: createEndUser(options: Object): Promise<Object>

2. Input Parameters

FieldRequiredTypeDescription
usernameRequiredStringUsername
passwordRequiredStringPassword
Password Strength Requirements

Password length should be not less than 8 and not greater than 32, and should contain both letters and numbers.

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier
UserEndUserInfoUser information

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};
const app = new CloudBase(cloudBaseConfig);

async function main() {
try {
const { User } = await app.user.createEndUser({
username: "your username",
password: "your password",
});

console.log(">>> New user information:", User);
} catch (error) {
console.log(">>> Failed to create user:", error.message);
}
}

main();

Update User Account Information

1. Interface Description

Function: Update the information of a specific user in the specified cloud environment.

Interface declaration: modifyEndUser(options: Object): Promise<Object>

2. Input Parameters

FieldRequiredTypeDescription
uuidRequiredStringCloudBase user unique identifier
usernameNoStringNew username
passwordNoStringNew password

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};
const app = new CloudBase(cloudBaseConfig);

async function main() {
try {
await app.user.modifyEndUser({
uuid: "your user uuid",
username: "your new username",
password: "your new password",
});

console.log(">>> User account information modified successfully");
} catch (error) {
console.log(
">>> Failed to modify user account information:",
error.message
);
}
}

main();

Update User Information

1. Interface Description

Function: Update the information of a specific user in the specified cloud environment.

Interface declaration: updateEndUser(options: Object): Promise<Object>

2. Input Parameters

FieldRequiredTypeDescription
uuidRequiredStringCloudBase user unique identifier
nickNameRequiredStringNew nickname
genderRequiredStringNew gender, `MALEFEMALE`
avatarUrlRequiredStringNew avatar
countryRequiredStringNew country
provinceRequiredStringNew province
cityRequiredStringNew city

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};
const app = new CloudBase(cloudBaseConfig);

async function main() {
try {
await app.user.updateEndUser({
uuid: "your user uuid",
nickName: "your new nickName",
gender: "your new gender",
avatarUrl: "your new avatarUrl",
country: "your new country",
province: "your new province",
city: "your new city",
});

console.log(">>> User information modified successfully");
} catch (error) {
console.log(">>> Failed to modify user information:", error.message);
}
}

main();

Set User Status

1. Interface Description

Function: Disable or enable a specific user in the cloud environment.

Interface declaration: setEndUserStatus(options: object): Promise<object>

2. Input Parameters

FieldRequiredTypeDescription
uuidRequiredStringCloudBase user unique identifier
statusRequiredString'DISABLE' or 'ENABLE'

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};
const app = new CloudBase(cloudBaseConfig);

async function main() {
try {
const { RequestId } = await app.user.setEndUserStatus({
uuid: "User uuid",
status: "DISABLE",
});
console.log(">>> Disabled successfully");
} catch (error) {
console.log(">>> Failed to disable", error.message);
}
}

main();

Batch Delete Users

1. Interface Description

Function: Batch delete users in a specified cloud environment

Interface declaration: deleteEndUsers(options: Object): Promise<Object>

2. Input Parameters

FieldRequiredTypeDescription
userListRequiredArray<String>List of user UUIDs

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier

4. Sample Code

const cloudbaseConfig = {
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
};

const app = new CloudBase(cloudBaseConfig);

async function main() {
try {
const { RequestId } = await app.user.deleteEndUsers({
userList: [
"uuid a",
"uuid b",
"uuid c",
// ......
],
});
console.log(">>> Batch deletion succeeded");
} catch (error) {
console.log(">>> Batch deletion failed", error.message);
}
}

main();