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
Field | Required | Type | Description |
---|---|---|---|
limit | Yes | Number | Number of users to fetch |
offset | Yes | Number | Offset |
3. Response
Field | Type | Description |
---|---|---|
Total | Number | Total users |
RequestId | String | Request unique identifier |
Users | Array<EndUserInfo> | User information list |
EndUserInfo
Field | Type | Description |
---|---|---|
UUId | String | User unique ID |
WXOpenId | String | WeChat ID |
QQOpenId | String | qq ID |
Phone | String | Phone number |
String | ||
NickName | String | Nickname |
Gender | String | Gender |
AvatarUrl | String | Avatar URL |
UpdateTime | String | Update time |
CreateTime | String | Creation time |
IsAnonymous | Boolean | Whether the user is anonymous |
IsDisabled | Boolean | Whether to disable the account |
HasPassword | Boolean | Whether the password has been set |
UserName | String | Username |
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
Field | Required | Type | Description |
---|---|---|---|
username | Required | String | Username |
password | Required | String | Password |
Password length should be not less than 8 and not greater than 32, and should contain both letters and numbers.
3. Response
Field | Type | Description |
---|---|---|
RequestId | String | Request unique identifier |
User | EndUserInfo | User 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
Field | Required | Type | Description |
---|---|---|---|
uuid | Required | String | CloudBase user unique identifier |
username | No | String | New username |
password | No | String | New password |
3. Response
Field | Type | Description |
---|---|---|
RequestId | String | Request 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
Field | Required | Type | Description | |
---|---|---|---|---|
uuid | Required | String | CloudBase user unique identifier | |
nickName | Required | String | New nickname | |
gender | Required | String | New gender, `MALE | FEMALE` |
avatarUrl | Required | String | New avatar | |
country | Required | String | New country | |
province | Required | String | New province | |
city | Required | String | New city |
3. Response
Field | Type | Description |
---|---|---|
RequestId | String | Request 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
Field | Required | Type | Description |
---|---|---|---|
uuid | Required | String | CloudBase user unique identifier |
status | Required | String | 'DISABLE' or 'ENABLE' |
3. Response
Field | Type | Description |
---|---|---|
RequestId | String | Request 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
Field | Required | Type | Description |
---|---|---|---|
userList | Required | Array<String> | List of user UUIDs |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request 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();