mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 21:01:36 +00:00
_getMain fixes
This commit is contained in:
@@ -41,7 +41,7 @@ def doDeleteBrowsers():
|
||||
customer=customerId, deviceId=deviceId)
|
||||
_getMain().entityActionPerformed([Ent.CHROME_BROWSER, deviceId])
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
|
||||
BROWSER_TIME_OBJECTS = {'firstRecordTime', 'lastActivityTime', 'lastPolicyFetchTime', 'lastRegistrationTime', 'lastStatusReportTime', 'safeBrowsingWarningsResetTime'}
|
||||
|
||||
@@ -133,7 +133,7 @@ def doInfoBrowsers():
|
||||
except GAPI.invalidArgument as e:
|
||||
_getMain().entityActionFailedWarning([Ent.CHROME_BROWSER, deviceId], str(e))
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
|
||||
# gam move browsers ou|org|orgunit <OrgUnitPath>
|
||||
# ((ids <DeviceIDList>) |
|
||||
@@ -250,7 +250,7 @@ def doUpdateBrowsers():
|
||||
body=browser, projection='BASIC', fields="deviceId")
|
||||
_getMain().entityActionPerformed([Ent.CHROME_BROWSER, deviceId], i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId, i, count)
|
||||
|
||||
def _getChromeProfileName():
|
||||
profileName = _getMain().getString(Cmd.OB_CHROMEPROFILE_NAME)
|
||||
@@ -800,7 +800,7 @@ def doPrintShowBrowsers():
|
||||
except GAPI.invalidArgument as e:
|
||||
_getMain().entityActionFailedWarning([Ent.CHROME_BROWSER, deviceId], str(e))
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_BROWSER, deviceId)
|
||||
if csvPF:
|
||||
if sortRows and orderBy:
|
||||
csvPF.SortRows(orderBy, reverse=sortOrder == 'DESCENDING')
|
||||
|
||||
@@ -121,7 +121,7 @@ def getCalendarACLScope():
|
||||
return {'list': [scopeType], 'dict': None}
|
||||
|
||||
def getCalendarSiteACLScopeEntity():
|
||||
ACLScopeEntity = {'list': getEntityList(Cmd.OB_ACL_SCOPE_ENTITY), 'dict': None}
|
||||
ACLScopeEntity = {'list': _getMain().getEntityList(Cmd.OB_ACL_SCOPE_ENTITY), 'dict': None}
|
||||
if isinstance(ACLScopeEntity['list'], dict):
|
||||
ACLScopeEntity['dict'] = ACLScopeEntity['list']
|
||||
return ACLScopeEntity
|
||||
@@ -168,7 +168,7 @@ def _normalizeCalIdGetRuleIds(origUser, user, origCal, calId, j, jcount, ACLScop
|
||||
def _processCalendarACLs(cal, function, entityType, calId, j, jcount, k, kcount, role, ruleId, sendNotifications):
|
||||
result = True
|
||||
if function == 'insert':
|
||||
kwargs = {'body': makeRoleRuleIdBody(role, ruleId), 'fields': '', 'sendNotifications': sendNotifications}
|
||||
kwargs = {'body': _getMain().makeRoleRuleIdBody(role, ruleId), 'fields': '', 'sendNotifications': sendNotifications}
|
||||
elif function == 'patch':
|
||||
kwargs = {'ruleId': ruleId, 'body': {'role': role}, 'fields': '', 'sendNotifications': sendNotifications}
|
||||
else: # elif function == 'delete':
|
||||
@@ -2122,7 +2122,7 @@ def _validateResourceId(cd, resourceId, i, count, exitOnNotFound):
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
if exitOnNotFound:
|
||||
_getMain().entityDoesNotExistExit(Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
return None
|
||||
|
||||
def _normalizeResourceIdGetRuleIds(cd, resourceId, i, count, ACLScopeEntity, showAction=True):
|
||||
|
||||
@@ -57,7 +57,7 @@ def doInfoChromeApp():
|
||||
_getMain().showJSON(None, appDetails, timeObjects=_getMain().CHROME_APPS_TIME_OBJECTS)
|
||||
Ind.Decrement()
|
||||
except (GAPI.badRequest, GAPI.notFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_APP, f'{app_type}/{app_id}')
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(None, Ent.CHROME_APP, f'{app_type}/{app_id}')
|
||||
|
||||
def _getPrintChromeGetting(subou, pfilter, entityType):
|
||||
orgUnitPath = subou[0]
|
||||
|
||||
@@ -204,7 +204,7 @@ def updateCrOSDevices(entityList):
|
||||
except GAPI.invalidOrgunit:
|
||||
_getMain().entityActionFailedWarning([Ent.CROS_DEVICE, deviceId], Msg.INVALID_ORGUNIT, i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
|
||||
# gam update cros|croses <CrOSEntity> <CrOSAttribute>+ [quickcrosmove [<Boolean>]] [nobatchupdate]
|
||||
# gam update cros|croses <CrOSEntity> action <CrOSAction> [acknowledge_device_touch_requirement]
|
||||
@@ -719,7 +719,7 @@ def infoCrOSDevices(entityList):
|
||||
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
||||
customerId=GC.Values[GC.CUSTOMER_ID], deviceId=deviceId, projection=projection, fields=fields)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden, GAPI.permissionDenied):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
continue
|
||||
checkTPMVulnerability(cros)
|
||||
if 'autoUpdateExpiration' in cros:
|
||||
@@ -1017,7 +1017,7 @@ def getCrOSDeviceFiles(entityList):
|
||||
_getMain().entityActionPerformed([Ent.DEVICE_FILE, downloadfilename], j, jcount)
|
||||
Ind.Decrement()
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, deviceId, i, count)
|
||||
|
||||
# gam get devicefile <CrOSEntity> [select <DeviceFileEntity>] [targetfolder <FilePath>]
|
||||
def doGetCrOSDeviceFiles():
|
||||
@@ -1207,7 +1207,7 @@ def doPrintCrOSDevices(entityList=None):
|
||||
else:
|
||||
http_status, reason, message = _getMain().checkGAPIError(exception)
|
||||
if reason in [GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN]:
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, ri[RI_ITEM], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, ri[RI_ITEM], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
else:
|
||||
errMsg = _getMain().getHTTPError({}, http_status, reason, message)
|
||||
_getMain().entityActionFailedWarning([Ent.CROS_DEVICE, ri[RI_ITEM]], errMsg, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
@@ -1487,7 +1487,7 @@ def doPrintCrOSActivity(entityList=None):
|
||||
else:
|
||||
http_status, reason, message = _getMain().checkGAPIError(exception)
|
||||
if reason in [GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN]:
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, ri[RI_ITEM], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.CROS_DEVICE, ri[RI_ITEM], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
else:
|
||||
errMsg = _getMain().getHTTPError({}, http_status, reason, message)
|
||||
_getMain().entityActionFailedWarning([Ent.CROS_DEVICE, ri[RI_ITEM]], errMsg, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
||||
|
||||
@@ -49,7 +49,7 @@ def doCreateOrg():
|
||||
except (GAPI.invalidOrgunit, GAPI.backendError):
|
||||
_getMain().entityDuplicateWarning([Ent.ORGANIZATIONAL_UNIT, fullPath])
|
||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, fullPath)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, fullPath)
|
||||
return True
|
||||
|
||||
cd = _getMain().buildGAPIObject(API.DIRECTORY)
|
||||
@@ -120,7 +120,7 @@ def doCreateOrg():
|
||||
if not _createOrg(body, body['parentOrgUnitPath'], fullPath):
|
||||
return
|
||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, fullPath)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, fullPath)
|
||||
|
||||
def checkOrgUnitPathExists(cd, orgUnitPath, i=0, count=0, showError=False):
|
||||
if orgUnitPath == '/':
|
||||
@@ -218,7 +218,7 @@ def _batchMoveCrOSesToOrgUnit(cd, orgUnitPath, orgUnitId, i, count, items, quick
|
||||
_getMain().entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath, Ent.CROS_DEVICE, ','.join(deviceIds)], str(e), i, count)
|
||||
break
|
||||
except (GAPI.badRequest, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath, i, count)
|
||||
bcount += kcount
|
||||
Ind.Decrement()
|
||||
|
||||
@@ -365,7 +365,7 @@ def _doUpdateOrgs(entityList):
|
||||
except GAPI.conditionNotMet as e:
|
||||
_getMain().entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
|
||||
# gam update orgs|ous <OrgUnitEntity> [name <String>] [description <String>] [parent <OrgUnitItem>]
|
||||
# gam update orgs|ous <OrgUnitEntity> add|move <CrosTypeEntity> [quickcrosmove [<Boolean>]]
|
||||
@@ -407,7 +407,7 @@ def _doDeleteOrgs(entityList):
|
||||
### Check for my_customer
|
||||
_getMain().entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath, Ent.CUSTOMER_ID, GC.Values[GC.CUSTOMER_ID]], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.loginRequired):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
|
||||
# gam delete orgs|ous <OrgUnitEntity>
|
||||
def doDeleteOrgs():
|
||||
@@ -494,7 +494,7 @@ def _doInfoOrgs(entityList):
|
||||
except (GAPI.invalidInput, GAPI.invalidOrgunit, GAPI.orgunitNotFound, GAPI.backendError):
|
||||
_getMain().entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], Msg.DOES_NOT_EXIST, i, count)
|
||||
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.ORGANIZATIONAL_UNIT, orgUnitPath)
|
||||
|
||||
# gam info org|ou <OrgUnitItem>
|
||||
# [nousers | ([notarchived|archived] [notsuspended|suspended])] [children|child]
|
||||
|
||||
@@ -563,7 +563,7 @@ def _doUpdateResourceCalendars(entityList):
|
||||
except (GAPI.invalid, GAPI.invalidInput, GAPI.serviceNotAvailable, GAPI.required) as e:
|
||||
_getMain().entityActionFailedWarning([Ent.RESOURCE_CALENDAR, resourceId], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
|
||||
# gam update resources <ResourceEntity> <ResourceAttribute>*
|
||||
def doUpdateResourceCalendars():
|
||||
@@ -589,7 +589,7 @@ def _doDeleteResourceCalendars(entityList):
|
||||
except GAPI.serviceNotAvailable as e:
|
||||
_getMain().entityActionFailedWarning([Ent.RESOURCE_CALENDAR, resourceId], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
|
||||
# gam delete resources <ResourceEntity>
|
||||
def doDeleteResourceCalendars():
|
||||
@@ -714,7 +714,7 @@ def _doInfoResourceCalendars(entityList):
|
||||
continue
|
||||
_showResource(cd, resource, i, count, FJQC, acls, noSelfOwner)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.forbidden):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.RESOURCE_CALENDAR, resourceId, i, count)
|
||||
|
||||
# gam info resources <ResourceEntity>
|
||||
# [acls] [noselfowner] [calendar] [formatjson]
|
||||
|
||||
@@ -168,7 +168,7 @@ def doCreateUpdateUserSchemas():
|
||||
except (GAPI.conditionNotMet, GAPI.fieldInUse) as e:
|
||||
_getMain().entityActionFailedWarning([Ent.USER_SCHEMA, schemaName], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaName, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaName, i, count)
|
||||
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
|
||||
@@ -190,7 +190,7 @@ def doDeleteUserSchemas():
|
||||
except GAPI.fieldInUse as e:
|
||||
_getMain().entityActionFailedWarning([Ent.USER_SCHEMA, schemaKey], str(e), i, count)
|
||||
except (GAPI.badRequest, GAPI.resourceNotFound):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
||||
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
|
||||
@@ -210,7 +210,7 @@ def doInfoUserSchemas():
|
||||
customerId=GC.Values[GC.CUSTOMER_ID], schemaKey=schemaKey)
|
||||
_showSchema(schema, i, count)
|
||||
except (GAPI.invalid, GAPI.badRequest, GAPI.resourceNotFound):
|
||||
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
||||
_getMain().checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
||||
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user