Updated option showlastmodification to gam <UserTypeEntity> print|show filecounts

This commit is contained in:
Ross Scroggs
2024-10-02 12:17:32 -07:00
parent ccaa76026c
commit 707d938656
12 changed files with 166 additions and 10255 deletions

View File

@@ -10,6 +10,14 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads-Installs-GAM7](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads-Installs) for Windows or other options, including manual installation
### 7.00.12
Updated option `showlastmodification` to `gam <UserTypeEntity> print|show filecounts` to handle
the case where all users owning files are suspended. In this case the `lastModifyingUser` column
will show the user's display name as the API doesn't return the user's email address.
Updated support for `Folders with limited access`; this is a work in progress.
### 7.00.11
Updated to Python 3.12.7 where possible.

View File

@@ -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.00.11 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.12 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.6 64-bit final
MacOS Sonoma 14.5 x86_64
@@ -923,7 +923,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
GAM7 7.00.11 - https://github.com/taers232c/GAM7 - pythonsource
GAM7 7.00.12 - https://github.com/taers232c/GAM7 - pythonsource
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.6 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -88,65 +88,67 @@
```
```
<DriveCapabilitiesSubfieldName> ::=
canacceptownership|
canaddchildren|
canaddfolderfromanotherdrive|
canaddmydriveparent|
canchangecopyrequireswriterpermission|
canchangecopyrequireswriterpermissionrestriction|
canchangedomainusersonlyrestriction|
canchangedrivebackground|
canchangedrivemembersonlyrestriction|
canchangesecurityupdateenabled|
canchangesharingfoldersrequiresorganizerpermissionrestriction|
canchangeviewerscancopycontent|
cancomment|
cancopy|
candelete|
candeletechildren|
candeletedrive|
candownload|
canedit|
canlistchildren|
canmanagemembers|
canmodifycontent|
canmodifycontentrestriction|
canmodifyeditorcontentrestriction|
canmodifylabels|
canmodifyownercontentrestriction|
canmovechildrenoutofdrive|
canmovechildrenoutofteamdrive|
canmovechildrenwithindrive|
canmovechildrenwithinteamdrive|
canmoveitemintodrive|
canmoveitemintoteamdrive|
canmoveitemoutofdrive|
canmoveitemoutofteamdrive|
canmoveitemwithindrive|
canmoveitemwithinteamdrive|
canmoveteamdriveitem|
canreaddrive|
canreadlabels|
canreadrevisions|
canreadteamdrive|
canremovechildren|
canremovecontentrestriction|
canremovemydriveparent|
canrename|
canrenamedrive|
canresetdriverestrictions|
canshare|
cantrash|
cantrashchildren|
canuntrash
capabilities.canacceptownership|
capabilities.canaddchildren|
capabilities.canaddfolderfromanotherdrive|
capabilities.canaddmydriveparent|
capabilities.canchangecopyrequireswriterpermission|
capabilities.canchangecopyrequireswriterpermissionrestriction|
capabilities.canchangedomainusersonlyrestriction|
capabilities.canchangedrivebackground|
capabilities.canchangedrivemembersonlyrestriction|
capabilities.canchangesecurityupdateenabled|
capabilities.canchangesharingfoldersrequiresorganizerpermissionrestriction|
capabilities.canchangeviewerscancopycontent|
capabilities.cancomment|
capabilities.cancopy|
capabilities.candelete|
capabilities.candeletechildren|
capabilities.candeletedrive|
capabilities.candisableinheritedpermissions|
capabilities.candownload|
capabilities.canedit|
capabilities.canenableinheritedpermissions|
capabilities.canlistchildren|
capabilities.canmanagemembers|
capabilities.canmodifycontent|
capabilities.canmodifycontentrestriction|
capabilities.canmodifyeditorcontentrestriction|
capabilities.canmodifylabels|
capabilities.canmodifyownercontentrestriction|
capabilities.canmovechildrenoutofdrive|
capabilities.canmovechildrenoutofteamdrive|
capabilities.canmovechildrenwithindrive|
capabilities.canmovechildrenwithinteamdrive|
capabilities.canmoveitemintodrive|
capabilities.canmoveitemintoteamdrive|
capabilities.canmoveitemoutofdrive|
capabilities.canmoveitemoutofteamdrive|
capabilities.canmoveitemwithindrive|
capabilities.canmoveitemwithinteamdrive|
capabilities.canmoveteamdriveitem|
capabilities.canreaddrive|
capabilities.canreadlabels|
capabilities.canreadrevisions|
capabilities.canreadteamdrive|
capabilities.canremovechildren|
capabilities.canremovecontentrestriction|
capabilities.canremovemydriveparent|
capabilities.canrename|
capabilities.canrenamedrive|
capabilities.canresetdriverestrictions|
capabilities.canshare|
capabilities.cantrash|
capabilities.cantrashchildren|
capabilities.canuntrash
<DriveContentRestrictionsSubfieldName> ::=
ownerrestricted|
readonly|
reason|
restrictinguser|
restrictiontime|
type
contentrestrictions.ownerrestricted|
contentrestrictions.readonly|
contentrestrictions.reason|
contentrestrictions.restrictinguser|
contentrestrictions.restrictiontime|
contentrestrictions.type
<DriveLabelInfoSubfieldName> ::=
labels.id| # modifiedByMe
@@ -257,6 +259,7 @@
iconlink|
id|
imagemediametadata|
inheritedpermissionsdisabled|
isappauthorized|
labelinfo|
<DriveLabelInfoSubfieldName>|
@@ -294,6 +297,8 @@
<DriveSharingUserSubfieldName>|
shortcutdetails|
<DriveShortcutDetailsSubfieldName>|
sha1checksum|
sha256checksum|
size|
spaces|
starred|

View File

@@ -117,6 +117,7 @@
(description <String>)|
(folderColorRgb <ColorValue>)|
(indexabletext <String>)|
(inheritedpermissionsdisabled [<Boolean>])|
(keeprevisionforever|pinned)|
(lastviewedbyme <Time>)|
(mimetype <MimeType>)|
@@ -127,10 +128,10 @@
(property <PropertyKey> <PropertyValue> [private|public])|
(restricted|restrict [<Boolean>])|
(securityupdate [<Boolean>])|
(shortcut <DriveFileID>)|
(starred|star [<Boolean>])|
(trashed|trash [<Boolean>])|
(viewed|view [<Boolean>])|
(shortcut <DriveFileID>)|
(viewerscancopycontent [<Boolean>])|
(writerscanshare|writerscantshare [<Boolean>])

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details
```
gam version
GAM 7.00.11 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.12 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.7 64-bit final
MacOS Sonoma 14.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.00.11 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.12 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.7 64-bit final
MacOS Sonoma 14.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.00.11 - https://github.com/GAM-team/GAM - pyinstaller
GAM 7.00.12 - https://github.com/GAM-team/GAM - pyinstaller
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.7 64-bit final
MacOS Sonoma 14.5 x86_64
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3
Version Check:
Current: 5.35.08
Latest: 7.00.11
Latest: 7.00.12
echo $?
1
```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details
```
gam version simple
7.00.11
7.00.12
```
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.00.11 - https://github.com/taers232c/GAMADV-XTD3
GAM 7.00.12 - https://github.com/taers232c/GAMADV-XTD3
GAM Team <google-apps-manager@googlegroups.com>
Python 3.12.7 64-bit final
MacOS Sonoma 14.5 x86_64

View File

@@ -6375,6 +6375,7 @@ gam <UserTypeEntity> print chatevents [todrive <ToDriveAttribute>*]
(description <String>)|
(folderColorRgb <ColorValue>)|
(indexabletext <String>)|
(inheritedpermissionsdisabled [<Boolean>])|
(keeprevisionforever|pinned)|
(lastviewedbyme <Time>)|
(mimetype <MimeType>)|
@@ -6399,9 +6400,6 @@ gam <UserTypeEntity> print chatevents [todrive <ToDriveAttribute>*]
(teamdriveparentid <DriveFolderID>)|
(teamdriveparent <SharedDriveName>)|
(teamdriveparentid <SharedDriveID> teamdriveparentname <DriveFolderName>)|
(teamdriveparent <SharedDriveName> teamdriveparentname <DriveFolderName>))|
(teamdriveparentid <DriveFolderID>)|(teamdriveparent <SharedDriveName>)|
(teamdriveparentid <SharedDriveID> teamdriveparentname <DriveFolderName>)|
(teamdriveparent <SharedDriveName> teamdriveparentname <DriveFolderName>)
<DriveFileCreateAttribute> ::=
@@ -6793,65 +6791,67 @@ gam <UserTypeEntity> collect orphans
[preview [todrive <ToDriveAttribute>*]]
<DriveCapabilitiesSubfieldName> ::=
canacceptownership|
canaddchildren|
canaddfolderfromanotherdrive|
canaddmydriveparent|
canchangecopyrequireswriterpermission|
canchangecopyrequireswriterpermissionrestriction|
canchangedomainusersonlyrestriction|
canchangedrivebackground|
canchangedrivemembersonlyrestriction|
canchangesecurityupdateenabled|
canchangesharingfoldersrequiresorganizerpermissionrestriction|
canchangeviewerscancopycontent|
cancomment|
cancopy|
candelete|
candeletechildren|
candeletedrive|
candownload|
canedit|
canlistchildren|
canmanagemembers|
canmodifycontent|
canmodifycontentrestriction|
canmodifyeditorcontentrestriction|
canmodifylabels|
canmodifyownercontentrestriction|
canmovechildrenoutofdrive|
canmovechildrenoutofteamdrive|
canmovechildrenwithindrive|
canmovechildrenwithinteamdrive|
canmoveitemintodrive|
canmoveitemintoteamdrive|
canmoveitemoutofdrive|
canmoveitemoutofteamdrive|
canmoveitemwithindrive|
canmoveitemwithinteamdrive|
canmoveteamdriveitem|
canreaddrive|
canreadlabels|
canreadrevisions|
canreadteamdrive|
canremovechildren|
canremovecontentrestriction|
canremovemydriveparent|
canrename|
canrenamedrive|
canresetdriverestrictions|
canshare|
cantrash|
cantrashchildren|
canuntrash
capabilities.canacceptownership|
capabilities.canaddchildren|
capabilities.canaddfolderfromanotherdrive|
capabilities.canaddmydriveparent|
capabilities.canchangecopyrequireswriterpermission|
capabilities.canchangecopyrequireswriterpermissionrestriction|
capabilities.canchangedomainusersonlyrestriction|
capabilities.canchangedrivebackground|
capabilities.canchangedrivemembersonlyrestriction|
capabilities.canchangesecurityupdateenabled|
capabilities.canchangesharingfoldersrequiresorganizerpermissionrestriction|
capabilities.canchangeviewerscancopycontent|
capabilities.cancomment|
capabilities.cancopy|
capabilities.candelete|
capabilities.candeletechildren|
capabilities.candeletedrive|
capabilities.candisableinheritedpermissions|
capabilities.candownload|
capabilities.canedit|
capabilities.canenableinheritedpermissions|
capabilities.canlistchildren|
capabilities.canmanagemembers|
capabilities.canmodifycontent|
capabilities.canmodifycontentrestriction|
capabilities.canmodifyeditorcontentrestriction|
capabilities.canmodifylabels|
capabilities.canmodifyownercontentrestriction|
capabilities.canmovechildrenoutofdrive|
capabilities.canmovechildrenoutofteamdrive|
capabilities.canmovechildrenwithindrive|
capabilities.canmovechildrenwithinteamdrive|
capabilities.canmoveitemintodrive|
capabilities.canmoveitemintoteamdrive|
capabilities.canmoveitemoutofdrive|
capabilities.canmoveitemoutofteamdrive|
capabilities.canmoveitemwithindrive|
capabilities.canmoveitemwithinteamdrive|
capabilities.canmoveteamdriveitem|
capabilities.canreaddrive|
capabilities.canreadlabels|
capabilities.canreadrevisions|
capabilities.canreadteamdrive|
capabilities.canremovechildren|
capabilities.canremovecontentrestriction|
capabilities.canremovemydriveparent|
capabilities.canrename|
capabilities.canrenamedrive|
capabilities.canresetdriverestrictions|
capabilities.canshare|
capabilities.cantrash|
capabilities.cantrashchildren|
capabilities.canuntrash
<DriveContentRestrictionsSubfieldName> ::=
ownerrestricted|
readonly|
reason|
restrictinguser|
restrictiontime|
type
contentrestrictions.ownerrestricted|
contentrestrictions.readonly|
contentrestrictions.reason|
contentrestrictions.restrictinguser|
contentrestrictions.restrictiontime|
contentrestrictions.type
<DriveLabelInfoSubfieldName> ::=
labels.id| # modifiedByMe
@@ -6961,6 +6961,7 @@ gam <UserTypeEntity> collect orphans
iconlink|
id|
imagemediametadata|
inheritedpermissionsdisabled|
isappauthorized|
labelinfo|
<DriveLabelInfoSubfieldName>|
@@ -6998,8 +6999,8 @@ gam <UserTypeEntity> collect orphans
<DriveSharingUserSubfieldName>|
shortcutdetails|
<DriveShortcutDetailsSubfieldName>|
sha1Checksum|
sha256Checksum|
sha1checksum|
sha256checksum|
size|
spaces|
starred|

View File

@@ -1,3 +1,11 @@
7.00.12
Updated option `showlastmodification` to `gam <UserTypeEntity> print|show filecounts` to handle
the case where all users owning files are suspended. In this case the `lastModifyingUser` column
will show the user's display name as the API doesn't return the user's email address.
Updated support for `Folders with limited access`; this is a work in progress.
7.00.11
Updated to Python 3.12.7 where possible.

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,6 @@ datas += [('admin-directory_v1.1beta1.json', '.')]
datas += [('cbcm-v1.1beta1.json', '.')]
datas += [('contactdelegation-v1.json', '.')]
datas += [('datastudio-v1.json', '.')]
datas += [('drive-v3beta.json', '.')]
datas += [('serviceaccountlookup-v1.json', '.')]
datas += [('cacerts.pem', '.')]
hiddenimports = [

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.00.11'
__version__ = '7.00.12'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position
@@ -4670,8 +4670,7 @@ def getAPIService(api, httpObj):
def getService(api, httpObj):
### Drive v3beta
if api == API.DRIVE3 and GC.Values[GC.DRIVE_V3_BETA]:
api = API.DRIVE3B
mapDriveURL = api == API.DRIVE3 and GC.Values[GC.DRIVE_V3_BETA]
hasLocalJSON = API.hasLocalJSON(api)
api, version, v2discovery = API.getVersion(api)
if api in GM.Globals[GM.CURRENT_API_SERVICES] and version in GM.Globals[GM.CURRENT_API_SERVICES][api]:
@@ -4687,6 +4686,9 @@ def getService(api, httpObj):
discoveryServiceUrl=DISCOVERY_URIS[v2discovery], static_discovery=False)
GM.Globals[GM.CURRENT_API_SERVICES].setdefault(api, {})
GM.Globals[GM.CURRENT_API_SERVICES][api][version] = service._rootDesc.copy()
### Drive v3beta
if mapDriveURL:
setattr(service, '_baseUrl', getattr(service, '_baseUrl').replace('/v3/', '/v3beta/'))
if GM.Globals[GM.CACHE_DISCOVERY_ONLY]:
clearServiceCache(service)
return service
@@ -4732,8 +4734,6 @@ def defaultSvcAcctScopes():
saScopes[API.DRIVE2] = saScopes[API.DRIVE3]
saScopes[API.DRIVETD] = saScopes[API.DRIVE3]
saScopes[API.SHEETSTD] = saScopes[API.SHEETS]
### Drive v3beta
saScopes[API.DRIVE3B] = saScopes[API.DRIVE3]
return saScopes
def _getSvcAcctData():
@@ -53774,12 +53774,12 @@ def showFileInfo(users):
j += 1
try:
result = callGAPI(drive.files(), 'get',
throwReasons=GAPI.DRIVE_GET_THROW_REASONS,
throwReasons=GAPI.DRIVE_GET_THROW_REASONS+[GAPI.INVALID],
fileId=fileId, includeLabels=includeLabels, fields=fields, supportsAllDrives=True)
if followShortcuts and result['mimeType'] == MIMETYPE_GA_SHORTCUT:
fileId = result['shortcutDetails']['targetId']
result = callGAPI(drive.files(), 'get',
throwReasons=GAPI.DRIVE_GET_THROW_REASONS,
throwReasons=GAPI.DRIVE_GET_THROW_REASONS+[GAPI.INVALID],
fileId=fileId, includeLabels=includeLabels, fields=fields, supportsAllDrives=True)
if stripCRsFromName:
result['name'] = _stripControlCharsFromName(result['name'])
@@ -55649,7 +55649,11 @@ def printFileList(users):
continue
extendFileTreeParents(drive, fileTree, fields)
DLP.GetLocationFileIdsFromTree(fileTree, fileIdEntity)
except (GAPI.invalidQuery, GAPI.invalid, GAPI.badRequest):
except (GAPI.invalidQuery, GAPI.invalid, GAPI.badRequest) as e:
errMsg = str(e)
if 'Invalid field selection' in errMsg:
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FILE_OR_FOLDER, None], errMsg, i, count)
break
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FILE_OR_FOLDER, None], invalidQuery(DLP.fileIdEntity['query']), i, count)
if not continueOnInvalidQuery:
break
@@ -56227,7 +56231,7 @@ def printShowFileCounts(users):
if showSize or (DLP.minimumFileSize is not None) or (DLP.maximumFileSize is not None):
fieldsList.append(sizeField)
if showLastModification:
fieldsList.extend(['id,name,modifiedTime,lastModifyingUser(emailAddress)'])
fieldsList.extend(['id,name,modifiedTime,lastModifyingUser(me, displayName, emailAddress)'])
if DLP.filenameMatchPattern:
fieldsList.append('name')
if DLP.excludeTrashed:
@@ -56422,7 +56426,8 @@ def printShowFileCounts(users):
userLastModification['lastModifiedFileId'] = f_file['id']
userLastModification['lastModifiedFileName'] = _stripControlCharsFromName(f_file['name'])
userLastModification['lastModifiedTime'] = f_file['modifiedTime']
userLastModification['lastModifyingUser'] = f_file['lastModifyingUser'].get('emailAddress', UNKNOWN)
userLastModification['lastModifyingUser'] = f_file['lastModifyingUser'].get('emailAddress',
f_file['lastModifyingUser'].get('displayName', UNKNOWN))
showMimeTypeInfo(user, mimeTypeInfo, sharedDriveId, sharedDriveName, userLastModification, i, count)
if showLastModification and userLastModification['lastModifiedTime'] > summaryLastModification['lastModifiedTime']:
summaryLastModification = userLastModification.copy()

File diff suppressed because it is too large Load Diff

View File

@@ -58,7 +58,6 @@ DIRECTORY_BETA = 'directory_beta'
DOCS = 'docs'
DRIVE2 = 'drive2'
DRIVE3 = 'drive3'
DRIVE3B = 'drive3b'
DRIVETD = 'drivetd'
DRIVEACTIVITY = 'driveactivity'
DRIVELABELS = 'drivelabels'
@@ -238,7 +237,6 @@ _INFO = {
DOCS: {'name': 'Docs API', 'version': 'v1', 'v2discovery': True},
DRIVE2: {'name': 'Drive API v2', 'version': 'v2', 'v2discovery': False, 'mappedAPI': 'drive'},
DRIVE3: {'name': 'Drive API v3', 'version': 'v3', 'v2discovery': False, 'mappedAPI': 'drive'},
DRIVE3B: {'name': 'Drive API v3beta', 'version': 'v3beta', 'v2discovery': False, 'mappedAPI': 'drive', 'localjson': True},
DRIVETD: {'name': 'Drive API v3 - todrive', 'version': 'v3', 'v2discovery': False, 'mappedAPI': 'drive'},
DRIVEACTIVITY: {'name': 'Drive Activity API v2', 'version': 'v2', 'v2discovery': True},
DRIVELABELS_ADMIN: {'name': 'Drive Labels API v2beta - Admin', 'version': 'v2beta', 'v2discovery': True, 'mappedAPI': DRIVELABELS},