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()
createBillingDeal
1. Interface Description
Function: Create environment billing order
Interface declaration: createBillingDeal(params: CreateBillingDealParams): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| DealType | Yes | String | Order operation type. Valid values: purchase, renew, modify |
| ProductType | Yes | String | Product type to purchase. Valid values: tcb-baas (BaaS plan), tcb-promotion (promotion package), tcb-package (resource package) |
| PackageId | Yes | String | Target product/plan ID |
| CreateAndPay | No | Boolean | Whether to auto-pay |
| TimeSpan | No | Number | Purchase duration |
| TimeUnit | No | String | Purchase duration unit. Valid values: d (day), m (month), y (year), p (one-time) |
| ResourceId | No | String | Unique resource identifier |
| Source | No | String | Source. Valid values: qcloud, miniapp |
| Alias | No | String | Resource alias |
| EnvId | No | String | Environment ID |
| EnableExcess | No | Boolean | Enable pay-as-you-go billing when exceeding quota |
| ModifyPackageId | No | String | Target product/plan ID for modification |
| Extension | No | String | Additional information (JSON string) |
| AutoVoucher | No | Boolean | Whether to automatically use vouchers for payment |
| ResourceTypes | No | String[] | Resource types to provision when creating a new environment. Valid values: flexdb, cos, cdn, scf |
3. Response
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Yes | String | Request ID |
| EnvId | Yes | String | Environment ID |
| TranId | Yes | String | Order transaction 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.createBillingDeal({
DealType: 'purchase',
ProductType: 'tcb-baas',
PackageId: 'baas_personal',
CreateAndPay: false,
TimeSpan: 1,
TimeUnit: 'm',
Alias: 'test',
EnvId: 'test-12345'
})
console.log(res.TranId) // Order transaction ID
}
test()
cancelDeal
1. Interface Description
Function: Cancel an unpaid order
Interface declaration: cancelDeal(params: Object): Promise<Object>
2. Input Parameters
| Field | Required | Type | Description |
|---|---|---|---|
| TranId | Yes | String | Order transaction ID |
| UserClientIp | Yes | String | User client IP |
| WxAppId | No | String | WeChat AppId (optional) |
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() {
// Create an order first
const dealRes = await env.createBillingDeal({
DealType: 'purchase',
ProductType: 'tcb-baas',
PackageId: 'baas_personal',
CreateAndPay: false,
TimeSpan: 1,
TimeUnit: 'm',
Alias: 'test',
EnvId: 'test-12345'
})
// Cancel the order
const res = await env.cancelDeal({
TranId: dealRes.TranId,
UserClientIp: '127.0.0.1'
})
console.log(res)
}
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()