Edits history of script submission #23552 for ' Archive or Unarchive Flow (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
    })
    
    /**
     * Archive or Unarchive Flow
     * Archive a flow by path, or bring an archived one back. Its past runs are kept either way.
     */
    export async function main(
      path: string,
      action: "archive" | "unarchive" = "archive"
    ) {
      return await wmill.FlowService.archiveFlowByPath({
        workspace: wmill.getWorkspace(),
        path,
        requestBody: { archived: action !== "unarchive" },
      })
    }
    

    Submitted by hugo989 5 hours ago