0

List Jobs

by
Published 6 days ago

List jobs (queued, running and completed), newest first, with optional filters on path, creator, status and start time.

Script windmill Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 7 days ago
1
//native
2

3
import * as wmill from "windmill-client"
4

5
// windmill-client errors only carry the status text: throw the response body, which says why
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 Jobs
15
 * List jobs (queued, running and completed), newest first, with optional filters on path, creator, status and start time.
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
  status: "any" | "success" | "failure" | "canceled" | "skipped" = "any",
23
  started_after: string | undefined,
24
  started_before: string | undefined,
25
  per_page: number | undefined
26
) {
27
  return await wmill.JobService.listJobs({
28
    workspace: wmill.getWorkspace(),
29
    scriptPathExact: script_path_exact || undefined,
30
    scriptPathStart: script_path_start || undefined,
31
    schedulePath: schedule_path || undefined,
32
    createdBy: created_by || undefined,
33
    status: !status || status === "any" ? undefined : status,
34
    startedAfter: started_after || undefined,
35
    startedBefore: started_before || undefined,
36
    perPage: per_page ?? undefined,
37
  })
38
}
39