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
Field | Required | Type | Description |
---|---|---|---|
EnvId | Yes | String | Environment ID |
AppName | Yes | String | Application Identifier |
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: "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
Field | Required | Type | Description |
---|---|---|---|
EnvId | Yes | String | Environment ID |
Offset | Yes | Number | Offset |
Limit | Yes | Number | Maximum number |
3. Response
Field | Required | Type | Description |
---|---|---|---|
TotalCount | Yes | Number | Total |
Data | Yes | Array<SafetySourceItem> | Security source list |
RequestId | Yes | String | Request unique identifier |
SafetySourceItem Field Description
Field | Required | Type | Description |
---|---|---|---|
Id | Required | String | Record ID |
AppName | Yes | String | Application Identifier |
AppSecretVersion | Required | String | Secret Version |
CreateTime | Required | String | Creation 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
Field | Required | Type | Description |
---|---|---|---|
EnvId | Required | String | Environment ID |
ItemId | Required | Object | Record ID, visible in the response data of the list interface |
3. Response
Field | Required | Type | Description |
---|---|---|---|
RequestId | Required | String | Request unique identifier |
AppSecretKey | Required | String | Credential |
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
Field | Required | Type | Description |
---|---|---|---|
EnvId | Required | String | Environment ID |
ItemId | Required | Object | Record ID, visible in the response data of the list interface |
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() {
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();