Skip to main content

HTTP Service

Deprecated

This module has been deprecated since v5.0.0. Migrate to Custom Domains and Access Routing. The new API features more explicit semantics and supports comprehensive domain management and routing rule configuration.

HTTP Service is a service provided by TCB for developers, enabling them to access their TCB resources via HTTP.

The API for HTTP Service can be invoked via commonService.

Creating an SCF HTTPService

1. API Description

API feature: Creating an SCF HTTPService

API declaration: manager.commonService().call({ Action: 'CreateCloudBaseGWAPI', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the environment ID.
PathYesStringCustom path
TypeRequiredNumberservice type. The default value for SCF is 1
NameRequiredStringFunction name

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request
APIIdRequiredStringAPIId

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
const res = await manager.commonService().call({
Action: 'CreateCloudBaseGWAPI',
Param: { ServiceId: envId, Path: '/sum', Type: 1, Name: 'sum' }
})
const { APIId } = res
console.log(APIId)
}

test()

Querying the SCF HTTP Service

1. API Description

API feature: Query SCF HTTP Service

API declaration: manager.commonService().call({ Action: 'DescribeCloudBaseGWAPI', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdNoStringService ID. The value of this field is the environment ID.
DomainNoStringBound domain
PathNoStringCustom path
APIIdNoStringAPIId

At least one of ServiceId or Domain must be set!

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request
APISetRequiredArray<CloudBaseGWAPI>List of HTTP services

CloudBaseGWAPI

FieldRequiredTypeDescription
ServiceIdRequiredStringEnvironment ID
APIIdRequiredStringAPIId
PathRequiredStringCustom path
TypeRequiredNumberservice type. The default value for SCF is 1
NameRequiredStringSCF name
CreateTimeRequiredNumberservice creation time
EnvIdRequiredStringEnvironment ID

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
const res = await manager.commonService().call({
Action: 'DescribeCloudBaseGWAPI',
Param: {
ServiceId: envId,
Path: '/sum'
}
})
const { APISet } = res
for (let api in APISet) {
console.log(api)
}
}

test()

Delete SCF HTTP Service

1. API Description

API feature: Delete SCF HTTP Service

API declaration: manager.commonService().call({ Action: 'DeleteCloudBaseGWAPI', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the environment ID.
PathNoStringCustom path
APIIdNoStringAPIId

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request
CountRequiredNumberNumber of deleted HTTP Services

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
const res = await manager.commonService().call({
Action: 'DeleteCloudBaseGWAPI',
Param: {
ServiceId: envId,
Path: '/sum'
// APIId: apiId
}
})
console.log(res.Count)
}

test()

Binding a Custom Domain to HTTP Service

1. API Description

API feature: Bind custom domain to HTTP Service

API declaration: manager.commonService().call({ Action: 'BindCloudBaseGWDomain', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

When binding a custom domain, be sure to configure the CNAME record with your domain name service provider.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the environment ID.
DomainYesStringBound domain
CertIdNoStringCertificate ID

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
await manager.commonService().call({
Action: 'BindCloudBaseGWDomain',
Param: {
ServiceId: envId,
Domain: 'xxx.xxx.xxx'
}
})
}

test()

Querying HTTP Service Domain

1. API Description

API feature: Query HTTP Service domain

API declaration: manager.commonService().call({ Action: 'DescribeCloudBaseGWService', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdNoStringService ID. The value of this field is the environment ID.
DomainNoStringBound domain

At least one of ServiceId or Domain must be set!

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request.
ServiceSetRequiredArray<CloudBaseGWService>HTTP Service domain name information

CloudBaseGWService

FieldRequiredTypeDescription
ServiceIdRequiredStringUnique identifier of the request
DomainRequiredStringHTTP Service domain name information
OpenTimeRequiredNumberservice start time
StatusRequiredNumberBinding status: 1: Binding in progress; 2: Binding failed; 3: Binding succeeded
Note: This field may return null, indicating that no valid value can be obtained.

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
const res = await manager.commonService().call({
Action: 'DescribeCloudBaseGWService',
Param: {
ServiceId: envId
}
})
const { Domain } = res
console.log(Domain)
}
test()

Unbinding a Domain from HTTP Service

1. API Description

API feature: Unbinding a Domain from HTTP Service

API declaration: manager.commonService().call({ Action: 'DeleteCloudBaseGWDomain', Param: {}}): Promise<Object>

⚠️ Starting from version 3.0.0, commonService is used as a method in this API with request parameters (service?: string, version?: string), which is an incompatible change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringAPI name
ParamYesObjectAPI parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the environment ID.
DomainYesStringBound domain

3. Return Results

FieldRequiredTypeDescription
RequestIdRequiredStringUnique identifier of the request
CountRequiredNumberNumber of unbound HTTP Service domains

4. Sample Code

import CloudBase from '@cloudbase/manager-node'

const manager = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // TCB environment ID, which can be obtained from the Tencent Cloud TCB console
})

async function test() {
const res = await manager.commonService().call({
Action: 'DeleteCloudBaseGWDomain',
Param: {
ServiceId: envId,
Domain: 'xxx.xxx.xxx'
}
})
console.log(res.Count)
}

test()