From b9a489251b1f67ca6042af1eb0671684c60439f4 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 20 Feb 2026 13:54:14 -0800 Subject: [PATCH] Added option `copyfolderpermissions []` to `gam copy|move drivefile` --- src/GamCommands.txt | 2 ++ src/GamUpdate.txt | 20 ++++++++++++++++++++ src/gam/__init__.py | 27 +++++++++++++++++++-------- src/gam/gamlib/glapi.py | 10 ++++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 04fdba60..0b057985 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -6907,6 +6907,7 @@ gam copy drivefile [copyfilepermissions []] [copyfileinheritedpermissions [] [copyfilenoninheritedpermissions [] + [copyfolderpermissions []] [copymergewithparentfolderpermissions []] [copymergedtopfolderpermissions []] [copytopfolderpermissions []] @@ -6936,6 +6937,7 @@ gam move drivefile [newfilename ]] [duplicatefiles overwriteolder|overwriteall|duplicatename|uniquename|skip] [duplicatefolders merge|duplicatename|uniquename|skip] + [copyfolderpermissions []] [copymergewithparentfolderpermissions []] [copymergedtopfolderpermissions []] [copytopfolderpermissions []] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 9e806f66..282acf57 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,23 @@ +7.34.06 + +Added option `copyfolderpermissions []` to `gam copy|move drivefile`. + +When `copyfolderpermissions false` is specified, no folder permissions are copied; this simplifies +disabling all folder permission copying. + +When not specified or `copyfolderpermissions [true]` is specified, folder permissions are copied based on the following options: +``` +copymergewithparentfolderpermissions [] +copymergedtopfolderpermissions [] +copytopfolderpermissions [] +copytopfolderiheritedpermissions [] +copytopfoldernoniheritedpermissions never|always|syncallfolders|syncupdatedfolders +copymergedsubfolderpermissions [] +copysubfolderpermissions [] +copysubfolderinheritedpermissions [] +copysubfoldernoniheritedpermissions never|always|syncallfolders|syncupdatedfolders +``` + 7.34.05 Updated `gam report ` to perform a reverse chronological sort diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 49e565ed..5ad13f01 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.34.05' +__version__ = '7.34.06' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' # pylint: disable=wrong-import-position @@ -37831,7 +37831,7 @@ def doCreateUpdateCIPolicy(): updateCmd = Act.Get() == Act.UPDATE groupEmail = orgUnit = None checkArgumentPresent('json', True) - jsonData = getJSON(['type']) + jsonData = getJSON(['customer', 'type']) if updateCmd: pname = jsonData.pop('name', None) else: @@ -62065,6 +62065,7 @@ def initCopyMoveOptions(copyCmd): 'copyFilePermissions': False, 'copyFileInheritedPermissions': True, 'copyFileNonInheritedPermissions': COPY_NONINHERITED_PERMISSIONS_ALWAYS, + 'copyFolderPermissions': True, 'copyMergeWithParentFolderPermissions': False, 'copyMergedTopFolderPermissions': copyCmd, 'copyMergedSubFolderPermissions': copyCmd, @@ -62142,6 +62143,8 @@ def getCopyMoveOptions(myarg, copyMoveOptions): copyMoveOptions['duplicateFiles'] = getChoice(DUPLICATE_FILE_CHOICES, mapChoice=True) elif myarg == 'duplicatefolders': copyMoveOptions['duplicateFolders'] = getChoice(DUPLICATE_FOLDER_CHOICES, mapChoice=True) + elif myarg == 'copyfolderpermissions': + copyMoveOptions['copyFolderPermissions'] = getBoolean() elif myarg == 'copymergewithparentfolderpermissions': copyMoveOptions['copyMergeWithParentFolderPermissions'] = getBoolean() elif myarg == 'copymergedtopfolderpermissions': @@ -62820,6 +62823,7 @@ copyReturnItemMap = { # [copyfilepermissions []] # [copyfileinheritedpermissions [] # [copyfilenoninheritedpermissions [] +# [copyfolderpermissions []] # [copymergewithparentfolderpermissions []] # [copymergedtopfolderpermissions []] # [copytopfolderpermissions []] @@ -62867,7 +62871,8 @@ def copyDriveFile(users): _writeCSVData(user, folderName, folderId, newParentName, newParentId, MIMETYPE_GA_FOLDER) Act.Set(action) _incrStatistic(statistics, STAT_FOLDER_MERGED) - if (copyMoveOptions['copyMergeWithParentFolderPermissions'] and + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions['copyMergeWithParentFolderPermissions'] and copyMoveOptions['destParentType'] != DEST_PARENT_MYDRIVE_ROOT): copyFolderNonInheritedPermissions =\ _getCopyFolderNonInheritedPermissions(copyMoveOptions, @@ -62897,7 +62902,8 @@ def copyDriveFile(users): _writeCSVData(user, folderName, folderId, newFolderName, newFolderId, MIMETYPE_GA_FOLDER) Act.Set(action) _incrStatistic(statistics, STAT_FOLDER_MERGED) - if (copyMoveOptions[['copyMergedSubFolderPermissions', 'copyMergedTopFolderPermissions'][atTop]] and + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions[['copyMergedSubFolderPermissions', 'copyMergedTopFolderPermissions'][atTop]] and (not atTop or copyMoveOptions['destParentType'] != DEST_PARENT_MYDRIVE_ROOT)): copyFolderNonInheritedPermissions =\ _getCopyFolderNonInheritedPermissions(copyMoveOptions, @@ -62949,7 +62955,8 @@ def copyDriveFile(users): else: _writeCSVData(user, folderName, folderId, newFolderName, newFolderId, body['mimeType']) _incrStatistic(statistics, STAT_FOLDER_COPIED_MOVED) - if copyMoveOptions[['copySubFolderPermissions', 'copyTopFolderPermissions'][atTop]]: + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions[['copySubFolderPermissions', 'copyTopFolderPermissions'][atTop]]): _copyPermissions(drive, user, i, count, j, jcount, Ent.DRIVE_FOLDER, folderId, folderName, newFolderId, newFolderName, statistics, STAT_FOLDER_PERMISSIONS_FAILED, @@ -63704,6 +63711,7 @@ def _recursiveUpdateMovePermissions(drive, user, i, count, # [createshortcutsfornonmovablefiles []] # [duplicatefiles overwriteolder|overwriteall|duplicatename|uniquename|skip] # [duplicatefolders merge|duplicatename|uniquename|skip] +# [copyfolderpermissions []] # [copymergewithparentfolderpermissions []] # [copymergedtopfolderpermissions []] # [copytopfolderpermissions []] @@ -63740,7 +63748,8 @@ def moveDriveFile(users): entityPerformActionModifierItemValueList(kvList, Act.MODIFIER_CONTENTS_WITH, [Ent.DRIVE_FOLDER, newParentNameId], j, jcount) Act.Set(action) _incrStatistic(statistics, STAT_FOLDER_MERGED) - if (copyMoveOptions['copyMergeWithParentFolderPermissions'] and + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions['copyMergeWithParentFolderPermissions'] and copyMoveOptions['destParentType'] != DEST_PARENT_MYDRIVE_ROOT): copyFolderNonInheritedPermissions =\ _getCopyFolderNonInheritedPermissions(copyMoveOptions, @@ -63770,7 +63779,8 @@ def moveDriveFile(users): entityModifierItemValueListActionPerformed(kvList, Act.MODIFIER_CONTENTS_WITH, [Ent.DRIVE_FOLDER, f'{newFolderName}({newFolderId})'], j, jcount) Act.Set(action) _incrStatistic(statistics, STAT_FOLDER_MERGED) - if (copyMoveOptions[['copyMergedSubFolderPermissions', 'copyMergedTopFolderPermissions'][atTop]] and + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions[['copyMergedSubFolderPermissions', 'copyMergedTopFolderPermissions'][atTop]] and (not atTop or copyMoveOptions['destParentType'] != DEST_PARENT_MYDRIVE_ROOT)): copyFolderNonInheritedPermissions =\ _getCopyFolderNonInheritedPermissions(copyMoveOptions, @@ -63864,7 +63874,8 @@ def moveDriveFile(users): j, jcount) Act.Set(action) _incrStatistic(statistics, STAT_FOLDER_COPIED_MOVED) - if copyMoveOptions[['copySubFolderPermissions', 'copyTopFolderPermissions'][atTop]]: + if (copyMoveOptions['copyFolderPermissions'] and + copyMoveOptions[['copySubFolderPermissions', 'copyTopFolderPermissions'][atTop]]): _copyPermissions(drive, user, i, count, j, jcount, Ent.DRIVE_FOLDER, folderId, folderName, newFolderId, newFolderName, statistics, STAT_FOLDER_PERMISSIONS_FAILED, diff --git a/src/gam/gamlib/glapi.py b/src/gam/gamlib/glapi.py index fed57997..36d309bc 100644 --- a/src/gam/gamlib/glapi.py +++ b/src/gam/gamlib/glapi.py @@ -649,6 +649,16 @@ _SVCACCT_SCOPES = [ 'api': CLOUDIDENTITY_DEVICES, 'subscopes': READONLY, 'scope': 'https://www.googleapis.com/auth/cloud-identity.devices'}, +# {'name': 'Cloud Identity API - Policy', +# 'api': CLOUDIDENTITY_POLICY, +# 'subscopes': READONLY, +# 'roByDefault': True, +# 'scope': 'https://www.googleapis.com/auth/cloud-identity.policies'}, +# {'name': 'Cloud Identity API - Policy Beta', +# 'api': CLOUDIDENTITY_POLICY_BETA, +# 'subscopes': [], +# 'offByDefault': True, +# 'scope': 'https://www.googleapis.com/auth/cloud-identity.policies'}, # {'name': 'Cloud Identity User Invitations API', # 'api': CLOUDIDENTITY_USERINVITATIONS, # 'subscopes': READONLY,