1 | |
2 |
|
3 | import * as wmill from "windmill-client" |
4 |
|
5 | |
6 | wmill.OpenAPI.interceptors.response.use(async (response) => { |
7 | if (!response.ok) { |
8 | throw new Error(`${response.status} ${await response.text()}`) |
9 | } |
10 | return response |
11 | }) |
12 |
|
13 | |
14 | * List Queued Jobs |
15 | * List jobs in the queue (waiting, running or suspended), with optional filters on path, creator and state. |
16 | */ |
17 | export async function main( |
18 | script_path_exact: string | undefined, |
19 | script_path_start: string | undefined, |
20 | schedule_path: string | undefined, |
21 | created_by: string | undefined, |
22 | state: "any" | "running" | "waiting" | "suspended" = "any", |
23 | page: number | undefined, |
24 | per_page: number | undefined |
25 | ) { |
26 | return await wmill.JobService.listQueue({ |
27 | workspace: wmill.getWorkspace(), |
28 | scriptPathExact: script_path_exact || undefined, |
29 | scriptPathStart: script_path_start || undefined, |
30 | schedulePath: schedule_path || undefined, |
31 | createdBy: created_by || undefined, |
32 | running: |
33 | state === "running" ? true : state === "waiting" ? false : undefined, |
34 | suspended: state === "suspended" ? true : undefined, |
35 | page: page ?? undefined, |
36 | perPage: per_page ?? undefined, |
37 | }) |
38 | } |
39 |
|