Updated on 2025-03-25 GMT+08:00

Creating a Policy

Function

This API is used to create a policy.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{cloudProjectId}/rule-sets/create

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

cloudProjectId

Yes

String

Project ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Policy name.

cloud_project_id

Yes

String

Project ID.

rules

Yes

Array of rules objects

Rule.

Table 3 rules

Parameter

Mandatory

Type

Description

id

Yes

String

Rule ID.

is_valid

Yes

Boolean

Enable or not.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

status

Boolean

Status.

rule_set_id

String

Policy ID.

Example Requests

POST https://{endpoint}/v2/2d09f712e9504b61b034cc8f40e475a8/rule-sets/create

{
  "name" : "New policy-20240625200400",
  "cloud_project_id" : "2d09f712e9504b61b034cc8f40e475a8",
  "rules" : [ {
    "id" : "597c7f2f775740a1bb522b03a16e6864",
    "is_valid" : true
  } ]
}

Example Responses

Status code: 200

Response body for creating a policy.

{
  "status" : true,
  "rule_set_id" : "e42be82e7d514437a322dce4d42bdec8"
}

Status Codes

Status Code

Description

200

Response body for creating a policy.

Error Codes

See Error Codes.