Skip to main content

HTTP Access Service

HTTP Access Service enables developers to access their own cloud development resources via HTTP.

Starting from version 3.4.0+, a new access service interface has been added. You can use the new interface. The original SDK can be migrated to the new interface, or continue using the old interface.

tip

All the following interfaces were added in version 3.4.0+.

Create HTTP Access Service

1. Interface Description

Function: Create HTTP Access Service.

Interface declaration: async createAccess(options: ICreateAccessOptions): Promise<ICreateRes>

2. Input Parameters

FieldRequiredTypeDescription
pathYesStringAccess path must start with /
nameYesStringBound service name
typeYesNumberBound service type: Cloud Function: 1, Serverless Cloud Application: 2
authNoBooleanWhether to enable authentication for the path corresponding to the HTTP access service

3. Response

FieldRequiredTypeDescription
RequestIdYesStringRequest unique identifier
APIIdYesStringHTTP access service Id

4. Sample Code

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

const app = 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 app.access.createAccess({
path: "/sum",
type: 1,
name: "sum",
});
const { APIId } = res;
console.log(APIId);
}

test();

Get HTTP Access Service

1. Interface Description

Function: Get HTTP Access Service

Interface declaration: async getAccessList(options: IGetOptions): Promise<IGetRes>

2. Input Parameters

FieldRequiredTypeDescription
pathNoStringAccess path must start with /
nameNoStringBound service name
offsetNoNumberOffset for querying the List
limitNoNumberNumber of records returned per query

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier
APISetArray<CloudBaseGWAPI>HTTP access service list
TotalNumberTotal number of HTTP access services
EnableServiceBooleanWhether the HTTP access service is enabled

CloudBaseGWAPI

FieldTypeDescription
APIIdStringAPIId
PathStringCustom path
TypeNumberservice type, Cloud Function defaults to 1
NameStringCloud function name
CreateTimeNumberservice creation time
EnvIdStringEnvironment ID
EnableAuthBooleanWhether authentication is enabled for the path corresponding to the HTTP access service

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 app.access.getAccessList();
console.log(res);
}

test();

Delete HTTP Access Service

1. Interface Description

Function: Delete Bound HTTP Access Service

Interface declaration: async deleteAccess(options: IDeleteOptions): Promise<IDeleteRes>

2. Input Parameters

FieldRequiredTypeDescription
nameNoStringBound service name
typeNoStringBound service type, Cloud Function: 1, Serverless Cloud Application: 2
apiIdNoStringHTTP access service Id
pathNoStringHTTP access service access path

The deleteAccess` interface supports three deletion conditions:

  • Delete by bound service name, i.e., using the name and type options, which will delete all access paths bound to this service
  • Delete by service Id, i.e., the apiId option
  • By access path, i.e., the path option

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() {
const res = await app.access.deleteAccess({
name: "sum",
});
}

test();

Switch HTTP Access Service Authentication

1. Interface Description

Function: Switch HTTP Access Service Authentication, Globally Effective

Interface declaration: async switchAuth(auth: boolean): Promise<IUpdateRes>

2. Input Parameters

FieldRequiredTypeDescription
authYesBooleanWhether to enable HTTP access service authentication, true enables, false disables

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() {
const res = await app.access.switchAuth(false);
console.log("Switch Authentication", res);
}

test();

Switch HTTP Access Service Path Authentication

1. Interface Description

Function: Switch HTTP Access Service Path Authentication, Only Takes Effect on a Single Path

Interface declaration: async switchPathAuth(options: IUpdateOptions)

2. Input Parameters

FieldRequiredTypeDescription
apiIdsYesArray<String>HTTP access service Id list
authYesBooleanWhether to enable service authentication, true enables, false disables

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() {
const res = await app.access.switchPathAuth({
apiIds: ["xxxxx"],
auth: false,
});
}

test();

Adding a Custom Domain to HTTP Access Service

1. Interface Description

Function: Add a custom domain

Interface declaration: async addCustomDomain(options: IDomainOptions): Promise<IAddRes>

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

2. Input Parameters

FieldRequiredTypeDescription
domainYesStringCustom domain
certIdNoStringTencent Cloud SSL certificate Id. The SSL certificate must be under the calling account.

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() {
const res = await app.access.addCustomDomain({
domain: "xxx",
certId: "xxx",
});
}

test();

List Custom Domains for HTTP Access Service

1. Interface Description

Function: List custom domains

Interface declaration: async getDomainList(): Promise<IDomainRes>

2. Input Parameters

None

3. Response

FieldTypeDescription
RequestIdStringRequest unique identifier
DefaultDomainStringDefault domain for HTTP access service
EnableServiceBooleanWhether the HTTP access service is enabled
ServiceSetArray<IService>HTTP access service domain list

IService

FieldTypeDescription
DomainStringDomain name
OpenTimeNumberActivation time
StatusNumberBinding status: 1 (Binding in progress), 2 (Binding failed), 3 (Binding succeeded)

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 app.access.getDomainList();
}

test();

Deleting a Custom Domain for HTTP Access Service

1. Interface Description

Function: Delete a custom domain

Interface declaration: async deleteCustomDomain(domain: string): Promise<IDeleteRes>

2. Input Parameters

FieldRequiredTypeDescription
domainYesStringCustom domain

3. Response

FieldTypeDescription
RequestIdStringRequest 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() {
const res = await app.access.deleteCustomDomain("xxxx");
}

test();