From 597a236e05e932b3456e81ab6e229a4aee6201a9 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 30 Jun 2017 12:03:50 -0700 Subject: [PATCH] Directory API Mobiledevices update no longer supported (#519) --- src/GamCommands.txt | 7 +++---- src/gam.py | 37 ++++++++++--------------------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index cbdc31b2..f3311e2e 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -472,9 +472,8 @@ Item attributes (whocanviewgroup ANYONE_CAN_VIEW|ALL_IN_DOMAIN_CAN_VIEW|ALL_MEMBERS_CAN_VIEW|ALL_MANAGERS_CAN_VIEW)| (whocanviewmembership ALL_IN_DOMAIN_CAN_VIEW|ALL_MEMBERS_CAN_VIEW|ALL_MANAGERS_CAN_VIEW) - ::= - (model )|(os )|(useragent )| - (action admin_remote_wipe|wipe|admin_account_wipe|accountwipe|wipeaccount|approve|block|cancel_remote_wipe_then_activate|cancel_remote_wipe_then_block) + ::= + admin_remote_wipe|wipe|admin_account_wipe|accountwipe|wipeaccount|approve|block|cancel_remote_wipe_then_activate|cancel_remote_wipe_then_block ::= (currentquota )|(dailyquota )| (defaultdisplayname )|(description )|(displayname )|(firmware )|(gcpversion )| @@ -655,7 +654,7 @@ The listlimit argument limits the number of recent users and time range The start and end arguments filter the time ranges. Delimiter defaults to comma. -gam update mobile + +gam update mobile action gam delete mobile gam info mobile gam print mobile [todrive] [query ] [basic|full] [orderby [ascending|descending]] diff --git a/src/gam.py b/src/gam.py index 8b5183b9..1651333c 100755 --- a/src/gam.py +++ b/src/gam.py @@ -7520,40 +7520,23 @@ def doUpdateMobile(): cd = buildGAPIObject(u'directory') resourceId = sys.argv[3] i = 4 - action_body = {} - patch_body = {} - doPatch = doAction = False + body = {} while i < len(sys.argv): if sys.argv[i].lower() == u'action': - action_body[u'action'] = sys.argv[i+1].lower() - if action_body[u'action'] == u'wipe': - action_body[u'action'] = u'admin_remote_wipe' - elif action_body[u'action'].replace(u'_', u'') in [u'accountwipe', u'wipeaccount']: - action_body[u'action'] = u'admin_account_wipe' - if action_body[u'action'] not in [u'admin_remote_wipe', u'admin_account_wipe', u'approve', u'block', u'cancel_remote_wipe_then_activate', u'cancel_remote_wipe_then_block']: - print u'ERROR: action must be one of wipe, wipeaccount, approve, block, cancel_remote_wipe_then_activate, cancel_remote_wipe_then_block; got %s' % action_body[u'action'] + body[u'action'] = sys.argv[i+1].lower() + if body[u'action'] == u'wipe': + body[u'action'] = u'admin_remote_wipe' + elif body[u'action'].replace(u'_', u'') in [u'accountwipe', u'wipeaccount']: + body[u'action'] = u'admin_account_wipe' + if body[u'action'] not in [u'admin_remote_wipe', u'admin_account_wipe', u'approve', u'block', u'cancel_remote_wipe_then_activate', u'cancel_remote_wipe_then_block']: + print u'ERROR: action must be one of wipe, wipeaccount, approve, block, cancel_remote_wipe_then_activate, cancel_remote_wipe_then_block; got %s' % body[u'action'] sys.exit(2) - doAction = True i += 2 - elif sys.argv[i].lower() == u'model': - patch_body[u'model'] = sys.argv[i+1] - i += 2 - doPatch = True - elif sys.argv[i].lower() == u'os': - patch_body[u'os'] = sys.argv[i+1] - i += 2 - doPatch = True - elif sys.argv[i].lower() == u'useragent': - patch_body[u'userAgent'] = sys.argv[i+1] - i += 2 - doPatch = True else: print u'ERROR: %s is not a valid argument for "gam update mobile"' % sys.argv[i] sys.exit(2) - if doPatch: - callGAPI(cd.mobiledevices(), u'update', resourceId=resourceId, body=patch_body, customerId=GC_Values[GC_CUSTOMER_ID]) - if doAction: - callGAPI(cd.mobiledevices(), u'action', resourceId=resourceId, body=action_body, customerId=GC_Values[GC_CUSTOMER_ID]) + if body: + callGAPI(cd.mobiledevices(), u'action', resourceId=resourceId, body=body, customerId=GC_Values[GC_CUSTOMER_ID]) def doDeleteMobile(): cd = buildGAPIObject(u'directory')