0

Create Folder

by
Published today

Create a folder. Its owners can manage it and everything under it; add more people with Add User to Folder.

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
 * Create Folder
15
 * Create a folder. Its owners can manage it and everything under it; add more people with Add User to Folder.
16
 */
17
export async function main(
18
  name: string,
19
  summary: string | undefined,
20
  owners: string[] | undefined
21
) {
22
  return await wmill.FolderService.createFolder({
23
    workspace: wmill.getWorkspace(),
24
    requestBody: {
25
      name,
26
      summary: summary || undefined,
27
      owners: owners?.length ? owners : undefined,
28
    },
29
  })
30
}
31