1
Update Shared Drive
One script reply has been approved by the moderators Verified
Created by rossmccrann 631 days ago Viewed 4364 times
0
Submitted by rossmccrann Deno
Verified 631 days ago
1
type Gdrive = {
2
  token: string;
3
};
4
export async function main(
5
  gdrive_auth: Gdrive,
6
  driveId: string,
7
  useDomainAdminAccess: boolean = true,
8
) {
9
  const UPDATE_SHARED_DRIVE_URL = `https://www.googleapis.com/drive/v3/drives/${driveId}/?useDomainAdminAccess=${useDomainAdminAccess}`;
10

11
  const token = gdrive_auth["token"];
12

13
  const body = {
14
    name: "Update Drive Test",
15
    restrictions: {
16
      adminManagedRestrictions: false,
17
      copyRequiresWriterPermission: false,
18
      domainUsersOnly: false,
19
      driveMembersOnly: false,
20
    },
21
    colorRgb: "#ff0000",
22
  };
23
  const response = await fetch(UPDATE_SHARED_DRIVE_URL, {
24
    method: "PATCH",
25
    body: JSON.stringify(body),
26
    headers: {
27
      Authorization: "Bearer " + token,
28
      "Content-Type": "application/json",
29
    },
30
  });
31

32
  return await response.text();
33
}
34