1

Update Shared Drive

by
Published Jul 27, 2022
Script gdrive Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
type Gdrive = {
4
  token: string;
5
};
6
export async function main(
7
  gdrive_auth: Gdrive,
8
  driveId: string,
9
  useDomainAdminAccess: boolean = true,
10
) {
11
  const UPDATE_SHARED_DRIVE_URL = `https://www.googleapis.com/drive/v3/drives/${driveId}/?useDomainAdminAccess=${useDomainAdminAccess}`;
12

13
  const token = gdrive_auth["token"];
14

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

34
  return await response.text();
35
}
36

Other submissions
  • Submitted by rossmccrann Deno
    Created 398 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