def getOrgUnitId(cd=None):
if cd is None:
cd = buildGAPIObject(API.DIRECTORY)
orgUnit = getOrgUnitItem()
if orgUnit[:3] == u'id:':
return (orgUnit, orgUnit)
try:
result = callGAPI(cd.orgunits(), u'get',
throw_reasons=[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=makeOrgUnitPathRelative(orgUnit),
fields=u'orgUnitId')
return (orgUnit, result[u'orgUnitId'])
except (GAPI.invalidOrgunit, GAPI.orgunitNotFound, GAPI.backendError):
entityDoesNotExistExit(Ent.ORGANIZATIONAL_UNIT, orgUnit)
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
accessErrorExit(cd)
评论列表
文章目录