Fix print users #1840

This commit is contained in:
Ross Scroggs
2025-09-25 08:59:39 -07:00
parent 882b930928
commit 3d3b3eac85
2 changed files with 88 additions and 70 deletions

View File

@@ -1,7 +1,12 @@
7.22.03
Fix backwards compatability bug introduced in 7.22.00 for `gam print users` that changed `suspended`
from a field name to a query option; it is now correctly interpreted as a field name.
7.22.02 7.22.02
An update to the httplib2 library caused GAM proxy connections to fail; this has been fixed An update to the httplib2 library caused GAM proxy connections to fail; this has been fixed
by includinbg the pysocks library needed by the latest httplib2 library. by including the pysocks library needed by the latest httplib2 library.
7.22.00 7.22.00

View File

@@ -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.22.02' __version__ = '7.22.03'
__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
@@ -18989,10 +18989,10 @@ def doPrintAliases():
pass pass
elif myarg == 'select': elif myarg == 'select':
_, users = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS) _, users = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS)
elif myarg in SUSPENDED_ARGUMENTS: elif myarg == 'issuspended':
isSuspended = _getIsSuspended(myarg) isSuspended = getBoolean()
elif myarg in ARCHIVED_ARGUMENTS: elif myarg == 'isarchived':
isArchived = _getIsArchived(myarg) isArchived = getBoolean()
elif myarg in {'user','users'}: elif myarg in {'user','users'}:
users.extend(convertEntityToList(getString(Cmd.OB_EMAIL_ADDRESS_LIST, minLen=0))) users.extend(convertEntityToList(getString(Cmd.OB_EMAIL_ADDRESS_LIST, minLen=0)))
elif myarg in {'group', 'groups'}: elif myarg in {'group', 'groups'}:
@@ -45754,7 +45754,18 @@ def doPrintUsers(entityList=None):
csvPF.WriteRowNoFilter(row) csvPF.WriteRowNoFilter(row)
def _printUser(userEntity, i, count): def _printUser(userEntity, i, count):
if isSuspended is None or isSuspended == userEntity.get('suspended', isSuspended):
if (isSuspended is None and isArchived is None):
showUser = True
elif (isSuspended is not None and isArchived is None):
showUser = isSuspended == userEntity.get('suspended', isSuspended)
elif (isSuspended is None and isArchived is not None):
showUser = isArchived == userEntity.get('archived', isArchived)
else:
showUser = ((isSuspended == userEntity.get('suspended', isSuspended)) and
(isArchived == userEntity.get('archived', isArchived)))
if not showUser:
return
if showValidColumn: if showValidColumn:
userEntity[showValidColumn] = True userEntity[showValidColumn] = True
userEmail = userEntity['primaryEmail'] userEmail = userEntity['primaryEmail']
@@ -45911,10 +45922,10 @@ def doPrintUsers(entityList=None):
showDeleted = True showDeleted = True
elif entityList is None and myarg == 'select': elif entityList is None and myarg == 'select':
_, entityList = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS) _, entityList = getEntityToModify(defaultEntityType=Cmd.ENTITY_USERS)
elif myarg in SUSPENDED_ARGUMENTS: elif myarg == 'issuspended':
isSuspended = _getIsSuspended(myarg) isSuspended = getBoolean()
elif myarg in ARCHIVED_ARGUMENTS: elif myarg == 'isarchived':
isArchived = _getIsArchived(myarg) isArchived = getBoolean()
elif myarg == 'orderby': elif myarg == 'orderby':
orderBy, sortOrder = getOrderBySortOrder(USERS_ORDERBY_CHOICE_MAP) orderBy, sortOrder = getOrderBySortOrder(USERS_ORDERBY_CHOICE_MAP)
elif myarg == 'userview': elif myarg == 'userview':
@@ -46092,6 +46103,8 @@ def doPrintUsers(entityList=None):
# If no individual fields were specified (allfields, basic, full) or individual fields other than primaryEmail were specified, look up each user # If no individual fields were specified (allfields, basic, full) or individual fields other than primaryEmail were specified, look up each user
if isSuspended is not None and fieldsList: if isSuspended is not None and fieldsList:
fieldsList.append('suspended') fieldsList.append('suspended')
if isArchived is not None and fieldsList:
fieldsList.append('archived')
if projectionSet or len(set(fieldsList)) > 1 or showValidColumn: if projectionSet or len(set(fieldsList)) > 1 or showValidColumn:
jcount = len(entityList) jcount = len(entityList)
fields = getFieldsFromFieldsList(fieldsList) fields = getFieldsFromFieldsList(fieldsList)