//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 }))
}
/**
* Update Variable
* Update a variable's value, description or path. Fields left empty keep their current value; whether it is a secret is left unchanged.
*/
export async function main(
path: DynSelect_path,
value: string | undefined,
description: string | undefined,
new_path: string | undefined
) {
return await wmill.VariableService.updateVariable({
workspace: wmill.getWorkspace(),
path,
requestBody: {
value: value || undefined,
description: description || undefined,
path: new_path || undefined,
},
})
}
Submitted by hugo989 5 hours ago