1 |
|
2 | * list all jobs |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | created_by: string | undefined, |
8 | parent_job: string | undefined, |
9 | script_path_exact: string | undefined, |
10 | script_path_start: string | undefined, |
11 | schedule_path: string | undefined, |
12 | script_hash: string | undefined, |
13 | started_before: string | undefined, |
14 | started_after: string | undefined, |
15 | created_or_started_before: string | undefined, |
16 | running: string | undefined, |
17 | scheduled_for_before_now: string | undefined, |
18 | created_or_started_after: string | undefined, |
19 | job_kinds: string | undefined, |
20 | args: string | undefined, |
21 | tag: string | undefined, |
22 | result: string | undefined, |
23 | is_skipped: string | undefined, |
24 | is_flow_step: string | undefined, |
25 | has_null_parent: string | undefined, |
26 | success: string | undefined, |
27 | all_workspaces: string | undefined |
28 | ) { |
29 | const url = new URL(`${BASE_URL}/api/w/${workspace}/jobs/list`); |
30 | for (const [k, v] of [ |
31 | ["created_by", created_by], |
32 | ["parent_job", parent_job], |
33 | ["script_path_exact", script_path_exact], |
34 | ["script_path_start", script_path_start], |
35 | ["schedule_path", schedule_path], |
36 | ["script_hash", script_hash], |
37 | ["started_before", started_before], |
38 | ["started_after", started_after], |
39 | ["created_or_started_before", created_or_started_before], |
40 | ["running", running], |
41 | ["scheduled_for_before_now", scheduled_for_before_now], |
42 | ["created_or_started_after", created_or_started_after], |
43 | ["job_kinds", job_kinds], |
44 | ["args", args], |
45 | ["tag", tag], |
46 | ["result", result], |
47 | ["is_skipped", is_skipped], |
48 | ["is_flow_step", is_flow_step], |
49 | ["has_null_parent", has_null_parent], |
50 | ["success", success], |
51 | ["all_workspaces", all_workspaces], |
52 | ]) { |
53 | if (v !== undefined && v !== "") { |
54 | url.searchParams.append(k, v); |
55 | } |
56 | } |
57 | const response = await fetch(url, { |
58 | method: "GET", |
59 | headers: { |
60 | Authorization: "Bearer " + WM_TOKEN, |
61 | }, |
62 | body: undefined, |
63 | }); |
64 | if (!response.ok) { |
65 | const text = await response.text(); |
66 | throw new Error(`${response.status} ${text}`); |
67 | } |
68 | return await response.json(); |
69 | } |
70 |
|