itecdn 5.x用户文档
itecdn 5.x / 用户 API

获取 CC 规则组详情

GET/v1/cc-rules/{rule_id}

按 ID 获取一条 CC 规则组的原始配置记录。系统内置规则组仅管理员身份可以读取;用户自定义规则组仅允许其所属用户读取,管理员身份本身不会绕过自定义规则组的所有者校验。返回的是 cc_rule 记录本身,不包含列表接口联表得到的任务状态、用户名或格式化时间字段;data 为序列化后的规则步骤 JSON 字符串,使用前需要再次解析。

身份认证

access-token

api-key + api-secret

认证定义
{
  "AccessToken": {
    "type": "apiKey",
    "in": "header",
    "name": "access-token",
    "description": "通过登录接口获得的短期访问令牌。"
  },
  "ApiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "api-key",
    "description": "API Key;必须和 api-secret 同时发送。"
  },
  "ApiSecret": {
    "type": "apiKey",
    "in": "header",
    "name": "api-secret",
    "description": "API Secret;必须和 api-key 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
rule_idpathinteger (int64)必填

要查询的 CC 规则组 ID;路由只接受十进制整数。

完整参数定义
{
  "name": "rule_id",
  "in": "path",
  "required": true,
  "description": "要查询的 CC 规则组 ID;路由只接受十进制整数。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  },
  "example": 10021
}

响应

HTTP 200

业务结果通过 HTTP 200 返回。规则组存在且当前身份有读取权限时返回完整原始配置;记录不存在、读取系统内置规则组时不是管理员、读取其他用户的自定义规则组或认证失效时返回字符串业务错误码。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,规则组详情读取成功时固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

详情读取成功时没有附加提示,固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
dataobject必填

数据库中的 CC 规则组原始配置记录。

约束 / 默认值 / 示例
{
  "required": [
    "id",
    "sort",
    "uid",
    "name",
    "des",
    "data",
    "show_to",
    "create_at",
    "update_at",
    "internal",
    "enable",
    "is_show",
    "task_id",
    "version"
  ],
  "additionalProperties": false
}
展开字段结构

数据库中的 CC 规则组原始配置记录。

字段类型必填说明与约束
idinteger (int64)必填

CC 规则组的唯一 ID。

约束 / 默认值 / 示例
{
  "format": "int64"
}
sortinteger (int32)必填

规则组排序值,数值越小越靠前。

约束 / 默认值 / 示例
{
  "format": "int32"
}
uidinteger (int64)必填

规则组所属用户的 ID;历史或系统内置记录不归属于具体用户时可能为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
namestring必填

规则组名称,同一所属用户下不可重名。

desstring必填

规则组备注,可为空字符串。

datastring必填

序列化后的规则步骤 JSON 数组。每个步骤包含 mode、action、matcher、filter1,并可包含 filter2、state 及界面展示用名称;客户端需要再次进行 JSON 解析。

show_tostring必填

允许看到该规则组的定向用户 ID,多个 ID 使用英文逗号分隔;空字符串表示未指定定向用户。

create_atstring必填

数据库返回的规则组创建时间;历史记录未保存时间时为 null。

约束 / 默认值 / 示例
{
  "nullable": true
}
update_atstring必填

数据库返回的规则组最后更新时间;历史记录未保存时间时为 null。

约束 / 默认值 / 示例
{
  "nullable": true
}
internalinteger必填

是否为系统内置规则组:1 表示内置,0 表示用户自定义。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
enableinteger必填

规则组启用状态:1 表示启用,0 表示禁用。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
is_showinteger必填

规则组前台显示状态:1 表示展示,0 表示隐藏。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
task_idinteger (int64)必填

最近一次规则组同步或删除任务的 ID;没有关联任务时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
versioninteger (int64)必填

规则组配置版本号,每次更新时递增。

约束 / 默认值 / 示例
{
  "format": "int64"
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

业务错误码:cc_rule-28 表示规则组不存在,cc_rule-29 表示当前账号不是自定义规则组的所有者,cc_rule-381 表示非管理员尝试读取系统内置规则组,login_required 表示认证无效。

约束 / 默认值 / 示例
{
  "enum": [
    "cc_rule-28",
    "cc_rule-29",
    "cc_rule-381",
    "login_required"
  ]
}
msgstring必填

与业务错误码对应的中文记录不存在、所有权、管理员权限或认证失败原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "成功状态码,规则组详情读取成功时固定为 0。"
        },
        "msg": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "详情读取成功时没有附加提示,固定为空字符串。"
        },
        "data": {
          "type": "object",
          "required": [
            "id",
            "sort",
            "uid",
            "name",
            "des",
            "data",
            "show_to",
            "create_at",
            "update_at",
            "internal",
            "enable",
            "is_show",
            "task_id",
            "version"
          ],
          "properties": {
            "id": {
              "type": "integer",
              "format": "int64",
              "description": "CC 规则组的唯一 ID。"
            },
            "sort": {
              "type": "integer",
              "format": "int32",
              "description": "规则组排序值,数值越小越靠前。"
            },
            "uid": {
              "type": "integer",
              "format": "int64",
              "nullable": true,
              "description": "规则组所属用户的 ID;历史或系统内置记录不归属于具体用户时可能为 null。"
            },
            "name": {
              "type": "string",
              "description": "规则组名称,同一所属用户下不可重名。"
            },
            "des": {
              "type": "string",
              "description": "规则组备注,可为空字符串。"
            },
            "data": {
              "type": "string",
              "description": "序列化后的规则步骤 JSON 数组。每个步骤包含 `mode`、`action`、`matcher`、`filter1`,并可包含 `filter2`、`state` 及界面展示用名称;客户端需要再次进行 JSON 解析。"
            },
            "show_to": {
              "type": "string",
              "description": "允许看到该规则组的定向用户 ID,多个 ID 使用英文逗号分隔;空字符串表示未指定定向用户。"
            },
            "create_at": {
              "type": "string",
              "nullable": true,
              "description": "数据库返回的规则组创建时间;历史记录未保存时间时为 null。"
            },
            "update_at": {
              "type": "string",
              "nullable": true,
              "description": "数据库返回的规则组最后更新时间;历史记录未保存时间时为 null。"
            },
            "internal": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "是否为系统内置规则组:1 表示内置,0 表示用户自定义。"
            },
            "enable": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "规则组启用状态:1 表示启用,0 表示禁用。"
            },
            "is_show": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "规则组前台显示状态:1 表示展示,0 表示隐藏。"
            },
            "task_id": {
              "type": "integer",
              "format": "int64",
              "nullable": true,
              "description": "最近一次规则组同步或删除任务的 ID;没有关联任务时为 null。"
            },
            "version": {
              "type": "integer",
              "format": "int64",
              "description": "规则组配置版本号,每次更新时递增。"
            }
          },
          "additionalProperties": false,
          "description": "数据库中的 CC 规则组原始配置记录。"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "cc_rule-28",
            "cc_rule-29",
            "cc_rule-381",
            "login_required"
          ],
          "description": "业务错误码:`cc_rule-28` 表示规则组不存在,`cc_rule-29` 表示当前账号不是自定义规则组的所有者,`cc_rule-381` 表示非管理员尝试读取系统内置规则组,`login_required` 表示认证无效。"
        },
        "msg": {
          "type": "string",
          "description": "与业务错误码对应的中文记录不存在、所有权、管理员权限或认证失败原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "msg": "",
  "data": {
    "id": 10021,
    "sort": 100,
    "uid": 2,
    "name": "验证码防护",
    "des": "匹配 API 请求后执行验证码过滤器",
    "data": "[{\"mode\": \"break\", \"action\": \"block\", \"matcher\": \"10021\", \"filter1\": \"10021\", \"filter2\": \"\", \"state\": true}]",
    "show_to": "",
    "create_at": "Thu, 25 Nov 2021 14:45:10 GMT",
    "update_at": "Thu, 25 Nov 2021 14:45:10 GMT",
    "internal": 0,
    "enable": 1,
    "is_show": 1,
    "task_id": 20031,
    "version": 1
  }
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/cc-rules/{rule_id}" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON