跳转至

更新托管规则组状态

1. 接口描述

接口请求路径:GET /prod-api/waf/wafv3/custody/rules/changeCustodyRuleGroupStatus

changeCustodyRuleGroupStatus 用于启用或关闭整个托管规则组。group_id 来自 查询托管规则组列表 返回的 groupId

Token 获取方式见 密钥鉴权

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
wafId Long Query 参数。策略组 ID
示例值:22
group_id Long Query 参数。规则组 ID
示例值:901
status String Query 参数。目标状态,支持以下值:
ON:启用
OFF:关闭
示例值:ON

3. 示例

示例1 启用托管规则组

输入示例

GET /prod-api/waf/wafv3/custody/rules/changeCustodyRuleGroupStatus?wafId=22&group_id=901&status=ON

代码调用

请将 {登录域名}token 替换为实际值。

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class ChangeCustodyRuleGroupStatusTest {

    public static void main(String[] args) throws Exception {
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        URIBuilder uriBuilder = new URIBuilder(
                "https://{登录域名}/prod-api/waf/wafv3/custody/rules/changeCustodyRuleGroupStatus");
        uriBuilder.addParameter("wafId", "22");
        uriBuilder.addParameter("group_id", "901");
        uriBuilder.addParameter("status", "ON");

        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpGet httpGet = new HttpGet(uriBuilder.build());
            httpGet.setHeader("Authorization", "Bearer " + token);

            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
                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 (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    q := url.Values{}
    q.Set("wafId", "22")
    q.Set("group_id", "901")
    q.Set("status", "ON")
    urlStr := "https://{登录域名}/prod-api/waf/wafv3/custody/rules/changeCustodyRuleGroupStatus?" + q.Encode()

    req, err := http.NewRequest(http.MethodGet, urlStr, nil)
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer "+token)

    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))
}

输出示例

{
  "msg": "更新成功",
  "code": 200,
  "data": 901
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:更新成功
data Long 被更新状态的规则组 ID(group_id)。示例值:901

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
状态[status]只能为OFF、ON status 取值非法
失败,无效的groupId group_id 不存在
wafId不能为空 未传 wafId
失败,groupId为959的规则组不能关闭 规则组 959 不允许关闭