Added option onlyusers <UserTypeEntity> to gam <UserTypeEntity> claim ownership <DriveFileEntity>`

This commit is contained in:
Ross Scroggs
2024-07-03 11:26:15 -07:00
parent cc3d79b3b9
commit 74bc4596ed
8 changed files with 56 additions and 19 deletions

View File

@@ -10,6 +10,12 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
### 6.77.05
Added option `onlyusers <UserTypeEntity>` to gam <UserTypeEntity> claim ownership <DriveFileEntity>`
that causes GAM to only claim ownership of files/folders owned by `onlyusers <UserTypeEntity>`.
This option is multually exclusive with `skipusers <UserTypeEntity>`.
### 6.77.04 ### 6.77.04
Fixed bug in `gam report users ... range <Date> <Date>` where an extraneous API call Fixed bug in `gam report users ... range <Date> <Date>` where an extraneous API call

View File

@@ -335,7 +335,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -1009,7 +1009,7 @@ writes the credentials into the file oauth2.txt.
C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt
C:\GAMADV-XTD3>gam version C:\GAMADV-XTD3>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
Windows-10-10.0.17134 AMD64 Windows-10-10.0.17134 AMD64

View File

@@ -9,7 +9,7 @@ Thank you.
* Gabriel Clifton - https://docs.google.com/document/d/1p32QOBTr89GaG7RfCafSbFuhlUQ9r3qBM_666E0xvQM/edit * Gabriel Clifton - https://docs.google.com/document/d/1p32QOBTr89GaG7RfCafSbFuhlUQ9r3qBM_666E0xvQM/edit
* Goldy Arora - https://www.goldyarora.com/license-notifier/ * Goldy Arora - https://www.goldyarora.com/license-notifier/
* Iain Macleod - https://docs.google.com/document/d/1QxWAPdhROcx70OXLpSD9Trh3vs-nJKSMiaMZCTwOOTg/edit?pli=1#heading=h.2a2azzpy36k0 * Iain Macleod - https://docs.google.com/document/d/1QxWAPdhROcx70OXLpSD9Trh3vs-nJKSMiaMZCTwOOTg/edit?pli=1#heading=h.2a2azzpy36k0
* James Seymour - https://sites.google.com/jis.edu.bn/gam-commands/home * James Seymour - https://sites.google.com/view/gam--commands/
* Kevin Melillo - https://github.com/KevinMelilloIEEE/gam-script * Kevin Melillo - https://github.com/KevinMelilloIEEE/gam-script
* Korey Rideout - https://chatgpt.com/g/g-PTxxnVPMG-gam-assist - A helpful tool to assist with, GAM (+Advance) and GYB commands to assist with syntax for Google Workspace Administrators. * Korey Rideout - https://chatgpt.com/g/g-PTxxnVPMG-gam-assist - A helpful tool to assist with, GAM (+Advance) and GYB commands to assist with syntax for Google Workspace Administrators.
* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Course on Udemy https://taming.tech/GAMCourse * Paul Ogier (Taming.Tech) - GAMADV-XTD3 Course on Udemy https://taming.tech/GAMCourse

View File

@@ -92,7 +92,7 @@ point to control the students further access to the files.
``` ```
gam <UserTypeEntity> claim ownership <DriveFileEntity> gam <UserTypeEntity> claim ownership <DriveFileEntity>
[<DriveFileParentAttribute>] [includetrashed] [<DriveFileParentAttribute>] [includetrashed]
[skipids <DriveFileEntity>] [skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>] [skipids <DriveFileEntity>] [onlyusers|skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>]
[restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]] [restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]]
[keepuser | (retainrole reader|commenter|writer|editor|none)] [noretentionmessages] [keepuser | (retainrole reader|commenter|writer|editor|none)] [noretentionmessages]
(orderby <DriveOrderByFieldName> [ascending|descending])* (orderby <DriveOrderByFieldName> [ascending|descending])*
@@ -107,8 +107,11 @@ By default, files in the trash are not transferred.
Specify order of file processing. Specify order of file processing.
* `(orderby <DriveOrderByFieldName> [ascending|descending])*` * `(orderby <DriveOrderByFieldName> [ascending|descending])*`
These options handle special cases where you want to prevent ownership from being transferred for selected files/folders. This option handles special cases where you want to prevent ownership from being transferred for selected files/folders.
* `skipids <DriveFileEntity>` - Do not transfer ownership for files/folders with the specified IDs. * `skipids <DriveFileEntity>` - Do not transfer ownership for files/folders with the specified IDs.
These mutually exclusive options handle special cases where you want to prevent ownership from being transferred based on the current file/folder owner.
* `onlyusers <UserTypeEntity>` - Only transfer ownership for files/folders owned by the specified users.
* `skipusers <UserTypeEntity>` - Do not transfer ownership for files/folders owned by the specified users. * `skipusers <UserTypeEntity>` - Do not transfer ownership for files/folders owned by the specified users.
By default, only files owned by users in the same domain as the claiming user have their ownership transferred. By default, only files owned by users in the same domain as the claiming user have their ownership transferred.

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details Print the current version of Gam with details
``` ```
gam version gam version
GAMADV-XTD3 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 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 Print the current version of Gam with details and time offset information
``` ```
gam version timeoffset gam version timeoffset
GAMADV-XTD3 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 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 Print the current version of Gam with extended details and SSL information
``` ```
gam version extended gam version extended
GAMADV-XTD3 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3 Path: /Users/Admin/bin/gamadv-xtd3
Version Check: Version Check:
Current: 5.35.08 Current: 5.35.08
Latest: 6.77.04 Latest: 6.77.05
echo $? echo $?
1 1
``` ```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details Print the current version number without details
``` ```
gam version simple gam version simple
6.77.04 6.77.05
``` ```
In Linux/MacOS you can do: In Linux/MacOS you can do:
``` ```
@@ -82,7 +82,7 @@ echo $VER
Print the current version of Gam and address of this Wiki Print the current version of Gam and address of this Wiki
``` ```
gam help gam help
GAM 6.77.04 - https://github.com/taers232c/GAMADV-XTD3 GAM 6.77.05 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64

View File

@@ -6696,7 +6696,7 @@ gam <UserTypeEntity> transfer ownership <DriveFileEntity> <UserItem>
[todrive <ToDriveAttribute>*] [todrive <ToDriveAttribute>*]
gam <UserTypeEntity> claim ownership <DriveFileEntity> gam <UserTypeEntity> claim ownership <DriveFileEntity>
[<DriveFileParentAttribute>] [includetrashed] [<DriveFileParentAttribute>] [includetrashed]
[skipids <DriveFileEntity>] [skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>] [skipids <DriveFileEntity>] [onlyusers|skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>]
[restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]] [restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]]
[keepuser | (retainrole commenter|reader|writer|editor|fileorganizer|none)] [noretentionmessages] [keepuser | (retainrole commenter|reader|writer|editor|fileorganizer|none)] [noretentionmessages]
(orderby <DriveFileOrderByFieldName> [ascending|descending])* (orderby <DriveFileOrderByFieldName> [ascending|descending])*

View File

@@ -13,6 +13,12 @@ where `date` is the earliest date for which report data was requested.
Merged GAM-Team version Merged GAM-Team version
6.77.05
Added option `onlyusers <UserTypeEntity>` to gam <UserTypeEntity> claim ownership <DriveFileEntity>`
that causes GAM to only claim ownership of files/folders owned by `onlyusers <UserTypeEntity>`.
This option is multually exclusive with `skipusers <UserTypeEntity>`.
6.77.04 6.77.04
Fixed bug in `gam report users ... range <Date> <Date>` where an extraneous API call Fixed bug in `gam report users ... range <Date> <Date>` where an extraneous API call
@@ -29,6 +35,17 @@ Thanks to jay, added the following Colab License SKUs:
Thanks to Jay, updated `gam print|show admins` to properly display addresses Thanks to Jay, updated `gam print|show admins` to properly display addresses
of service accounts with admin role assignments. of service accounts with admin role assignments.
Added option `limitdatechanges <Integer>` to `gam report users|customers`.
If no report is available for the specified date, can an earlier date be used?
* `limitdatechanges -1' - Back up to earlier dates to find report data; this is the default.
* `limitdatechanges 0 | nodatechange' - Do not report on an earlier date if no report data is available for the specified date.
* `limitdatechanges N' - Back up to earlier dates to find report data; do not back up more than N times.
By default, when `gam report user user <UserItem>` is specified and no report data is available, there is no output.
If `csv_output_users_audit = true` in `gam.cfg`, then a row with columns `email,date` will be displayed
where `date` is the earliest date for which report data was requested.
6.77.02 6.77.02
Cleaned up problems with some of the new Chat API asadmin commands. Cleaned up problems with some of the new Chat API asadmin commands.
@@ -69,7 +86,7 @@ gam <UserItem> info chatmember asadmin
gam <UserItem> print|show chatmembers|asadmin gam <UserItem> print|show chatmembers|asadmin
``` ```
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Chat * See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Chat#developer-preview-admin-access
Added `use_chat_admin_access` Boolean variable to `gam.cfg`. Added `use_chat_admin_access` Boolean variable to `gam.cfg`.
``` ```

View File

@@ -60805,7 +60805,7 @@ def transferOwnership(users):
# gam <UserTypeEntity> claim ownership <DriveFileEntity> # gam <UserTypeEntity> claim ownership <DriveFileEntity>
# [<DriveFileParentAttribute>] [includetrashed] # [<DriveFileParentAttribute>] [includetrashed]
# [skipids <DriveFileEntity>] [skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>] # [skipids <DriveFileEntity>] [onlyUsers|skipusers <UserTypeEntity>] [subdomains <DomainNameEntity>]
# [restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]] # [restricted [<Boolean>]] [writerscanshare|writerscantshare [<Boolean>]]
# [keepuser | (retainrole reader|commenter|writer|editor|none)] [noretentionmessages] # [keepuser | (retainrole reader|commenter|writer|editor|none)] [noretentionmessages]
# (orderby <DriveFileOrderByFieldName> [ascending|descending])* # (orderby <DriveFileOrderByFieldName> [ascending|descending])*
@@ -60822,7 +60822,7 @@ def claimOwnership(users):
childEntryInfo = childEntry['info'] childEntryInfo = childEntry['info']
if includeTrashed or not childEntryInfo['trashed']: if includeTrashed or not childEntryInfo['trashed']:
owner = childEntryInfo['owners'][0]['emailAddress'] owner = childEntryInfo['owners'][0]['emailAddress']
if not childEntryInfo['ownedByMe'] and owner not in skipusers: if (not childEntryInfo['ownedByMe']) and ((not checkOwner) or (checkOnly and owner in onlyOwners) or (checkSkip and owner not in skipOwners)):
oldOwnerPermissionIds[owner] = childEntryInfo['owners'][0]['permissionId'] oldOwnerPermissionIds[owner] = childEntryInfo['owners'][0]['permissionId']
filesToClaim.setdefault(owner, {}) filesToClaim.setdefault(owner, {})
if childFileId not in filesToClaim[owner]: if childFileId not in filesToClaim[owner]:
@@ -60850,7 +60850,7 @@ def claimOwnership(users):
if filepath: if filepath:
fileTree[childFileId] = {'info': childEntryInfo} fileTree[childFileId] = {'info': childEntryInfo}
owner = childEntryInfo['owners'][0]['emailAddress'] owner = childEntryInfo['owners'][0]['emailAddress']
if not childEntryInfo['ownedByMe'] and owner not in skipusers: if (not childEntryInfo['ownedByMe']) and ((not checkOwner) or (checkOnly and owner in onlyOwners) or (checkSkip and owner not in skipOwners)):
oldOwnerPermissionIds[owner] = childEntryInfo['owners'][0]['permissionId'] oldOwnerPermissionIds[owner] = childEntryInfo['owners'][0]['permissionId']
filesToClaim.setdefault(owner, {}) filesToClaim.setdefault(owner, {})
if childFileId not in filesToClaim[owner]: if childFileId not in filesToClaim[owner]:
@@ -60885,7 +60885,9 @@ def claimOwnership(users):
skipFileIdEntity = initDriveFileEntity() skipFileIdEntity = initDriveFileEntity()
OBY = OrderBy(DRIVEFILE_ORDERBY_CHOICE_MAP) OBY = OrderBy(DRIVEFILE_ORDERBY_CHOICE_MAP)
body = {} body = {}
skipusers = [] checkOnly = checkSkip = False
onlyOwners = set()
skipOwners = set()
subdomains = [] subdomains = []
filepath = includeTrashed = False filepath = includeTrashed = False
pathDelimiter = '/' pathDelimiter = '/'
@@ -60908,8 +60910,14 @@ def claimOwnership(users):
showRetentionMessages = False showRetentionMessages = False
elif myarg == 'skipids': elif myarg == 'skipids':
skipFileIdEntity = getDriveFileEntity() skipFileIdEntity = getDriveFileEntity()
elif myarg == 'onlyusers':
_, userList = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS)
checkOnly = True
onlyOwners = set(userList)
elif myarg == 'skipusers': elif myarg == 'skipusers':
_, skipusers = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS) _, userList = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS)
checkSkip = len(userList) > 0
skipOwners = set(userList)
elif myarg == 'subdomains': elif myarg == 'subdomains':
subdomains = getEntityList(Cmd.OB_DOMAIN_NAME_ENTITY) subdomains = getEntityList(Cmd.OB_DOMAIN_NAME_ENTITY)
elif myarg == 'includetrashed': elif myarg == 'includetrashed':
@@ -60936,6 +60944,9 @@ def claimOwnership(users):
changeParents = True changeParents = True
else: else:
unknownArgumentExit() unknownArgumentExit()
if checkOnly and checkSkip:
usageErrorExit(Msg.ARE_MUTUALLY_EXCLUSIVE.format('onlyusers', 'skipusers'))
checkOwner = checkOnly or checkSkip
Act.Set(Act.CLAIM_OWNERSHIP) Act.Set(Act.CLAIM_OWNERSHIP)
if csvPF: if csvPF:
if filepath: if filepath:
@@ -61020,7 +61031,7 @@ def claimOwnership(users):
filesTransferred.add(fileId) filesTransferred.add(fileId)
if fileId not in skipFileIdEntity['list'] and (includeTrashed or not fileEntryInfo['trashed']): if fileId not in skipFileIdEntity['list'] and (includeTrashed or not fileEntryInfo['trashed']):
owner = fileEntryInfo['owners'][0]['emailAddress'] owner = fileEntryInfo['owners'][0]['emailAddress']
if not fileEntryInfo['ownedByMe'] and owner not in skipusers: if (not fileEntryInfo['ownedByMe']) and ((not checkOwner) or (checkOnly and owner in onlyOwners) or (checkSkip and owner not in skipOwners)):
oldOwnerPermissionIds[owner] = fileEntryInfo['owners'][0]['permissionId'] oldOwnerPermissionIds[owner] = fileEntryInfo['owners'][0]['permissionId']
filesToClaim.setdefault(owner, {}) filesToClaim.setdefault(owner, {})
if fileId not in filesToClaim[owner]: if fileId not in filesToClaim[owner]: