0

List Users

by
Published Sep 1, 2023

List the users of the workspace with their roles and groups. 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 Users
15
 * List the users of the workspace with their roles and groups. Requires a workspace admin.
16
 */
17
export async function main() {
18
  return await wmill.UserService.listUsers({
19
    workspace: wmill.getWorkspace(),
20
  })
21
}
22

Other submissions
  • Submitted by sindre svendby964 Deno
    Created 1089 days ago
    1
    // import * as wmill from "npm:windmill-client@1"
    2
    
    
    3
    export async function main() {
    4
      const workspace = Deno.env.get("WM_WORKSPACE");
    5
      const baseUrl = Deno.env.get("WM_BASE_URL");
    6
      const url = `${baseUrl}/api/w/${workspace}/users/list`;
    7
      const response = await fetch(url, {
    8
        headers: {
    9
          Authorization: "Bearer " + Deno.env.get("WM_TOKEN") || "",
    10
        },
    11
      });
    12
    
    
    13
      if (response.statusText.toUpperCase() != "OK") {
    14
        let errorMsg: string;
    15
        if (response.headers.get("Content-Type")?.includes("json")) {
    16
          errorMsg = await response.json();
    17
        } else {
    18
          errorMsg = await response.text();
    19
        }
    20
        throw new Error(`${response.status} ${response.statusText}: ${errorMsg}`);
    21
      }
    22
      const jsonData = await response.json();
    23
      return jsonData;
    24
    }
    25