获取自定义控制规则¶
1. 接口描述¶
接口请求路径:POST /prod-api/waf/nlaV1/custom/rules/describeCustomRules
describeCustomRules 用于分页查询指定策略组下的自定义控制规则列表,返回规则名称、状态、匹配目标摘要、动作展示名及排序。
Token 获取方式见 密钥鉴权。
2. 输入参数¶
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| aclId | 是 | Long | 策略组 ID 示例值: 74 |
| pageNum | 是 | Integer | 当前页数 示例值: 1 |
| pageSize | 是 | Integer | 每页显示条目个数 示例值: 20 |
3. 示例¶
示例1 分页查询自定义规则¶
输入示例¶
代码调用¶
请将 {登录域名}、token 替换为实际值。
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class DescribeCustomRulesTest {
public static void main(String[] args) throws Exception {
String url = "https://{登录域名}/prod-api/waf/nlaV1/custom/rules/describeCustomRules";
String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";
String requestBody = "{\"pageNum\":1,\"pageSize\":20,\"aclId\":74}";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", "Bearer " + token);
httpPost.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
System.out.println("Status Code: " + statusCode);
System.out.println("Body: " + body);
}
}
}
}
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://{登录域名}/prod-api/waf/nlaV1/custom/rules/describeCustomRules"
token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
requestBody := []byte(`{
"pageNum": 1,
"pageSize": 20,
"aclId": 74
}`)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBody))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println("Body:", string(body))
}
输出示例¶
{
"total": 2,
"rows": [
{
"customRuleId": 128,
"ruleMessage": "鉴权",
"status": "enable",
"targets": [
{
"name": "主机名",
"value": "HOST"
},
{
"name": "Uri请求",
"value": "REQUEST_URI"
}
],
"ruleClass": "custom",
"action": "鉴权",
"updateTime": "2026-05-14 14:47:05",
"sort": 1
},
{
"customRuleId": 122,
"ruleMessage": "人机",
"status": "enable",
"targets": [
{
"name": "Uri请求",
"value": "REQUEST_URI"
}
],
"ruleClass": "custom",
"action": "人机验证",
"updateTime": "2026-03-02 13:54:12",
"sort": 2
}
],
"code": 200,
"msg": "成功"
}
4. 输出参数¶
| 参数名称 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码。示例值:200 |
| msg | String | 提示信息。示例值:成功 |
| total | Integer | 符合条件的总条数。示例值:2 |
| rows | Array | 规则列表 |
| rows[].customRuleId | Long | 自定义规则 ID。示例值:128 |
| rows[].ruleMessage | String | 规则名称。示例值:鉴权 |
| rows[].status | String | 启用状态,支持以下值:enable:启用disable:关闭示例值: enable |
| rows[].targets | Array | 匹配目标摘要(展示用) |
| rows[].targets[].name | String | 目标中文名。示例值:主机名 |
| rows[].targets[].value | String | 目标编码,与 查询条件参数 中 target 一致。示例值:HOST |
| rows[].ruleClass | String | 规则类别,支持以下值:custom:自定义default:默认示例值: custom |
| rows[].action | String | 动作展示名(中文)。示例值:鉴权 |
| rows[].updateTime | String | 更新时间,格式 yyyy-MM-dd HH:mm:ss示例值: 2026-05-14 14:47:05 |
| rows[].sort | Integer | 排序权重,数值越小越靠前。示例值:1 |
5. 错误码¶
| HTTP 状态码 / 业务提示 | 描述 |
|---|---|
| 200 | 成功 |
| 401 | 未鉴权或 Token 无效 |
| 403 | 无权限 |
| aclId不能为空 | 未传 aclId |