Added option showwebviewlink to gam print|show shareddrives

This commit is contained in:
Ross Scroggs
2025-06-30 09:43:32 -07:00
parent db40ada5d0
commit 626eb1eadc
3 changed files with 28 additions and 2 deletions

View File

@ -4817,11 +4817,13 @@ gam print shareddrives [todrive <ToDriveAttribute>*]
[teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
[fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
[showwebviewlink]
[formatjson [quotechar <Character>]]
gam show shareddrives
[teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
[fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
[showwebviewlink]
[formatjson] [noorgunits [<Boolean>]]
gam print shareddriveorganizers [todrive <ToDriveAttribute>*]
@ -4902,12 +4904,14 @@ gam <UserTypeEntity> print shareddrives [todrive <ToDriveAttribute>*]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
(role|roles <SharedDriveACLRoleList>)*
[fields <SharedDriveFieldNameList>]
[showwebviewlink]
[guiroles [<Boolean>]] [formatjson [quotechar <Character>]]
gam <UserTypeEntity> show shareddrives
[teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
(role|roles <SharedDriveACLRoleList>)*
[fields <SharedDriveFieldNameList>]
[showwebviewlink]
[guiroles [<Boolean>]] [formatjson]
<PermissionMatch> ::=

View File

@ -1,3 +1,8 @@
7.10.09
Added option `showwebviewlink` to `gam [<UserTypeEntity>] print|show shareddrives` that
displays the web view link for the Shared Drive: `https://drive.google.com/drive/folders/<SharedDriveID>`.
7.10.08
Fixed bug in commands that modify messages where the `labelids <LabelIdList>` option

View File

@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__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 <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
# (role|roles <SharedDriveACLRoleList>)*
# [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
# [showwebviewlink]
# [guiroles [<Boolean>]] [formatjson [quotechar <Character>]]
# [showitemcountonly]
# gam <UserTypeEntity> show shareddrives
@ -65882,6 +65883,7 @@ SHAREDDRIVE_ACL_ROLES_MAP = {
# [matchname <REMatchPattrn>] [orgunit|org|ou <OrgUnitPath>]
# (role|roles <SharedDriveACLRoleLIst>)*
# [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
# [showwebviewlink]
# [guiroles [<Boolean>]] [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: