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

Querying the Parser Rule List

Function

This API is used to query the list of parser rules.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/workspaces/{workspace_id}/collector/module-templates/restriction

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

Value Range

N/A

Default value

N/A

workspace_id

Yes

String

Workspace ID.

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

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

template_ids

Yes

Array of strings

Description.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

[items]

Array of ShowTemplateFields objects

Template description information array.

Table 5 ShowTemplateFields

Parameter

Type

Description

fields

Array of TemplateField objects

Description.

template_id

String

UUID

Table 6 TemplateField

Parameter

Type

Description

default_value

String

Default Value

description

String

Description.

example

String

Example.

name

String

Rule name.

required

Boolean

Mandatory or not.

restrictions

Array of Restriction objects

Description.

template_field_id

String

UUID

title

String

Related title.

type

String

Rule type.

Table 7 Restriction

Parameter

Type

Description

logic

Boolean

Logical condition.

title

String

Related title.

type

String

Rule type.

value

String

Rule name.

Example Requests

https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/collector/module-templates/restriction

{
  "template_ids" : [ "d51164ad-40a4-4b26-9b9d-d454da34adec" ]
}

Example Responses

Status code: 200

Successful.

[ {
  "fields" : [ {
    "default_value" : "server",
    "description" : "Mode",
    "example" : "mode=>\"server\"",
    "name" : "mode",
    "required" : true,
    "restrictions" : [ {
      "logic" : false,
      "title" : "Server",
      "type" : "option",
      "value" : "server"
    } ],
    "template_field_id" : "926867ed-e31f-4766-911b-bad57f0c436a",
    "title" : "Mode",
    "type" : "string"
  }, {
    "default_value" : "1025",
    "description" : "Port",
    "example" : "port=>1025",
    "name" : "port",
    "required" : true,
    "restrictions" : [ {
      "logic" : false,
      "title" : "min",
      "type" : "min",
      "value" : "1025"
    }, {
      "logic" : false,
      "title" : "max",
      "type" : "max",
      "value" : "65535"
    } ],
    "template_field_id" : "a784d1d7-e049-4602-a7a8-c8cc1bff8c65",
    "title" : "Port",
    "type" : "number"
  }, {
    "default_value" : "plain",
    "description" : "Codec",
    "example" : "codec=>\"plain\"",
    "name" : "codec",
    "required" : true,
    "restrictions" : [ {
      "logic" : false,
      "title" : "Json",
      "type" : "option",
      "value" : "json"
    }, {
      "logic" : false,
      "title" : "Plain",
      "type" : "option",
      "value" : "plain"
    } ],
    "template_field_id" : "4d839ce2-485c-4a93-b778-fd02b6ad308e",
    "title" : "Codec",
    "type" : "string"
  }, {
    "default_value" : "tcp",
    "description" : "Type",
    "example" : "type=>\"tcp\"",
    "name" : "type",
    "required" : false,
    "template_field_id" : "774ce36f-6a46-4114-9d9f-6fba83590fd7",
    "title" : "Type",
    "type" : "string"
  }, {
    "default_value" : "null",
    "description" : "Ssl_cert",
    "example" : "ssl_cert=>\"/opt/123.cert\"",
    "name" : "ssl_cert",
    "required" : false,
    "template_field_id" : "c68ff654-9f36-44f9-8e26-0613c06f4839",
    "title" : "Ssl_cert",
    "type" : "file"
  }, {
    "default_value" : "false",
    "description" : "Ssl_enable",
    "example" : "ssl_enable=>true",
    "name" : "ssl_enable",
    "required" : false,
    "restrictions" : [ {
      "logic" : false,
      "title" : "False",
      "type" : "option",
      "value" : "false"
    }, {
      "logic" : false,
      "title" : "True",
      "type" : "option",
      "value" : "true"
    } ],
    "template_field_id" : "ec928aae-fdda-4261-af9c-373ec5203ab5",
    "title" : "Ssl_enable",
    "type" : "boolean"
  }, {
    "default_value" : "",
    "description" : "Ssl_key",
    "example" : "ssl_key=>\"/opt/123.cert\"",
    "name" : "ssl_key",
    "required" : false,
    "template_field_id" : "5ea8b7b5-b773-4658-8c85-2241b1a19fc6",
    "title" : "Ssl_key",
    "type" : "file"
  }, {
    "default_value" : "",
    "description" : "Ssl_key_passphrase",
    "example" : "ssl_key_passphrase=>\"\"",
    "name" : "ssl_key_passphrase",
    "required" : false,
    "template_field_id" : "359ff2a8-7fab-4206-b7ba-590dbeb55682",
    "title" : "Ssl_key_passphrase",
    "type" : "string"
  } ],
  "template_id" : "d51164ad-40a4-4b26-9b9d-d454da34adec"
} ]

SDK Sample Code

The SDK sample code is as follows.

 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
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 ListCollectorModuleRestrictionsSolution {

    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();
        ListCollectorModuleRestrictionsRequest request = new ListCollectorModuleRestrictionsRequest();
        request.withWorkspaceId("{workspace_id}");
        ModuleTemplateFieldDto body = new ModuleTemplateFieldDto();
        List<String> listbodyTemplateIds = new ArrayList<>();
        listbodyTemplateIds.add("d51164ad-40a4-4b26-9b9d-d454da34adec");
        body.withTemplateIds(listbodyTemplateIds);
        request.withBody(body);
        try {
            ListCollectorModuleRestrictionsResponse response = client.listCollectorModuleRestrictions(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());
        }
    }
}
 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
# 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 = ListCollectorModuleRestrictionsRequest()
        request.workspace_id = "{workspace_id}"
        listTemplateIdsbody = [
            "d51164ad-40a4-4b26-9b9d-d454da34adec"
        ]
        request.body = ModuleTemplateFieldDto(
            template_ids=listTemplateIdsbody
        )
        response = client.list_collector_module_restrictions(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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.ListCollectorModuleRestrictionsRequest{}
	request.WorkspaceId = "{workspace_id}"
	var listTemplateIdsbody = []string{
        "d51164ad-40a4-4b26-9b9d-d454da34adec",
    }
	request.Body = &model.ModuleTemplateFieldDto{
		TemplateIds: listTemplateIdsbody,
	}
	response, err := client.ListCollectorModuleRestrictions(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.

Error Codes

See Error Codes.