查询当前用户的任务申请记录
/v1/jobs分页查询当前登录用户创建的任务申请及其关联执行任务状态,按任务申请 ID 倒序返回。可按任务类型、两个业务索引字段和创建时间筛选,limit=0 时返回全部匹配记录。注意:当 type 精确传 backup 时,服务端使用独立查询条件,不再按当前用户 ID 限制结果;该行为按当前 Python 主控实现保留。
身份认证
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。服务端仅校验为数字,分页偏移为 (page - 1) × limit。 完整参数定义 |
limit | query | integer (int32) | 可选 | 每页记录数,默认 10。传字符串 0 时不附加 SQL limit,返回全部匹配记录。 完整参数定义 |
type | query | string | 可选 | 任务类型筛选。可用逗号分隔多个仅含字母、数字、下划线或连字符的类型,例如 clean_url,unlock_ip;精确值 backup 使用特殊查询逻辑,不按当前用户 ID 过滤。 完整参数定义 |
key1 | query | string | 可选 | 精确筛选任务申请的 key1 字段。该字段由创建任务时的具体业务类型写入,例如缓存任务的域名。 完整参数定义 |
key2 | query | string | 可选 | 精确筛选任务申请的 key2 字段。该字段由创建任务时的具体业务类型写入,例如缓存任务的 URL。 完整参数定义 |
start | query | string | 可选 | 创建时间下限,筛选 create_at 大于或等于该值。服务端直接将值交给数据库比较,不在接口层校验格式。 完整参数定义 |
end | query | string | 可选 | 创建时间上限(不含),筛选 create_at 小于该值。服务端直接将值交给数据库比较,不在接口层校验格式。 完整参数定义 |
响应
HTTP 200
业务结果使用 HTTP 200 返回。成功响应包含 code、count、data,不含 msg;分页参数、type 格式不正确或登录失效时返回统一业务错误封装。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 成功状态码,固定为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count | integer (int64) | 必填 | 当前筛选条件下、未应用分页前的任务申请总数。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | array <object> | 必填 | 当前页任务申请记录,按 job.id 倒序排列。 展开字段结构当前页任务申请记录,按 job.id 倒序排列。 数组元素 · object 任务申请及其关联执行任务状态。
|
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | page 或 limit 格式错误、type 含非法字符或认证失败的业务错误码。 约束 / 默认值 / 示例 |
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": "当前筛选条件下、未应用分页前的任务申请总数。"
},
"data": {
"type": "array",
"description": "当前页任务申请记录,按 job.id 倒序排列。",
"items": {
"type": "object",
"required": [
"id",
"uid",
"type",
"data",
"create_at",
"task_id",
"create_at2"
],
"properties": {
"enable": {
"type": "integer",
"nullable": true,
"description": "关联 task 的启用标记;没有关联执行任务时为 null。"
},
"id": {
"type": "integer",
"format": "int64",
"description": "任务申请(job)ID。"
},
"uid": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "创建该任务申请的用户 ID。"
},
"type": {
"type": "string",
"nullable": true,
"description": "任务类型,例如 clean_url、clean_dir、pre_cache_url、cancel_task、unlock_ip、clean_white_ip 或 down_http_access_log。"
},
"key1": {
"type": "string",
"nullable": true,
"description": "任务业务索引字段 1,具体含义取决于任务类型。"
},
"key2": {
"type": "string",
"nullable": true,
"description": "任务业务索引字段 2,具体含义取决于任务类型。"
},
"data": {
"type": "string",
"nullable": true,
"description": "创建任务时保存的 JSON 文本;接口不解析该字段,具体键由任务类型决定。"
},
"create_at": {
"type": "string",
"format": "date-time",
"nullable": true,
"description": "数据库返回的任务申请创建时间。"
},
"task_id": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "关联 task 的 ID。"
},
"create_at2": {
"type": "string",
"nullable": true,
"description": "格式化后的任务申请创建时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"end_at": {
"type": "string",
"format": "date-time",
"nullable": true,
"description": "关联 task 的结束时间;任务未结束或无关联任务时为 null。"
},
"state": {
"type": "string",
"nullable": true,
"description": "关联 task 的执行状态,例如 pending、running、success 或 failed;无关联任务时为 null。"
},
"ret": {
"type": "string",
"nullable": true,
"description": "关联 task 的返回内容或错误信息;无返回内容时为 null。"
},
"progress": {
"type": "string",
"nullable": true,
"description": "关联 task 的进度文本;无进度信息时为 null。"
}
},
"additionalProperties": false,
"description": "任务申请及其关联执行任务状态。"
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "string",
"enum": [
"job-21",
"job-22",
"job-41",
"login_required"
],
"description": "page 或 limit 格式错误、type 含非法字符或认证失败的业务错误码。"
},
"msg": {
"type": "string",
"description": "具体错误原因。"
},
"data": {
"type": "string",
"enum": [
""
],
"description": "业务错误时固定为空字符串。"
}
},
"additionalProperties": false
}
]
}示例
{
"code": 0,
"count": 1,
"data": [
{
"enable": 1,
"id": 1201,
"uid": 12,
"type": "clean_url",
"key1": "www.example.invalid",
"key2": "https://www.example.invalid/index.html",
"data": "{\"url\": \"https://www.example.invalid/index.html\"}",
"create_at": "2026-01-02T08:00:00",
"task_id": 9876,
"create_at2": "2026-01-02 08:00:00",
"end_at": null,
"state": "pending",
"ret": null,
"progress": null
}
]
}查询成功
{
"code": 0,
"count": 1,
"data": [
{
"enable": 1,
"id": 1201,
"uid": 12,
"type": "clean_url",
"key1": "www.example.invalid",
"key2": "https://www.example.invalid/index.html",
"data": "{\"url\": \"https://www.example.invalid/index.html\"}",
"create_at": "2026-01-02T08:00:00",
"task_id": 9876,
"create_at2": "2026-01-02 08:00:00",
"end_at": null,
"state": "pending",
"ret": null,
"progress": null
}
]
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/jobs" \
--header "access-token: YOUR_ACCESS_TOKEN"