thread-master/apps/backend/generate/api/jobs.api

68 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "v1"
type (
JobPublic {
Id string `json:"id"`
TemplateType string `json:"template_type"`
Status string `json:"status"`
ProgressSummary string `json:"progress_summary"`
ProgressPercent int `json:"progress_percent"`
Error string `json:"error,optional"`
// 業務關聯threads 帳號 id、人設 id
RefId string `json:"ref_id,optional"`
// 任務 payload JSON{"username":"x"}
Payload string `json:"payload,optional"`
// 排程執行時間 unix ns0立刻可領
RunAfter int64 `json:"run_after,optional"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
CompletedAt int64 `json:"completed_at,optional"`
}
// tab: recurring=遠期定期排程 | active=執行中/待領取 | history=終態歷史
JobListReq {
Tab string `form:"tab,optional"`
Page int `form:"page,optional"`
PageSize int `form:"pageSize,optional"`
}
JobListData {
List []JobPublic `json:"list"`
Pagination Pagination `json:"pagination"`
}
JobIdPath {
Id string `path:"id"`
}
)
@server (
jwt: Auth
group: jobs
prefix: /api/v1/jobs
middleware: AuthJWT
)
service gateway {
@handler ListJobs
get / (JobListReq) returns (JobListData)
@handler GetJob
get /:id (JobIdPath) returns (JobPublic)
// 手動刪除任務(執行中不可刪;終態/已排程可刪)
@handler DeleteJob
delete /:id (JobIdPath) returns (OkData)
}
// 管理員:產生 demo測試任務由 demo-worker 消費)
@server (
jwt: Auth
group: jobs
prefix: /api/v1/jobs
middleware: AuthJWT,AdminAuth
)
service gateway {
@handler StartDemoJob
post /demo returns (JobPublic)
}