1 | |
2 |
|
3 | import * as wmill from "windmill-client" |
4 |
|
5 | |
6 | wmill.OpenAPI.interceptors.response.use(async (response) => { |
7 | if (!response.ok) { |
8 | throw new Error(`${response.status} ${await response.text()}`) |
9 | } |
10 | return response |
11 | }) |
12 |
|
13 | export type DynSelect_path = string |
14 |
|
15 | export async function path() { |
16 | const variables = await wmill.VariableService.listVariable({ |
17 | workspace: wmill.getWorkspace(), |
18 | perPage: 1000, |
19 | }) |
20 | return variables.map((v) => ({ value: v.path, label: v.path })) |
21 | } |
22 |
|
23 | |
24 | * Update Variable |
25 | * Update a variable's value, description or path. Fields left empty keep their current value; whether it is a secret is left unchanged. |
26 | */ |
27 | export async function main( |
28 | path: DynSelect_path, |
29 | value: string | undefined, |
30 | description: string | undefined, |
31 | new_path: string | undefined |
32 | ) { |
33 | return await wmill.VariableService.updateVariable({ |
34 | workspace: wmill.getWorkspace(), |
35 | path, |
36 | requestBody: { |
37 | value: value || undefined, |
38 | description: description || undefined, |
39 | path: new_path || undefined, |
40 | }, |
41 | }) |
42 | } |
43 |
|