From 4f8c80dcabee9bf1e9a1e728a3767f2349bcd477 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Tue, 27 May 2025 13:21:43 -0700 Subject: [PATCH] Added option `showitemcountonly` to `gam [] print|show shareddrives` --- wiki/GamUpdates.md | 5 ++ wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md | 4 +- wiki/Shared-Drives.md | 67 +++++++++++++++++++---- wiki/Users-Shared-Drives.md | 30 ++++++++++ wiki/Version-and-Help.md | 12 ++-- 5 files changed, 100 insertions(+), 18 deletions(-) diff --git a/wiki/GamUpdates.md b/wiki/GamUpdates.md index 952d10b0..93504a14 100644 --- a/wiki/GamUpdates.md +++ b/wiki/GamUpdates.md @@ -10,6 +10,11 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads-Installs-GAM7](https://github.com/GAM-team/GAM/wiki/Downloads-Installs) for Windows or other options, including manual installation +### 7.07.13 + +Added option `showitemcountonly` to `gam [] print|show shareddrives` that causes GAM to display the +number of Shared Drives on stdout; no CSV file is written. + ### 7.07.12 Fixed bug in `gam print|show oushareddrives` that caused a trap. diff --git a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md index cabbd6be..92da6730 100644 --- a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md +++ b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md @@ -251,7 +251,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAM 7.07.12 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.07.13 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final MacOS Sequoia 15.5 x86_64 @@ -989,7 +989,7 @@ writes the credentials into the file oauth2.txt. C:\>del C:\GAMConfig\oauth2.txt C:\>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAM 7.07.12 - https://github.com/GAM-team/GAM - pythonsource +GAM 7.07.13 - https://github.com/GAM-team/GAM - pythonsource GAM Team Python 3.13.3 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/wiki/Shared-Drives.md b/wiki/Shared-Drives.md index 78dd05d8..0a21db62 100644 --- a/wiki/Shared-Drives.md +++ b/wiki/Shared-Drives.md @@ -12,8 +12,9 @@ - [Delete a Shared Drive](#delete-a-shared-drive) - [Change Shared Drive visibility](#change-shared-drive-visibility) - [Display Shared Drives](#display-shared-drives) -- [Display List of Shared Drives in an Organizational Unit other than /](#display-list-of-shared-drives-in-an-organizational-unit-other-than-) +- [Display Shared Drive Counts](#display-shared-drive-counts) - [Display List of Shared Drives in an Organizational Unit](#display-list-of-shared-drives-in-an-organizational-unit) +- [Display Count of Shared Drives in an Organizational Unit](#display-count-of-shared-drives-in-an-organizational-unit) - [Display all Shared Drives with no members](#display-all-shared-drives-with-no-members) - [Display all Shared Drives with no organizers](#display-all-shared-drives-with-no-organizers) - [Display all Shared Drives with a specific organizer](#display-all-shared-drives-with-a-specific-organizer) @@ -416,6 +417,36 @@ gam print teamdrives query "memberCount = 0" gam print teamdrives query "organizerCount = 0" ``` +## Display Shared Drive Counts +Display the number of Shared Drives. +``` +gam [] show|print shareddrives + [adminaccess|asadmin] [teamdriveadminquery|query ] + [matchname ] [orgunit|org|ou ] + showitemcountonly +``` +By default, all Shared Drives are counted; use the following options to select a subset of Shared Drives: +* `teamdriveadminquery|query ` - Use a query to select Shared Drives +* `matchname ` - Retrieve Shared Drives with names that match a pattern. +* `orgunit|org|ou ` - Only Shared Drives in the specified Org Unit are selected + +Example +``` +$ gam print shareddrives showitemcountonly +Getting all Shared Drives, may take some time on a large Google Workspace Account... +Got 12 Shared Drives... +12 +``` +The `Getting` and `Got` messages are written to stderr, the count is writtem to stdout. + +To retrieve the count with `showitemcountonly`: +``` +Linux/MacOS +count=$(gam print shareddrives showitemcountonly) +Windows PowerShell +count = & gam print shareddrives showitemcountonly +``` + ## Display all Shared Drives with a specific organizer Substitute actual email address for `organizer@domain.com`. ``` @@ -428,18 +459,9 @@ Substitute actual email address for `organizer@domain.com`. gam config csv_output_header_filter "id,name" print teamdriveacls pm emailaddress organizer@domain.com role organizer em pma skip pmselect ``` -## Display List of Shared Drives in an Organizational Unit other than / -Get the orgUnitID of OU / and use it (without the id:) in the print|show command. Adjust fields as desired. -``` -gam info ou / nousers -gam show teamdrives query "orgUnitId!='00gjdgxs2p9cxyz'" fields id,name,orgunit,createdtime -gam print teamdrives query "orgUnitId!='00gjdgxs2p9cxyz'" fields id,name,orgunit,createdtime -``` - ## Display List of Shared Drives in an Organizational Unit Get the orgUnitID of the desired OU and use it (without the id:) in the print|show command. Adjust fields as desired. ``` -gam info ou nousers gam show teamdrives query "orgUnitId='03ph8a2z21rexy'" fields id,name,orgunit,createdtime gam print teamdrives query "orgUnitId='03ph8a2z21rexy'" fields id,name,orgunit,createdtime ``` @@ -453,6 +475,31 @@ gam print oushareddrives [todrive *] [formatjson [quotechar ]] ``` +## Display Count of Shared Drives in an Organizational Unit +``` +gam print|show oushareddrives + [ou|org|orgunit ] + showitemcountonly +``` +`` defaults to `"/"`. + +Example +``` +$ gam print oushareddrives showitemcountonly +Getting all Shared Drives for /, may take some time on a large Organizational Unit... +Got 9 Shared Drives for /... +9 +``` +The `Getting` and `Got` messages are written to stderr, the count is writtem to stdout. + +To retrieve the count with `showitemcountonly`: +``` +Linux/MacOS +count=$(gam print oushareddrives showitemcountonly) +Windows PowerShell +count = & gam print oushareddrives showitemcountonly +``` + ## Manage Shared Drive access These commands are used to manage the ACLs on Shared Drives themselves, not the files/folders on the Shared Drives. diff --git a/wiki/Users-Shared-Drives.md b/wiki/Users-Shared-Drives.md index 40fddb45..3cf5dd07 100644 --- a/wiki/Users-Shared-Drives.md +++ b/wiki/Users-Shared-Drives.md @@ -11,6 +11,7 @@ - [Delete a Shared Drive](#delete-a-shared-drive) - [Change Shared Drive visibility](#change-shared-drive-visibility) - [Display Shared Drives](#display-shared-drives) +- [Display Shared Drive Counts](#display-shared-drive-counts) - [Manage Shared Drive access](#manage-shared-drive-access) - [Display Shared Drive access](#display-shared-drive-access) - [Display Shared Drive access for specific Shared Drives](#display-shared-drive-access-for-specific-shared-drives) @@ -356,6 +357,35 @@ When using the `formatjson` option, double quotes are used extensively in the da The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. +## Display Shared Drive Counts +Display the number of Shared Drives. +``` +gam show|print shareddrives + [teamdriveadminquery|query ] + [matchname ] [orgunit|org|ou ] + showitemcountonly +``` +By default, all Shared Drives are counted; use the following options to select a subset of Shared Drives: +* `teamdriveadminquery|query ` - Use a query to select Shared Drives +* `matchname ` - Retrieve Shared Drives with names that match a pattern. +* `orgunit|org|ou ` - Only Shared Drives in the specified Org Unit are selected + +Example +``` +$ gam user user@domain.com print shareddrives showitemcountonly +Getting all Shared Drives for user@domain.com +Got 4 Shared Drives for user@domain.com ... +4 +``` +The `Getting` and `Got` messages are written to stderr, the count is writtem to stdout. + +To retrieve the count with `showitemcountonly`: +``` +Linux/MacOS +count=$(gam user user@domain.com print shareddrives showitemcountonly) +Windows PowerShell +count = & gam user user@domain.com print shareddrives showitemcountonly +``` ## Manage Shared Drive access These commands must be issued by a user with Shared Drive permission role organizer. ### Process single ACLs. diff --git a/wiki/Version-and-Help.md b/wiki/Version-and-Help.md index 502caf23..bac00d9b 100644 --- a/wiki/Version-and-Help.md +++ b/wiki/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAM 7.07.12 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.07.13 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final MacOS Sequoia 15.5 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAM 7.07.12 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.07.13 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final MacOS Sequoia 15.5 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAM 7.07.12 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.07.13 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final MacOS Sequoia 15.5 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gam7 Version Check: Current: 5.35.08 - Latest: 7.07.12 + Latest: 7.07.13 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -7.07.12 +7.07.13 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 7.07.12 - https://github.com/GAM-team/GAM +GAM 7.07.13 - https://github.com/GAM-team/GAM GAM Team Python 3.13.3 64-bit final MacOS Sequoia 15.5 x86_64