Updated on 2026-02-05 GMT+08:00

Querying the Policy View List

Function

This API is used to query the policy view list.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/workspaces/{workspace_id}/soc/policys/search

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID, which is used to specify the project that a resource belongs to. You can query the resources of a project by project ID. You can obtain the project ID from the API or console. Obtaining the Project ID

Constraints

N/A

Range

N/A

Default Value

N/A

workspace_id

Yes

String

Definition

Workspace ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. You can obtain it by calling the IAM API for obtaining a user token. The user token is the value of X-Subject-Token in the response header. Obtaining a User Token

Constraints

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

Content type.

  • application/json;charset=UTF-8: common API request type

Constraints

N/A

Range

  • application/json;charset=UTF-8

Default Value

N/A

X-Secmaster-Version

Yes

String

Service version, for example, 25.5.0.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Number of records on each page.

offset

No

Integer

Offset.

condition

No

condition object

Query condition.

sort

No

Array of sort objects

Sorting criteria.

group_by

No

group_by object

Aggregation condition.

Table 4 condition

Parameter

Mandatory

Type

Description

conditions

No

Array of conditions objects

Query condition.

logics

No

Array of strings

Condition name.

Table 5 conditions

Parameter

Mandatory

Type

Description

name

No

String

Condition name.

data

No

Array of strings

Condition key-value pair.

Table 6 sort

Parameter

Mandatory

Type

Description

sort_by

No

String

Sorting field.

order

No

String

Ascending or descending order.

Table 7 group_by

Parameter

Mandatory

Type

Description

group_by_fields

No

Array of strings

Aggregation fields.

group_by_hit

No

group_by_hit object

Aggregation result.

Table 8 group_by_hit

Parameter

Mandatory

Type

Description

source

No

String

Source field.

dest

No

String

Target field.

Response Parameters

Status code: 200

Table 9 Response header parameters

Parameter

Type

Description

content-type

String

Content type.

Table 10 Response body parameters

Parameter

Type

Description

code

String

Return code.

data

Array of objects

Return data.

message

String

Response message.

page

Integer

Page.

request_id

String

Request ID.

size

Integer

Number of records on a page.

success

Boolean

Success status.

total

Integer

Total volume.

Status code: 400

Table 11 Response header parameters

Parameter

Type

Description

content-type

String

Content type.

Table 12 Response body parameters

Parameter

Type

Description

code

String

Definition

Error code.

Range

N/A

message

String

Definition

Error description.

Range

N/A

Example Requests

Query the policy view list.

https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/soc/policys/search

{
  "limit" : 10,
  "offset" : 0,
  "condition" : {
    "conditions" : [ {
      "name" : "logic_0",
      "data" : [ "defense_policy_object.defense_block_status", "=", "SUCCESS" ]
    } ],
    "logics" : [ "logic_0" ]
  },
  "sort" : [ {
    "sort_by" : "create_time",
    "order" : "desc"
  } ],
  "group_by" : {
    "group_by_fields" : [ "block_target", "workspace_id", "policy_task_id" ],
    "group_by_hit" : {
      "source" : "defense_policy_object",
      "dest" : "defense_policy_list"
    }
  }
}

Example Responses

Status code: 200

Successful.

{
  "code" : "00000000",
  "data" : [ {
    "aggs_data_objects" : [ {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "e5384393-95d8-4767-bec1-b9d83cd19bd7",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:55:52.648+08:00",
      "is_deleted" : false,
      "block_target" : "2.2.2.2",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_EGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "a4b06b03-7971-402e-a330-b5e806d7ca10",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:55:48.612+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "7fa91ea0-d6e6-4718-9677-21bbc90750be"
      },
      "id" : "61afc7ba-e2ee-4200-b725-8ca71955ebc4",
      "policy_direction" : "EGRESS",
      "create_time" : "2025-10-14T14:55:48.691+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-VPC-20251014145548",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    }, {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "36e11d45-45a5-4ddf-8fd7-2899f18e96d4",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T15:14:46.363+08:00",
      "is_deleted" : false,
      "block_target" : "2.2.2.2",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_EGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "fb619dcd-30dc-4b00-beb7-db9f960a7bcd",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T15:14:42.861+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "8846a9979e464df3817056a9e8f70e53",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "c7caf237-c8cd-45cc-ba5d-2e8af3567878"
      },
      "id" : "e08a7d0f-1e3f-4e2d-b19a-4051ad1061b3",
      "policy_direction" : "EGRESS",
      "create_time" : "2025-10-14T15:14:42.927+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-VPC-20251014151442",
      "labels" : "",
      "environment" : {
        "domain_id" : "c54198aa774c48eabb0ed1f018f2f2de",
        "domain_name" : "DomainName",
        "project_id" : "8846a9979e464df3817056a9e8f70e53",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    } ],
    "create_time" : null,
    "data_object" : {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "e5384393-95d8-4767-bec1-b9d83cd19bd7",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:55:52.648Z+0800",
      "is_deleted" : false,
      "block_target" : "2.2.2.2",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "id" : "61afc7ba-e2ee-4200-b725-8ca71955ebc4",
      "policy_direction" : "EGRESS",
      "defense_policy_list" : [ {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_EGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "a4b06b03-7971-402e-a330-b5e806d7ca10",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:55:48.612+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "7fa91ea0-d6e6-4718-9677-21bbc90750be"
      }, {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_EGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "fb619dcd-30dc-4b00-beb7-db9f960a7bcd",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T15:14:42.861+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "8846a9979e464df3817056a9e8f70e53",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "c7caf237-c8cd-45cc-ba5d-2e8af3567878"
      } ],
      "create_time" : "2025-10-14T14:55:48.691Z+0800",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-VPC-20251014145548",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    },
    "dataclass_ref" : null,
    "format_version" : 0,
    "id" : "",
    "project_id" : "",
    "type" : null,
    "update_time" : null,
    "version" : 0,
    "workspace_id" : ""
  }, {
    "aggs_data_objects" : [ {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "892b17e8-36fb-431e-92a3-2b65b43a3cb4",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:38:41.855+08:00",
      "is_deleted" : false,
      "block_target" : "20.25.10.14",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "CFW",
        "defense_type" : "CFW",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "88b8d048-4f83-3923-80de-d41178e53700",
        "defense_id" : "66cb0fe9-a567-4c09-9f2a-51918db3cc23",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "7febc6f5-b9f6-4aa7-b0f5-ca7889e8187c"
      },
      "id" : "90212f27-a0fb-4bf7-a7aa-97b73ef98421",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:38:36.902+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-VPC-WAF-20251014143836",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "creator_name" : "test_domain_name"
    }, {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "892b17e8-36fb-431e-92a3-2b65b43a3cb4",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:38:40.431+08:00",
      "is_deleted" : false,
      "block_target" : "20.25.10.14",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "a0fe2ee5-d957-4e4a-a746-cf70dd1ddf30",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "d5c257da-840c-4fa3-8245-b0881c9823e2"
      },
      "id" : "6d87192b-86a9-44ac-bd5d-3aa28c027f8d",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:38:36.902+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-VPC-WAF-20251014143836",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "creator_name" : "test_domain_name"
    }, {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "892b17e8-36fb-431e-92a3-2b65b43a3cb4",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:38:43.188+08:00",
      "is_deleted" : false,
      "block_target" : "20.25.10.14",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "WAF",
        "defense_type" : "WAF",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Ip_Group_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "034f0a01-0d90-36c9-a1a1-f87e9af23833",
        "defense_id" : "c412f52a-4f35-4da5-912c-5129acd6a844",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "ab5a6a1c79c7408080ef88aaa8099f31"
      },
      "id" : "fc59ad0b-8418-42b0-a20e-db10263dcecc",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:38:36.902+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-VPC-WAF-20251014143836",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "creator_name" : "test_domain_name"
    } ],
    "create_time" : null,
    "data_object" : {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "892b17e8-36fb-431e-92a3-2b65b43a3cb4",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:38:41.855Z+0800",
      "is_deleted" : false,
      "block_target" : "20.25.10.14",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "id" : "90212f27-a0fb-4bf7-a7aa-97b73ef98421",
      "policy_direction" : "INGRESS",
      "defense_policy_list" : [ {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "CFW",
        "defense_type" : "CFW",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "88b8d048-4f83-3923-80de-d41178e53700",
        "defense_id" : "66cb0fe9-a567-4c09-9f2a-51918db3cc23",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "7febc6f5-b9f6-4aa7-b0f5-ca7889e8187c"
      }, {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "a0fe2ee5-d957-4e4a-a746-cf70dd1ddf30",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "d5c257da-840c-4fa3-8245-b0881c9823e2"
      }, {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "WAF",
        "defense_type" : "WAF",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Ip_Group_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "034f0a01-0d90-36c9-a1a1-f87e9af23833",
        "defense_id" : "c412f52a-4f35-4da5-912c-5129acd6a844",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:38:36.631+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
        "defense_policy_id" : "ab5a6a1c79c7408080ef88aaa8099f31"
      } ],
      "create_time" : "2025-10-14T14:38:36.902Z+0800",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-VPC-WAF-20251014143836",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "modifier_id" : "fb520ccb7d94467588e4bf20f5191d77",
      "creator_name" : "test_domain_name"
    },
    "dataclass_ref" : null,
    "format_version" : 0,
    "id" : "",
    "project_id" : "",
    "type" : null,
    "update_time" : null,
    "version" : 0,
    "workspace_id" : ""
  }, {
    "aggs_data_objects" : [ {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "9d678c08-1622-43c6-91e4-1544dec0a027",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:20:40.411+08:00",
      "is_deleted" : false,
      "block_target" : "1.1.1.1",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "CFW",
        "defense_type" : "CFW",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "88b8d048-4f83-3923-80de-d41178e53700",
        "defense_id" : "dccd5aa3-be3c-4839-9fa4-38d2fd70547e",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:20:36.222+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "7febc6f5-b9f6-4aa7-b0f5-ca7889e8187c"
      },
      "id" : "4036391d-8e53-4c0c-a79f-7e272b3cb26c",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:20:36.338+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-20251014142036",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    }, {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "f5b13ebd-4f65-4a1b-b79f-d7da5a64c435",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:23:56.696+08:00",
      "is_deleted" : false,
      "block_target" : "1.1.1.1",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "6e924a55-0fc2-47a0-9e23-f39f7cc3062a",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:23:53.708+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "d5c257da-840c-4fa3-8245-b0881c9823e2"
      },
      "id" : "354ddb04-887e-44f2-b5b4-bb3a31019a22",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:23:53.819+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-VPC-20251014142353",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    }, {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "a96c2b30-cb08-48ec-9f94-0e4d12c4cfaa",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:24:49.920+08:00",
      "is_deleted" : false,
      "block_target" : "1.1.1.1",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "defense_policy_object" : {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "WAF",
        "defense_type" : "WAF",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Ip_Group_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "034f0a01-0d90-36c9-a1a1-f87e9af23833",
        "defense_id" : "24ff4061-6614-4425-b553-c060615faf1b",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:24:37.793+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "ab5a6a1c79c7408080ef88aaa8099f31"
      },
      "id" : "6c34f1f8-f851-4fed-8f45-6eff1cfc35c8",
      "policy_direction" : "INGRESS",
      "create_time" : "2025-10-14T14:24:37.904+08:00",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-WAF-20251014142437",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    } ],
    "create_time" : null,
    "data_object" : {
      "modifier_name" : "test_domain_name",
      "block_age" : {
        "is_block_ageing" : false,
        "block_ageing" : null
      },
      "description" : "",
      "policy_task_id" : "9d678c08-1622-43c6-91e4-1544dec0a027",
      "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
      "workspace_id" : "ff631ed9-96ac-439f-880f-5de3ddd72cbb",
      "domain_name" : "test_domain_name",
      "update_time" : "2025-10-14T14:20:40.411Z+0800",
      "is_deleted" : false,
      "block_target" : "1.1.1.1",
      "project_id" : "3bb27e024693436da46b5f5aaf499060",
      "region_name" : null,
      "id" : "4036391d-8e53-4c0c-a79f-7e272b3cb26c",
      "policy_direction" : "INGRESS",
      "defense_policy_list" : [ {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "CFW",
        "defense_type" : "CFW",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "88b8d048-4f83-3923-80de-d41178e53700",
        "defense_id" : "dccd5aa3-be3c-4839-9fa4-38d2fd70547e",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:20:36.222+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "7febc6f5-b9f6-4aa7-b0f5-ca7889e8187c"
      }, {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "VPC",
        "defense_type" : "VPC",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Group_IPv4_INGRESS_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "4c1adb13-10a4-383d-8216-4f5714b6128c",
        "defense_id" : "6e924a55-0fc2-47a0-9e23-f39f7cc3062a",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:23:53.708+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "d5c257da-840c-4fa3-8245-b0881c9823e2"
      }, {
        "target_project_name" : "RegionName",
        "defense_connection_name" : "WAF",
        "defense_type" : "WAF",
        "defense_policy_list" : null,
        "target_enterprise_id" : "0",
        "defense_connection_region_id" : "RegionId",
        "description" : null,
        "defense_policy_name" : "SecMaster_Ip_Group_BLOCK0",
        "defense_modifier_name" : "test_domain_name",
        "defense_connection_id" : "034f0a01-0d90-36c9-a1a1-f87e9af23833",
        "defense_id" : "24ff4061-6614-4425-b553-c060615faf1b",
        "defense_connection_region_name" : "RegionName",
        "target_enterprise_name" : "default",
        "defense_update_time" : "2025-10-14T14:24:37.793+08:00",
        "dataobject_id" : null,
        "defense_block_status" : "SUCCESS",
        "target_project_id" : "3bb27e024693436da46b5f5aaf499060",
        "defense_modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
        "defense_policy_id" : "ab5a6a1c79c7408080ef88aaa8099f31"
      } ],
      "create_time" : "2025-10-14T14:20:36.338Z+0800",
      "region_id" : "RegionId",
      "dataclass_id" : "782353cb-e951-3f94-be8c-9ab0e140a137",
      "policy_task_name" : "test_domain_name-CFW-20251014142036",
      "labels" : "",
      "environment" : {
        "domain_id" : "94aee09081c649cfa9eef5d25200ec50",
        "domain_name" : "test_domain_name",
        "project_id" : "3bb27e024693436da46b5f5aaf499060",
        "region_id" : "RegionId",
        "region_name" : "RegionName",
        "vendor_type" : "cloud"
      },
      "policy_type" : {
        "policy_type" : "Source Ip",
        "id" : "4d67fe756fcefbf60337e5c8debdff6d",
        "category" : "defense direction"
      },
      "trigger_flag" : true,
      "policy_category" : "BLOCK",
      "creator_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "modifier_id" : "b6566bce94194f3d9dc6d397c72e40b2",
      "creator_name" : "test_domain_name"
    },
    "dataclass_ref" : null,
    "format_version" : 0,
    "id" : "",
    "project_id" : "",
    "type" : null,
    "update_time" : null,
    "version" : 0,
    "workspace_id" : ""
  } ],
  "message" : "",
  "page" : 0,
  "request_id" : "",
  "size" : 10,
  "success" : true,
  "total" : 3
}

SDK Sample Code

The SDK sample code is as follows.

Query the policy view list.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.secmaster.v1.region.SecMasterRegion;
import com.huaweicloud.sdk.secmaster.v1.*;
import com.huaweicloud.sdk.secmaster.v1.model.*;

import java.util.List;
import java.util.ArrayList;

public class SearchPolicySolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        SecMasterClient client = SecMasterClient.newBuilder()
                .withCredential(auth)
                .withRegion(SecMasterRegion.valueOf("<YOUR REGION>"))
                .build();
        SearchPolicyRequest request = new SearchPolicyRequest();
        request.withWorkspaceId("{workspace_id}");
        SearchPolicyRequestBody body = new SearchPolicyRequestBody();
        SearchPolicyRequestBodyGroupByGroupByHit groupByHitGroupBy = new SearchPolicyRequestBodyGroupByGroupByHit();
        groupByHitGroupBy.withSource("defense_policy_object")
            .withDest("defense_policy_list");
        List<String> listGroupByGroupByFields = new ArrayList<>();
        listGroupByGroupByFields.add("block_target");
        listGroupByGroupByFields.add("workspace_id");
        listGroupByGroupByFields.add("policy_task_id");
        SearchPolicyRequestBodyGroupBy groupBybody = new SearchPolicyRequestBodyGroupBy();
        groupBybody.withGroupByFields(listGroupByGroupByFields)
            .withGroupByHit(groupByHitGroupBy);
        List<SearchPolicyRequestBodySort> listbodySort = new ArrayList<>();
        listbodySort.add(
            new SearchPolicyRequestBodySort()
                .withSortBy("create_time")
                .withOrder("desc")
        );
        List<String> listConditionLogics = new ArrayList<>();
        listConditionLogics.add("logic_0");
        List<String> listConditionsData = new ArrayList<>();
        listConditionsData.add("defense_policy_object.defense_block_status");
        listConditionsData.add("=");
        listConditionsData.add("SUCCESS");
        List<SearchPolicyRequestBodyConditionConditions> listConditionConditions = new ArrayList<>();
        listConditionConditions.add(
            new SearchPolicyRequestBodyConditionConditions()
                .withName("logic_0")
                .withData(listConditionsData)
        );
        SearchPolicyRequestBodyCondition conditionbody = new SearchPolicyRequestBodyCondition();
        conditionbody.withConditions(listConditionConditions)
            .withLogics(listConditionLogics);
        body.withGroupBy(groupBybody);
        body.withSort(listbodySort);
        body.withCondition(conditionbody);
        body.withOffset(0);
        body.withLimit(10);
        request.withBody(body);
        try {
            SearchPolicyResponse response = client.searchPolicy(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Query the policy view list.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksecmaster.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = SecMasterClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = SearchPolicyRequest()
        request.workspace_id = "{workspace_id}"
        groupByHitGroupBy = SearchPolicyRequestBodyGroupByGroupByHit(
            source="defense_policy_object",
            dest="defense_policy_list"
        )
        listGroupByFieldsGroupBy = [
            "block_target",
            "workspace_id",
            "policy_task_id"
        ]
        groupBybody = SearchPolicyRequestBodyGroupBy(
            group_by_fields=listGroupByFieldsGroupBy,
            group_by_hit=groupByHitGroupBy
        )
        listSortbody = [
            SearchPolicyRequestBodySort(
                sort_by="create_time",
                order="desc"
            )
        ]
        listLogicsCondition = [
            "logic_0"
        ]
        listDataConditions = [
            "defense_policy_object.defense_block_status",
            "=",
            "SUCCESS"
        ]
        listConditionsCondition = [
            SearchPolicyRequestBodyConditionConditions(
                name="logic_0",
                data=listDataConditions
            )
        ]
        conditionbody = SearchPolicyRequestBodyCondition(
            conditions=listConditionsCondition,
            logics=listLogicsCondition
        )
        request.body = SearchPolicyRequestBody(
            group_by=groupBybody,
            sort=listSortbody,
            condition=conditionbody,
            offset=0,
            limit=10
        )
        response = client.search_policy(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Query the policy view list.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := secmaster.NewSecMasterClient(
        secmaster.SecMasterClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.SearchPolicyRequest{}
	request.WorkspaceId = "{workspace_id}"
	sourceGroupByHit:= "defense_policy_object"
	destGroupByHit:= "defense_policy_list"
	groupByHitGroupBy := &model.SearchPolicyRequestBodyGroupByGroupByHit{
		Source: &sourceGroupByHit,
		Dest: &destGroupByHit,
	}
	var listGroupByFieldsGroupBy = []string{
        "block_target",
	    "workspace_id",
	    "policy_task_id",
    }
	groupBybody := &model.SearchPolicyRequestBodyGroupBy{
		GroupByFields: &listGroupByFieldsGroupBy,
		GroupByHit: groupByHitGroupBy,
	}
	sortBySort:= "create_time"
	orderSort:= "desc"
	var listSortbody = []model.SearchPolicyRequestBodySort{
        {
            SortBy: &sortBySort,
            Order: &orderSort,
        },
    }
	var listLogicsCondition = []string{
        "logic_0",
    }
	var listDataConditions = []string{
        "defense_policy_object.defense_block_status",
	    "=",
	    "SUCCESS",
    }
	nameConditions:= "logic_0"
	var listConditionsCondition = []model.SearchPolicyRequestBodyConditionConditions{
        {
            Name: &nameConditions,
            Data: &listDataConditions,
        },
    }
	conditionbody := &model.SearchPolicyRequestBodyCondition{
		Conditions: &listConditionsCondition,
		Logics: &listLogicsCondition,
	}
	offsetSearchPolicyRequestBody:= int32(0)
	limitSearchPolicyRequestBody:= int32(10)
	request.Body = &model.SearchPolicyRequestBody{
		GroupBy: groupBybody,
		Sort: &listSortbody,
		Condition: conditionbody,
		Offset: &offsetSearchPolicyRequestBody,
		Limit: &limitSearchPolicyRequestBody,
	}
	response, err := client.SearchPolicy(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Successful.

400

Response body for failed policy view queries.

Error Codes

See Error Codes.