From abb49ed33622431d6aa786980059b197d21e1419 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 18 Sep 2024 07:14:53 -0700 Subject: [PATCH] Updated `gam delete ou` and `gam print admins` to handle the following error: ERROR: 503: serviceNotAvailable - The service is currently unavailable. --- src/GamUpdate.txt | 5 +++++ src/gam/__init__.py | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 2ebd2f8f..5521a752 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -8,6 +8,11 @@ where 7.00.02 MacOS builds usually took ~7 seconds to run "gam version", 7.00.03 MacOS builds are now signed by Jay's Apple Developer ID and notarized (scanned for malware) by Apple. This should resolve MacOS security warnings that need to be overridden when running GAM. +Updated `gam delete ou` and `gam print admins` to handle the following error: +``` +ERROR: 503: serviceNotAvailable - The service is currently unavailable. +``` + 7.00.02 Added option `showlastmodification` to `gam print|show filecounts` that adds diff --git a/src/gam/__init__.py b/src/gam/__init__.py index caa4f6b8..7474153d 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -16623,13 +16623,15 @@ def doPrintShowAdmins(): try: admins = callGAPIpages(cd.roleAssignments(), 'list', 'items', pageMessage=getPageMessage(), - throwReasons=[GAPI.INVALID, GAPI.USER_NOT_FOUND, GAPI.BAD_REQUEST, - GAPI.CUSTOMER_NOT_FOUND, GAPI.FORBIDDEN], + throwReasons=[GAPI.INVALID, GAPI.USER_NOT_FOUND, + GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE, + GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND], + retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS, customer=GC.Values[GC.CUSTOMER_ID], fields=fields, **kwargs) except (GAPI.invalid, GAPI.userNotFound): entityUnknownWarning(Ent.ADMINISTRATOR, userKey) return - except GAPI.forbidden as e: + except (GAPI.forbidden, GAPI.serviceNotAvailable) as e: entityActionFailedExit([Ent.ADMINISTRATOR, userKey, Ent.ADMIN_ROLE, roleId], str(e)) except (GAPI.badRequest, GAPI.customerNotFound): accessErrorExit(cd) @@ -17334,14 +17336,17 @@ def _doDeleteOrgs(entityList): try: orgUnitPath = makeOrgUnitPathAbsolute(orgUnitPath) 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], + throwReasons=[GAPI.CONDITION_NOT_MET, GAPI.INVALID_ORGUNIT, GAPI.ORGUNIT_NOT_FOUND, GAPI.BACKEND_ERROR, + GAPI.INVALID_CUSTOMER_ID, GAPI.SERVICE_NOT_AVAILABLE, + GAPI.BAD_REQUEST, GAPI.LOGIN_REQUIRED], + retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS, customerId=GC.Values[GC.CUSTOMER_ID], orgUnitPath=encodeOrgUnitPath(makeOrgUnitPathRelative(orgUnitPath))) entityActionPerformed([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], i, count) except GAPI.conditionNotMet: entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], Msg.HAS_CHILD_ORGS.format(Ent.Plural(Ent.ORGANIZATIONAL_UNIT)), i, count) except (GAPI.invalidOrgunit, GAPI.orgunitNotFound, GAPI.backendError): entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath], Msg.DOES_NOT_EXIST, i, count) - except GAPI.invalidCustomerId as e: + except (GAPI.invalidCustomerId, GAPI.serviceNotAvailable) as e: ### Check for my_customer entityActionFailedWarning([Ent.ORGANIZATIONAL_UNIT, orgUnitPath, Ent.CUSTOMER_ID, GC.Values[GC.CUSTOMER_ID]], str(e), i, count) except (GAPI.badRequest, GAPI.loginRequired):