Edits history of script submission #23561 for ' Create Variable (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 Variable
     * Create a variable, optionally stored encrypted as a secret.
     */
    export async function main(
      path: string,
      value: string,
      is_secret: boolean,
      description: string | undefined
    ) {
      return await wmill.VariableService.createVariable({
        workspace: wmill.getWorkspace(),
        requestBody: {
          path,
          value,
          is_secret: is_secret ?? false,
          description: description ?? "",
        },
      })
    }
    

    Submitted by hugo989 5 hours ago