分页查询 CC 匹配器列表
/v1/cc-matchs分页查询当前身份可见的 CC 请求匹配器。普通用户始终只返回归属于自己的匹配器;管理员默认可查看全部用户及系统内置匹配器,并可按所属用户筛选。接口支持按匹配器 ID、名称、启用状态和是否为内置匹配器筛选,结果按匹配器 ID 倒序排列;系统保留的 10020 号记录始终不会出现在列表中。响应中的 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 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
page | query | integer (int32) | 可选 | 页码,从 1 开始;省略时为 1。只能传十进制非负整数字符串,非数字值返回 完整参数定义 |
limit | query | integer (int32) | 可选 | 每页返回的匹配器数量,省略时为 10;传 0 表示不分页并返回全部匹配记录。非数字值返回 完整参数定义 |
uid | query | integer (int64) | 可选 | 按匹配器所属用户 ID 精确筛选,仅管理员身份生效;普通用户传入该参数时仍只返回自己的匹配器。 完整参数定义 |
internal | query | integer | 可选 | 按是否为系统内置匹配器精确筛选:1 表示内置,0 表示用户自定义。使用该筛选条件要求管理员身份,普通用户传入时返回 完整参数定义 |
enable | query | integer | 可选 | 按启用状态精确筛选:1 表示已启用,0 表示已禁用。 完整参数定义 |
id | query | integer (int64) | 可选 | 按 CC 匹配器 ID 精确筛选列表;系统保留的 10020 号记录即使匹配也不会返回。 完整参数定义 |
name | query | string | 可选 | 按匹配器名称进行包含匹配。 完整参数定义 |
响应
HTTP 200
请求通过 HTTP 200 返回。成功时给出符合身份范围及筛选条件的总数和当前页匹配器列表;页码或每页数量格式错误、普通用户筛选内置匹配器或认证失效时,通过字符串 code 和 msg 返回业务错误。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 成功状态码,列表查询成功时固定为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count | integer (int64) | 必填 | 符合身份范围及筛选条件的匹配器总数,不受当前页 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | array <object> | 必填 | 当前页的 CC 匹配器记录,按匹配器 ID 从大到小排列。 展开字段结构当前页的 CC 匹配器记录,按匹配器 ID 从大到小排列。 数组元素 · object
|
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | 业务错误码: 约束 / 默认值 / 示例 |
msg | string | 必填 | 与业务错误码对应的中文参数、权限或认证失败原因。 |
data | string | 必填 | 业务错误时固定为空字符串。 约束 / 默认值 / 示例 |
完整 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 匹配器记录,按匹配器 ID 从大到小排列。",
"items": {
"type": "object",
"required": [
"id",
"uid",
"c.uid",
"name",
"des",
"data",
"create_at",
"update_at",
"internal",
"enable",
"task_id",
"version",
"state",
"create_at2",
"update_at2",
"username"
],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "CC 匹配器的唯一 ID。"
},
"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。`{}` 表示匹配全部请求;条件数组中的每项包含 `item`、`op` 和规范化后的 `value`。"
},
"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 表示禁用。"
},
"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_match-28",
"cc_match-29",
"cc_match-42",
"login_required"
],
"description": "业务错误码:`cc_match-28` 表示 page 不是数字,`cc_match-29` 表示 limit 不是数字,`cc_match-42` 表示当前身份无权筛选内置匹配器,`login_required` 表示认证无效。"
},
"msg": {
"type": "string",
"description": "与业务错误码对应的中文参数、权限或认证失败原因。"
},
"data": {
"type": "string",
"enum": [
""
],
"description": "业务错误时固定为空字符串。"
}
},
"additionalProperties": false
}
]
}示例
{
"code": 0,
"count": 1,
"data": [
{
"id": 10021,
"uid": 2,
"c.uid": 2,
"name": "匹配 API 请求",
"des": "匹配 URI 中包含 /api 的请求",
"data": "[{\"item\": \"req_uri\", \"op\": \"contain\", \"value\": \"/api\"}]",
"create_at": "Thu, 25 Nov 2021 14:17:49 GMT",
"update_at": "Thu, 25 Nov 2021 14:17:49 GMT",
"internal": 0,
"enable": 1,
"task_id": null,
"version": 1,
"state": null,
"create_at2": "2021-11-25 14:17:49",
"update_at2": "2021-11-25 14:17:49",
"username": "example-user"
}
]
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/cc-matchs" \
--header "access-token: YOUR_ACCESS_TOKEN"