From 626eb1eadc366ee4cd952b97e4f35ccf58d17e1b Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Mon, 30 Jun 2025 09:43:32 -0700 Subject: [PATCH] Added option `showwebviewlink` to `gam print|show shareddrives` --- src/GamCommands.txt | 4 ++++ src/GamUpdate.txt | 5 +++++ src/gam/__init__.py | 21 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 640c69c8..f19b2790 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -4817,11 +4817,13 @@ gam print shareddrives [todrive *] [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [noorgunits []] + [showwebviewlink] [formatjson [quotechar ]] gam show shareddrives [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [noorgunits []] + [showwebviewlink] [formatjson] [noorgunits []] gam print shareddriveorganizers [todrive *] @@ -4902,12 +4904,14 @@ gam print shareddrives [todrive *] [matchname ] [orgunit|org|ou ] (role|roles )* [fields ] + [showwebviewlink] [guiroles []] [formatjson [quotechar ]] gam show shareddrives [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] (role|roles )* [fields ] + [showwebviewlink] [guiroles []] [formatjson] ::= diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index d0e46acf..990ec558 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,8 @@ +7.10.09 + +Added option `showwebviewlink` to `gam [] print|show shareddrives` that +displays the web view link for the Shared Drive: `https://drive.google.com/drive/folders/`. + 7.10.08 Fixed bug in commands that modify messages where the `labelids ` option diff --git a/src/gam/__init__.py b/src/gam/__init__.py index a449ba38..e3ba684b 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki """ __author__ = 'GAM Team ' -__version__ = '7.10.08' +__version__ = '7.10.09' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' #pylint: disable=wrong-import-position @@ -65800,7 +65800,7 @@ def _showSharedDrive(user, shareddrive, j, jcount, FJQC): printKeyValueList(['hidden', shareddrive['hidden']]) if 'createdTime' in shareddrive: printKeyValueList(['createdTime', formatLocalTime(shareddrive['createdTime'])]) - for setting in ['backgroundImageLink', 'colorRgb', 'themeId', 'orgUnit', 'orgUnitId']: + for setting in ['backgroundImageLink', 'colorRgb', 'themeId', 'orgUnit', 'orgUnitId', 'webViewLink']: if setting in shareddrive: printKeyValueList([setting, shareddrive[setting]]) if 'role' in shareddrive: @@ -65875,6 +65875,7 @@ SHAREDDRIVE_ACL_ROLES_MAP = { # [matchname ] [orgunit|org|ou ] # (role|roles )* # [fields ] [noorgunits []] +# [showwebviewlink] # [guiroles []] [formatjson [quotechar ]] # [showitemcountonly] # gam show shareddrives @@ -65882,6 +65883,7 @@ SHAREDDRIVE_ACL_ROLES_MAP = { # [matchname ] [orgunit|org|ou ] # (role|roles )* # [fields ] [noorgunits []] +# [showwebviewlink] # [guiroles []] [formatjson] # [showitemcountonly] def printShowSharedDrives(users, useDomainAdminAccess=False): @@ -65890,6 +65892,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False): td_ouid = shareddrive.get('orgUnitId') if td_ouid: shareddrive['orgUnit'] = orgUnitIdToPathMap.get(f'id:{td_ouid}', UNKNOWN) + if showWebViewLink: + shareddrive['webViewLink'] = 'https://drive.google.com/drive/folders/'+shareddrive['id'] if not showFields: return shareddrive sshareddrive = {} @@ -65908,6 +65912,7 @@ def printShowSharedDrives(users, useDomainAdminAccess=False): showOrgUnitPaths = True orgUnitIdToPathMap = None guiRoles = showItemCountOnly = False + showWebViewLink = False while Cmd.ArgumentsRemaining(): myarg = getArgument() if csvPF and myarg == 'todrive': @@ -65937,6 +65942,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False): showOrgUnitPaths = not getBoolean() elif myarg == 'guiroles': guiRoles = getBoolean() + elif myarg == 'showwebviewlink': + showWebViewLink = True elif myarg == 'showitemcountonly': showItemCountOnly = True showOrgUnitPaths = False @@ -65961,6 +65968,14 @@ def printShowSharedDrives(users, useDomainAdminAccess=False): orgUnitIdToPathMap = getOrgUnitIdToPathMap(cd) if showFields: showFields.add('orgUnit') + if showWebViewLink: + if showFields: + showFields.add('webViewLink') + if csvPF: + csvPF.AddTitle('webViewLink') + if FJQC.formatJSON: + csvPF.AddJSONTitles(['webViewLink']) + csvPF.MoveJSONTitlesToEnd(['JSON']) i, count, users = getEntityArgument(users) for user in users: i += 1 @@ -66029,6 +66044,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False): row = {'User': user, 'id': shareddrive['id'], 'name': shareddrive['name']} if not useDomainAdminAccess: row['role'] = shareddrive['role'] if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[shareddrive['role']] + if showWebViewLink: + row['webViewLink'] = shareddrive['webViewLink'] row['JSON'] = json.dumps(cleanJSON(shareddrive, timeObjects=SHAREDDRIVE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True) csvPF.WriteRow(row) else: