I want to get or set restrictions value in Drive.Drives.list

Asked 2 years ago, Updated 2 years ago, 43 views

Drive.Drives.list({pageToken:pageToken, maxResults:100, useDomainAdminAccess:true});
I was able to get the id and name values from the return values that get, but I cannot get the restrictions and I cannot set them.
How can I retrieve and configure it?

Dear Tanaike, Thank you for your reply.
I was able to get it.
I would like to ask you more information, but the reply in the comment was not enough characters, so I will write it down here.

Similarly, I would like to set restrictions, but I tried several Drives.update in the following pattern, but it doesn't work.
I'm sorry, but could you tell me how to set it up?

For 1, the following error occurs:

GoogleJsonResponseException: The requesting user does not have the administrator privilege required to manage the shared drive0ADwtxWXOI0f9Uk9PVA.

For 2, the condition appears to have been ignored.

Here's the code I tried:

//1
    var updateResources={
      useDomainAdminAccess: true,
      name: "New Name",
      restrictions: {
        adminManagedRestrictions: true,
        domainUsersOnly: true,
        driveMembersOnly: true,
        copyRequiresWriterPermission: true
      },
      fields: "items(name, restrictions)"
    }; 
    varres_update=Drive.Drives.update(updateResources,driveID);

    // 2
    var updateResources={
      useDomainAdminAccess: true,
      name: "New Name",
      fields: "items(name, restrictions)"
    }; 
    var updateOptions = {
      restrictions: {
        adminManagedRestrictions: true,
        domainUsersOnly: true,
        driveMembersOnly: true,
        copyRequiresWriterPermission: true
      }
    };
    varres_update = Drive.Drives.update(updateResources, driveID, updateOptions);

Thank you for your cooperation.

google-apps-script

2022-09-30 10:42

1 Answers

Drive.Drives.list only returns id,name,kind as the default.Therefore, fields must be used to obtain restrictions.At this time, you can choose to retrieve all properties, or to retrieve certain properties.

To retrieve all properties

Drive.Drives.list ({pageToken:pageToken, maxResults:100, useDomainAdminAccess:true, fields:"*"});

To retrieve specific properties

Drive.Drives.list({pageToken:pageToken,maxResults:100,useDomainAdminAccess:true,fields:"items(name,restrictions,id),nextPageToken});
  • In this case, name, restrictions, id, nextPageToken is returned.

Reference


2022-09-30 10:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.