update instance group

Script windmill Verified

by hugo697 ยท 3/6/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * update instance group
3
 *
4
 */
5
export async function main(
6
  name: string,
7
  body: { new_summary: string; [k: string]: unknown }
8
) {
9
  const url = new URL(`${BASE_URL}/api/groups/update/${name}`);
10

11
  const response = await fetch(url, {
12
    method: "POST",
13
    headers: {
14
      "Content-Type": "application/json",
15
      Authorization: "Bearer " + WM_TOKEN,
16
    },
17
    body: JSON.stringify(body),
18
  });
19
  if (!response.ok) {
20
    const text = await response.text();
21
    throw new Error(`${response.status} ${text}`);
22
  }
23
  return await response.text();
24
}
25