Made serviceNotAvailable retryable

This commit is contained in:
Ross Scroggs
2023-08-23 20:46:05 -07:00
parent a7097a7310
commit d5eef1faf5
6 changed files with 41 additions and 129 deletions

View File

@@ -6305,7 +6305,6 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
result = callGAPIpages(croom.courses().teachers(), 'list', 'teachers',
pageMessage=getPageMessageForWhom(),
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, fields='nextPageToken,teachers/profile/emailAddress',
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for teacher in result:
@@ -6318,7 +6317,6 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
result = callGAPIpages(croom.courses().students(), 'list', 'students',
pageMessage=getPageMessageForWhom(),
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, fields='nextPageToken,students/profile/emailAddress',
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for student in result:
@@ -15852,7 +15850,6 @@ def doCreateAdmin():
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
GAPI.FORBIDDEN, GAPI.CUSTOMER_EXCEEDED_ROLE_ASSIGNMENTS_LIMIT, GAPI.SERVICE_NOT_AVAILABLE,
GAPI.INVALID_ORGUNIT, GAPI.DUPLICATE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='roleAssignmentId,assigneeType')
assigneeType = result.get('assigneeType')
if assigneeType == 'user':
@@ -15884,7 +15881,6 @@ def doDeleteAdmin():
throwReasons=[GAPI.NOT_FOUND, GAPI.OPERATION_NOT_SUPPORTED, GAPI.FORBIDDEN,
GAPI.INVALID_INPUT, GAPI.SERVICE_NOT_AVAILABLE,
GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], roleAssignmentId=roleAssignmentId)
entityActionPerformed([Ent.ADMIN_ROLE_ASSIGNMENT, roleAssignmentId])
except (GAPI.notFound, GAPI.operationNotSupported, GAPI.forbidden,
@@ -20161,7 +20157,6 @@ def _getPeopleOtherContacts(people, entityType, user, i=0, count=0):
results = callGAPIpages(people.otherContacts(), 'list', 'otherContacts',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageSize=1000,
readMask='emailAddresses', fields='nextPageToken,otherContacts(etag,resourceName,emailAddresses(value,type))')
otherContacts = {}
@@ -20184,7 +20179,6 @@ def queryPeopleContacts(people, contactQuery, fields, sortOrder, entityType, use
results = callGAPIpages(people.people().connections(), 'list', 'connections',
pageMessage=pageMessage,
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
resourceName='people/me', sources=sources, personFields=fields,
sortOrder=sortOrder, fields='nextPageToken,connections')
@@ -20217,7 +20211,6 @@ def queryPeopleContacts(people, contactQuery, fields, sortOrder, entityType, use
resourceName=contactQuery['group'], maxMembers=totalItems, groupFields='name')
for resourceName in results.get('memberResourceNames', []):
result = callGAPI(people.people(), 'get',
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName, sources=sources, personFields=fields)
entityList.append(result)
@@ -20238,7 +20231,6 @@ def queryPeopleOtherContacts(people, contactQuery, fields, entityType, user, i=0
entityList = callGAPIpages(people.otherContacts(), 'list', 'otherContacts',
pageMessage=pageMessage,
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
readMask=fields, fields='nextPageToken,otherContacts', sources=sources)
else:
@@ -20355,7 +20347,6 @@ def createUserPeopleContact(users):
try:
result = callGAPI(people.people(), 'createContact',
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS+[GAPI.INVALID_ARGUMENT],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
personFields=','.join(personFields), body=body, sources=sources)
resourceName = result['resourceName']
if returnIdOnly:
@@ -20474,7 +20465,6 @@ def _clearUpdatePeopleContacts(users, updateContacts):
contact = callGAPI(people.people(), 'get',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=contact, sources=sources, personFields='emailAddresses,memberships')
else:
if not localPeopleContactSelects(contactQuery, contact):
@@ -20516,7 +20506,6 @@ def _clearUpdatePeopleContacts(users, updateContacts):
callGAPI(people.people(), 'deleteContact',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName)
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
continue
@@ -20524,7 +20513,6 @@ def _clearUpdatePeopleContacts(users, updateContacts):
updatePersonFields = [PEOPLE_EMAIL_ADDRESSES]
person = callGAPI(people.people(), 'updateContact',
throwReasons=[GAPI.INVALID_ARGUMENT, GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName,
updatePersonFields=','.join(updatePersonFields), body=body, sources=sources)
entityActionPerformed([entityType, user, peopleEntityType, person['resourceName']], j, jcount)
@@ -20657,7 +20645,6 @@ def dedupReplaceDomainUserPeopleContacts(users):
contact = callGAPI(people.people(), 'get',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=contact, sources=sources, personFields='emailAddresses,memberships')
else:
if action == Act.DEDUP and not localPeopleContactSelects(contactQuery, contact):
@@ -20672,7 +20659,6 @@ def dedupReplaceDomainUserPeopleContacts(users):
Act.Set(Act.UPDATE)
callGAPI(people.people(), 'updateContact',
throwReasons=[GAPI.INVALID_ARGUMENT, GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName,
updatePersonFields='emailAddresses', body=contact)
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
@@ -20728,7 +20714,6 @@ def deleteUserPeopleContacts(users):
callGAPI(people.people(), 'deleteContact',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName)
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
except (GAPI.notFound, GAPI.internalError):
@@ -21004,7 +20989,6 @@ def _infoPeople(users, entityType, source):
result = callGAPI(people.people(), 'get',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR, GAPI.INVALID_ARGUMENT]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName, sources=sources, personFields=fields)
except (GAPI.notFound, GAPI.internalError):
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
@@ -21277,7 +21261,6 @@ def processUserPeopleOtherContacts(users):
try:
callGAPI(upeople.people(), 'updateContact',
throwReasons=[GAPI.INVALID_ARGUMENT, GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=peopleResourceName,
updatePersonFields=','.join(updatePersonFields), body=body, sources=sources)
if action != Act.DELETE:
@@ -21290,7 +21273,6 @@ def processUserPeopleOtherContacts(users):
callGAPI(upeople.people(), 'deleteContact',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=peopleResourceName)
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
break
@@ -21537,7 +21519,6 @@ def printShowUserPeopleProfiles(users):
try:
result = callGAPI(people.people(), 'get',
throwReasons=[GAPI.NOT_FOUND]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName='people/me', sources=sources, personFields=fields)
except GAPI.notFound:
entityUnknownWarning(Ent.PEOPLE_PROFILE, user, i, count)
@@ -21631,7 +21612,6 @@ def _processPeopleContactPhotos(users, function):
result = callGAPI(people.people(), 'get',
bailOnInternalError=True,
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName, sources=sources, personFields='emailAddresses')
if function == 'updateContactPhoto':
if subForContactId or subForEmail:
@@ -21650,7 +21630,6 @@ def _processPeopleContactPhotos(users, function):
filename = os.path.join(targetFolder, filename)
result = callGAPI(people.people(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.INTERNAL_ERROR]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=resourceName, personFields='photos')
url = None
for photo in result.get('photos', []):
@@ -25393,7 +25372,6 @@ def buildChromeSchemas(cp=None, sfilter=None):
cp = buildGAPIObject(API.CHROMEPOLICY)
parent = _getCustomersCustomerIdWithC()
schemas = callGAPIpages(cp.customers().policySchemas(), 'list', 'policySchemas',
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
parent=parent, filter=sfilter)
schema_objects = {}
for schema in schemas:
@@ -25451,7 +25429,6 @@ def doDeleteChromePolicy():
callGAPI(cp.customers().policies().orgunits(), 'batchInherit',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED,
GAPI.INVALID_ARGUMENT, GAPI.SERVICE_NOT_AVAILABLE, GAPI.QUOTA_EXCEEDED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, body=body)
entityActionPerformed(kvList)
except (GAPI.notFound, GAPI.permissionDenied, GAPI.invalidArgument, GAPI.serviceNotAvailable, GAPI.quotaExceeded) as e:
@@ -25696,7 +25673,6 @@ def doUpdateChromePolicy():
callGAPI(cp.customers().policies().orgunits(), 'batchModify',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.INVALID_ARGUMENT,
GAPI.SERVICE_NOT_AVAILABLE, GAPI.QUOTA_EXCEEDED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, body=body)
entityActionPerformed(kvList)
except (GAPI.notFound, GAPI.permissionDenied, GAPI.invalidArgument, GAPI.serviceNotAvailable, GAPI.quotaExceeded) as e:
@@ -26132,7 +26108,6 @@ def doCreateChromeNetwork():
bailOnInternalError=True,
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.PERMISSION_DENIED, GAPI.INVALID_ARGUMENT,
GAPI.INTERNAL_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, body=body)
entityActionPerformed(kvList+[Ent.CHROME_NETWORK_ID, result['networkId']])
except (GAPI.alreadyExists, GAPI.permissionDenied, GAPI.invalidArgument,
@@ -26153,7 +26128,6 @@ def doDeleteChromeNetwork():
callGAPI(cp.customers().policies().networks(), 'removeNetwork',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED,
GAPI.INVALID_ARGUMENT, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, body=body)
entityActionPerformed(kvList)
except (GAPI.notFound, GAPI.permissionDenied, GAPI.invalidArgument, GAPI.serviceNotAvailable) as e:
@@ -26211,7 +26185,6 @@ def getCIDeviceEntity():
try:
devices = callGAPIpages(ci.devices(), 'list', 'devices',
throwReasons=[GAPI.INVALID, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
customer=customer, filter=query,
fields='nextPageToken,devices(name)', pageSize=100)
@@ -26246,7 +26219,6 @@ def getCIDeviceUserEntity():
try:
deviceUsers = callGAPIpages(ci.devices().deviceUsers(), 'list', 'deviceUsers',
throwReasons=[GAPI.INVALID, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
customer=customer, filter=query, parent='devices/-',
fields='nextPageToken,deviceUsers(name)', pageSize=20)
@@ -26446,7 +26418,6 @@ def doSyncCIDevices():
try:
result = callGAPIpages(ci.devices(), 'list', 'devices',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
customer=customer, filter=query, view='COMPANY_INVENTORY',
fields=fields, pageSize=100)
@@ -26715,7 +26686,6 @@ def doPrintCIDevices():
devices = callGAPIpages(ci.devices(), 'list', 'devices',
pageMessage=pageMessage,
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, filter=query,
orderBy=OBY.orderBy, view=view, fields=fields, pageSize=100)
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied) as e:
@@ -26732,7 +26702,6 @@ def doPrintCIDevices():
deviceUsers = callGAPIpages(ci.devices().deviceUsers(), 'list', 'deviceUsers',
pageMessage=pageMessage,
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, filter=query, parent=parent,
orderBy=OBY.orderBy, fields=userFields, pageSize=20)
for deviceUser in deviceUsers:
@@ -26894,7 +26863,6 @@ def doPrintCIDeviceUsers():
deviceUsers = callGAPIpages(ci.devices().deviceUsers(), 'list', 'deviceUsers',
pageMessage=pageMessage,
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customer, filter=query,
orderBy=OBY.orderBy, parent=parent, fields=userFields, pageSize=20)
for deviceUser in deviceUsers:
@@ -27525,7 +27493,6 @@ def doPrintShowChromeApps():
try:
apps = callGAPIpages(cm.customers().reports(), 'countInstalledApps', 'installedApps',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
customer=customerId, orgUnitId=orgUnitId, filter=pfilter, orderBy=orderBy)
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
@@ -27673,7 +27640,6 @@ def doPrintShowChromeAppDevices():
try:
devices = callGAPIpages(cm.customers().reports(), 'findInstalledAppDevices', 'devices',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
appId=appId, appType=appType,
customer=customerId, orgUnitId=orgUnitId, filter=pfilter, orderBy=orderBy)
@@ -27792,7 +27758,6 @@ def doPrintShowChromeAues():
try:
aues = callGAPI(cm.customers().reports(), 'countChromeDevicesReachingAutoExpirationDate',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customerId, orgUnitId=orgUnitId, minAueDate=minAueDate, maxAueDate=maxAueDate).get('deviceAueCountReports', [])
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning([Ent.CHROME_MODEL, None], str(e))
@@ -27898,7 +27863,6 @@ def doPrintShowChromeNeedsAttn():
try:
result = callGAPI(cm.customers().reports(), 'countChromeDevicesThatNeedAttention',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=customerId, orgUnitId=orgUnitId, readMask=','.join(CHROME_NEEDSATTN_TITLES))
for field in CHROME_NEEDSATTN_TITLES:
result.setdefault(field, 0)
@@ -28024,7 +27988,6 @@ def doPrintShowChromeVersions():
try:
versions = callGAPIpages(cm.customers().reports(), 'countChromeVersions', 'browserVersions',
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
pageMessage=pageMessage,
customer=customerId, orgUnitId=orgUnitId, filter=pfilter)
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
@@ -31323,7 +31286,6 @@ def doPrintGroupMembers():
try:
info = callGAPI(people.people(), 'get',
throwReasons=[GAPI.NOT_FOUND]+GAPI.PEOPLE_ACCESS_THROW_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName=f'people/{memberId}', personFields='names')
if 'names' in info:
for sourceType in ['PROFILE', 'CONTACT']:
@@ -31489,7 +31451,6 @@ def doPrintGroupMembers():
try:
mbinfo = callGAPI(cd.users(), 'get',
throwReasons=GAPI.USER_GET_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userKey=memberId, fields=userFields)
if memberOptions[MEMBEROPTION_MEMBERNAMES]:
row['name'] = mbinfo['name'].pop('fullName')
@@ -34171,7 +34132,6 @@ def doCreateResourceCalendar():
callGAPI(cd.resources().calendars(), 'insert',
throwReasons=[GAPI.INVALID, GAPI.INVALID_INPUT, GAPI.SERVICE_NOT_AVAILABLE,
GAPI.REQUIRED, GAPI.DUPLICATE, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='')
entityActionPerformed([Ent.RESOURCE_CALENDAR, body['resourceId']])
except (GAPI.invalid, GAPI.invalidInput, GAPI.serviceNotAvailable) as e:
@@ -34200,7 +34160,6 @@ def _doUpdateResourceCalendars(entityList):
if featureChanges['add'] or featureChanges['remove']:
features = callGAPI(cd.resources().calendars(), 'get',
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE, GAPI.FORBIDDEN],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], calendarResourceId=resourceId, fields='featureInstances(feature(name))')
bodyFeatures = body.pop('featureInstances', [])
body['featureInstances'] = []
@@ -34224,7 +34183,6 @@ def _doUpdateResourceCalendars(entityList):
callGAPI(cd.resources().calendars(), 'patch',
throwReasons=[GAPI.INVALID, GAPI.INVALID_INPUT, GAPI.SERVICE_NOT_AVAILABLE, GAPI.REQUIRED,
GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], calendarResourceId=resourceId, body=body, fields='')
entityActionPerformed([Ent.RESOURCE_CALENDAR, resourceId], i, count)
except (GAPI.invalid, GAPI.invalidInput, GAPI.serviceNotAvailable, GAPI.required) as e:
@@ -34250,7 +34208,6 @@ def _doDeleteResourceCalendars(entityList):
try:
callGAPI(cd.resources().calendars(), 'delete',
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
customer=GC.Values[GC.CUSTOMER_ID], calendarResourceId=resourceId)
entityActionPerformed([Ent.RESOURCE_CALENDAR, resourceId], i, count)
except GAPI.serviceNotAvailable as e:
@@ -40488,7 +40445,6 @@ def doCreateUser():
callGAPI(parameters['lic'].licenseAssignments(), 'insert',
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET, GAPI.INVALID,
GAPI.USER_NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
productId=productId, skuId=skuId, body={'userId': user}, fields='')
entityActionPerformed([Ent.USER, user, Ent.LICENSE, SKU.formatSKUIdDisplayName(skuId)])
except (GAPI.internalError, GAPI.duplicate, GAPI.conditionNotMet, GAPI.invalid,
@@ -42260,7 +42216,7 @@ def _getInboundSSOProfiles(ci):
filter=f'customer=="{customer}"')
except (GAPI.notFound, GAPI.domainNotFound, GAPI.domainCannotUseApis,
GAPI.forbidden, GAPI.badRequest, GAPI.invalid,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning([Ent.INBOUND_SSO_PROFILE, customer], str(e))
return []
@@ -42348,7 +42304,7 @@ def doCreateInboundSSOProfile():
_processInboundSSOProfileResult(result, returnNameOnly, kvlist, 'create')
except (GAPI.failedPrecondition, GAPI.notFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam update inboundssoprofile <SSOProfileItem>
@@ -42369,7 +42325,7 @@ def doUpdateInboundSSOProfile():
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam delete inboundssoprofile <SSOProfileItem>
@@ -42388,7 +42344,7 @@ def doDeleteInboundSSOProfile():
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
def _getInboundSSOProfile(ci, name):
@@ -42401,7 +42357,7 @@ def _getInboundSSOProfile(ci, name):
except GAPI.notFound:
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
return None
@@ -42463,7 +42419,7 @@ def getInboundSSOProfileCredentials(ci, profile):
parent=profile)
except (GAPI.notFound, GAPI.domainNotFound, GAPI.domainCannotUseApis,
GAPI.forbidden, GAPI.badRequest, GAPI.invalid,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning([Ent.INBOUND_SSO_PROFILE, profile], str(e))
return None
@@ -42559,7 +42515,7 @@ def doCreateInboundSSOCredential():
entityActionFailedWarning([Ent.INBOUND_SSO_PROFILE, profile], str(e))
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam delete inboundssocredential <SSOCredentialsName>
@@ -42580,7 +42536,7 @@ def doDeleteInboundSSOCredential(ci=None, name=None):
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam info inboundssocredential <SSOCredentialsName> [formatjson]
@@ -42598,7 +42554,7 @@ def doInfoInboundSSOCredential():
except GAPI.notFound:
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam show inboundssocredentials [profile|profiles <SSOProfileItemList>]
@@ -42657,7 +42613,7 @@ def _getInboundSSOAssignment(ci, name):
except GAPI.notFound:
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.badRequest, GAPI.invalid, GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
return None
@@ -42670,7 +42626,7 @@ def _getInboundSSOAssignments(ci):
filter=f'customer=="{customer}"')
except (GAPI.notFound, GAPI.domainNotFound, GAPI.domainCannotUseApis,
GAPI.forbidden, GAPI.badRequest, GAPI.invalid,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning([Ent.INBOUND_SSO_ASSIGNMENT, customer], str(e))
return None
@@ -42782,7 +42738,7 @@ def doCreateInboundSSOAssignment():
_processInboundSSOAssignmentResult(result, kvlist, ci, cd, 'create')
except (GAPI.failedPrecondition, GAPI.notFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam update inboundssoassignment [(group <GroupItem> rank <Number>)|(ou|org|orgunit <OrgUnitItem>)]
@@ -42803,7 +42759,7 @@ def doUpdateInboundSSOAssignment():
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam delete inboundssoassignment <SSOAssignmentSelector>
@@ -42827,7 +42783,7 @@ def doDeleteInboundSSOAssignment():
entityActionFailedWarning(kvlist, Msg.DOES_NOT_EXIST)
except (GAPI.failedPrecondition, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden,
GAPI.badRequest, GAPI.invalid, GAPI.invalidInput, GAPI.invalidArgument,
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError) as e:
GAPI.systemError, GAPI.permissionDenied, GAPI.internalError, GAPI.serviceNotAvailable) as e:
entityActionFailedWarning(kvlist, str(e))
# gam info inboundssoassignment <SSOAssignmentSelector> [formatjson]
@@ -43056,7 +43012,6 @@ def checkCourseExists(croom, courseId, i=0, count=0, entityType=Ent.COURSE):
try:
result = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields='id,ownerId')
return result
except GAPI.notFound:
@@ -43290,7 +43245,6 @@ class CourseAttributes():
self.courseAnnouncements = callGAPIpages(self.croom.courses().announcements(), 'list', 'announcements',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=self.courseId, announcementStates=self.announcementStates,
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseAnnouncement in self.courseAnnouncements:
@@ -43307,7 +43261,6 @@ class CourseAttributes():
self.courseMaterials = callGAPIpages(self.croom.courses().courseWorkMaterials(), 'list', 'courseWorkMaterial',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=self.courseId, courseWorkMaterialStates=self.materialStates,
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseMaterial in self.courseMaterials:
@@ -43328,7 +43281,6 @@ class CourseAttributes():
self.courseWorks = callGAPIpages(self.croom.courses().courseWork(), 'list', 'courseWork',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=self.courseId, courseWorkStates=self.workStates,
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseWork in self.courseWorks:
@@ -43352,7 +43304,6 @@ class CourseAttributes():
courseTopics = callGAPIpages(self.croom.courses().topics(), 'list', 'topic',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=self.courseId, fields='nextPageToken,topic(topicId,name)',
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for topic in courseTopics:
@@ -43440,7 +43391,6 @@ class CourseAttributes():
try:
newCourseTopics = callGAPIpages(self.croom.courses().topics(), 'list', 'topic',
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.FAILED_PRECONDITION, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=newCourseId, fields='nextPageToken,topic(topicId,name)',
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
newTopicsByName = {}
@@ -43463,7 +43413,6 @@ class CourseAttributes():
try:
result = callGAPI(tcroom.courses().topics(), 'create',
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.FAILED_PRECONDITION, GAPI.INVALID_ARGUMENT, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=newCourseId, body={'name': topicName}, fields='topicId')
newTopicsByName[topicName] = result['topicId']
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_TOPIC, topicName], Act.MODIFIER_FROM,
@@ -43491,7 +43440,6 @@ class CourseAttributes():
result = callGAPI(tcroom.courses().announcements(), 'create',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FORBIDDEN,
GAPI.BAD_REQUEST, GAPI.FAILED_PRECONDITION, GAPI.BACKEND_ERROR, GAPI.INTERNAL_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=newCourseId, body=body, fields='id')
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_ANNOUNCEMENT_ID, result['id']], Act.MODIFIER_FROM,
[Ent.COURSE, self.courseId, Ent.COURSE_ANNOUNCEMENT_ID, courseAnnouncementId], j, jcount)
@@ -43527,7 +43475,6 @@ class CourseAttributes():
result = callGAPI(tcroom.courses().courseWorkMaterials(), 'create',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FORBIDDEN,
GAPI.BAD_REQUEST, GAPI.FAILED_PRECONDITION, GAPI.BACKEND_ERROR, GAPI.INTERNAL_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=newCourseId, body=body, fields='id')
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_MATERIAL_ID, result['id']], Act.MODIFIER_FROM,
[Ent.COURSE, self.courseId, Ent.COURSE_MATERIAL_ID, courseMaterialId], j, jcount)
@@ -43568,7 +43515,6 @@ class CourseAttributes():
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FORBIDDEN,
GAPI.BAD_REQUEST, GAPI.FAILED_PRECONDITION, GAPI.BACKEND_ERROR,
GAPI.INTERNAL_ERROR, GAPI.INVALID_ARGUMENT, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=newCourseId, body=body, fields='id')
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_WORK_ID, result['id']], Act.MODIFIER_FROM,
[Ent.COURSE, self.courseId, Ent.COURSE_WORK, f'{body.get("title", courseWorkId)}'], j, jcount)
@@ -43614,7 +43560,6 @@ def doCreateCourse():
result = callGAPI(croom.courses(), 'create',
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED,
GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
body=courseAttributes.body, fields='id,name,ownerId,courseState,teacherFolder(id)')
entityActionPerformed([Ent.COURSE_NAME, result['name'], Ent.COURSE, result['id']])
if courseAttributes.courseId:
@@ -43644,12 +43589,10 @@ def _doUpdateCourses(entityList):
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FAILED_PRECONDITION,
GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.INVALID_ARGUMENT,
GAPI.INTERNAL_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, body=body, updateMask=','.join(list(body)), fields='id,name,ownerId,courseState,teacherFolder(id)')
else:
result = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields='id,name,ownerId,courseState,teacherFolder(id)')
if courseAttributes.body:
if not newOwner:
@@ -43679,7 +43622,6 @@ def _doUpdateCourses(entityList):
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR,
GAPI.ALREADY_EXISTS, GAPI.FAILED_PRECONDITION,
GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, body={'userId': newOwner}, fields='')
modifier = Act.MODIFIER_WITH_NEW_TEACHER_OWNER
time.sleep(10)
@@ -43746,7 +43688,6 @@ def _doDeleteCourses(entityList):
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FAILED_PRECONDITION,
GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.INVALID_ARGUMENT,
GAPI.INTERNAL_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, body=body, updateMask=updateMask, fields='')
callGAPI(croom.courses(), 'delete',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.FAILED_PRECONDITION, GAPI.INTERNAL_ERROR],
@@ -43898,7 +43839,6 @@ def _convertCourseUserIdToEmail(croom, userId, emails, entityValueList, i, count
try:
userEmail = callGAPI(croom.userProfiles(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userId=userId, fields='emailAddress').get('emailAddress')
except (GAPI.notFound, GAPI.permissionDenied, GAPI.badRequest, GAPI.forbidden, GAPI.serviceNotAvailable):
pass
@@ -43925,7 +43865,6 @@ def _getCourseAliasesMembers(croom, courseId, courseShowProperties, teachersFiel
aliases = callGAPIpages(croom.courses().aliases(), 'list', 'aliases',
pageMessage=pageMessage,
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE, GAPI.NOT_IMPLEMENTED],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.notImplemented):
pass
@@ -43939,7 +43878,6 @@ def _getCourseAliasesMembers(croom, courseId, courseShowProperties, teachersFiel
teachers = callGAPIpages(croom.courses().teachers(), 'list', 'teachers',
pageMessage=pageMessage,
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, fields=teachersFields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
except (GAPI.notFound, GAPI.serviceNotAvailable):
pass
@@ -43952,7 +43890,6 @@ def _getCourseAliasesMembers(croom, courseId, courseShowProperties, teachersFiel
students = callGAPIpages(croom.courses().students(), 'list', 'students',
pageMessage=pageMessage,
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, fields=studentsFields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
except (GAPI.notFound, GAPI.serviceNotAvailable):
pass
@@ -43990,7 +43927,6 @@ def _doInfoCourses(entityList):
try:
course = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields=fields)
if courseShowProperties['ownerEmail']:
course['ownerEmail'] = _convertCourseUserIdToEmail(croom, course['ownerId'], ownerEmails,
@@ -44139,7 +44075,6 @@ def _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getO
return callGAPIpages(croom.courses(), 'list', 'courses',
pageMessage=getPageMessage(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.BAD_REQUEST, GAPI.INVALID, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
teacherId=courseSelectionParameters['teacherId'],
studentId=courseSelectionParameters['studentId'],
courseStates=courseSelectionParameters['courseStates'],
@@ -44161,7 +44096,6 @@ def _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getO
try:
info = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields=fields)
coursesInfo.append(info)
except GAPI.notFound:
@@ -44420,7 +44354,6 @@ def doPrintCourseAnnouncements():
results = callGAPIpages(croom.courses().announcements(), 'list', 'announcements',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, announcementStates=courseAnnouncementStates, orderBy=OBY.orderBy,
fields=fields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseAnnouncement in results:
@@ -44438,7 +44371,6 @@ def doPrintCourseAnnouncements():
try:
courseAnnouncement = callGAPI(croom.courses().announcements(), 'get',
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, id=courseAnnouncementId, fields=fields)
_printCourseAnnouncement(course, courseAnnouncement, i, count)
except GAPI.notFound:
@@ -44507,7 +44439,6 @@ def doPrintCourseTopics():
results = callGAPIpages(croom.courses().topics(), 'list', 'topic',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId,
fields=fields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseTopic in results:
@@ -44525,7 +44456,6 @@ def doPrintCourseTopics():
try:
courseTopic = callGAPI(croom.courses().topics(), 'get',
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, id=courseTopicId, fields=fields)
_printCourseTopic(course, courseTopic)
except GAPI.notFound:
@@ -44610,7 +44540,6 @@ def doPrintCourseWM(entityIDType, entityStateType):
try:
results = callGAPIpages(croom.courses().topics(), 'list', 'topic',
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId,
fields='nextPageToken,topic(topicId,name)', pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for courseTopic in results:
@@ -44822,7 +44751,6 @@ def doPrintCourseSubmissions():
try:
userProfile = callGAPI(tcroom.userProfiles(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userId=userId, fields='emailAddress,name')
userProfiles[userId] = {'profile': {'emailAddress': userProfile.get('emailAddress', ''), 'name': userProfile['name']}}
except (GAPI.notFound, GAPI.permissionDenied, GAPI.serviceNotAvailable):
@@ -44909,7 +44837,6 @@ def doPrintCourseSubmissions():
results = callGAPIpages(croom.courses().courseWork(), 'list', 'courseWork',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, courseWorkStates=courseWMSelectionParameters['courseWMStates'], orderBy=OBY.orderBy,
fields='nextPageToken,courseWork(id)', pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
courseWorkIdsForCourse = [courseWork['id'] for courseWork in results]
@@ -44934,7 +44861,6 @@ def doPrintCourseSubmissions():
results = callGAPIpages(croom.courses().courseWork().studentSubmissions(), 'list', 'studentSubmissions',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, courseWorkId=courseWorkId, states=courseSubmissionStates, late=late, userId=courseSelectionParameters['studentId'],
fields=fields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
for submission in results:
@@ -44959,7 +44885,6 @@ def doPrintCourseSubmissions():
try:
submission = callGAPI(croom.courses().courseWork().studentSubmissions(), 'get',
throwReasons=GAPI.COURSE_ACCESS_THROW_REASONS+[GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
courseId=courseId, courseWorkId=courseWorkId, id=courseSubmissionId,
fields=fields)
_printCourseSubmission(course, submission)
@@ -45194,7 +45119,6 @@ def _getCoursesOwnerInfo(croom, courseIds, coursesInfo, useAdminAccess):
try:
info = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields='name,ownerId')
if not useAdminAccess:
_, ocroom = buildGAPIServiceObject(API.CLASSROOM, f'uid:{info["ownerId"]}')
@@ -45472,7 +45396,6 @@ def _inviteGuardian(croom, studentId, guardianEmail, i=0, count=0, j=0, jcount=0
throwReasons=[GAPI.NOT_FOUND, GAPI.ALREADY_EXISTS,
GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
GAPI.PERMISSION_DENIED, GAPI.RESOURCE_EXHAUSTED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, body=body, fields='invitationId')
entityActionPerformed([Ent.STUDENT, studentId, Ent.GUARDIAN, body['invitedEmailAddress'], Ent.GUARDIAN_INVITATION, result['invitationId']], j, jcount)
return 1
@@ -45521,7 +45444,6 @@ def _cancelGuardianInvitation(croom, studentId, invitationId, i=0, count=0, j=0,
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION,
GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, invitationId=invitationId, updateMask='state', body={'state': 'COMPLETE'}, fields='invitedEmailAddress')
entityActionPerformed([Ent.STUDENT, studentId, Ent.GUARDIAN_INVITATION, result['invitedEmailAddress']], j, jcount)
return 1
@@ -45568,7 +45490,6 @@ def _deleteGuardian(croom, studentId, guardianId, guardianEmail, i, count, j, jc
try:
callGAPI(croom.userProfiles().guardians(), 'delete',
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, guardianId=guardianId)
entityActionPerformed([Ent.STUDENT, studentId, Ent.GUARDIAN, guardianEmail], j, jcount)
return 1
@@ -45593,7 +45514,6 @@ def _doDeleteGuardian(croom, studentId, guardianId, guardianClass, i=0, count=0,
invitations = callGAPIpages(croom.userProfiles().guardianInvitations(), 'list', 'guardianInvitations',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, invitedEmailAddress=guardianId, states=['PENDING'],
fields='nextPageToken,guardianInvitations(studentId,invitationId)')
for invitation in invitations:
@@ -45612,7 +45532,6 @@ def _doDeleteGuardian(croom, studentId, guardianId, guardianClass, i=0, count=0,
guardians = callGAPIpages(croom.userProfiles().guardians(), 'list', 'guardians',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, invitedEmailAddress=guardianId,
fields='nextPageToken,guardians(studentId,guardianId)')
for guardian in guardians:
@@ -45682,7 +45601,6 @@ def clearGuardians(users):
invitations = callGAPIpages(croom.userProfiles().guardianInvitations(), 'list', 'guardianInvitations',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, states=['PENDING'], fields='nextPageToken,guardianInvitations(invitationId)')
Act.Set(Act.CANCEL)
jcount = len(invitations)
@@ -45728,12 +45646,10 @@ def syncGuardians(users):
invitations = callGAPIpages(croom.userProfiles().guardianInvitations(), 'list', 'guardianInvitations',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, states=['PENDING'], fields='nextPageToken,guardianInvitations(invitationId,invitedEmailAddress)')
guardians = callGAPIpages(croom.userProfiles().guardians(), 'list', 'guardians',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, fields='nextPageToken,guardians(guardianId,invitedEmailAddress)')
except GAPI.notFound:
entityUnknownWarning(Ent.STUDENT, studentId, i, count)
@@ -45778,7 +45694,6 @@ def _getCourseName(croom, courseNames, courseId):
courseName = callGAPI(croom.courses(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
id=courseId, fields='name')['name']
except (GAPI.notFound, GAPI.invalidArgument, GAPI.badRequest, GAPI.forbidden, GAPI.permissionDenied, GAPI.serviceNotAvailable):
pass
@@ -45796,7 +45711,6 @@ def _getClassroomEmail(croom, classroomEmails, userId, user):
userEmail = callGAPI(croom.userProfiles(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userId=userId, fields='emailAddress').get('emailAddress')
except (GAPI.notFound, GAPI.invalidArgument, GAPI.badRequest, GAPI.forbidden, GAPI.permissionDenied, GAPI.serviceNotAvailable):
pass
@@ -45896,7 +45810,6 @@ def _printShowGuardians(entityList=None):
pageMessage=pageMessage,
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, invitedEmailAddress=invitedEmailAddress, states=states)
jcount = len(invitations)
if not csvPF:
@@ -45939,7 +45852,6 @@ def _printShowGuardians(entityList=None):
pageMessage=pageMessage,
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
studentId=studentId, invitedEmailAddress=invitedEmailAddress)
jcount = len(guardians)
if not csvPF:
@@ -46004,7 +45916,6 @@ def _getClassroomInvitations(croom, userId, courseId, role, i, count, j=0, jcoun
invitations = callGAPIpages(croom.invitations(), 'list', 'invitations',
throwReasons=[GAPI.NOT_FOUND, GAPI.INVALID_ARGUMENT, GAPI.BAD_REQUEST,
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userId=userId, courseId=courseId)
except GAPI.notFound:
if userId is not None:
@@ -46373,7 +46284,6 @@ def printShowClassroomProfile(users):
try:
result = callGAPI(croom.userProfiles(), 'get',
throwReasons=[GAPI.NOT_FOUND, GAPI.PERMISSION_DENIED, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
userId=userId, fields='*')
result.setdefault('verifiedTeacher', False)
if not csvPF:
@@ -50390,7 +50300,6 @@ def showFileInfo(users):
try:
result['permissions'] = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=fileId, fields=permissionsFields, supportsAllDrives=True)
for permission in result['permissions']:
permission.pop('teamDrivePermissionDetails', None)
@@ -51703,7 +51612,6 @@ def printFileList(users):
try:
f_file['permissions'] = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=f_file['id'], fields=permissionsFields, supportsAllDrives=True)
if not DLP.CheckFilePermissionMatches(f_file):
return
@@ -52557,7 +52465,6 @@ def printShowFileCounts(users):
try:
f_file['permissions'] = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS+[GAPI.BAD_REQUEST],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=f_file['id'], fields=permissionsFields, supportsAllDrives=True)
if not DLP.CheckFilePermissionMatches(f_file):
continue
@@ -54340,7 +54247,6 @@ def _copyPermissions(drive, user, i, count, j, jcount,
try:
result = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=fid,
fields='nextPageToken,permissions(allowFileDiscovery,domain,emailAddress,expirationTime,id,role,type,deleted,view,pendingOwner,permissionDetails)',
useDomainAdminAccess=copyMoveOptions['useDomainAdminAccess'], supportsAllDrives=True)
@@ -55429,7 +55335,6 @@ def _updateMoveFilePermissions(drive, user, i, count,
try:
result = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=fid,
fields='nextPageToken,permissions(allowFileDiscovery,domain,emailAddress,expirationTime,id,role,type,deleted,view,pendingOwner,permissionDetails)',
useDomainAdminAccess=copyMoveOptions['useDomainAdminAccess'], supportsAllDrives=True)
@@ -56936,7 +56841,6 @@ def transferDrive(users):
try:
permissions = callGAPIpages(ownerDrive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS+[GAPI.BAD_REQUEST],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
fileId=childFileId, fields='nextPageToken,permissions')
if getSourcePermissionFromOwner:
for permission in permissions:
@@ -59244,7 +59148,6 @@ def printShowDriveFileACLs(users, useDomainAdminAccess=False):
try:
permissions = callGAPIpages(drive.permissions(), 'list', 'permissions',
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS+[GAPI.NOT_FOUND],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
useDomainAdminAccess=useDomainAdminAccess,
includePermissionsForView=includePermissionsForView,
fileId=fileId, fields=fields, supportsAllDrives=True)
@@ -60634,7 +60537,6 @@ def printShowSharedDriveACLs(users, useDomainAdminAccess=False):
permissions = callGAPIpages(drive.permissions(), 'list', 'permissions',
pageMessage=getPageMessageForWhom(),
throwReasons=GAPI.DRIVE3_GET_ACL_REASONS,
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
useDomainAdminAccess=useDomainAdminAccess,
fileId=shareddrive['id'], fields=fields, supportsAllDrives=True)
if not permissions:
@@ -61981,7 +61883,6 @@ def _createLicenses(lic, productId, skuId, parameters, jcount, users, i, count,
bailOnInternalError=True,
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET, GAPI.INVALID,
GAPI.USER_NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
productId=productId, skuId=skuId, body={'userId': user}, fields='')
message = Act.SUCCESS
entityActionPerformed([Ent.USER, user, Ent.LICENSE, SKU.formatSKUIdDisplayName(skuId)], j, jcount)
@@ -62041,7 +61942,6 @@ def updateLicense(users):
bailOnInternalError=True,
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.NOT_FOUND, GAPI.CONDITION_NOT_MET, GAPI.INVALID,
GAPI.USER_NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
productId=productId, skuId=oldSkuId, userId=user, body=body, fields='')
message = Act.SUCCESS
entityModifierNewValueActionPerformed([Ent.USER, user, Ent.LICENSE, SKU.skuIdToDisplayName(skuId)],
@@ -62074,7 +61974,6 @@ def _deleteLicenses(lic, productId, skuId, parameters, jcount, users, i, count):
callGAPI(lic.licenseAssignments(), 'delete',
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.NOT_FOUND, GAPI.CONDITION_NOT_MET, GAPI.INVALID,
GAPI.USER_NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR, GAPI.SERVICE_NOT_AVAILABLE],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
productId=productId, skuId=skuId, userId=user)
message = Act.SUCCESS
entityActionPerformed([Ent.USER, user, Ent.LICENSE, SKU.formatSKUIdDisplayName(skuId)], j, jcount)
@@ -62317,7 +62216,6 @@ def getPhoto(users, profileMode):
else:
result = callGAPI(people.people(), 'get',
throwReasons=[GAPI.NOT_FOUND],
retryReasons=[GAPI.SERVICE_NOT_AVAILABLE],
resourceName='people/me', personFields='photos')
default = False
url = None