Edits history of script submission #23557 for ' Create Folder (windmill)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    import * as wmill from "windmill-client"
    
    // windmill-client errors only carry the status text: throw the response body, which says why
    wmill.OpenAPI.interceptors.response.use(async (response) => {
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
      return response
    })
    
    /**
     * Create Folder
     * Create a folder. Its owners can manage it and everything under it; add more people with Add User to Folder.
     */
    export async function main(
      name: string,
      summary: string | undefined,
      owners: string[] | undefined
    ) {
      return await wmill.FolderService.createFolder({
        workspace: wmill.getWorkspace(),
        requestBody: {
          name,
          summary: summary || undefined,
          owners: owners?.length ? owners : undefined,
        },
      })
    }
    

    Submitted by hugo989 5 hours ago