Update gam info user <UserItem> to eliminate 5 second delay when getting license info.

This commit is contained in:
Ross Scroggs
2025-08-27 19:38:09 -07:00
parent e4880a3814
commit 33065438d8
2 changed files with 17 additions and 10 deletions

View File

@@ -1,3 +1,10 @@
7.19.02
Update `gam info user <UserItem>` to eliminate 5 second delay when getting license info.
Additional information:
* See: https://github.com/GAM-team/GAM/wiki/Licenses#info-user-performance
7.19.01 7.19.01
Updated `gam <UserTypeEntity> print|show signature` to handle the following error Updated `gam <UserTypeEntity> print|show signature` to handle the following error

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.19.01' __version__ = '7.19.02'
__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
@@ -32228,9 +32228,9 @@ def doUpdateMobileDevices():
[Msg.ACTION_APPLIED, body['action']], i, count) [Msg.ACTION_APPLIED, body['action']], i, count)
except GAPI.internalError: except GAPI.internalError:
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], Msg.DOES_NOT_EXIST, i, count) entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], Msg.DOES_NOT_EXIST, i, count)
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound) as e: except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden) as e:
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], str(e), i, count) entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], str(e), i, count)
except (GAPI.forbidden, GAPI.permissionDenied) as e: except GAPI.permissionDenied as e:
ClientAPIAccessDeniedExit(str(e)) ClientAPIAccessDeniedExit(str(e))
# gam delete mobile|mobiles <MobileDeviceEntity> # gam delete mobile|mobiles <MobileDeviceEntity>
@@ -44907,6 +44907,12 @@ def waitForMailbox(entityList):
Ind.Decrement() Ind.Decrement()
def getUserLicenses(lic, user, skus): def getUserLicenses(lic, user, skus):
reasons_to_quit = [
GAPI.ACCESS_NOT_CONFIGURED, # license API not turned on
GAPI.PERMISSION_DENIED, # Admin doesn't have rights to license assignments
GAPI.NOT_FOUND # API call succeeded, user does not have this license
]
def _callbackGetLicense(request_id, response, exception): def _callbackGetLicense(request_id, response, exception):
if exception is None: if exception is None:
if response and 'skuId' in response: if response and 'skuId' in response:
@@ -44914,18 +44920,12 @@ def getUserLicenses(lic, user, skus):
del sku_calls[request_id] del sku_calls[request_id]
else: else:
_, reason, _ = checkGAPIError(exception, softErrors=True) _, reason, _ = checkGAPIError(exception, softErrors=True)
reasons_to_quit = [
GAPI.ACCESS_NOT_CONFIGURED, # license API not turned on
GAPI.PERMISSION_DENIED, # Admin doesn't have rights to license assignments
GAPI.NOT_FOUND # API call succeeded, user does not have this license
]
if reason in reasons_to_quit: if reason in reasons_to_quit:
del sku_calls[request_id] del sku_calls[request_id]
licenses = [] licenses = []
svcargs = dict([('userId', user['primaryEmail']), ('productId', None), ('skuId', None), ('fields', 'skuId')]+GM.Globals[GM.EXTRA_ARGS_LIST]) svcargs = dict([('userId', user['primaryEmail']), ('productId', None), ('skuId', None), ('fields', 'skuId')]+GM.Globals[GM.EXTRA_ARGS_LIST])
method = getattr(lic.licenseAssignments(), 'get') method = getattr(lic.licenseAssignments(), 'get')
dbatch = lic.new_batch_http_request(callback=_callbackGetLicense)
sku_calls = {} sku_calls = {}
for sku in skus: for sku in skus:
svcparms = svcargs.copy() svcparms = svcargs.copy()