From df177ac43f3d8f732b23a866f0b45bfc742597cf Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 27 Sep 2017 18:52:36 -0400 Subject: [PATCH] When displaying license info to user, show Id and displayName if available (#603) Plus documentation update thatgot left behind --- src/GamCommands.txt | 4 ++-- src/gam.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index f1f88883..afffd334 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -553,7 +553,7 @@ Item attributes (customerid )| (email|primaryemail|username )| (otheremail clear|(work|home|other| ))| - (externalid clear|(account|customer|network|organization| ))| + (externalid clear|(account|customer|login_id|network|organization| ))| (firstname|givenname )| (gal|includeinglobaladdresslist )| (im clear|(type work|home|other|(custom ) protocol aim|gtalk|icq|jabber|msn|net_meeting|qq|skype|yahoo|(custom_protocol ) [notprimary|primary]))| @@ -568,7 +568,7 @@ Item attributes (phone clear|([type work|home|other|work_fax|home_fax|other_fax|main|company_main|assistant|mobile|work_mobile|pager|work_pager|car|radio|callback|isdn|telex|tty_tdd|grand_central|(custom )] [value ] notprimary|primary))| (posix clear|(username uid gid [system|systemid ] [home|homedirectory ] [shell ] [gecos ] [primary ] endposix))| - (relation clear|(spouse|child|mother|father|parent|brother|sister|friend|relative|domestic_partner|manager|assistant|referred_by|partner| ))| + (relation clear|(spouse|child|mother|father|parent|brother|sister|friend|relative|domestic_partner|manager|dotted-line_managerassistant|admin_assistant|exec_assistant|referred_by|partner| ))| (sshkeys clear|(key [expires ] endssh))| (suspended )| (website clear|(home_page|blog|profile|work|home|other|ftp|reservations|app_install_page| [notprimary|primary]))| diff --git a/src/gam.py b/src/gam.py index 77153e05..9d7a7b9f 100755 --- a/src/gam.py +++ b/src/gam.py @@ -4799,10 +4799,10 @@ def doLicense(users, operation): if user.find(u'@') == -1: user = u'%s@%s' % (user, GC_Values[GC_DOMAIN]) if operation == u'delete': - print u'Removing license %s from user %s' % (_skuIdToDisplayName(skuId), user) + print u'Removing license %s from user %s' % (_formatSKUIdDisplayName(skuId), user) callGAPI(lic.licenseAssignments(), operation, soft_errors=True, productId=productId, skuId=skuId, userId=user) elif operation == u'insert': - print u'Adding license %s to user %s' % (_skuIdToDisplayName(skuId), user) + print u'Adding license %s to user %s' % (_formatSKUIdDisplayName(skuId), user) callGAPI(lic.licenseAssignments(), operation, soft_errors=True, productId=productId, skuId=skuId, body={u'userId': user}) elif operation == u'patch': try: @@ -4813,7 +4813,7 @@ def doLicense(users, operation): print u'ERROR: You need to specify the user\'s old SKU as the last argument' sys.exit(2) _, old_sku = getProductAndSKU(old_sku) - print u'Changing user %s from license %s to %s' % (user, _skuIdToDisplayName(old_sku), _skuIdToDisplayName(skuId)) + print u'Changing user %s from license %s to %s' % (user, _formatSKUIdDisplayName(old_sku), _formatSKUIdDisplayName(skuId)) callGAPI(lic.licenseAssignments(), operation, soft_errors=True, productId=productId, skuId=old_sku, userId=user, body={u'skuId': skuId}) def doPop(users): @@ -8776,11 +8776,17 @@ def doGetUserInfo(user_email=None): lbatch.add(lic.licenseAssignments().get(userId=user_email, productId=productId, skuId=skuId, fields=u'skuId')) lbatch.execute() for user_license in user_licenses: - print ' %s' % _skuIdToDisplayName(user_license) + print ' %s' % (_formatSKUIdDisplayName(user_license)) def _skuIdToDisplayName(skuId): return SKUS[skuId][u'displayName'] if skuId in SKUS else skuId +def _formatSKUIdDisplayName(skuId): + skuIdDisplay = _skuIdToDisplayName(skuId) + if skuId == skuIdDisplay: + return skuId + return u'{0} ({1})'.format(skuId, skuIdDisplay) + def doGetGroupInfo(group_name=None): cd = buildGAPIObject(u'directory') gs = buildGAPIObject(u'groupssettings')