0

List Queued Jobs

by
Published Jan 3, 2023

List jobs in the queue (waiting, running or suspended), with optional filters on path, creator and state.

Script windmill Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 19 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 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

Other submissions
  • Submitted by admin Deno
    Created 544 days ago
    1
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    2
    
    
    3
    export async function main(
    4
      scriptPathExact?: string,
    5
      onlySuspendedJobs: boolean
    6
    ) {
    7
      return wmill.JobService.listQueue({
    8
        workspace: wmill.getWorkspace(),
    9
        suspended: onlySuspendedJobs,
    10
        perPage: 50,
    11
        scriptPathExact,
    12
      });
    13
    }
    14