m365ken
m365ken

Reputation: 31

Cannot Get Total Shared Drive Size using Google Drive API

We use the Drive API in a few scripts to get info on all our Shared Drives. Using the “useDomainAdminAccess” parameter in the drives list/get methods, we can get just about all drive details without adding the script account as owner on the target drives. One detail we cannot get using this method is total drive size. It appears there is no native property for drive size when querying details at the drive level. We can get a size param when querying individual files (but we must add the script account as an owner on the drive).
In summary, to get drive size we must add the script account as an owner on the drive. Then iterate through all files within the drive, getting the size param for each and adding it to a global variable which we return as total drive size at the end of the iteration. After this we remove the script account from the drive. This, of course, seems very inefficient for getting a single property.
Do we know if Google plans to include a size param within the drives.list/drives.get api, or add the “useDomainAdminAccess” param to the files.list/files.get api or maybe there is another Google API that can provide this detail with less effort (reporting / gws admin api)? Thanks

https://developers.google.com/drive/api/v3/reference/drives/list https://developers.google.com/drive/api/v3/reference/files/list

Upvotes: 3

Views: 786

Answers (1)

ale13
ale13

Reputation: 6072

You may benefit from filing a feature request on Google's Issue Tracker and provide all the necessary details there.

I suggest you fill in this template here.

As for an alternative for your current workaround, I suggest you take a look at service accounts and domain-wide delegation in order to impersonate the owner of the drive and perform the request on their behalf.

A service account is a special kind of account used by an application or a virtual machine (VM) instance, not a person. Applications use service accounts to make authorized API calls.

Reference

Upvotes: 0

Related Questions