Fix browser error messages, item name map in update browser (#1293)

* Update cbcm.py

Fix error message
$ gam update browser a27590cb-61fc-4ca3-8ef7-34bf736c4973 asset FileMakerServer

ERROR: asset is not a valid argument for "gam print browsers"

Fix item name map
$ gam update browser a27590cb-61fc-4ca3-8ef7-34bf736c4973 assetid FileMakerServer location Location notes Notes user User

ERROR: 400: Invalid JSON payload received. Unknown name "annotatedAssetid" at 'browser': Cannot find field. - invalid

* Fix more error messages
This commit is contained in:
Ross Scroggs
2020-12-11 06:20:03 -08:00
committed by GitHub
parent a8f1031e0f
commit 3036366de5

View File

@@ -103,12 +103,12 @@ def move():
i += 2
else:
controlflow.invalid_argument_exit(sys.argv[i],
'gam update browsers')
'gam move browsers')
if 'org_unit_path' not in body:
controlflow.missing_argument_exit('ou', 'gam update browsers')
controlflow.missing_argument_exit('ou', 'gam move browsers')
elif not resource_ids:
controlflow.missing_argument_exit('query or ids',
'gam update browsers')
'gam move browsers')
# split moves into max 600 devices per batch
for chunk in range(0, len(resource_ids), batch_size):
body['resource_ids'] = resource_ids[chunk:chunk + batch_size]
@@ -166,21 +166,26 @@ def print_():
display.sort_csv_titles(['name',], titles)
display.write_csv_file(csv_rows, titles, 'Browsers', todrive)
attributes = {
'assetid': 'annotatedAssetId',
'location': 'annotatedLocation',
'notes': 'annotatedNotes',
'user': 'annotatedUser'
}
def update():
cbcm = build()
device_id = sys.argv[3]
body = {'deviceId': device_id}
attributes = ['user', 'location', 'notes', 'assetid']
i = 4
while i < len(sys.argv):
myarg = sys.argv[i].lower().replace('_', '')
if myarg in attributes:
attribute = f'annotated{myarg.capitalize()}'
body[attribute] = sys.argv[i+1]
body[attributes[myarg]] = sys.argv[i+1]
i += 2
else:
controlflow.invalid_argument_exit(sys.argv[i],
'gam print browsers')
'gam update browser')
result = gapi.call(cbcm.chromebrowsers(), 'update', deviceId=device_id,
customer=GC_Values[GC_CUSTOMER_ID], body=body,
projection='BASIC', fields="deviceId")