Added command gam <UserTypeEntity> print diskusage to display disk usage by folder.

This commit is contained in:
Ross Scroggs
2023-08-10 11:06:40 -07:00
parent 790d38b646
commit ae4578758a
11 changed files with 327 additions and 5 deletions

View File

@@ -10,6 +10,16 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation.
### 6.62.05
Added progress messages (suppressible) to `gam <UserTypeEntity> print diskusage`.
### 6.62.04
Added command `gam <UserTypeEntity> print diskusage` to display disk usage by folder.
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Files-Display#display-disk-usage
### 6.62.03
Handled Google Directory API bug in `gam print groups` that caused a trap.

View File

@@ -329,7 +329,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 6.62.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.62.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.10.8 64-bit final
MacOS High Sierra 10.13.6 x86_64
@@ -969,7 +969,7 @@ writes the credentials into the file oauth2.txt.
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
C:\GAMADV-XTD3>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 6.62.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.62.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.11.4 64-bit final
Windows-10-10.0.17134 AMD64
@@ -1234,6 +1234,8 @@ Section: DEFAULT
num_threads = 5
oauth2_txt = oauth2.txt ; C:\GAMConfig\oauth2.txt
oauth2service_json = oauth2service.json ; C:\GAMConfig\oauth2service.json
output_dateformat = ''
output_timeformat = ''
people_max_results = 100
quick_cros_move = false
quick_info_user = False

View File

@@ -53,6 +53,7 @@ use the `returnnameonly` option to have GAM display just the profile name of the
This will be useful in scripts that create|update a profile and then want to perform subsequent GAM commands that
reference the profile.
```
gam delete inboundssoprofile <SSOProfileItem>
```

View File

@@ -11,3 +11,5 @@ Thank you.
* Amado Tejada - https://github.com/amadotejada/GAMpass
* Workspace Admins YouTube Channel - https://youtube.com/@googleworkspaceadmins
* Goldy Arora - https://www.goldyarora.com/license-notifier/
* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Tutorials https://www.youtube.com/watch?v=g9LDeyXQNLI&list=PL_dLiK09pJVhKJxZHNk9CHK0q5hkZ856w
* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Course on Udemy https://taming.tech/GAMCourse

View File

@@ -28,6 +28,7 @@
- [File selection starting point for Display file list](#file-selection-starting-point-for-display-file-list)
- [File selection with a particular drive label](#file-selection-with-a-particular-drive-label)
- [Handle empty file lists](#handle-empty-file-lists)
- [Display disk usage](#display-disk-usage)
## API documentation
* https://developers.google.com/drive/api/v3/reference/files
@@ -1350,3 +1351,93 @@ Got 0 Drive Files/Folders that matched query ('me' in owners and name contains '
$ more Files.csv
BadNews-NoData
```
## Display disk usage
```
gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
[anyowner|(showownedby any|me|others)]
[pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
(addcsvdata <FieldName> <String>)*
[noprogress] [show all|summary|summaryandtrash]
```
For each folder in `<DiskFileEntity>`, the following items are displayed:
* `User` - The email address of the user in `<UserTypeEntity>`
* `Owner` - The email address of the owner of the folder; omitted when displaying disk usage on Shared Drives
* `ownedByMe` - True if the folder is owned by `User`, False otherwise; omitted when displaying disk usage on Shared Drives
* `id` - The folder ID
* `name` - The Folder name
* `trashed` - True if the folder has been trashed, either explicitly or from a trashed parent folder, False otherwise
* `explicitlyTrashed` - True if the folder has been explicitly trashed, as opposed to recursively trashed from a parent folder, False otherwise
* `directFileCount` - The number of files directly in the folder
* `directFileSize` - The sum of the sizes of the files directly in the folder
* `directFolderCount` - The number of folders directly in the folder
* `totalFileCount` - The number of files directly in the folder and all of its subfolders
* `totalFileSize` - The sum of the sizes of the files directly in the folder and all of its subfolders
* `totalFolderCount` - The number of folders directly in the folder and all of its subfolders
* `path` - The path of the folder
There is a final row detailing files and folders in the trash; it is omitted if `excludetrashed` or `show summary` are specified.
* `User` - The email address of the user in `<UserTypeEntity>`
* `Owner` - The email address of the user in `<UserTypeEntity>`
* `ownedByMe` - True
* `id` - Trash
* `name` - Trash
* `trashed` - True if there are any items in the trash
* `explicitlyTrashed` - True if any items have been explicitly trashed
* `directFileCount` - The number of explicitly trashed files
* `directFileSize` - The sum of the sizes of the explicitly trashed files
* `directFolderCount` - The number of explicitly trashed folders
* `totalFileCount` - The number of files in the trash
* `totalFileSize` - The sum of the sizes of the files in the trash
* `totalFolderCount` - The number of folders in the trash
* `path` - Trash
By default, files owned by the user are counted. These options update the current query with the desired ownership.
* `showownedby me` - Count files owned by the user; this is the default
* `showownedby any` or `anyowner` - Count files accessible by the user
* `showownedby others` - Count files not owned by the user
All folders are counted, regardless of ownership.
By default, file path components are separated by `/`; use `pathdelimiter <Character>` to use `<Character>` as the separator.
Use the `excludetrashed` option to suppress counting files and folders in the trash.
The `stripcrsfromname` option strips nulls, carriage returns and linefeeds from drive file names.
Use this option if you discover filenames containing these special characters; it is not common.
Add additional columns of data from the command line to the output:
* `addcsvdata <FieldName> <String>`
By default, progress messages are displayed for each folder, use `noprogress` to suppress these messages.
Use the `show` option to control the display of data:
* `all` - Display a row for every folder in `<DriveFileEntity>` and a row detailing items in the trash when `excludetrashed` is omitted. This is the default.
* `summary` - Display a single row for the first folder in `<DriveFileEntity>`
* `summaryandtrash` - Display a single row for the first folder in `<DriveFileEntity>` and a row detailing items in the trash when `excludetrashed` is omitted.
### Examples
```
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage mydrive
User: testsimple@domain.com, Print 1 Drive Disk Usage
$ more MyDriveUsage.csv
User,Owner,id,name,ownedByMe,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
testsimple@domain.com,testsimple@domain.com,012YenC8f12ALUk9PVA,My Drive,,False,False,100,138212,24,167,189598,79,My Drive
testsimple@domain.com,testsimple@domain.com,456YenC8f12ALfndaQ1NHc0RtUG92Y1BIUUl4bjVBRmNkWG5oakNqVVFDcXJWOHNmdFlwZmc,Classroom,True,False,False,0,0,15,9,6840,17,My Drive/Classroom
...
testsimple@domain.com,testsimple@domain.com,1bHS_Tp77W3KSGRNSs_jP1RhAJhIGRCaI,XferFolder,True,False,False,1,1024,0,1,1024,0,My Drive/XferFolder
testsimple@domain.com,testsimple@domain.com,Trash,Trash,,True,True,0,0,1,3,3072,9,Trash
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage mydrive show summaryandtrash
User: testsimple@domain.com, Print 1 Drive Disk Usage
$ more MyDriveUsage.csv
User,Owner,id,name,ownedByMe,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
testsimple@domain.com,testsimple@domain.com,012YenC8f12ALUk9PVA,My Drive,,False,False,100,138212,24,167,189598,79,My Drive
testsimple@domain.com,testsimple@domain.com,Trash,Trash,,True,True,0,0,1,3,3072,9,Trash
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage shareddriveid 0AL5LiIe4dqxZUk9PVA show summaryandtrash
User: testsimple@domain.com, Print 1 Drive Disk Usage
$ more MyDriveUsage.csv
User,id,name,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
testsimple@domain.com,0125LiIe4dqxZUk9PVA,TS Shared Drive 1,False,False,16,6144,7,42,73799,25,SharedDrives/TS Shared Drive 1
testsimple@domain.com,Trash,Trash,True,True,1,1024,0,1,1024,0,Trash
```

View File

@@ -69,7 +69,7 @@ Alternatively, you can direct the output to a CSV file:
To retrieve the shortcut ID with `returnidonly`:
```
Linux/MacOS
fileId=`gam user user@domain.com create drivefileshortcut ... returnidonly`
fileId=$(gam user user@domain.com create drivefileshortcut ... returnidonly)
Windows PowerShell
$fileId = & gam user user@domain.com create drivefileshortcut ... returnidonly
```