807 lines
19 KiB
YAML
807 lines
19 KiB
YAML
basePath: /api/v1
|
|
definitions:
|
|
utils.PaginationData:
|
|
properties:
|
|
list: {}
|
|
page:
|
|
type: integer
|
|
page_size:
|
|
type: integer
|
|
total:
|
|
type: integer
|
|
type: object
|
|
utils.Response:
|
|
properties:
|
|
code:
|
|
type: integer
|
|
data: {}
|
|
msg:
|
|
type: string
|
|
type: object
|
|
vo.EnvVO:
|
|
properties:
|
|
created_at:
|
|
type: string
|
|
hidden:
|
|
type: boolean
|
|
id:
|
|
type: string
|
|
name:
|
|
type: string
|
|
remark:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
value:
|
|
type: string
|
|
type: object
|
|
vo.ExecutionResultVO:
|
|
properties:
|
|
duration:
|
|
type: integer
|
|
end_time:
|
|
type: string
|
|
error:
|
|
type: string
|
|
exit_code:
|
|
type: integer
|
|
log_id:
|
|
type: string
|
|
output:
|
|
type: string
|
|
start_time:
|
|
type: string
|
|
status:
|
|
type: string
|
|
success:
|
|
type: boolean
|
|
task_id:
|
|
type: string
|
|
type: object
|
|
vo.TaskLogVO:
|
|
properties:
|
|
agent_id:
|
|
type: string
|
|
command:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
duration:
|
|
type: integer
|
|
end_time:
|
|
type: string
|
|
error:
|
|
type: string
|
|
exit_code:
|
|
type: integer
|
|
id:
|
|
type: string
|
|
output:
|
|
type: string
|
|
start_time:
|
|
type: string
|
|
status:
|
|
type: string
|
|
task_id:
|
|
type: string
|
|
task_name:
|
|
type: string
|
|
task_type:
|
|
type: string
|
|
type: object
|
|
vo.TaskVO:
|
|
properties:
|
|
agent_id:
|
|
type: string
|
|
clean_config:
|
|
type: string
|
|
command:
|
|
type: string
|
|
config:
|
|
type: string
|
|
created_at:
|
|
type: string
|
|
enabled:
|
|
type: boolean
|
|
envs:
|
|
type: string
|
|
id:
|
|
type: string
|
|
languages:
|
|
items:
|
|
additionalProperties:
|
|
type: string
|
|
type: object
|
|
type: array
|
|
last_run:
|
|
type: string
|
|
name:
|
|
type: string
|
|
next_run:
|
|
type: string
|
|
random_range:
|
|
type: integer
|
|
retry_count:
|
|
type: integer
|
|
retry_interval:
|
|
type: integer
|
|
schedule:
|
|
type: string
|
|
tags:
|
|
type: string
|
|
timeout:
|
|
type: integer
|
|
trigger_type:
|
|
type: string
|
|
type:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
work_dir:
|
|
type: string
|
|
type: object
|
|
host: localhost:8052
|
|
info:
|
|
contact:
|
|
email: support@swagger.io
|
|
name: API Support
|
|
url: http://www.swagger.io/support
|
|
description: Baihu Panel API Server documentation.
|
|
license:
|
|
name: Apache 2.0
|
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
|
termsOfService: http://swagger.io/terms/
|
|
title: Baihu Panel API
|
|
version: "1.0"
|
|
paths:
|
|
/env:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 分页获取环境变量列表,支持按名称筛选
|
|
parameters:
|
|
- description: 按名称模糊查询
|
|
in: query
|
|
name: name
|
|
type: string
|
|
- description: 页码
|
|
in: query
|
|
name: page
|
|
type: integer
|
|
- description: 每页数量
|
|
in: query
|
|
name: page_size
|
|
type: integer
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.PaginationData'
|
|
- properties:
|
|
list:
|
|
items:
|
|
$ref: '#/definitions/vo.EnvVO'
|
|
type: array
|
|
type: object
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取环境变量列表
|
|
tags:
|
|
- 环境变量
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: 创建新的环境变量
|
|
parameters:
|
|
- description: 环境变量信息
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.EnvVO'
|
|
type: object
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 创建环境变量
|
|
tags:
|
|
- 环境变量
|
|
/env/{id}:
|
|
delete:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 删除环境变量,支持强制删除
|
|
parameters:
|
|
- description: 环境变量ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: 是否强制删除
|
|
in: query
|
|
name: force
|
|
type: boolean
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
"409":
|
|
description: 引用冲突
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/vo.TaskVO'
|
|
type: array
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 删除环境变量
|
|
tags:
|
|
- 环境变量
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 获取环境变量详情
|
|
parameters:
|
|
- description: 环境变量ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.EnvVO'
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取环境变量详情
|
|
tags:
|
|
- 环境变量
|
|
put:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 更新环境变量信息
|
|
parameters:
|
|
- description: 环境变量ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: 更新信息
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.EnvVO'
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 更新环境变量
|
|
tags:
|
|
- 环境变量
|
|
/env/{id}/tasks:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 获取引用了该环境变量的任务列表
|
|
parameters:
|
|
- description: 环境变量ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/vo.TaskVO'
|
|
type: array
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取关联任务
|
|
tags:
|
|
- 环境变量
|
|
/env/all:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 获取当前用户的所有环境变量(不分页)
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/vo.EnvVO'
|
|
type: array
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取所有环境变量
|
|
tags:
|
|
- 环境变量
|
|
/execute/command:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: 临时执行单次命令
|
|
parameters:
|
|
- description: 命令内容 (需包含 command 字段)
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.ExecutionResultVO'
|
|
type: object
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 执行命令
|
|
tags:
|
|
- 任务执行
|
|
/execute/results:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 获取最新任务或命令执行的结果列表
|
|
parameters:
|
|
- description: 数量 (默认 10)
|
|
in: query
|
|
name: count
|
|
type: integer
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/vo.ExecutionResultVO'
|
|
type: array
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取最新执行结果
|
|
tags:
|
|
- 任务执行
|
|
/execute/task/{id}:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: 立即执行指定的任务
|
|
parameters:
|
|
- description: 任务ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: '执行参数 (envs: 环境变量字典)'
|
|
in: body
|
|
name: body
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.ExecutionResultVO'
|
|
type: object
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 运行任务
|
|
tags:
|
|
- 任务
|
|
/logs:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 分页获取任务日志列表,支持按任务 ID、任务名称、状态筛选
|
|
parameters:
|
|
- description: 任务 ID
|
|
in: query
|
|
name: task_id
|
|
type: string
|
|
- description: 任务名称
|
|
in: query
|
|
name: task_name
|
|
type: string
|
|
- description: 状态
|
|
in: query
|
|
name: status
|
|
type: string
|
|
- description: 页码
|
|
in: query
|
|
name: page
|
|
type: integer
|
|
- description: 每页数量
|
|
in: query
|
|
name: page_size
|
|
type: integer
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.PaginationData'
|
|
- properties:
|
|
list:
|
|
items:
|
|
$ref: '#/definitions/vo.TaskLogVO'
|
|
type: array
|
|
type: object
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取任务日志列表
|
|
tags:
|
|
- 日志
|
|
/logs/{id}:
|
|
delete:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 删除单条任务日志
|
|
parameters:
|
|
- description: 日志ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 删除日志
|
|
tags:
|
|
- 日志
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 获取任务日志详细内容(包含输出)
|
|
parameters:
|
|
- description: 日志ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.TaskLogVO'
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取日志详情
|
|
tags:
|
|
- 日志
|
|
/logs/clear:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: 清空所有日志或指定任务的日志
|
|
parameters:
|
|
- description: 清空范围信息
|
|
in: body
|
|
name: body
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 清空日志
|
|
tags:
|
|
- 日志
|
|
/tasks:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 分页获取任务列表,支持按名称、Agent ID、标签、类型筛选
|
|
parameters:
|
|
- description: 任务名称
|
|
in: query
|
|
name: name
|
|
type: string
|
|
- description: Agent ID
|
|
in: query
|
|
name: agent_id
|
|
type: string
|
|
- description: 标签
|
|
in: query
|
|
name: tags
|
|
type: string
|
|
- description: 任务类型
|
|
in: query
|
|
name: type
|
|
type: string
|
|
- description: 页码
|
|
in: query
|
|
name: page
|
|
type: integer
|
|
- description: 每页数量
|
|
in: query
|
|
name: page_size
|
|
type: integer
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.PaginationData'
|
|
- properties:
|
|
list:
|
|
items:
|
|
$ref: '#/definitions/vo.TaskVO'
|
|
type: array
|
|
type: object
|
|
type: object
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取任务列表
|
|
tags:
|
|
- 任务
|
|
/tasks/{id}:
|
|
delete:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 删除任务
|
|
parameters:
|
|
- description: 任务ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 删除任务
|
|
tags:
|
|
- 任务
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 获取任务详情
|
|
parameters:
|
|
- description: 任务ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.TaskVO'
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 获取任务详情
|
|
tags:
|
|
- 任务
|
|
put:
|
|
consumes:
|
|
- application/json
|
|
description: 根据 ID 更新任务信息
|
|
parameters:
|
|
- description: 任务ID
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: 任务更新信息
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: object
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.Response'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/vo.TaskVO'
|
|
type: object
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 更新任务
|
|
tags:
|
|
- 任务
|
|
/tasks/stop/{logID}:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: 根据运行日志 ID 停止正在执行的任务
|
|
parameters:
|
|
- description: 运行日志ID
|
|
in: path
|
|
name: logID
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/utils.Response'
|
|
security:
|
|
- ApiKeyAuth: []
|
|
summary: 停止任务
|
|
tags:
|
|
- 任务
|
|
securityDefinitions:
|
|
ApiKeyAuth:
|
|
in: header
|
|
name: Authorization
|
|
type: apiKey
|
|
swagger: "2.0"
|