mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 09:51:36 +00:00
Tow updates/fixes (#1084)
* Allow : in row filter field names export GAM_CSV_ROW_FILTER="'\"accounts:used_quota_in_mb\":count>=15000'" * Updated code to handle Directory API issue that prevents looking up the orgUnitId of OU / This affected `gam report` if you used the `orgunit /` option. This affected `gam create admin <UserItem> <RoleItem> org_unit /`.
This commit is contained in:
34
src/gam.py
34
src/gam.py
@@ -506,7 +506,9 @@ def SetGlobalVariables():
|
||||
if not filterVal:
|
||||
continue
|
||||
try:
|
||||
column, filterStr = filterVal.split(':', 1)
|
||||
filterTokens = shlexSplitList(filterVal, ':')
|
||||
column = filterTokens[0]
|
||||
filterStr = ':'.join(filterTokens[1:])
|
||||
except ValueError:
|
||||
controlflow.system_error_exit(3, 'Item: {0}, Value: "{1}", Expected column:filter'.format(itemName, filterVal))
|
||||
filterDict[column] = filterStr
|
||||
@@ -10674,16 +10676,6 @@ def getOrgUnitItem(orgUnit, pathOnly=False, absolutePath=True):
|
||||
return makeOrgUnitPathAbsolute(orgUnit)
|
||||
return makeOrgUnitPathRelative(orgUnit)
|
||||
|
||||
def getOrgUnitId(orgUnit, cd=None):
|
||||
if cd is None:
|
||||
cd = buildGAPIObject('directory')
|
||||
orgUnit = getOrgUnitItem(orgUnit)
|
||||
if orgUnit[:3] == 'id:':
|
||||
return (orgUnit, orgUnit)
|
||||
result = gapi.call(cd.orgunits(), 'get',
|
||||
customerId=GC_Values[GC_CUSTOMER_ID], orgUnitPath=encodeOrgUnitPath(makeOrgUnitPathRelative(orgUnit)), fields='orgUnitId')
|
||||
return (orgUnit, result['orgUnitId'])
|
||||
|
||||
def getTopLevelOrgId(cd, orgUnitPath):
|
||||
try:
|
||||
# create a temp org so we can learn what the top level org ID is (sigh)
|
||||
@@ -10696,6 +10688,26 @@ def getTopLevelOrgId(cd, orgUnitPath):
|
||||
pass
|
||||
return None
|
||||
|
||||
def getOrgUnitId(orgUnit, cd=None):
|
||||
if cd is None:
|
||||
cd = buildGAPIObject('directory')
|
||||
orgUnit = getOrgUnitItem(orgUnit)
|
||||
if orgUnit[:3] == 'id:':
|
||||
return (orgUnit, orgUnit)
|
||||
if orgUnit == '/':
|
||||
result = gapi.call(cd.orgunits(), 'list',
|
||||
customerId=GC_Values[GC_CUSTOMER_ID], orgUnitPath='/', type='children',
|
||||
fields='organizationUnits(parentOrgUnitId)')
|
||||
if result.get('organizationUnits', []):
|
||||
return (orgUnit, result['organizationUnits'][0]['parentOrgUnitId'])
|
||||
topLevelOrgId = getTopLevelOrgId(cd, '/')
|
||||
if topLevelOrgId:
|
||||
return (orgUnit, topLevelOrgId)
|
||||
return (orgUnit, '/') #Bogus but should never happen
|
||||
result = gapi.call(cd.orgunits(), 'get',
|
||||
customerId=GC_Values[GC_CUSTOMER_ID], orgUnitPath=encodeOrgUnitPath(makeOrgUnitPathRelative(orgUnit)), fields='orgUnitId')
|
||||
return (orgUnit, result['orgUnitId'])
|
||||
|
||||
def doGetOrgInfo(name=None, return_attrib=None):
|
||||
cd = buildGAPIObject('directory')
|
||||
checkSuspended = None
|
||||
|
||||
Reference in New Issue
Block a user