Edits history of script submission #23580 for ' Get Variable Value (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
    })
    
    export type DynSelect_path = string
    
    export async function path() {
      const variables = await wmill.VariableService.listVariable({
        workspace: wmill.getWorkspace(),
        perPage: 1000,
      })
      return variables.map((v) => ({ value: v.path, label: v.path }))
    }
    
    /**
     * Get Variable Value
     * Get the value of a variable, decrypted if it is a secret. Reading a secret is recorded in the audit log.
     */
    export async function main(path: DynSelect_path) {
      return await wmill.VariableService.getVariableValue({
        workspace: wmill.getWorkspace(),
        path,
      })
    }
    

    Submitted by hugo989 5 hours ago