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

分页查询 CC 规则组列表

GET/v1/cc-rules

分页查询当前身份可见的 CC 规则组。默认情况下普通用户只返回自己创建的规则组,管理员返回全部规则组或通过 uid 限定所属用户;传 internal_self=1 时改为返回全局可见的内置规则、目标用户自己的规则以及 show_to 明确授权给该用户的规则。接口还支持按规则组 ID、名称、启用状态、前台显示状态和是否内置筛选,系统保留的 10020 号记录始终不会返回。结果先按 sort 升序,再按创建时间倒序排列;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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
pagequeryinteger (int32)可选

页码,从 1 开始;省略时为 1。只能传十进制非负整数字符串,非数字值返回 cc_rule-30;limit=0 时该参数不影响返回范围。

完整参数定义
{
  "name": "page",
  "in": "query",
  "required": false,
  "description": "页码,从 1 开始;省略时为 1。只能传十进制非负整数字符串,非数字值返回 `cc_rule-30`;`limit=0` 时该参数不影响返回范围。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 1,
    "default": 1
  },
  "example": 1
}
limitqueryinteger (int32)可选

每页返回的规则组数量,省略时为 10;传 0 表示不分页并返回全部匹配记录。非数字值返回 cc_rule-31。

完整参数定义
{
  "name": "limit",
  "in": "query",
  "required": false,
  "description": "每页返回的规则组数量,省略时为 10;传 0 表示不分页并返回全部匹配记录。非数字值返回 `cc_rule-31`。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 0,
    "default": 10
  },
  "example": 10
}
uidqueryinteger (int64)可选

目标用户 ID。未使用 internal_self 时按所属用户精确筛选;使用 internal_self=1 时作为可见性计算的目标用户。该参数仅管理员可用,普通用户传入时返回 cc_rule-382。

完整参数定义
{
  "name": "uid",
  "in": "query",
  "required": false,
  "description": "目标用户 ID。未使用 `internal_self` 时按所属用户精确筛选;使用 `internal_self=1` 时作为可见性计算的目标用户。该参数仅管理员可用,普通用户传入时返回 `cc_rule-382`。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  },
  "example": 2
}
internal_selfqueryinteger可选

传 1 时返回全局内置规则、目标用户自己的规则以及 show_to 中包含目标用户 ID 的规则;省略 uid 时目标用户为当前登录用户。

完整参数定义
{
  "name": "internal_self",
  "in": "query",
  "required": false,
  "description": "传 1 时返回全局内置规则、目标用户自己的规则以及 `show_to` 中包含目标用户 ID 的规则;省略 `uid` 时目标用户为当前登录用户。",
  "schema": {
    "type": "integer",
    "enum": [
      1
    ]
  },
  "example": 1
}
internalqueryinteger可选

按是否为系统内置规则组精确筛选:1 表示内置,0 表示用户自定义。该筛选条件仅管理员可用,普通用户传入时返回 cc_rule-383。

完整参数定义
{
  "name": "internal",
  "in": "query",
  "required": false,
  "description": "按是否为系统内置规则组精确筛选:1 表示内置,0 表示用户自定义。该筛选条件仅管理员可用,普通用户传入时返回 `cc_rule-383`。",
  "schema": {
    "type": "integer",
    "enum": [
      0,
      1
    ]
  },
  "example": 1
}
enablequeryinteger可选

按启用状态精确筛选:1 表示已启用,0 表示已禁用。

完整参数定义
{
  "name": "enable",
  "in": "query",
  "required": false,
  "description": "按启用状态精确筛选:1 表示已启用,0 表示已禁用。",
  "schema": {
    "type": "integer",
    "enum": [
      0,
      1
    ]
  },
  "example": 1
}
is_showqueryinteger可选

按前台显示状态精确筛选:1 表示展示给可见用户,0 表示不在前台选择列表中展示。

完整参数定义
{
  "name": "is_show",
  "in": "query",
  "required": false,
  "description": "按前台显示状态精确筛选:1 表示展示给可见用户,0 表示不在前台选择列表中展示。",
  "schema": {
    "type": "integer",
    "enum": [
      0,
      1
    ]
  },
  "example": 1
}
idqueryinteger (int64)可选

按 CC 规则组 ID 精确筛选;系统保留的 10020 号记录即使匹配也不会返回。

完整参数定义
{
  "name": "id",
  "in": "query",
  "required": false,
  "description": "按 CC 规则组 ID 精确筛选;系统保留的 10020 号记录即使匹配也不会返回。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  },
  "example": 10021
}
namequerystring可选

按规则组名称进行包含匹配。

完整参数定义
{
  "name": "name",
  "in": "query",
  "required": false,
  "description": "按规则组名称进行包含匹配。",
  "schema": {
    "type": "string"
  },
  "example": "验证码防护"
}

响应

HTTP 200

请求通过 HTTP 200 返回。成功时给出符合可见性及筛选条件的总数和当前页规则组列表;普通用户指定目标用户或筛选内置状态、页码或每页数量格式错误、认证失效时,通过字符串 code 和 msg 返回业务错误。

application/json

oneOf

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

成功状态码,列表查询成功时固定为 0。

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

符合可见性及筛选条件的规则组总数,不受当前页 limit 限制。

约束 / 默认值 / 示例
{
  "format": "int64",
  "minimum": 0
}
dataarray <object>必填

当前页的 CC 规则组记录,按排序值升序、相同排序值按创建时间倒序排列。

展开字段结构

当前页的 CC 规则组记录,按排序值升序、相同排序值按创建时间倒序排列。

数组元素 · object
字段类型必填说明与约束
idinteger (int64)必填

CC 规则组的唯一 ID。

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

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

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

规则组所属用户的 ID;不归属于具体用户的系统内置规则可为 null。

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

查询结果中因再次选择所属用户列而生成的重复字段,值与 uid 相同;系统内置规则可为 null。

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

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

desstring必填

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

datastring必填

序列化后的规则步骤 JSON 数组。每步包含执行模式、匹配器 ID、动作、启用状态、第一过滤器 ID,并可包含第二过滤器及用于界面显示的名称。

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"
}
statestring必填

关联任务的当前状态;规则组没有关联任务时为 null。

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

格式化为 YYYY-MM-DD HH:mm:ss 的创建时间;原始创建时间为 null 时也为 null。

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

格式化为 YYYY-MM-DD HH:mm:ss 的最后更新时间;原始更新时间为 null 时也为 null。

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

规则组所属用户的名称;不归属于具体用户的系统内置规则为 null。

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

业务错误码:cc_rule-30 表示 page 不是数字,cc_rule-31 表示 limit 不是数字,cc_rule-382 表示普通用户指定目标用户,cc_rule-383 表示普通用户筛选内置状态,login_required 表示认证无效。

约束 / 默认值 / 示例
{
  "enum": [
    "cc_rule-30",
    "cc_rule-31",
    "cc_rule-382",
    "cc_rule-383",
    "login_required"
  ]
}
msgstring必填

与业务错误码对应的中文参数、权限或认证失败原因。

datastring必填

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

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "count",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "成功状态码,列表查询成功时固定为 0。"
        },
        "count": {
          "type": "integer",
          "format": "int64",
          "minimum": 0,
          "description": "符合可见性及筛选条件的规则组总数,不受当前页 `limit` 限制。"
        },
        "data": {
          "type": "array",
          "description": "当前页的 CC 规则组记录,按排序值升序、相同排序值按创建时间倒序排列。",
          "items": {
            "type": "object",
            "required": [
              "id",
              "sort",
              "uid",
              "c.uid",
              "name",
              "des",
              "data",
              "show_to",
              "create_at",
              "update_at",
              "internal",
              "enable",
              "is_show",
              "task_id",
              "version",
              "state",
              "create_at2",
              "update_at2",
              "username"
            ],
            "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。"
              },
              "c.uid": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "查询结果中因再次选择所属用户列而生成的重复字段,值与 `uid` 相同;系统内置规则可为 null。"
              },
              "name": {
                "type": "string",
                "description": "规则组名称,同一用户下不可重名。"
              },
              "des": {
                "type": "string",
                "description": "规则组备注,可为空字符串。"
              },
              "data": {
                "type": "string",
                "description": "序列化后的规则步骤 JSON 数组。每步包含执行模式、匹配器 ID、动作、启用状态、第一过滤器 ID,并可包含第二过滤器及用于界面显示的名称。"
              },
              "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": "规则组配置版本号,每次更新时递增。"
              },
              "state": {
                "type": "string",
                "nullable": true,
                "description": "关联任务的当前状态;规则组没有关联任务时为 null。"
              },
              "create_at2": {
                "type": "string",
                "nullable": true,
                "description": "格式化为 `YYYY-MM-DD HH:mm:ss` 的创建时间;原始创建时间为 null 时也为 null。"
              },
              "update_at2": {
                "type": "string",
                "nullable": true,
                "description": "格式化为 `YYYY-MM-DD HH:mm:ss` 的最后更新时间;原始更新时间为 null 时也为 null。"
              },
              "username": {
                "type": "string",
                "nullable": true,
                "description": "规则组所属用户的名称;不归属于具体用户的系统内置规则为 null。"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "cc_rule-30",
            "cc_rule-31",
            "cc_rule-382",
            "cc_rule-383",
            "login_required"
          ],
          "description": "业务错误码:`cc_rule-30` 表示 page 不是数字,`cc_rule-31` 表示 limit 不是数字,`cc_rule-382` 表示普通用户指定目标用户,`cc_rule-383` 表示普通用户筛选内置状态,`login_required` 表示认证无效。"
        },
        "msg": {
          "type": "string",
          "description": "与业务错误码对应的中文参数、权限或认证失败原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "id": 10021,
      "sort": 100,
      "uid": 2,
      "c.uid": 2,
      "name": "验证码防护",
      "des": "匹配 API 请求后执行验证码过滤器",
      "data": "[{\"mode\": \"break\", \"matcher\": \"10021\", \"action\": \"block\", \"state\": true, \"filter1\": \"10021\", \"filter2\": \"\", \"matcher_name\": \"匹配 API 请求\", \"filter1_name\": \"验证码\", \"filter2_name\": \"\"}]",
      "show_to": "",
      "create_at": "Thu, 25 Nov 2021 18:09:35 GMT",
      "update_at": "Thu, 25 Nov 2021 18:09:35 GMT",
      "internal": 0,
      "enable": 1,
      "is_show": 1,
      "task_id": null,
      "version": 1,
      "state": null,
      "create_at2": "2021-11-25 18:09:35",
      "update_at2": "2021-11-25 18:09:35",
      "username": "example-user"
    }
  ]
}

cURL 示例

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

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

查看完整接口 JSON