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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface parameters |
Param Field Description
Field | Required | Type | Description |
---|---|---|---|
ServiceId | Yes | String | Service ID. The value of this field is the Environment ID. |
Path | Required | String | Custom path |
Type | Required | Number | service type, Cloud Function defaults to 1 |
Name | Yes | String | Function name |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request unique identifier |
APIId | Yes | String | APIId |
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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface 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 the ServiceId or Domain fields must be set!
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request unique identifier |
APISet | Yes | Array<CloudBaseGWAPI> | HTTP service list |
CloudBaseGWAPI
Field | Required | Type | Description |
---|---|---|---|
ServiceId | Yes | String | Environment ID |
APIId | Yes | String | APIId |
Path | Required | String | Custom path |
Type | Required | Number | service type, Cloud Function defaults to 1 |
Name | Required | String | Cloud function name |
CreateTime | Required | Number | service creation time |
EnvId | Yes | 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", // 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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface 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. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request unique identifier |
Count | Yes | 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", // 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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface parameters |
Param Field Description
Field | Required | Type | Description |
---|---|---|---|
ServiceId | Yes | String | Service ID. The value of this field is the Environment ID. |
Domain | Required | String | Bound domain |
CertId | No | String | Certificate ID |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request 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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface 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 the ServiceId or Domain fields must be set!
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Yes | String | Request unique identifier |
ServiceSet | Yes | Array<CloudBaseGWService> | HTTP Service domain information |
CloudBaseGWService
Field | Required | Type | Description |
---|---|---|---|
ServiceId | Yes | String | Request unique identifier |
Domain | Yes | String | HTTP Service domain information |
OpenTime | Yes | Number | service activation time |
Status | Yes | Number | Binding 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
Field | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Interface name |
Param | Yes | Object | Interface parameters |
Param Field Description
Field | Required | Type | Description |
---|---|---|---|
ServiceId | Yes | String | Service ID. The value of this field is the Environment ID. |
Domain | Required | String | Bound domain |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request unique identifier |
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", // 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();