mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-07 21:23:34 +00:00
Use allIncludingParent
This commit is contained in:
@ -1602,25 +1602,19 @@ def getTopLevelOrgId(cd, parentOrgUnitPath):
|
|||||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, parentOrgUnitPath)
|
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, parentOrgUnitPath)
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
result = callGAPI(cd.orgunits(), 'insert',
|
result = callGAPI(cd.orgunits(), 'list',
|
||||||
throwReasons=[GAPI.INVALID_ORGUNIT, GAPI.BACKEND_ERROR,
|
throwReasons=GAPI.ORGUNIT_GET_THROW_REASONS,
|
||||||
GAPI.BAD_REQUEST, GAPI.INVALID_CUSTOMER_ID, GAPI.LOGIN_REQUIRED],
|
customerId=GC.Values[GC.CUSTOMER_ID], orgUnitPath='/', type='allIncludingParent',
|
||||||
customerId=GC.Values[GC.CUSTOMER_ID], body={'name': 'temp-delete-me', 'parentOrgUnitPath': parentOrgUnitPath}, fields='parentOrgUnitId,orgUnitId')
|
fields='organizationUnits(orgUnitId,orgUnitPath)')
|
||||||
except (GAPI.invalidOrgunit, GAPI.backendError):
|
for orgUnit in result.get('organizationUnits', []):
|
||||||
|
if orgUnit['orgUnitPath'] == '/':
|
||||||
|
return orgUnit['orgUnitId']
|
||||||
|
return None
|
||||||
|
except (GAPI.invalidOrgunit, GAPI.orgunitNotFound, GAPI.backendError):
|
||||||
return None
|
return None
|
||||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
||||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, parentOrgUnitPath)
|
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, parentOrgUnitPath)
|
||||||
return None
|
return None
|
||||||
try:
|
|
||||||
callGAPI(cd.orgunits(), 'delete',
|
|
||||||
throwReasons=[GAPI.CONDITION_NOT_MET, GAPI.INVALID_ORGUNIT, GAPI.ORGUNIT_NOT_FOUND, GAPI.BACKEND_ERROR,
|
|
||||||
GAPI.BAD_REQUEST, GAPI.INVALID_CUSTOMER_ID, GAPI.LOGIN_REQUIRED],
|
|
||||||
customerId=GC.Values[GC.CUSTOMER_ID], orgUnitPath=result['orgUnitId'])
|
|
||||||
except (GAPI.conditionNotMet, GAPI.invalidOrgunit, GAPI.orgunitNotFound, GAPI.backendError):
|
|
||||||
pass
|
|
||||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
|
||||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, parentOrgUnitPath)
|
|
||||||
return result['parentOrgUnitId']
|
|
||||||
|
|
||||||
def getOrgUnitId(cd=None, orgUnit=None):
|
def getOrgUnitId(cd=None, orgUnit=None):
|
||||||
if cd is None:
|
if cd is None:
|
||||||
|
Reference in New Issue
Block a user