mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Added option oneuserperrow to gam print devices
This commit is contained in:
@@ -4119,7 +4119,7 @@ gam print devices [todrive <ToDriveAttribute>*]
|
|||||||
<DeviceFieldName>* [fields <DeviceFieldNameList>] [userfields <DeviceUserFieldNameList>]
|
<DeviceFieldName>* [fields <DeviceFieldNameList>] [userfields <DeviceUserFieldNameList>]
|
||||||
[orderby <DeviceOrderByFieldName> [ascending|descending]]
|
[orderby <DeviceOrderByFieldName> [ascending|descending]]
|
||||||
[all|company|personal|nocompanydevices|nopersonaldevices]
|
[all|company|personal|nocompanydevices|nopersonaldevices]
|
||||||
[nodeviceusers]
|
[nodeviceusers|oneuserperrow]
|
||||||
[formatjson [quotechar <Character>]]
|
[formatjson [quotechar <Character>]]
|
||||||
[showitemcountonly]
|
[showitemcountonly]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
7.07.17
|
||||||
|
|
||||||
|
Added option `oneuserperrow` to `gam print devices` to have each of a
|
||||||
|
device's users displayed on a separate row with all of the other device fields.
|
||||||
|
|
||||||
7.07.16
|
7.07.16
|
||||||
|
|
||||||
Added `chromeostype`, `diskspaceusage` and `faninfo` to `<CrOSFieldName>` for use in `gam info|print cros`.
|
Added `chromeostype`, `diskspaceusage` and `faninfo` to `<CrOSFieldName>` for use in `gam info|print cros`.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||||
__version__ = '7.07.16'
|
__version__ = '7.07.17'
|
||||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||||
|
|
||||||
#pylint: disable=wrong-import-position
|
#pylint: disable=wrong-import-position
|
||||||
@@ -29587,7 +29587,7 @@ DEVICE_ORDERBY_CHOICE_MAP = {
|
|||||||
# <DeviceFieldName>* [fields <DeviceFieldNameList>] [userfields <DeviceUserFieldNameList>]
|
# <DeviceFieldName>* [fields <DeviceFieldNameList>] [userfields <DeviceUserFieldNameList>]
|
||||||
# [orderby <DeviceOrderByFieldName> [ascending|descending]]
|
# [orderby <DeviceOrderByFieldName> [ascending|descending]]
|
||||||
# [all|company|personal|nocompanydevices|nopersonaldevices]
|
# [all|company|personal|nocompanydevices|nopersonaldevices]
|
||||||
# [nodeviceusers]
|
# [nodeviceusers|oneuserperrow]
|
||||||
# [formatjson [quotechar <Character>]]
|
# [formatjson [quotechar <Character>]]
|
||||||
# [showitemcountonly]
|
# [showitemcountonly]
|
||||||
def doPrintCIDevices():
|
def doPrintCIDevices():
|
||||||
@@ -29603,7 +29603,7 @@ def doPrintCIDevices():
|
|||||||
queries = [None]
|
queries = [None]
|
||||||
view, entityType = DEVICE_VIEW_CHOICE_MAP['all']
|
view, entityType = DEVICE_VIEW_CHOICE_MAP['all']
|
||||||
getDeviceUsers = True
|
getDeviceUsers = True
|
||||||
showItemCountOnly = False
|
oneUserPerRow = showItemCountOnly = False
|
||||||
while Cmd.ArgumentsRemaining():
|
while Cmd.ArgumentsRemaining():
|
||||||
myarg = getArgument()
|
myarg = getArgument()
|
||||||
if csvPF and myarg == 'todrive':
|
if csvPF and myarg == 'todrive':
|
||||||
@@ -29618,6 +29618,8 @@ def doPrintCIDevices():
|
|||||||
view, entityType = DEVICE_VIEW_CHOICE_MAP[myarg]
|
view, entityType = DEVICE_VIEW_CHOICE_MAP[myarg]
|
||||||
elif myarg == 'nodeviceusers':
|
elif myarg == 'nodeviceusers':
|
||||||
getDeviceUsers = False
|
getDeviceUsers = False
|
||||||
|
elif myarg in {'oneuserperrow', 'oneitemperrow'}:
|
||||||
|
getDeviceUsers = oneUserPerRow = True
|
||||||
elif getFieldsList(myarg, DEVICE_FIELDS_CHOICE_MAP, fieldsList, initialField='name'):
|
elif getFieldsList(myarg, DEVICE_FIELDS_CHOICE_MAP, fieldsList, initialField='name'):
|
||||||
pass
|
pass
|
||||||
elif getFieldsList(myarg, DEVICEUSER_FIELDS_CHOICE_MAP, userFieldsList, initialField='name', fieldsArg='userfields'):
|
elif getFieldsList(myarg, DEVICEUSER_FIELDS_CHOICE_MAP, userFieldsList, initialField='name', fieldsArg='userfields'):
|
||||||
@@ -29631,6 +29633,8 @@ def doPrintCIDevices():
|
|||||||
fields = getItemFieldsFromFieldsList('devices', fieldsList)
|
fields = getItemFieldsFromFieldsList('devices', fieldsList)
|
||||||
userFields = getItemFieldsFromFieldsList('deviceUsers', userFieldsList)
|
userFields = getItemFieldsFromFieldsList('deviceUsers', userFieldsList)
|
||||||
substituteQueryTimes(queries, queryTimes)
|
substituteQueryTimes(queries, queryTimes)
|
||||||
|
if FJQC.formatJSON and oneUserPerRow:
|
||||||
|
csvPF.SetJSONTitles(['name', 'user.name', 'JSON'])
|
||||||
itemCount = 0
|
itemCount = 0
|
||||||
for query in queries:
|
for query in queries:
|
||||||
printGettingAllAccountEntities(entityType, query)
|
printGettingAllAccountEntities(entityType, query)
|
||||||
@@ -29672,6 +29676,7 @@ def doPrintCIDevices():
|
|||||||
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied) as e:
|
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied) as e:
|
||||||
entityActionFailedWarning([entityType, None], str(e))
|
entityActionFailedWarning([entityType, None], str(e))
|
||||||
for device in devices:
|
for device in devices:
|
||||||
|
if not oneUserPerRow or 'users' not in device:
|
||||||
row = flattenJSON(device, timeObjects=DEVICE_TIME_OBJECTS)
|
row = flattenJSON(device, timeObjects=DEVICE_TIME_OBJECTS)
|
||||||
if not FJQC.formatJSON:
|
if not FJQC.formatJSON:
|
||||||
csvPF.WriteRowTitles(row)
|
csvPF.WriteRowTitles(row)
|
||||||
@@ -29679,6 +29684,18 @@ def doPrintCIDevices():
|
|||||||
csvPF.WriteRowNoFilter({'name': device['name'],
|
csvPF.WriteRowNoFilter({'name': device['name'],
|
||||||
'JSON': json.dumps(cleanJSON(device, timeObjects=DEVICE_TIME_OBJECTS),
|
'JSON': json.dumps(cleanJSON(device, timeObjects=DEVICE_TIME_OBJECTS),
|
||||||
ensure_ascii=False, sort_keys=True)})
|
ensure_ascii=False, sort_keys=True)})
|
||||||
|
else:
|
||||||
|
deviceUsers = device.pop('users')
|
||||||
|
baserow = flattenJSON(device, timeObjects=DEVICE_TIME_OBJECTS)
|
||||||
|
for deviceUser in deviceUsers:
|
||||||
|
row = flattenJSON({'user': deviceUser}, flattened=baserow.copy(), timeObjects=DEVICE_TIME_OBJECTS)
|
||||||
|
if not FJQC.formatJSON:
|
||||||
|
csvPF.WriteRowTitles(row)
|
||||||
|
elif csvPF.CheckRowTitles(row):
|
||||||
|
device['user'] = deviceUser
|
||||||
|
csvPF.WriteRowNoFilter({'name': device['name'], 'user.name': deviceUser['name'],
|
||||||
|
'JSON': json.dumps(cleanJSON(device, timeObjects=DEVICE_TIME_OBJECTS),
|
||||||
|
ensure_ascii=False, sort_keys=True)})
|
||||||
if showItemCountOnly:
|
if showItemCountOnly:
|
||||||
writeStdout(f'{itemCount}\n')
|
writeStdout(f'{itemCount}\n')
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user