1 | |
2 | * list all available queued jobs |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | order_desc: string | undefined, |
8 | created_by: string | undefined, |
9 | parent_job: string | undefined, |
10 | script_path_exact: string | undefined, |
11 | script_path_start: string | undefined, |
12 | schedule_path: string | undefined, |
13 | script_hash: string | undefined, |
14 | started_before: string | undefined, |
15 | started_after: string | undefined, |
16 | success: string | undefined, |
17 | job_kinds: string | undefined, |
18 | suspended: string | undefined, |
19 | running: string | undefined, |
20 | args: string | undefined, |
21 | result: string | undefined, |
22 | tag: string | undefined |
23 | ) { |
24 | const url = new URL(`${BASE_URL}/api/w/${workspace}/jobs/queue/list`); |
25 | for (const [k, v] of [ |
26 | ["order_desc", order_desc], |
27 | ["created_by", created_by], |
28 | ["parent_job", parent_job], |
29 | ["script_path_exact", script_path_exact], |
30 | ["script_path_start", script_path_start], |
31 | ["schedule_path", schedule_path], |
32 | ["script_hash", script_hash], |
33 | ["started_before", started_before], |
34 | ["started_after", started_after], |
35 | ["success", success], |
36 | ["job_kinds", job_kinds], |
37 | ["suspended", suspended], |
38 | ["running", running], |
39 | ["args", args], |
40 | ["result", result], |
41 | ["tag", tag], |
42 | ]) { |
43 | if (v !== undefined) { |
44 | url.searchParams.append(k, v); |
45 | } |
46 | } |
47 | const response = await fetch(url, { |
48 | method: "GET", |
49 | headers: { |
50 | Authorization: "Bearer " + WM_TOKEN, |
51 | }, |
52 | body: undefined, |
53 | }); |
54 | return await response.json(); |
55 | } |
56 |
|