mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-06 13:51:36 +00:00
Require doit argument to update >1 devices
This commit is contained in:
13
src/gam.py
13
src/gam.py
@@ -9694,6 +9694,7 @@ def doUpdateMobile():
|
|||||||
cd = buildGAPIObject('directory')
|
cd = buildGAPIObject('directory')
|
||||||
resourceIds = sys.argv[3]
|
resourceIds = sys.argv[3]
|
||||||
only_users = None
|
only_users = None
|
||||||
|
doit = False
|
||||||
if resourceIds[:6] == 'query:':
|
if resourceIds[:6] == 'query:':
|
||||||
query = resourceIds[6:]
|
query = resourceIds[6:]
|
||||||
fields='nextPageToken,mobiledevices(resourceId,email)'
|
fields='nextPageToken,mobiledevices(resourceId,email)'
|
||||||
@@ -9716,16 +9717,26 @@ def doUpdateMobile():
|
|||||||
elif myarg == 'ifusers':
|
elif myarg == 'ifusers':
|
||||||
only_users = getUsersToModify(entity_type=sys.argv[i+1].lower(), entity=sys.argv[i+2])
|
only_users = getUsersToModify(entity_type=sys.argv[i+1].lower(), entity=sys.argv[i+2])
|
||||||
i += 3
|
i += 3
|
||||||
|
elif myarg == 'doit':
|
||||||
|
doit = True
|
||||||
else:
|
else:
|
||||||
systemErrorExit(2, '%s is not a valid argument for "gam update mobile"' % sys.argv[i])
|
systemErrorExit(2, '%s is not a valid argument for "gam update mobile"' % sys.argv[i])
|
||||||
if body:
|
if body:
|
||||||
|
if len(devices) == 1:
|
||||||
|
doit = True
|
||||||
|
if doit:
|
||||||
print('Updating %s devices' % len(devices))
|
print('Updating %s devices' % len(devices))
|
||||||
|
describe_as = 'Performing'
|
||||||
|
else:
|
||||||
|
print('Showing changes that would be made, not actually making changes because doit argument not specified')
|
||||||
|
describe_as = 'Would perform'
|
||||||
for device in devices:
|
for device in devices:
|
||||||
device_user = device.get('email', [''])[0]
|
device_user = device.get('email', [''])[0]
|
||||||
if only_users and device_user not in only_users:
|
if only_users and device_user not in only_users:
|
||||||
print('Skipping device for user %s that did not match if_users argument' % device_user)
|
print('Skipping device for user %s that did not match if_users argument' % device_user)
|
||||||
else:
|
else:
|
||||||
print('Performing %s on user %s device %s' % (body['action'], device_user, device['resourceId']))
|
print('%s %s on user %s device %s' % (describe_as, body['action'], device_user, device['resourceId'])
|
||||||
|
if doit:
|
||||||
callGAPI(cd.mobiledevices(), 'action', resourceId=device['resourceId'], body=body, customerId=GC_Values[GC_CUSTOMER_ID])
|
callGAPI(cd.mobiledevices(), 'action', resourceId=device['resourceId'], body=body, customerId=GC_Values[GC_CUSTOMER_ID])
|
||||||
|
|
||||||
def doDeleteMobile():
|
def doDeleteMobile():
|
||||||
|
|||||||
Reference in New Issue
Block a user