list all available jobs

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * list all available 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
  job_kinds: string | undefined,
16
  args: string | undefined,
17
  tag: string | undefined,
18
  result: string | undefined,
19
  is_skipped: string | undefined,
20
  is_flow_step: string | undefined,
21
  success: string | undefined
22
) {
23
  const url = new URL(`${BASE_URL}/api/w/${workspace}/jobs/list`);
24
  for (const [k, v] of [
25
    ["created_by", created_by],
26
    ["parent_job", parent_job],
27
    ["script_path_exact", script_path_exact],
28
    ["script_path_start", script_path_start],
29
    ["schedule_path", schedule_path],
30
    ["script_hash", script_hash],
31
    ["started_before", started_before],
32
    ["started_after", started_after],
33
    ["job_kinds", job_kinds],
34
    ["args", args],
35
    ["tag", tag],
36
    ["result", result],
37
    ["is_skipped", is_skipped],
38
    ["is_flow_step", is_flow_step],
39
    ["success", success],
40
  ]) {
41
    if (v !== undefined) {
42
      url.searchParams.append(k, v);
43
    }
44
  }
45
  const response = await fetch(url, {
46
    method: "GET",
47
    headers: {
48
      Authorization: "Bearer " + WM_TOKEN,
49
    },
50
    body: undefined,
51
  });
52
  return await response.json();
53
}
54