From d9b7f88287a193434938f23a7506d9e40aec85c7 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Mon, 13 Feb 2023 21:51:41 +0000 Subject: [PATCH] 6.42 - build shared drive restrictions dynamically --- src/gam/__init__.py | 18 ++++-------------- src/gam/var.py | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 1a5abcbc..11a36561 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -8175,20 +8175,14 @@ def doCreateSharedDrive(users): 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): i, driveId = getSharedDriveId(5) body = {} useDomainAdminAccess = False change_hide = 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): myarg = sys.argv[i].lower().replace('_', '') if myarg == 'name': @@ -8214,19 +8208,15 @@ def doUpdateSharedDrive(users): elif myarg == 'asadmin': useDomainAdminAccess = True i += 1 -# elif myarg in ['ou', 'org', 'orgunit']: -# body['orgUnitId'] = gapi_directory_orgunits.getOrgUnitId(sys.argv[i + 1]) -# i += 2 elif myarg in ['hidden']: if getBoolean(sys.argv[i+1], myarg): change_hide = 'hide' else: change_hide = 'unhide' i += 2 - elif myarg in TEAMDRIVE_RESTRICTIONS_MAP: + elif myarg in restrictions_map: body.setdefault('restrictions', {}) - body['restrictions'][ - TEAMDRIVE_RESTRICTIONS_MAP[myarg]] = getBoolean( + body['restrictions'][restrictions_map[myarg]] = getBoolean( sys.argv[i + 1], myarg) i += 2 else: diff --git a/src/gam/var.py b/src/gam/var.py index a0ba961a..ef59d690 100644 --- a/src/gam/var.py +++ b/src/gam/var.py @@ -8,7 +8,7 @@ import platform import re GAM_AUTHOR = 'Jay Lee ' -GAM_VERSION = '6.41' +GAM_VERSION = '6.42' GAM_LICENSE = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' GAM_URL = 'https://jaylee.us/gam'