mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 12:51:36 +00:00
Fix print users #1840
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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,71 +45754,82 @@ 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 showValidColumn:
|
if (isSuspended is None and isArchived is None):
|
||||||
userEntity[showValidColumn] = True
|
showUser = True
|
||||||
userEmail = userEntity['primaryEmail']
|
elif (isSuspended is not None and isArchived is None):
|
||||||
if printOptions['emailParts']:
|
showUser = isSuspended == userEntity.get('suspended', isSuspended)
|
||||||
if userEmail.find('@') != -1:
|
elif (isSuspended is None and isArchived is not None):
|
||||||
userEntity['primaryEmailLocal'], userEntity['primaryEmailDomain'] = splitEmailAddress(userEmail)
|
showUser = isArchived == userEntity.get('archived', isArchived)
|
||||||
if 'languages' in userEntity and not FJQC.formatJSON:
|
else:
|
||||||
userEntity['languages'] = _formatLanguagesList(userEntity.pop('languages'), delimiter)
|
showUser = ((isSuspended == userEntity.get('suspended', isSuspended)) and
|
||||||
for location in userEntity.get('locations', []):
|
(isArchived == userEntity.get('archived', isArchived)))
|
||||||
location['buildingName'] = _getBuildingNameById(cd, location.get('buildingId', ''))
|
if not showUser:
|
||||||
if quotePlusPhoneNumbers:
|
return
|
||||||
for phone in userEntity.get('phones', []):
|
if showValidColumn:
|
||||||
phoneNumber = phone.get('value', '')
|
userEntity[showValidColumn] = True
|
||||||
if phoneNumber.startswith('+'):
|
userEmail = userEntity['primaryEmail']
|
||||||
phone['value'] = "'"+phoneNumber
|
if printOptions['emailParts']:
|
||||||
if schemaParms['selectedSchemaFields']:
|
if userEmail.find('@') != -1:
|
||||||
_filterSchemaFields(userEntity, schemaParms)
|
userEntity['primaryEmailLocal'], userEntity['primaryEmailDomain'] = splitEmailAddress(userEmail)
|
||||||
if printOptions['getGroupFeed']:
|
if 'languages' in userEntity and not FJQC.formatJSON:
|
||||||
printGettingAllEntityItemsForWhom(Ent.GROUP_MEMBERSHIP, userEmail, i, count)
|
userEntity['languages'] = _formatLanguagesList(userEntity.pop('languages'), delimiter)
|
||||||
try:
|
for location in userEntity.get('locations', []):
|
||||||
groups = callGAPIpages(cd.groups(), 'list', 'groups',
|
location['buildingName'] = _getBuildingNameById(cd, location.get('buildingId', ''))
|
||||||
pageMessage=getPageMessageForWhom(),
|
if quotePlusPhoneNumbers:
|
||||||
throwReasons=GAPI.GROUP_LIST_USERKEY_THROW_REASONS,
|
for phone in userEntity.get('phones', []):
|
||||||
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
phoneNumber = phone.get('value', '')
|
||||||
userKey=userEmail, orderBy='email', fields='nextPageToken,groups(email)')
|
if phoneNumber.startswith('+'):
|
||||||
numGroups = len(groups)
|
phone['value'] = "'"+phoneNumber
|
||||||
if not printOptions['groupsInColumns']:
|
if schemaParms['selectedSchemaFields']:
|
||||||
userEntity['GroupsCount'] = numGroups
|
_filterSchemaFields(userEntity, schemaParms)
|
||||||
userEntity['Groups'] = delimiter.join([groupname['email'] for groupname in groups])
|
if printOptions['getGroupFeed']:
|
||||||
else:
|
printGettingAllEntityItemsForWhom(Ent.GROUP_MEMBERSHIP, userEmail, i, count)
|
||||||
if numGroups > printOptions['maxGroups']:
|
try:
|
||||||
printOptions['maxGroups'] = numGroups
|
groups = callGAPIpages(cd.groups(), 'list', 'groups',
|
||||||
userEntity['Groups'] = numGroups
|
pageMessage=getPageMessageForWhom(),
|
||||||
for j, group in enumerate(groups):
|
throwReasons=GAPI.GROUP_LIST_USERKEY_THROW_REASONS,
|
||||||
userEntity[f'Groups{GC.Values[GC.CSV_OUTPUT_SUBFIELD_DELIMITER]}{j}'] = group['email']
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
except (GAPI.invalidMember, GAPI.invalidInput):
|
userKey=userEmail, orderBy='email', fields='nextPageToken,groups(email)')
|
||||||
badRequestWarning(Ent.GROUP, Ent.MEMBER, userEmail)
|
numGroups = len(groups)
|
||||||
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.forbidden, GAPI.badRequest):
|
if not printOptions['groupsInColumns']:
|
||||||
accessErrorExit(cd)
|
userEntity['GroupsCount'] = numGroups
|
||||||
if aliasMatchPattern and 'aliases' in userEntity:
|
userEntity['Groups'] = delimiter.join([groupname['email'] for groupname in groups])
|
||||||
userEntity['aliases'] = [alias for alias in userEntity['aliases'] if aliasMatchPattern.match(alias)]
|
|
||||||
if printOptions['getLicenseFeed'] or printOptions['getLicenseFeedByUser']:
|
|
||||||
if printOptions['getLicenseFeed']:
|
|
||||||
u_licenses = licenses.get(userEmail.lower(), [])
|
|
||||||
else:
|
else:
|
||||||
u_licenses = getUserLicenses(lic, userEntity, skus)
|
if numGroups > printOptions['maxGroups']:
|
||||||
if not oneLicensePerRow:
|
printOptions['maxGroups'] = numGroups
|
||||||
userEntity['LicensesCount'] = len(u_licenses)
|
userEntity['Groups'] = numGroups
|
||||||
if u_licenses:
|
for j, group in enumerate(groups):
|
||||||
userEntity['Licenses'] = delimiter.join(u_licenses)
|
userEntity[f'Groups{GC.Values[GC.CSV_OUTPUT_SUBFIELD_DELIMITER]}{j}'] = group['email']
|
||||||
userEntity['LicensesDisplay'] = delimiter.join([SKU.skuIdToDisplayName(skuId) for skuId in u_licenses])
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
||||||
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, userEmail)
|
||||||
|
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.forbidden, GAPI.badRequest):
|
||||||
|
accessErrorExit(cd)
|
||||||
|
if aliasMatchPattern and 'aliases' in userEntity:
|
||||||
|
userEntity['aliases'] = [alias for alias in userEntity['aliases'] if aliasMatchPattern.match(alias)]
|
||||||
|
if printOptions['getLicenseFeed'] or printOptions['getLicenseFeedByUser']:
|
||||||
|
if printOptions['getLicenseFeed']:
|
||||||
|
u_licenses = licenses.get(userEmail.lower(), [])
|
||||||
else:
|
else:
|
||||||
u_licenses = []
|
u_licenses = getUserLicenses(lic, userEntity, skus)
|
||||||
if not oneLicensePerRow:
|
if not oneLicensePerRow:
|
||||||
_writeUserEntity(userEntity)
|
userEntity['LicensesCount'] = len(u_licenses)
|
||||||
else:
|
|
||||||
if u_licenses:
|
if u_licenses:
|
||||||
for skuId in u_licenses:
|
userEntity['Licenses'] = delimiter.join(u_licenses)
|
||||||
userEntity['License'] = skuId
|
userEntity['LicensesDisplay'] = delimiter.join([SKU.skuIdToDisplayName(skuId) for skuId in u_licenses])
|
||||||
userEntity['LicenseDisplay'] = SKU.skuIdToDisplayName(skuId)
|
else:
|
||||||
_writeUserEntity(userEntity)
|
u_licenses = []
|
||||||
else:
|
if not oneLicensePerRow:
|
||||||
userEntity['License'] = userEntity['LicenseDisplay'] = ''
|
_writeUserEntity(userEntity)
|
||||||
|
else:
|
||||||
|
if u_licenses:
|
||||||
|
for skuId in u_licenses:
|
||||||
|
userEntity['License'] = skuId
|
||||||
|
userEntity['LicenseDisplay'] = SKU.skuIdToDisplayName(skuId)
|
||||||
_writeUserEntity(userEntity)
|
_writeUserEntity(userEntity)
|
||||||
|
else:
|
||||||
|
userEntity['License'] = userEntity['LicenseDisplay'] = ''
|
||||||
|
_writeUserEntity(userEntity)
|
||||||
|
|
||||||
def _updateDomainCounts(emailAddress):
|
def _updateDomainCounts(emailAddress):
|
||||||
nonlocal domainCounts
|
nonlocal domainCounts
|
||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user