mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 06:33:34 +00:00
Add view all|company|personal to print devices (#1254)
* Add view all|company|personal to print devices Update documentation * sync devices cleanup * Update sync devices documentation * Cleanup; The advantage here is that they will be no filter errors unless you specify a particular view and a filter that doesn't match * Simplify selection of devices to print Default - all Positve choices Negative choices - backwards compatible
This commit is contained in:
@ -1146,18 +1146,17 @@ gam block deviceuser [id] <DeviceUserID>
|
|||||||
gam delete deviceuser [id] <DeviceUserID>
|
gam delete deviceuser [id] <DeviceUserID>
|
||||||
gam cancelwipe deviceuser [id] <DeviceUserID>
|
gam cancelwipe deviceuser [id] <DeviceUserID>
|
||||||
gam wipe deviceuser [id] <DeviceUserID>
|
gam wipe deviceuser [id] <DeviceUserID>
|
||||||
gam print devices [todrive] [query <QueryDevice>]
|
gam print devices [todrive] [filter|query <QueryDevice>]
|
||||||
[orderby <DeviceOrderByFieldName> [ascending|descending]]
|
[orderby <DeviceOrderByFieldName> [ascending|descending]]
|
||||||
[nocompanydevices] [nouserdevices] [nousers]
|
[company|personal|nocompanydevices|nopersonaldevices]
|
||||||
[formatjson [quotechar <Character>]]
|
[nodeviceusers]
|
||||||
gam sync devices
|
gam sync devices [filter|query <QueryDevice>]
|
||||||
csvfile <FileName>
|
csvfile <FileName>
|
||||||
[serialnumber_column <String>]
|
(devicetype_column <String>)|(static_devicetype <DeviceType>)
|
||||||
[devicetype_column <String>]
|
serialnumber_column <String>
|
||||||
[assetid_column <String>]
|
[assettag_column <String>]
|
||||||
[static_devicetype <DeviceType>]
|
[unassigned_missing_action delete|wipe|donothing]
|
||||||
[unassigned_missing_action delete|wipe|nonothing]
|
[assigned_missing_action delete|wipe|donothing]
|
||||||
[assigned_missing_action delete|wipe|nonothing]
|
|
||||||
|
|
||||||
gam update mobile <MobileID>|query:<QueryMobile> action <MobileAction> [doit] [if_users|match_users <UserTypeEntity>]
|
gam update mobile <MobileID>|query:<QueryMobile> action <MobileAction> [doit] [if_users|match_users <UserTypeEntity>]
|
||||||
gam delete mobile <MobileID>
|
gam delete mobile <MobileID>
|
||||||
|
@ -117,7 +117,7 @@ def print_():
|
|||||||
parent = 'devices/-'
|
parent = 'devices/-'
|
||||||
device_filter = None
|
device_filter = None
|
||||||
get_device_users = True
|
get_device_users = True
|
||||||
get_device_views = ['COMPANY_INVENTORY', 'USER_ASSIGNED_DEVICES']
|
view = None
|
||||||
orderByList = []
|
orderByList = []
|
||||||
titles = []
|
titles = []
|
||||||
csvRows = []
|
csvRows = []
|
||||||
@ -127,13 +127,19 @@ def print_():
|
|||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower().replace('_', '')
|
myarg = sys.argv[i].lower().replace('_', '')
|
||||||
if myarg in ['filter', 'query']:
|
if myarg in ['filter', 'query']:
|
||||||
device_filter = sys.argv[i+1]
|
device_filter = sys.argv[i+1]
|
||||||
i += 2
|
i += 2
|
||||||
|
elif myarg == 'company':
|
||||||
|
view = 'COMPANY_INVENTORY'
|
||||||
|
i += 1
|
||||||
|
elif myarg == 'personal':
|
||||||
|
view = 'USER_ASSIGNED_DEVICES'
|
||||||
|
i += 1
|
||||||
elif myarg == 'nocompanydevices':
|
elif myarg == 'nocompanydevices':
|
||||||
get_device_views.remove('COMPANY_INVENTORY')
|
view = 'USER_ASSIGNED_DEVICES'
|
||||||
i += 1
|
i += 1
|
||||||
elif myarg == 'nopersonaldevices':
|
elif myarg == 'nopersonaldevices':
|
||||||
get_device_views.remove('USER_ASSIGNED_DEVICES')
|
view = 'COMPANY_INVENTORY'
|
||||||
i += 1
|
i += 1
|
||||||
elif myarg == 'nodeviceusers':
|
elif myarg == 'nodeviceusers':
|
||||||
get_device_users = False
|
get_device_users = False
|
||||||
@ -166,6 +172,7 @@ def print_():
|
|||||||
else:
|
else:
|
||||||
controlflow.invalid_argument_exit(sys.argv[i], 'gam print devices')
|
controlflow.invalid_argument_exit(sys.argv[i], 'gam print devices')
|
||||||
view_name_map = {
|
view_name_map = {
|
||||||
|
None: 'Devices',
|
||||||
'COMPANY_INVENTORY': 'Company Devices',
|
'COMPANY_INVENTORY': 'Company Devices',
|
||||||
'USER_ASSIGNED_DEVICES': 'Personal Devices',
|
'USER_ASSIGNED_DEVICES': 'Personal Devices',
|
||||||
}
|
}
|
||||||
@ -174,12 +181,10 @@ def print_():
|
|||||||
else:
|
else:
|
||||||
orderBy = None
|
orderBy = None
|
||||||
devices = []
|
devices = []
|
||||||
for view in get_device_views:
|
page_message = gapi.got_total_items_msg(view_name_map[view], '...\n')
|
||||||
view_name = view_name_map.get(view, 'Devices')
|
devices += gapi.get_all_pages(ci.devices(), 'list', 'devices',
|
||||||
page_message = gapi.got_total_items_msg(view_name, '...\n')
|
customer=customer, page_message=page_message,
|
||||||
devices += gapi.get_all_pages(ci.devices(), 'list', 'devices',
|
pageSize=100, filter=device_filter, view=view, orderBy=orderBy)
|
||||||
customer=customer, page_message=page_message,
|
|
||||||
pageSize=100, filter=device_filter, view=view, orderBy=orderBy)
|
|
||||||
if get_device_users:
|
if get_device_users:
|
||||||
page_message = gapi.got_total_items_msg('Device Users', '...\n')
|
page_message = gapi.got_total_items_msg('Device Users', '...\n')
|
||||||
device_users = gapi.get_all_pages(ci.devices().deviceUsers(), 'list',
|
device_users = gapi.get_all_pages(ci.devices().deviceUsers(), 'list',
|
||||||
@ -273,8 +278,7 @@ def sync():
|
|||||||
for row in input_file:
|
for row in input_file:
|
||||||
# upper() is very important to comparison since Google
|
# upper() is very important to comparison since Google
|
||||||
# always return uppercase serials
|
# always return uppercase serials
|
||||||
serialnumber = row[serialnumber_column].strip().upper()
|
local_device = {'serialNumber': row[serialnumber_column].strip().upper()}
|
||||||
local_device = {'serialNumber': serialnumber}
|
|
||||||
if static_devicetype:
|
if static_devicetype:
|
||||||
local_device['deviceType'] = static_devicetype
|
local_device['deviceType'] = static_devicetype
|
||||||
else:
|
else:
|
||||||
@ -294,10 +298,10 @@ def sync():
|
|||||||
remote_device_map = {}
|
remote_device_map = {}
|
||||||
for remote_device in remote_devices:
|
for remote_device in remote_devices:
|
||||||
sn = remote_device['serialNumber']
|
sn = remote_device['serialNumber']
|
||||||
last_sync = remote_device.pop('lastSyncTime')
|
last_sync = remote_device.pop('lastSyncTime', NEVER_TIME_NOMS)
|
||||||
name = remote_device.pop('name')
|
name = remote_device.pop('name')
|
||||||
remote_device_map[sn] = {'name': name}
|
remote_device_map[sn] = {'name': name}
|
||||||
if last_sync == '1970-01-01T00:00:00Z':
|
if last_sync == NEVER_TIME_NOMS:
|
||||||
remote_device_map[sn]['unassigned'] = True
|
remote_device_map[sn]['unassigned'] = True
|
||||||
devices_to_add = [device for device in local_devices if device not in remote_devices]
|
devices_to_add = [device for device in local_devices if device not in remote_devices]
|
||||||
missing_devices = [device for device in remote_devices if device not in local_devices]
|
missing_devices = [device for device in remote_devices if device not in local_devices]
|
||||||
|
@ -1359,6 +1359,7 @@ GC_VAR_INFO = {
|
|||||||
# Google API constants
|
# Google API constants
|
||||||
|
|
||||||
NEVER_TIME = '1970-01-01T00:00:00.000Z'
|
NEVER_TIME = '1970-01-01T00:00:00.000Z'
|
||||||
|
NEVER_TIME_NOMS = '1970-01-01T00:00:00Z'
|
||||||
ROLE_MANAGER = 'MANAGER'
|
ROLE_MANAGER = 'MANAGER'
|
||||||
ROLE_MEMBER = 'MEMBER'
|
ROLE_MEMBER = 'MEMBER'
|
||||||
ROLE_OWNER = 'OWNER'
|
ROLE_OWNER = 'OWNER'
|
||||||
|
Reference in New Issue
Block a user