edit workspace git sync settings

Script windmill Verified

by hugo697 ยท 3/6/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * edit workspace git sync settings
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: {
8
    git_sync_settings?: {
9
      include_path?: string[];
10
      include_type?: (
11
        | "script"
12
        | "flow"
13
        | "app"
14
        | "folder"
15
        | "resource"
16
        | "variable"
17
        | "secret"
18
        | "resourcetype"
19
        | "schedule"
20
      )[];
21
      repositories?: {
22
        script_path: string;
23
        git_repo_resource_path: string;
24
        use_individual_branch?: boolean;
25
        exclude_types_override?: (
26
          | "script"
27
          | "flow"
28
          | "app"
29
          | "folder"
30
          | "resource"
31
          | "variable"
32
          | "secret"
33
          | "resourcetype"
34
          | "schedule"
35
        )[];
36
        [k: string]: unknown;
37
      }[];
38
      [k: string]: unknown;
39
    };
40
    [k: string]: unknown;
41
  }
42
) {
43
  const url = new URL(
44
    `${BASE_URL}/api/w/${workspace}/workspaces/edit_git_sync_config`
45
  );
46

47
  const response = await fetch(url, {
48
    method: "POST",
49
    headers: {
50
      "Content-Type": "application/json",
51
      Authorization: "Bearer " + WM_TOKEN,
52
    },
53
    body: JSON.stringify(body),
54
  });
55
  if (!response.ok) {
56
    const text = await response.text();
57
    throw new Error(`${response.status} ${text}`);
58
  }
59
  return await response.json();
60
}
61