Updated code in gam delete|update chromepolicy to handle the policyTargetKey[additionalTargetKeys] field in a more general manner for future use.

This commit is contained in:
Ross Scroggs 2025-04-17 16:17:17 -07:00
parent 742a6f14fe
commit d2b7e339ff
No known key found for this signature in database
GPG Key ID: 54585EA0887857D5
5 changed files with 34 additions and 22 deletions

View File

@ -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 <ActivityApplictionName>` where a report with no activities

View File

@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__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 or printer_id:
request['policyTargetKey'].setdefault('additionalTargetKeys', {})
if app_id:
request['policyTargetKey']['additionalTargetKeys'] = {'app_id': app_id}
request['policyTargetKey']['additionalTargetKeys']['app_id'] = app_id
elif printer_id:
request['policyTargetKey']['additionalTargetKeys'] = {'printer_id': printer_id}
request['policyTargetKey']['additionalTargetKeys']['printer_id'] = printer_id
# gam delete chromepolicy
# (<SchemaName> [<JSONData>])+
@ -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

View File

@ -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 <ActivityApplictionName>` where a report with no activities

View File

@ -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 <google-apps-manager@googlegroups.com>
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 <google-apps-manager@googlegroups.com>
Python 3.13.3 64-bit final
Windows-10-10.0.17134 AMD64

View File

@ -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 <google-apps-manager@googlegroups.com>
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 <google-apps-manager@googlegroups.com>
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 <google-apps-manager@googlegroups.com>
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 <google-apps-manager@googlegroups.com>
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