Skip to main content

HTTP Service

HTTP Service is an HTTP access service provided by Cloud Development for developers, enabling them to access their own cloud development resources via HTTP.

The interfaces of HTTP Service can be called via commonService .

Creating a Cloud Function HTTPService

1. Interface Description

Function: Create Cloud Function HTTPService

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the Environment ID.
PathRequiredStringCustom path
TypeRequiredNumberservice type, Cloud Function defaults to 1
NameYesStringFunction name

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier
APIIdYesStringAPIId

4. Sample Code

import CloudBase from "@cloudbase/manager-node";

const manager = 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 manager.commonService().call({
Action: "CreateCloudBaseGWAPI",
Param: { ServiceId: envId, Path: "/sum", Type: 1, Name: "sum" },
});
const { APIId } = res;
console.log(APIId);
}

test();

Querying Cloud Function HTTP Service

1. Interface Description

Function: Query Cloud Function HTTP Service

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface 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 the ServiceId or Domain fields must be set!

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier
APISetYesArray<CloudBaseGWAPI>HTTP service list

CloudBaseGWAPI

FieldRequiredTypeDescription
ServiceIdYesStringEnvironment ID
APIIdYesStringAPIId
PathRequiredStringCustom path
TypeRequiredNumberservice type, Cloud Function defaults to 1
NameRequiredStringCloud function name
CreateTimeRequiredNumberservice creation time
EnvIdYesStringEnvironment ID

4. Sample Code

import CloudBase from "@cloudbase/manager-node";

const manager = 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 manager.commonService().call({
Action: "DescribeCloudBaseGWAPI",
Param: {
ServiceId: envId,
Path: "/sum",
},
});
const { APISet } = res;
for (let api in APISet) {
console.log(api);
}
}

test();

Delete Cloud Function HTTP Service

1. Interface Description

Function: Delete Cloud Function HTTP Service

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface parameters

Param Field Description

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

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier
CountYesNumberNumber 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", // CloudBase environment ID, obtain from the Tencent CloudBase Console
});

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

test();

Bind Custom Domain to HTTP Service

1. Interface Description

Function: Bind custom domain to HTTP Service

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

When binding a custom domain, be sure to configure CNAME resolution with your domain name provider

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the Environment ID.
DomainRequiredStringBound domain
CertIdNoStringCertificate ID

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier

4. Sample Code

import CloudBase from "@cloudbase/manager-node";

const manager = new CloudBase({
secretId: "Your SecretId",
secretKey: "Your SecretKey",
envId: "Your envId", // CloudBase environment ID, obtain from the Tencent CloudBase Console
});

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

test();

Querying HTTP Service Domain

1. Interface Description

Function: Querying HTTP Service Domain

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface parameters

Param Field Description

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

At least one of the ServiceId or Domain fields must be set!

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier
ServiceSetYesArray<CloudBaseGWService>HTTP Service domain information

CloudBaseGWService

FieldRequiredTypeDescription
ServiceIdYesStringRequest unique identifier
DomainYesStringHTTP Service domain information
OpenTimeYesNumberservice activation time
StatusYesNumberBinding status: 1 (Binding in progress), 2 (Binding failed), 3 (Binding succeeded)
Note: This field may return null, indicating that no valid values 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", // CloudBase environment ID, obtain from the Tencent CloudBase Console
});

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

Unbind Domain from HTTP Service

1. Interface Description

Function: Unbind Domain from HTTP Service

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

⚠️ Starting from version 3.0.0, commonService is used as a method with request parameters (service?: string, version?: string), which constitutes a breaking change.

2. Input Parameters

FieldRequiredTypeDescription
ActionYesStringInterface name
ParamYesObjectInterface parameters

Param Field Description

FieldRequiredTypeDescription
ServiceIdYesStringService ID. The value of this field is the Environment ID.
DomainRequiredStringBound domain

3. Response

FieldRequiredTypeDescription
RequestIdRequiredStringRequest unique identifier
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", // CloudBase environment ID, obtain from the Tencent CloudBase Console
});

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

test();