Update Shared Drive restriction settings

This commit is contained in:
Ross Scroggs
2025-07-25 12:58:34 -07:00
parent a0282ba775
commit 78453a15af
3 changed files with 27 additions and 12 deletions

View File

@@ -4860,8 +4860,8 @@ gam <UserTypeEntity> sendemail from <EmailAddress>
allowcontentmanagerstosharefolders|
copyrequireswriterpermission|
domainusersonly|
downloadrestrictedforreaders|
downloadrestrictedforwriters|
downloadrestrictedforreaders|downloadrestrictions.restrictedforreaders|
downloadrestrictedforwriters|downloadrestrictions.restrictedforwriters|
drivemembersonly|teammembersonly|
sharingfoldersrequiresorganizerpermission
@@ -4878,7 +4878,7 @@ In these commands, the Google administrator named in oauth2.txt is used.
gam show shareddrivethemes
gam create shareddrive <Name>
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<SharedDriveRestrictionsSubfieldName> <Boolean>)*
([restrictions.]<SharedDriveRestrictionsSubfieldName> <Boolean>)*
[hide|hidden <Boolean>] [ou|org|orgunit <OrgUnitItem>]
[errorretries <Integer>] [updateinitialdelay <Integer>] [updateretrydelay <Integer>]
[movetoorgunitdelay <Integer>]
@@ -4932,7 +4932,7 @@ In these commands, you specify an administrator and then indicate that you want
gam <UserTypeEntity> create shareddrive <Name> adminaccess
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<SharedDriveRestrictionsSubfieldName> <Boolean>)*
([restrictions.]<SharedDriveRestrictionsSubfieldName> <Boolean>)*
[hide|hidden <Boolean>] [ou|org|orgunit <OrgUnitItem>]
[errorretries <Integer>] [updateinitialdelay <Integer>] [updateretrydelay <Integer>]
[movetoorgunitdelay <Integer>]
@@ -4966,7 +4966,7 @@ In these commands, you specify a user, administrator access is not used.
gam <UserTypeEntity> create shareddrive <Name>
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<SharedDriveRestrictionsSubfieldName> <Boolean>)*
([restrictions.]<SharedDriveRestrictionsSubfieldName> <Boolean>)*
[hide|hidden <Boolean>] [ou|org|orgunit <OrgUnitItem>]
[errorretries <Integer>] [updateinitialdelay <Integer>] [updateretrydelay <Integer>]
[movetoorgunitdelay <Integer>]
@@ -8475,8 +8475,8 @@ gam <UserTypeEntity> print tasklists [todrive <ToDriveAttribute>*]
allowcontentmanagerstosharefolders|
copyrequireswriterpermission|
domainusersonly|
downloadrestrictedforreaders|
downloadrestrictedforwriters|
downloadrestrictedforreaders|downloadrestrictions.restrictedforreaders|
downloadrestrictedforwriters|downloadrestrictions.restrictedforwriters|
drivemembersonly|teammembersonly|
sharingfoldersrequiresorganizerpermission
@@ -8491,13 +8491,13 @@ sharingfoldersrequiresorganizerpermission true
gam <UserTypeEntity> show shareddrivethemes
gam <UserTypeEntity> create shareddrive <Name>
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<SharedDriveRestrictionsSubfieldName> <Boolean>)*
([restrictions.]<SharedDriveRestrictionsSubfieldName> <Boolean>)*
[hide|hidden <Boolean>]
[errorretries <Integer>] [updateinitialdelay <Integer>] [updateretrydelay <Integer>]
[(csv [todrive <ToDriveAttribute>*] (addcsvdata <FieldName> <String>)*) | returnidonly]
gam <UserTypeEntity> update shareddrive <SharedDriveEntity> [name <Name>]
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<SharedDriveRestrictionsSubfieldName> <Boolean>)*
([restrictions.]<SharedDriveRestrictionsSubfieldName> <Boolean>)*
[hide|hidden <Boolean>]
gam <UserTypeEntity> delete shareddrive <SharedDriveEntity>
[allowitemdeletion]

View File

@@ -1,3 +1,9 @@
7.15.01
Added `downloadrestrictions.restrictedforreaders` and `downloadrestrictions.restrictedforwriters`
to `<SharedDriveRestrictionsSubfieldName>`; previously, only the abbreviations `downloadrestrictedforreaders`
and `downloadrestrictedforwriters` were supported (they are still supported).
7.15.00
Updated `gam print shareddriveorganizers` to make `shownoorganizerdrives` default to `True`

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.15.00'
__version__ = '7.15.01'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position
@@ -60309,7 +60309,7 @@ def _checkForExistingShortcut(drive, fileId, fileName, parentId):
supportsAllDrives=True, includeItemsFromAllDrives=True,
q=f"shortcutDetails.targetId = '{fileId}' and trashed = False", fields='files(id,name,parents)')['files']
for shortcut in existingShortcuts:
if parentId in shortcut['parents'] and fileName == shortcut['name']:
if parentId in shortcut.get('parents', []) and fileName == shortcut['name']:
return shortcut['id']
except (GAPI.invalidQuery, GAPI.invalid, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
pass
@@ -65885,6 +65885,10 @@ SHAREDDRIVE_RESTRICTIONS_MAP = {
'sharingfoldersrequiresorganizerpermission': 'sharingFoldersRequiresOrganizerPermission',
'teammembersonly': 'driveMembersOnly',
}
SHAREDDRIVE_DOWNLOAD_RESTRICTIONS_MAP = {
'restrictedforreaders': 'downloadrestrictedforreaders',
'restrictedforwriters': 'downloadrestrictedforwriters',
}
def _getSharedDriveRestrictions(myarg, body):
def _setRestriction(restriction):
@@ -65899,7 +65903,12 @@ def _getSharedDriveRestrictions(myarg, body):
if myarg.startswith('restrictions.'):
_, subField = myarg.split('.', 1)
if subField in SHAREDDRIVE_RESTRICTIONS_MAP:
if subField.startswith('downloadrestrictions.'):
_, subField = subField.split('.', 1)
if subField in SHAREDDRIVE_DOWNLOAD_RESTRICTIONS_MAP:
_setRestriction(SHAREDDRIVE_DOWNLOAD_RESTRICTIONS_MAP[subField])
return True
elif subField in SHAREDDRIVE_RESTRICTIONS_MAP:
_setRestriction(subField)
return True
invalidChoiceExit(subField, SHAREDDRIVE_RESTRICTIONS_MAP, True)