From 201d89c45a378cd084b1f40f11f23adfe1e0c96f Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 3 Jul 2026 11:15:17 -0400 Subject: [PATCH] _getMain fixes --- src/gam/cmd/browsers.py | 8 ++++---- src/gam/cmd/calendar.py | 6 +++--- src/gam/cmd/chromeapps.py | 2 +- src/gam/cmd/cros.py | 10 +++++----- src/gam/cmd/orgunits.py | 12 ++++++------ src/gam/cmd/resources.py | 6 +++--- src/gam/cmd/schemas.py | 6 +++--- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gam/cmd/browsers.py b/src/gam/cmd/browsers.py index 3ff0dd7f..8778eb45 100644 --- a/src/gam/cmd/browsers.py +++ b/src/gam/cmd/browsers.py @@ -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 # ((ids ) | @@ -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') diff --git a/src/gam/cmd/calendar.py b/src/gam/cmd/calendar.py index 3233bb74..f33e2dc9 100644 --- a/src/gam/cmd/calendar.py +++ b/src/gam/cmd/calendar.py @@ -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): diff --git a/src/gam/cmd/chromeapps.py b/src/gam/cmd/chromeapps.py index d6dee7e4..12c724d2 100644 --- a/src/gam/cmd/chromeapps.py +++ b/src/gam/cmd/chromeapps.py @@ -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] diff --git a/src/gam/cmd/cros.py b/src/gam/cmd/cros.py index 2d13ba5c..abbf972e 100644 --- a/src/gam/cmd/cros.py +++ b/src/gam/cmd/cros.py @@ -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 + [quickcrosmove []] [nobatchupdate] # gam update cros|croses action [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 [select ] [targetfolder ] 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])) diff --git a/src/gam/cmd/orgunits.py b/src/gam/cmd/orgunits.py index 01431248..28504778 100644 --- a/src/gam/cmd/orgunits.py +++ b/src/gam/cmd/orgunits.py @@ -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 [name ] [description ] [parent ] # gam update orgs|ous add|move [quickcrosmove []] @@ -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 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 # [nousers | ([notarchived|archived] [notsuspended|suspended])] [children|child] diff --git a/src/gam/cmd/resources.py b/src/gam/cmd/resources.py index 84466aa0..004477e7 100644 --- a/src/gam/cmd/resources.py +++ b/src/gam/cmd/resources.py @@ -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 * 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 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 # [acls] [noselfowner] [calendar] [formatjson] diff --git a/src/gam/cmd/schemas.py b/src/gam/cmd/schemas.py index 192aa64a..5dfb676b 100644 --- a/src/gam/cmd/schemas.py +++ b/src/gam/cmd/schemas.py @@ -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))