mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-09 14:13:35 +00:00
Add skus <SKUIDList> to gam info user
This commit is contained in:
20
src/gam.py
20
src/gam.py
@ -6418,6 +6418,8 @@ def doGetUserInfo(user_email=None):
|
|||||||
getSchemas = getAliases = getGroups = getLicenses = True
|
getSchemas = getAliases = getGroups = getLicenses = True
|
||||||
projection = u'full'
|
projection = u'full'
|
||||||
customFieldMask = viewType = None
|
customFieldMask = viewType = None
|
||||||
|
skus = [u'Google-Apps-For-Business', u'Google-Apps-Unlimited', u'Google-Apps-For-Postini',
|
||||||
|
u'Google-Apps-Lite', u'Google-Vault', u'Google-Vault-Former-Employee']
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower()
|
myarg = sys.argv[i].lower()
|
||||||
if myarg == u'noaliases':
|
if myarg == u'noaliases':
|
||||||
@ -6429,6 +6431,9 @@ def doGetUserInfo(user_email=None):
|
|||||||
elif myarg in [u'nolicenses', u'nolicences']:
|
elif myarg in [u'nolicenses', u'nolicences']:
|
||||||
getLicenses = False
|
getLicenses = False
|
||||||
i += 1
|
i += 1
|
||||||
|
elif myarg in [u'sku', u'skus']:
|
||||||
|
skus = sys.argv[i+1].replace(u',', u' ').split()
|
||||||
|
i += 2
|
||||||
elif myarg == u'noschemas':
|
elif myarg == u'noschemas':
|
||||||
getSchemas = False
|
getSchemas = False
|
||||||
projection = u'basic'
|
projection = u'basic'
|
||||||
@ -6578,12 +6583,11 @@ def doGetUserInfo(user_email=None):
|
|||||||
print u' %s <%s>' % (group[u'name'], group[u'email'])
|
print u' %s <%s>' % (group[u'name'], group[u'email'])
|
||||||
if getLicenses:
|
if getLicenses:
|
||||||
print u'Licenses:'
|
print u'Licenses:'
|
||||||
lic = buildGAPIObject(api='licensing')
|
lic = buildGAPIObject(u'licensing')
|
||||||
for sku in [u'Google-Apps-For-Business', u'Google-Apps-Unlimited', u'Google-Apps-For-Postini',
|
for sku in skus:
|
||||||
u'Google-Apps-Lite', u'Google-Vault', u'Google-Vault-Former-Employee']:
|
|
||||||
productId, skuId = getProductAndSKU(sku)
|
productId, skuId = getProductAndSKU(sku)
|
||||||
try:
|
try:
|
||||||
result = callGAPI(service=lic.licenseAssignments(), function=u'get', throw_reasons=['notFound'], userId=user_email, productId=productId, skuId=skuId)
|
result = callGAPI(service=lic.licenseAssignments(), function=u'get', throw_reasons=[u'notFound', u'invalid', u'forbidden'], userId=user_email, productId=productId, skuId=skuId)
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
continue
|
continue
|
||||||
print u' %s' % result[u'skuId']
|
print u' %s' % result[u'skuId']
|
||||||
@ -8151,10 +8155,10 @@ def doPrintLicenses(return_list=False, skus=None):
|
|||||||
todrive = True
|
todrive = True
|
||||||
i += 1
|
i += 1
|
||||||
elif sys.argv[i].lower() in [u'products', u'product']:
|
elif sys.argv[i].lower() in [u'products', u'product']:
|
||||||
products = sys.argv[i+1].split(',')
|
products = sys.argv[i+1].replace(u',', u' ').split()
|
||||||
i += 2
|
i += 2
|
||||||
elif sys.argv[i].lower() in [u'sku', u'skus']:
|
elif sys.argv[i].lower() in [u'sku', u'skus']:
|
||||||
skus = sys.argv[i+1].split(',')
|
skus = sys.argv[i+1].replace(u',', u' ').split()
|
||||||
i += 2
|
i += 2
|
||||||
else:
|
else:
|
||||||
print u'ERROR: %s is not a valid argument for "gam print licenses"' % sys.argv[i]
|
print u'ERROR: %s is not a valid argument for "gam print licenses"' % sys.argv[i]
|
||||||
@ -8167,7 +8171,7 @@ def doPrintLicenses(return_list=False, skus=None):
|
|||||||
licenses += callGAPIpages(service=lic.licenseAssignments(), function=u'listForProductAndSku', throw_reasons=[u'invalid', u'forbidden'], page_message=page_message,
|
licenses += callGAPIpages(service=lic.licenseAssignments(), function=u'listForProductAndSku', throw_reasons=[u'invalid', u'forbidden'], page_message=page_message,
|
||||||
customerId=GC_Values[GC_DOMAIN], productId=product, skuId=sku, fields=u'items(productId,skuId,userId),nextPageToken')
|
customerId=GC_Values[GC_DOMAIN], productId=product, skuId=sku, fields=u'items(productId,skuId,userId),nextPageToken')
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
licenses += []
|
pass
|
||||||
else:
|
else:
|
||||||
for productId in products:
|
for productId in products:
|
||||||
page_message = u'Got %%%%total_items%%%% Licenses for %s...\n' % productId
|
page_message = u'Got %%%%total_items%%%% Licenses for %s...\n' % productId
|
||||||
@ -8175,7 +8179,7 @@ def doPrintLicenses(return_list=False, skus=None):
|
|||||||
licenses += callGAPIpages(service=lic.licenseAssignments(), function=u'listForProduct', throw_reasons=[u'invalid', u'forbidden'], page_message=page_message,
|
licenses += callGAPIpages(service=lic.licenseAssignments(), function=u'listForProduct', throw_reasons=[u'invalid', u'forbidden'], page_message=page_message,
|
||||||
customerId=GC_Values[GC_DOMAIN], productId=productId, fields=u'items(productId,skuId,userId),nextPageToken')
|
customerId=GC_Values[GC_DOMAIN], productId=productId, fields=u'items(productId,skuId,userId),nextPageToken')
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
licenses = +[]
|
pass
|
||||||
for u_license in licenses:
|
for u_license in licenses:
|
||||||
a_license = dict()
|
a_license = dict()
|
||||||
for title in u_license:
|
for title in u_license:
|
||||||
|
Reference in New Issue
Block a user