mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-09 14:13:35 +00:00
Use true customer_id with licensing API
This commit is contained in:
@ -7,8 +7,17 @@ from gam import controlflow
|
|||||||
from gam import display
|
from gam import display
|
||||||
from gam import gapi
|
from gam import gapi
|
||||||
from gam.gapi import errors as gapi_errors
|
from gam.gapi import errors as gapi_errors
|
||||||
|
from gam.gapi.directory import customer as gapi_directory_customer
|
||||||
|
|
||||||
|
|
||||||
|
def _get_customerid():
|
||||||
|
''' returns customerId with format C{customer_id}'''
|
||||||
|
gapi_directory_customer.setTrueCustomerId()
|
||||||
|
customer_id = GC_Values[GC_CUSTOMER_ID]
|
||||||
|
if customer_id[0] != 'C':
|
||||||
|
customer_id = 'C' + customer_id
|
||||||
|
return customer_id
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
return gam.buildGAPIObject('licensing')
|
return gam.buildGAPIObject('licensing')
|
||||||
|
|
||||||
@ -127,6 +136,7 @@ def print_(returnFields=None,
|
|||||||
countsOnly=False,
|
countsOnly=False,
|
||||||
returnCounts=False):
|
returnCounts=False):
|
||||||
lic = build()
|
lic = build()
|
||||||
|
customer_id = _get_customerid()
|
||||||
products = []
|
products = []
|
||||||
licenses = []
|
licenses = []
|
||||||
licenseCounts = []
|
licenseCounts = []
|
||||||
@ -174,6 +184,7 @@ def print_(returnFields=None,
|
|||||||
titles = ['productId', 'licenses']
|
titles = ['productId', 'licenses']
|
||||||
else:
|
else:
|
||||||
fields = f'nextPageToken,items({returnFields})'
|
fields = f'nextPageToken,items({returnFields})'
|
||||||
|
customer_id = _get_customerid()
|
||||||
if skus:
|
if skus:
|
||||||
for sku in skus:
|
for sku in skus:
|
||||||
if not products:
|
if not products:
|
||||||
@ -193,7 +204,7 @@ def print_(returnFields=None,
|
|||||||
gapi_errors.ErrorReason.FORBIDDEN
|
gapi_errors.ErrorReason.FORBIDDEN
|
||||||
],
|
],
|
||||||
page_message=page_message,
|
page_message=page_message,
|
||||||
customerId=GC_Values[GC_DOMAIN],
|
customerId=customer_id,
|
||||||
productId=product,
|
productId=product,
|
||||||
skuId=sku,
|
skuId=sku,
|
||||||
fields=fields)
|
fields=fields)
|
||||||
@ -223,7 +234,7 @@ def print_(returnFields=None,
|
|||||||
gapi_errors.ErrorReason.FORBIDDEN
|
gapi_errors.ErrorReason.FORBIDDEN
|
||||||
],
|
],
|
||||||
page_message=page_message,
|
page_message=page_message,
|
||||||
customerId=GC_Values[GC_DOMAIN],
|
customerId=customer_id,
|
||||||
productId=productId,
|
productId=productId,
|
||||||
fields=fields)
|
fields=fields)
|
||||||
if countsOnly:
|
if countsOnly:
|
||||||
|
Reference in New Issue
Block a user