HTTP Service
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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Yes | String | Service ID. The value of this field is the environment ID. |
| Path | Yes | String | Custom path |
| Type | Required | Number | service type. The default value for SCF is 1 |
| Name | Required | String | Function name |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request |
| APIId | Required | String | APIId |
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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | No | String | Service ID. The value of this field is the environment ID. |
| Domain | No | String | Bound domain |
| Path | No | String | Custom path |
| APIId | No | String | APIId |
At least one of ServiceId or Domain must be set!
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request |
| APISet | Required | Array<CloudBaseGWAPI> | List of HTTP services |
CloudBaseGWAPI
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Required | String | Environment ID |
| APIId | Required | String | APIId |
| Path | Required | String | Custom path |
| Type | Required | Number | service type. The default value for SCF is 1 |
| Name | Required | String | SCF name |
| CreateTime | Required | Number | service creation time |
| EnvId | Required | String | Environment 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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Yes | String | Service ID. The value of this field is the environment ID. |
| Path | No | String | Custom path |
| APIId | No | String | APIId |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request |
| Count | Required | Number | Number 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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Yes | String | Service ID. The value of this field is the environment ID. |
| Domain | Yes | String | Bound domain |
| CertId | No | String | Certificate ID |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique 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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | No | String | Service ID. The value of this field is the environment ID. |
| Domain | No | String | Bound domain |
At least one of ServiceId or Domain must be set!
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request. |
| ServiceSet | Required | Array<CloudBaseGWService> | HTTP Service domain name information |
CloudBaseGWService
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Required | String | Unique identifier of the request |
| Domain | Required | String | HTTP Service domain name information |
| OpenTime | Required | Number | service start time |
| Status | Required | Number | Binding 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
| Field | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | API name |
| Param | Yes | Object | API parameters |
Param Field Description
| Field | Required | Type | Description |
|---|---|---|---|
| ServiceId | Yes | String | Service ID. The value of this field is the environment ID. |
| Domain | Yes | String | Bound domain |
3. Return Results
| Field | Required | Type | Description |
|---|---|---|---|
| RequestId | Required | String | Unique identifier of the request |
| Count | Required | Number | Number 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()