0

List Audit Logs

by
Published today

List the workspace's audit logs, optionally filtered by user, operation, resource and time range. Requires a workspace admin.

Script windmill Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours 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 Audit Logs
15
 * List the workspace's audit logs, optionally filtered by user, operation, resource and time range. Requires a workspace admin.
16
 */
17
export async function main(
18
  username: string | undefined,
19
  operation: string | undefined,
20
  resource: string | undefined,
21
  action_kind: "any" | "Create" | "Update" | "Delete" | "Execute" = "any",
22
  after: string | undefined,
23
  before: string | undefined,
24
  page: number | undefined,
25
  per_page: number | undefined
26
) {
27
  return await wmill.AuditService.listAuditLogs({
28
    workspace: wmill.getWorkspace(),
29
    username: username || undefined,
30
    operation: operation || undefined,
31
    resource: resource || undefined,
32
    actionKind: !action_kind || action_kind === "any" ? undefined : action_kind,
33
    after: after || undefined,
34
    before: before || undefined,
35
    page: page ?? undefined,
36
    perPage: per_page ?? undefined,
37
  })
38
}
39