From d2b7e339ff187b3c94bc9dfca4e40ad02898c4d7 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Thu, 17 Apr 2025 16:17:17 -0700 Subject: [PATCH] Updated code in `gam delete|update chromepolicy` to handle the `policyTargetKey[additionalTargetKeys]` field in a more general manner for future use. --- src/GamUpdate.txt | 5 +++++ src/gam/__init__.py | 20 +++++++++++--------- wiki/GamUpdates.md | 5 +++++ wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md | 6 +++--- wiki/Version-and-Help.md | 20 ++++++++++---------- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 61d88a46..a5319194 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,8 @@ +7.06.05 + +Updated code in `gam delete|update chromepolicy` to handle the `policyTargetKey[additionalTargetKeys]` +field in a more general manner for future use. + 7.06.04 Fixed bug in `gam report ` where a report with no activities diff --git a/src/gam/__init__.py b/src/gam/__init__.py index b7b31be0..f972cd11 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.06.04' +__version__ = '7.06.05' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' #pylint: disable=wrong-import-position @@ -28090,10 +28090,12 @@ def updatePolicyRequests(body, targetResource, printer_id, app_id): for request in body['requests']: request.setdefault('policyTargetKey', {}) request['policyTargetKey']['targetResource'] = targetResource - if app_id: - request['policyTargetKey']['additionalTargetKeys'] = {'app_id': app_id} - elif printer_id: - request['policyTargetKey']['additionalTargetKeys'] = {'printer_id': printer_id} + if app_id or printer_id: + request['policyTargetKey'].setdefault('additionalTargetKeys', {}) + if app_id: + request['policyTargetKey']['additionalTargetKeys']['app_id'] = app_id + elif printer_id: + request['policyTargetKey']['additionalTargetKeys']['printer_id'] = printer_id # gam delete chromepolicy # ( [])+ @@ -28126,9 +28128,9 @@ def doDeleteChromePolicy(): if checkArgumentPresent('json'): jsonData = getJSON(['direct', 'name', 'orgUnitPath', 'parentOrgUnitPath', 'group']) if 'additionalTargetKeys' in jsonData: - body['requests'][-1].setdefault('policyTargetKey', {}) + body['requests'][-1].setdefault('policyTargetKey', {'additionalTargetKeys': {}}) for atk in jsonData['additionalTargetKeys']: - body['requests'][-1]['policyTargetKey']['additionalTargetKeys'] = {atk['name']: atk['value']} + body['requests'][-1]['policyTargetKey']['additionalTargetKeys'][atk['name']] = atk['value'] checkPolicyArgs(targetResource, printer_id, app_id) count = len(body['requests']) if count != 1: @@ -28281,9 +28283,9 @@ def doUpdateChromePolicy(): jsonData = getJSON(['direct', 'name', 'orgUnitPath', 'parentOrgUnitPath', 'group']) schemaNameAppId = schemaName if 'additionalTargetKeys' in jsonData: - body['requests'][-1].setdefault('policyTargetKey', {}) + body['requests'][-1].setdefault('policyTargetKey', {'additionalTargetKeys': {}}) for atk in jsonData['additionalTargetKeys']: - body['requests'][-1]['policyTargetKey']['additionalTargetKeys'] = {atk['name']: atk['value']} + body['requests'][-1]['policyTargetKey']['additionalTargetKeys'][atk['name']] = atk['value'] if atk['name'] == 'app_id': schemaNameAppId += f"({atk['value']})" schemaNameList[-1] = schemaNameAppId diff --git a/wiki/GamUpdates.md b/wiki/GamUpdates.md index 9e8c1794..dba0d5f3 100644 --- a/wiki/GamUpdates.md +++ b/wiki/GamUpdates.md @@ -10,6 +10,11 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads-Installs-GAM7](https://github.com/GAM-team/GAM/wiki/Downloads-Installs) for Windows or other options, including manual installation +### 7.06.05 + +Updated code in `gam delete|update chromepolicy` to handle the `policyTargetKey[additionalTargetKeys]` +field in a more general manner for future use. + ### 7.06.04 Fixed bug in `gam report ` where a report with no activities diff --git a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md index 3fcaea93..4b607785 100644 --- a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md +++ b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md @@ -251,10 +251,10 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAM 7.06.04 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.06.05 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final -MacOS Sequoia 15.4 x86_64 +MacOS Sequoia 15.4.1 x86_64 Path: /Users/admin/bin/gam7 Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain: domain.com @@ -989,7 +989,7 @@ writes the credentials into the file oauth2.txt. C:\>del C:\GAMConfig\oauth2.txt C:\>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAM 7.06.04 - https://github.com/GAM-team/GAM - pythonsource +GAM 7.06.05 - https://github.com/GAM-team/GAM - pythonsource GAM Team Python 3.13.3 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/wiki/Version-and-Help.md b/wiki/Version-and-Help.md index 25521426..4d1b52ee 100644 --- a/wiki/Version-and-Help.md +++ b/wiki/Version-and-Help.md @@ -4,10 +4,10 @@ k Print the current version of Gam with details ``` gam version -GAM 7.06.04 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.06.05 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final -MacOS Sequoia 15.4 x86_64 +MacOS Sequoia 15.4.1 x86_64 Path: /Users/Admin/bin/gam7 Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain: domain.com Time: 2023-06-02T21:10:00-07:00 @@ -16,10 +16,10 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAM 7.06.04 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.06.05 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final -MacOS Sequoia 15.4 x86_64 +MacOS Sequoia 15.4.1 x86_64 Path: /Users/Admin/bin/gam7 Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain: domain.com Your system time differs from www.googleapis.com by less than 1 second @@ -28,10 +28,10 @@ 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 ``` gam version extended -GAM 7.06.04 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.06.05 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.13.3 64-bit final -MacOS Sequoia 15.4 x86_64 +MacOS Sequoia 15.4.1 x86_64 Path: /Users/Admin/bin/gam7 Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain: domain.com Time: 2023-06-02T21:10:00-07:00 @@ -65,7 +65,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gam7 Version Check: Current: 5.35.08 - Latest: 7.06.04 + Latest: 7.06.05 echo $? 1 ``` @@ -73,7 +73,7 @@ echo $? Print the current version number without details ``` gam version simple -7.06.04 +7.06.05 ``` In Linux/MacOS you can do: ``` @@ -83,10 +83,10 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 7.06.04 - https://github.com/GAM-team/GAM +GAM 7.06.05 - https://github.com/GAM-team/GAM GAM Team Python 3.13.3 64-bit final -MacOS Sequoia 15.4 x86_64 +MacOS Sequoia 15.4.1 x86_64 Path: /Users/Admin/bin/gam7 Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, customer_id: my_customer, domain: domain.com Time: 2023-06-02T21:10:00-07:00