Skip to main content

Security Source

The interfaces of Security Rules can be called via commonService .

Add Security Origin​

1. Interface Description​

Function: Add Security Origin

Interface declaration: manager.commonService().call({ Action: 'CreateSafetySource', 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
EnvIdYesStringEnvironment ID
AppNameYesStringApplication Identifier

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: "CreateSafetySource",
Param: { EnvId: "Your envId", AppName: "xxx" },
});
}

test();

Get Security Source List​

1. Interface Description​

Function: Get Security Source List

Interface declaration: manager.commonService().call({ Action: 'DescribeSafetySource', 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
EnvIdYesStringEnvironment ID
OffsetYesNumberOffset
LimitYesNumberMaximum number

3. Response​

FieldRequiredTypeDescription
TotalCountYesNumberTotal
DataYesArray<SafetySourceItem>Security source list
RequestIdYesStringRequest unique identifier

SafetySourceItem Field Description​

FieldRequiredTypeDescription
IdRequiredStringRecord ID
AppNameYesStringApplication Identifier
AppSecretVersionRequiredStringSecret Version
CreateTimeRequiredStringCreation time

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: "DescribeSafetySource",
Param: {
EnvId: "Your envId",
Offset: 0,
Limit: 20,
},
});
const { Data } = res;
for (let item in Data) {
console.log(item);
}
}

test();

View Secret Key of Security Source​

1. Interface Description​

Function: View Secret Key of Security Source

Interface declaration: manager.commonService().call({ Action: 'DescribeSafetySourceSecretKey', 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
EnvIdRequiredStringEnvironment ID
ItemIdRequiredObjectRecord ID, visible in the response data of the list interface

3. Response​

FieldRequiredTypeDescription
RequestIdRequiredStringRequest unique identifier
AppSecretKeyRequiredStringCredential

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: "DescribeSafetySource",
Param: { EnvId: envId, Offset: 0, Limit: 20 },
});

const res1 = await manager.commonService().call({
Action: "DescribeSafetySourceSecretKey",
Param: {
EnvId: envId,
ItemId: res.Data[0].Id,
// APIId: apiId
},
});
console.log(res1.AppSecretKey);
}

test();

Delete Security Source​

1. Interface Description​

Function: Delete Security Source

Interface declaration: manager.commonService().call({ Action: 'DeleteSafetySource', 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
EnvIdRequiredStringEnvironment ID
ItemIdRequiredObjectRecord ID, visible in the response data of the list interface

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 manager.commonService().call({
Action: "DescribeSafetySource",
Param: { EnvId: envId, Offset: 0, Limit: 20 },
});

// Delete the first security source
await commonService.call({
Action: "DeleteSafetySource",
Param: { EnvId: envId, ItemId: res.Data[0].Id },
});
}

test();