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>] [teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>] [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
[fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]] [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
[showwebviewlink]
[formatjson [quotechar <Character>]] [formatjson [quotechar <Character>]]
gam show shareddrives gam show shareddrives
[teamdriveadminquery|query <QueryTeamDrive>] [teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>] [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
[fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]] [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
[showwebviewlink]
[formatjson] [noorgunits [<Boolean>]] [formatjson] [noorgunits [<Boolean>]]
gam print shareddriveorganizers [todrive <ToDriveAttribute>*] gam print shareddriveorganizers [todrive <ToDriveAttribute>*]
@ -4902,12 +4904,14 @@ gam <UserTypeEntity> print shareddrives [todrive <ToDriveAttribute>*]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>] [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
(role|roles <SharedDriveACLRoleList>)* (role|roles <SharedDriveACLRoleList>)*
[fields <SharedDriveFieldNameList>] [fields <SharedDriveFieldNameList>]
[showwebviewlink]
[guiroles [<Boolean>]] [formatjson [quotechar <Character>]] [guiroles [<Boolean>]] [formatjson [quotechar <Character>]]
gam <UserTypeEntity> show shareddrives gam <UserTypeEntity> show shareddrives
[teamdriveadminquery|query <QueryTeamDrive>] [teamdriveadminquery|query <QueryTeamDrive>]
[matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>] [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
(role|roles <SharedDriveACLRoleList>)* (role|roles <SharedDriveACLRoleList>)*
[fields <SharedDriveFieldNameList>] [fields <SharedDriveFieldNameList>]
[showwebviewlink]
[guiroles [<Boolean>]] [formatjson] [guiroles [<Boolean>]] [formatjson]
<PermissionMatch> ::= <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 7.10.08
Fixed bug in commands that modify messages where the `labelids <LabelIdList>` option 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>' __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)' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position #pylint: disable=wrong-import-position
@ -65800,7 +65800,7 @@ def _showSharedDrive(user, shareddrive, j, jcount, FJQC):
printKeyValueList(['hidden', shareddrive['hidden']]) printKeyValueList(['hidden', shareddrive['hidden']])
if 'createdTime' in shareddrive: if 'createdTime' in shareddrive:
printKeyValueList(['createdTime', formatLocalTime(shareddrive['createdTime'])]) 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: if setting in shareddrive:
printKeyValueList([setting, shareddrive[setting]]) printKeyValueList([setting, shareddrive[setting]])
if 'role' in shareddrive: if 'role' in shareddrive:
@ -65875,6 +65875,7 @@ SHAREDDRIVE_ACL_ROLES_MAP = {
# [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>] # [matchname <REMatchPattern>] [orgunit|org|ou <OrgUnitPath>]
# (role|roles <SharedDriveACLRoleList>)* # (role|roles <SharedDriveACLRoleList>)*
# [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]] # [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
# [showwebviewlink]
# [guiroles [<Boolean>]] [formatjson [quotechar <Character>]] # [guiroles [<Boolean>]] [formatjson [quotechar <Character>]]
# [showitemcountonly] # [showitemcountonly]
# gam <UserTypeEntity> show shareddrives # gam <UserTypeEntity> show shareddrives
@ -65882,6 +65883,7 @@ SHAREDDRIVE_ACL_ROLES_MAP = {
# [matchname <REMatchPattrn>] [orgunit|org|ou <OrgUnitPath>] # [matchname <REMatchPattrn>] [orgunit|org|ou <OrgUnitPath>]
# (role|roles <SharedDriveACLRoleLIst>)* # (role|roles <SharedDriveACLRoleLIst>)*
# [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]] # [fields <SharedDriveFieldNameList>] [noorgunits [<Boolean>]]
# [showwebviewlink]
# [guiroles [<Boolean>]] [formatjson] # [guiroles [<Boolean>]] [formatjson]
# [showitemcountonly] # [showitemcountonly]
def printShowSharedDrives(users, useDomainAdminAccess=False): def printShowSharedDrives(users, useDomainAdminAccess=False):
@ -65890,6 +65892,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
td_ouid = shareddrive.get('orgUnitId') td_ouid = shareddrive.get('orgUnitId')
if td_ouid: if td_ouid:
shareddrive['orgUnit'] = orgUnitIdToPathMap.get(f'id:{td_ouid}', UNKNOWN) shareddrive['orgUnit'] = orgUnitIdToPathMap.get(f'id:{td_ouid}', UNKNOWN)
if showWebViewLink:
shareddrive['webViewLink'] = 'https://drive.google.com/drive/folders/'+shareddrive['id']
if not showFields: if not showFields:
return shareddrive return shareddrive
sshareddrive = {} sshareddrive = {}
@ -65908,6 +65912,7 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
showOrgUnitPaths = True showOrgUnitPaths = True
orgUnitIdToPathMap = None orgUnitIdToPathMap = None
guiRoles = showItemCountOnly = False guiRoles = showItemCountOnly = False
showWebViewLink = False
while Cmd.ArgumentsRemaining(): while Cmd.ArgumentsRemaining():
myarg = getArgument() myarg = getArgument()
if csvPF and myarg == 'todrive': if csvPF and myarg == 'todrive':
@ -65937,6 +65942,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
showOrgUnitPaths = not getBoolean() showOrgUnitPaths = not getBoolean()
elif myarg == 'guiroles': elif myarg == 'guiroles':
guiRoles = getBoolean() guiRoles = getBoolean()
elif myarg == 'showwebviewlink':
showWebViewLink = True
elif myarg == 'showitemcountonly': elif myarg == 'showitemcountonly':
showItemCountOnly = True showItemCountOnly = True
showOrgUnitPaths = False showOrgUnitPaths = False
@ -65961,6 +65968,14 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
orgUnitIdToPathMap = getOrgUnitIdToPathMap(cd) orgUnitIdToPathMap = getOrgUnitIdToPathMap(cd)
if showFields: if showFields:
showFields.add('orgUnit') 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) i, count, users = getEntityArgument(users)
for user in users: for user in users:
i += 1 i += 1
@ -66029,6 +66044,8 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
row = {'User': user, 'id': shareddrive['id'], 'name': shareddrive['name']} row = {'User': user, 'id': shareddrive['id'], 'name': shareddrive['name']}
if not useDomainAdminAccess: if not useDomainAdminAccess:
row['role'] = shareddrive['role'] if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[shareddrive['role']] 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) row['JSON'] = json.dumps(cleanJSON(shareddrive, timeObjects=SHAREDDRIVE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True)
csvPF.WriteRow(row) csvPF.WriteRow(row)
else: else: