6.42 - build shared drive restrictions dynamically

This commit is contained in:
Jay Lee
2023-02-13 21:51:41 +00:00
parent ae28c09560
commit d9b7f88287
2 changed files with 5 additions and 15 deletions

View File

@@ -8175,20 +8175,14 @@ def doCreateSharedDrive(users):
print(f'Created Shared Drive {body["name"]} with id {result["id"]}') print(f'Created Shared Drive {body["name"]} with id {result["id"]}')
TEAMDRIVE_RESTRICTIONS_MAP = {
'adminmanagedrestrictions': 'adminManagedRestrictions',
'copyrequireswriterpermission': 'copyRequiresWriterPermission',
'domainusersonly': 'domainUsersOnly',
'teammembersonly': 'teamMembersOnly',
}
def doUpdateSharedDrive(users): def doUpdateSharedDrive(users):
i, driveId = getSharedDriveId(5) i, driveId = getSharedDriveId(5)
body = {} body = {}
useDomainAdminAccess = False useDomainAdminAccess = False
change_hide = None change_hide = None
orgUnit = None orgUnit = None
_, d = buildDrive3GAPIObject(_get_admin_email())
restrictions_map = {r.lower(): r for r in d._rootDesc['schemas']['Drive']['properties']['restrictions']['properties'].keys()}
while i < len(sys.argv): while i < len(sys.argv):
myarg = sys.argv[i].lower().replace('_', '') myarg = sys.argv[i].lower().replace('_', '')
if myarg == 'name': if myarg == 'name':
@@ -8214,19 +8208,15 @@ def doUpdateSharedDrive(users):
elif myarg == 'asadmin': elif myarg == 'asadmin':
useDomainAdminAccess = True useDomainAdminAccess = True
i += 1 i += 1
# elif myarg in ['ou', 'org', 'orgunit']:
# body['orgUnitId'] = gapi_directory_orgunits.getOrgUnitId(sys.argv[i + 1])
# i += 2
elif myarg in ['hidden']: elif myarg in ['hidden']:
if getBoolean(sys.argv[i+1], myarg): if getBoolean(sys.argv[i+1], myarg):
change_hide = 'hide' change_hide = 'hide'
else: else:
change_hide = 'unhide' change_hide = 'unhide'
i += 2 i += 2
elif myarg in TEAMDRIVE_RESTRICTIONS_MAP: elif myarg in restrictions_map:
body.setdefault('restrictions', {}) body.setdefault('restrictions', {})
body['restrictions'][ body['restrictions'][restrictions_map[myarg]] = getBoolean(
TEAMDRIVE_RESTRICTIONS_MAP[myarg]] = getBoolean(
sys.argv[i + 1], myarg) sys.argv[i + 1], myarg)
i += 2 i += 2
else: else:

View File

@@ -8,7 +8,7 @@ import platform
import re import re
GAM_AUTHOR = 'Jay Lee <jay0lee@gmail.com>' GAM_AUTHOR = 'Jay Lee <jay0lee@gmail.com>'
GAM_VERSION = '6.41' GAM_VERSION = '6.42'
GAM_LICENSE = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' GAM_LICENSE = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
GAM_URL = 'https://jaylee.us/gam' GAM_URL = 'https://jaylee.us/gam'