Environment Management
listEnvs
1. Interface Description
Function: Get All Environment Information
Interface declaration: listEnvs(): Promise<Object>
2. Input Parameters
None
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request unique identifier |
EnvList | Yes | Array<EnvItem> | Environment array |
EnvItem
Field | Required | Type | Description |
---|---|---|---|
EnvId | Yes | String | Environment ID |
Source | Yes | String | Source |
Alias | Yes | String | Environment alias |
Status | Yes | String | Environment status |
CreateTime | Yes | String | Creation time |
UpdateTime | Yes | String | Update time |
PackageId | Yes | String | Environment package ID |
PackageName | Yes | String | Package name |
Databases | Yes | Array | Database resource details |
Storages | Yes | Array | Storage resource details |
Functions | Yes | Array | Function resource details |
LogServices | Yes | Array | Log resource details |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.listEnvs()
const { EnvList } = res
for (let env in EnvList) {
// Traverse envList
console.log(env)
}
}
test()
getEnvAuthDomains
1. Interface Description
Function: List valid domains
Interface declaration: getEnvAuthDomains(): Promise<Object>
2. Input Parameters
None
3. Response
Field | Required | Type | Description |
---|---|---|---|
Domains | Required | Array<Domain> | Domain list |
envId | Yes | String | Environment ID |
Domain
Field | Required | Type | Description |
---|---|---|---|
Id | Required | String | Domain ID |
Domain | Required | String | Domain name |
Type | Required | String | Domain type. Valid values: system, user |
Status | Required | String | Status. Valid values: ENABLE, DISABLE |
CreateTime | Required | String | Creation time |
UpdateTime | Required | String | Update time |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.getEnvAuthDomains()
const { Domains } = res
for (let domain in Domains) {
console.log(domain)
}
}
test()
createEnvDomain
1. Interface Description
Function: Add environment security domain
Interface declaration: createEnvDomain(domains: string[]): Promise<Object>
2. Input Parameters
Field | Required | Type | Description |
---|---|---|---|
domains | Required | Array<String> | Security domain array |
3. Response
Field | Type | Description |
---|---|---|
RequestId | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.createEnvDomain(['luke.com'])
console.log(res)
}
test()
deleteEnvDomain
1. Interface Description
Function: Delete environment security domain
Interface declaration: deleteEnvDomain(domains: string[]): Promise<Object>
2. Input Parameters
Field | Required | Type | Description |
---|---|---|---|
domains | Required | Array<String> | Security domain array |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request ID |
Deleted | Required | Number | Number of successfully deleted domains |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.deleteEnvDomain(['luke.com'])
const { Deleted } = res
console.log(Deleted) // Number of domains deleted
}
test()
getEnvInfo
1. Interface Description
Function: Get Environment Information
Interface declaration: getEnvInfo(): Promise<Object>
2. Input Parameters
None
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request ID |
EnvInfo | Yes | EnvItem | Environment information |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.getEnvInfo()
const { EnvInfo } = res
console.log(EnvInfo)
}
test()
updateEnvInfo
1. Interface Description
Function: Modify Environment Alias
Interface declaration: updateEnvInfo(alias: string): Promise<Object>
2. Input Parameters
Field | Required | Type | Description |
---|---|---|---|
alias | Yes | String | Environment alias |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.updateEnvInfo('lukemodify')
console.log(res)
}
test()
getLoginConfigList
1. Interface Description
Function: Pull login configuration list
Interface declaration: getLoginConfigList(): Promise<Object>
2. Input Parameters
None
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request ID |
ConfigList | Yes | Array<ConfigItem> | Login configuration list |
ConfigItem
Field | Required | Type | Description |
---|---|---|---|
Id | Required | String | Configuration ID |
Platform | Required | String | Platform type |
PlatformId | Required | String | Platform ID |
Status | Required | String | Configuration status |
UpdateTime | Required | String | Configuration update time |
CreateTime | Required | String | Configuration creation time |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.getLoginConfigList()
const { ConfigList } = res
for (let config in ConfigList) {
console.log(config)
}
}
test()
createLoginConfig
1. Interface Description
Function: Create login method
Interface declaration: createLoginConfig(platform, appId, appSecret): Promise<Object>
2. Input Parameters
Field | Required | Type | Description |
---|---|---|---|
platform | Required | String | Platform "WECHAT-OPEN" "WECHAT-PUBLIC" "QQ" "ANONYMOUS" |
appId | Required | String | AppID of the third-party platform. Note: For anonymous login (platform:ANONYMOUS), set appId to 'anonymous' |
appSecret | Optional | String | AppSecret of the third-party platform. Note: For anonymous login (platform:ANONYMOUS), appSecret can be omitted |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
await env.createLoginConfig('WECHAT-OPEN', 'appId', 'appSecret')
}
test()
updateLoginConfig
1. Interface Description
Function: Update login method configuration
Interface declaration: updateLoginConfig(configId, status, appId, appSecret): Promise<Object>
2. Input Parameters
Field | Required | Type | Description |
---|---|---|---|
configId | Required | String | Configuration record ID |
status | Required | String | "ENABLE", "DISABLE" |
appId | Required | String | AppId of the third-party platform; for anonymous login, set appId to 'anonymous' |
appSecret | Optional | String | AppSecret of the third-party platform; can be omitted for anonymous login |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request ID |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const loginConfigRes = await env.getLoginConfigList()
await env.updateLoginConfig(
loginConfigRes.ConfigList[0].Id,
'ENABLE',
'appId',
'appSecret'
)
}
test()
createCustomLoginKeys
1. Interface Description
Function: Create custom login key
Interface declaration: createCustomLoginKeys(): Promise<Object>
2. Input Parameters
None
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request ID |
KeyID | Required | String | Key ID |
PrivateKey | Required | String | Private key |
4. Sample Code
import CloudBase from '@cloudbase/manager-node'
const { env } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // CloudBase environment ID, obtain from the Tencent CloudBase Console
})
async function test() {
const res = await env.createCustomLoginKeys()
const { KeyID, PrivateKey } = res
console.log(KeyID, PrivateKey)
}
test()