gam7 7.11.0__py3-none-any.whl → 7.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gam7 might be problematic. Click here for more details.
- gam/__init__.py +465 -275
- gam/gamlib/glclargs.py +1 -0
- gam/gamlib/glgapi.py +6 -2
- {gam7-7.11.0.dist-info → gam7-7.12.0.dist-info}/METADATA +1 -1
- {gam7-7.11.0.dist-info → gam7-7.12.0.dist-info}/RECORD +8 -8
- {gam7-7.11.0.dist-info → gam7-7.12.0.dist-info}/WHEEL +0 -0
- {gam7-7.11.0.dist-info → gam7-7.12.0.dist-info}/entry_points.txt +0 -0
- {gam7-7.11.0.dist-info → gam7-7.12.0.dist-info}/licenses/LICENSE +0 -0
gam/__init__.py
CHANGED
|
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
|
28
|
-
__version__ = '7.
|
|
28
|
+
__version__ = '7.12.00'
|
|
29
29
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
|
30
30
|
|
|
31
31
|
#pylint: disable=wrong-import-position
|
|
@@ -337,6 +337,7 @@ ENTITY_IS_A_GROUP_RC = 22
|
|
|
337
337
|
ENTITY_IS_A_GROUP_ALIAS_RC = 23
|
|
338
338
|
ENTITY_IS_AN_UNMANAGED_ACCOUNT_RC = 24
|
|
339
339
|
ORGUNIT_NOT_EMPTY_RC = 25
|
|
340
|
+
USER_SUSPENDED_RC = 26
|
|
340
341
|
CHECK_USER_GROUPS_ERROR_RC = 29
|
|
341
342
|
ORPHANS_COLLECTED_RC = 30
|
|
342
343
|
# Warnings/Errors
|
|
@@ -634,7 +635,8 @@ def accessErrorMessage(cd, errMsg=None):
|
|
|
634
635
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
635
636
|
try:
|
|
636
637
|
callGAPI(cd.customers(), 'get',
|
|
637
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
638
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
639
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
638
640
|
customerKey=GC.Values[GC.CUSTOMER_ID], fields='id')
|
|
639
641
|
except (GAPI.badRequest, GAPI.invalidInput):
|
|
640
642
|
return formatKeyValueList('',
|
|
@@ -671,14 +673,16 @@ def accessErrorExitNonDirectory(api, errMsg):
|
|
|
671
673
|
''))
|
|
672
674
|
|
|
673
675
|
def ClientAPIAccessDeniedExit(errMsg=None):
|
|
674
|
-
|
|
675
|
-
|
|
676
|
+
if errMsg is None:
|
|
677
|
+
stderrErrorMsg(Msg.API_ACCESS_DENIED)
|
|
678
|
+
missingScopes = API.getClientScopesSet(GM.Globals[GM.CURRENT_CLIENT_API])-GM.Globals[GM.CURRENT_CLIENT_API_SCOPES]
|
|
679
|
+
if missingScopes:
|
|
680
|
+
writeStderr(Msg.API_CHECK_CLIENT_AUTHORIZATION.format(GM.Globals[GM.OAUTH2_CLIENT_ID],
|
|
681
|
+
','.join(sorted(missingScopes))))
|
|
682
|
+
systemErrorExit(API_ACCESS_DENIED_RC, None)
|
|
683
|
+
else:
|
|
676
684
|
stderrErrorMsg(errMsg)
|
|
677
|
-
|
|
678
|
-
if missingScopes:
|
|
679
|
-
writeStderr(Msg.API_CHECK_CLIENT_AUTHORIZATION.format(GM.Globals[GM.OAUTH2_CLIENT_ID],
|
|
680
|
-
','.join(sorted(missingScopes))))
|
|
681
|
-
systemErrorExit(API_ACCESS_DENIED_RC, None)
|
|
685
|
+
systemErrorExit(API_ACCESS_DENIED_RC, Msg.REAUTHENTICATION_IS_NEEDED)
|
|
682
686
|
|
|
683
687
|
def SvcAcctAPIAccessDenied():
|
|
684
688
|
_getSvcAcctData()
|
|
@@ -4458,6 +4462,8 @@ def handleOAuthTokenError(e, softErrors, displayError=False, i=0, count=0):
|
|
|
4458
4462
|
errMsg.startswith('invalid_request: Invalid impersonation "sub" field')):
|
|
4459
4463
|
if not GM.Globals[GM.CURRENT_SVCACCT_USER]:
|
|
4460
4464
|
ClientAPIAccessDeniedExit()
|
|
4465
|
+
# 403 Forbidden, API disabled, user not enabled
|
|
4466
|
+
# 400 Bad Request, user not defined
|
|
4461
4467
|
if softErrors:
|
|
4462
4468
|
entityActionFailedWarning([Ent.USER, GM.Globals[GM.CURRENT_SVCACCT_USER], Ent.USER, None], errMsg, i, count)
|
|
4463
4469
|
return None
|
|
@@ -4465,6 +4471,7 @@ def handleOAuthTokenError(e, softErrors, displayError=False, i=0, count=0):
|
|
|
4465
4471
|
if errMsg in API.OAUTH2_UNAUTHORIZED_ERRORS:
|
|
4466
4472
|
if not GM.Globals[GM.CURRENT_SVCACCT_USER]:
|
|
4467
4473
|
ClientAPIAccessDeniedExit()
|
|
4474
|
+
# 401 Unauthorized, API disabled, user enabled
|
|
4468
4475
|
if softErrors:
|
|
4469
4476
|
if displayError:
|
|
4470
4477
|
apiOrScopes = API.getAPIName(GM.Globals[GM.CURRENT_SVCACCT_API]) if GM.Globals[GM.CURRENT_SVCACCT_API] else ','.join(sorted(GM.Globals[GM.CURRENT_SVCACCT_API_SCOPES]))
|
|
@@ -6515,7 +6522,8 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
|
|
|
6515
6522
|
printGettingAllEntityItemsForWhom(Ent.TEACHER, removeCourseIdScope(courseId), entityType=Ent.COURSE)
|
|
6516
6523
|
result = callGAPIpages(courseInfo['croom'].courses().teachers(), 'list', 'teachers',
|
|
6517
6524
|
pageMessage=getPageMessageForWhom(),
|
|
6518
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
6525
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.SERVICE_NOT_AVAILABLE,
|
|
6526
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
6519
6527
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
6520
6528
|
courseId=courseId, fields='nextPageToken,teachers/profile/emailAddress',
|
|
6521
6529
|
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
|
|
@@ -6528,7 +6536,8 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
|
|
|
6528
6536
|
printGettingAllEntityItemsForWhom(Ent.STUDENT, removeCourseIdScope(courseId), entityType=Ent.COURSE)
|
|
6529
6537
|
result = callGAPIpages(courseInfo['croom'].courses().students(), 'list', 'students',
|
|
6530
6538
|
pageMessage=getPageMessageForWhom(),
|
|
6531
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
6539
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.SERVICE_NOT_AVAILABLE,
|
|
6540
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
6532
6541
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
6533
6542
|
courseId=courseId, fields='nextPageToken,students/profile/emailAddress',
|
|
6534
6543
|
pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
|
|
@@ -6544,8 +6553,8 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
|
|
|
6544
6553
|
entityActionNotPerformedWarning([Ent.COURSE, removeCourseIdScope(courseId)], str(e))
|
|
6545
6554
|
GM.Globals[GM.CLASSROOM_SERVICE_NOT_AVAILABLE] = True
|
|
6546
6555
|
break
|
|
6547
|
-
except (GAPI.forbidden, GAPI.badRequest):
|
|
6548
|
-
ClientAPIAccessDeniedExit()
|
|
6556
|
+
except (GAPI.forbidden, GAPI.permissionDenied, GAPI.badRequest) as e:
|
|
6557
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
6549
6558
|
elif entityType == Cmd.ENTITY_CROS:
|
|
6550
6559
|
buildGAPIObject(API.DIRECTORY)
|
|
6551
6560
|
result = convertEntityToList(entity)
|
|
@@ -9023,7 +9032,7 @@ class CSVPrintFile():
|
|
|
9023
9032
|
normalizeSortHeaders()
|
|
9024
9033
|
if self.outputTranspose:
|
|
9025
9034
|
newRows = []
|
|
9026
|
-
newTitlesList =
|
|
9035
|
+
newTitlesList = list(range(len(self.rows) + 1))
|
|
9027
9036
|
for title in titlesList:
|
|
9028
9037
|
i = 0
|
|
9029
9038
|
newRow = {i: title}
|
|
@@ -15065,7 +15074,7 @@ def getRecipients():
|
|
|
15065
15074
|
# (embedimage <FileName> <String>)*
|
|
15066
15075
|
# [newuser <EmailAddress> firstname|givenname <String> lastname|familyname <string> password <Password>]
|
|
15067
15076
|
# (<SMTPDateHeader> <Time>)* (<SMTPHeader> <String>)* (header <String> <String>)*
|
|
15068
|
-
# gam <UserTypeEntity> sendemail recipient <RecipientEntity> [replyto <EmailAddress>]
|
|
15077
|
+
# gam <UserTypeEntity> sendemail recipient|to <RecipientEntity> [replyto <EmailAddress>]
|
|
15069
15078
|
# [cc <RecipientEntity>] [bcc <RecipientEntity>] [singlemessage]
|
|
15070
15079
|
# [subject <String>]
|
|
15071
15080
|
# [<MessageContent>]
|
|
@@ -15098,11 +15107,12 @@ def doSendEmail(users=None):
|
|
|
15098
15107
|
if checkArgumentPresent({'recipient', 'recipients', 'to'}):
|
|
15099
15108
|
msgFroms = [normalizeEmailAddressOrUID(entity) for entity in entityList]
|
|
15100
15109
|
recipients = getRecipients()
|
|
15101
|
-
|
|
15102
|
-
if checkArgumentPresent({'from'}):
|
|
15103
|
-
msgFroms = [getString(Cmd.OB_EMAIL_ADDRESS)]
|
|
15104
|
-
count = 1
|
|
15110
|
+
elif checkArgumentPresent({'from'}):
|
|
15105
15111
|
recipients = [normalizeEmailAddressOrUID(entity) for entity in entityList]
|
|
15112
|
+
msgFroms = [getString(Cmd.OB_EMAIL_ADDRESS)]
|
|
15113
|
+
count = 1
|
|
15114
|
+
else:
|
|
15115
|
+
missingArgumentExit('recipient|to|from')
|
|
15106
15116
|
msgHeaders = {}
|
|
15107
15117
|
ccRecipients = []
|
|
15108
15118
|
bccRecipients = []
|
|
@@ -16010,8 +16020,9 @@ def doCreateDomainAlias():
|
|
|
16010
16020
|
checkForExtraneousArguments()
|
|
16011
16021
|
try:
|
|
16012
16022
|
callGAPI(cd.domainAliases(), 'insert',
|
|
16013
|
-
throwReasons=[GAPI.DOMAIN_NOT_FOUND, GAPI.DUPLICATE, GAPI.INVALID, GAPI.
|
|
16014
|
-
GAPI.
|
|
16023
|
+
throwReasons=[GAPI.DOMAIN_NOT_FOUND, GAPI.DUPLICATE, GAPI.INVALID, GAPI.CONFLICT,
|
|
16024
|
+
GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16025
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16015
16026
|
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='')
|
|
16016
16027
|
entityActionPerformed([Ent.DOMAIN, body['parentDomainName'], Ent.DOMAIN_ALIAS, body['domainAliasName']])
|
|
16017
16028
|
except GAPI.domainNotFound:
|
|
@@ -16020,8 +16031,10 @@ def doCreateDomainAlias():
|
|
|
16020
16031
|
entityActionFailedWarning([Ent.DOMAIN, body['parentDomainName'], Ent.DOMAIN_ALIAS, body['domainAliasName']], Msg.DUPLICATE)
|
|
16021
16032
|
except (GAPI.invalid, GAPI.conflict) as e:
|
|
16022
16033
|
entityActionFailedWarning([Ent.DOMAIN, body['parentDomainName'], Ent.DOMAIN_ALIAS, body['domainAliasName']], str(e))
|
|
16023
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16034
|
+
except (GAPI.badRequest, GAPI.notFound) as e:
|
|
16024
16035
|
accessErrorExit(cd, str(e))
|
|
16036
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16037
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16025
16038
|
|
|
16026
16039
|
# gam delete domainalias|aliasdomain <DomainAlias>
|
|
16027
16040
|
def doDeleteDomainAlias():
|
|
@@ -16030,13 +16043,16 @@ def doDeleteDomainAlias():
|
|
|
16030
16043
|
checkForExtraneousArguments()
|
|
16031
16044
|
try:
|
|
16032
16045
|
callGAPI(cd.domainAliases(), 'delete',
|
|
16033
|
-
throwReasons=[GAPI.DOMAIN_ALIAS_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16046
|
+
throwReasons=[GAPI.DOMAIN_ALIAS_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16047
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16034
16048
|
customer=GC.Values[GC.CUSTOMER_ID], domainAliasName=domainAliasName)
|
|
16035
16049
|
entityActionPerformed([Ent.DOMAIN_ALIAS, domainAliasName])
|
|
16036
16050
|
except GAPI.domainAliasNotFound:
|
|
16037
16051
|
entityActionFailedWarning([Ent.DOMAIN_ALIAS, domainAliasName], Msg.DOES_NOT_EXIST)
|
|
16038
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16052
|
+
except (GAPI.badRequest, GAPI.notFound) as e:
|
|
16039
16053
|
accessErrorExit(cd, str(e))
|
|
16054
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16055
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16040
16056
|
|
|
16041
16057
|
DOMAIN_TIME_OBJECTS = {'creationTime'}
|
|
16042
16058
|
DOMAIN_ALIAS_PRINT_ORDER = ['parentDomainName', 'creationTime', 'verified']
|
|
@@ -16064,14 +16080,17 @@ def doInfoDomainAlias():
|
|
|
16064
16080
|
FJQC = FormatJSONQuoteChar(formatJSONOnly=True)
|
|
16065
16081
|
try:
|
|
16066
16082
|
result = callGAPI(cd.domainAliases(), 'get',
|
|
16067
|
-
throwReasons=[GAPI.DOMAIN_ALIAS_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16083
|
+
throwReasons=[GAPI.DOMAIN_ALIAS_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16084
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16068
16085
|
customer=GC.Values[GC.CUSTOMER_ID], domainAliasName=domainAliasName)
|
|
16069
16086
|
aliasSkipObjects = DOMAIN_ALIAS_SKIP_OBJECTS
|
|
16070
16087
|
_showDomainAlias(result, FJQC, aliasSkipObjects)
|
|
16071
16088
|
except GAPI.domainAliasNotFound:
|
|
16072
16089
|
entityActionFailedWarning([Ent.DOMAIN_ALIAS, domainAliasName], Msg.DOES_NOT_EXIST)
|
|
16073
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16090
|
+
except (GAPI.badRequest, GAPI.notFound) as e:
|
|
16074
16091
|
accessErrorExit(cd, str(e))
|
|
16092
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16093
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16075
16094
|
|
|
16076
16095
|
def _printDomain(domain, csvPF):
|
|
16077
16096
|
row = {}
|
|
@@ -16107,7 +16126,8 @@ def doPrintShowDomainAliases():
|
|
|
16107
16126
|
FJQC.GetFormatJSONQuoteChar(myarg, True)
|
|
16108
16127
|
try:
|
|
16109
16128
|
domainAliases = callGAPIitems(cd.domainAliases(), 'list', 'domainAliases',
|
|
16110
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16129
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16130
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16111
16131
|
customer=GC.Values[GC.CUSTOMER_ID])
|
|
16112
16132
|
count = len(domainAliases)
|
|
16113
16133
|
if showItemCountOnly:
|
|
@@ -16125,8 +16145,10 @@ def doPrintShowDomainAliases():
|
|
|
16125
16145
|
csvPF.WriteRowNoFilter({'domainAliasName': domainAlias['domainAliasName'],
|
|
16126
16146
|
'JSON': json.dumps(cleanJSON(domainAlias, timeObjects=DOMAIN_TIME_OBJECTS),
|
|
16127
16147
|
ensure_ascii=False, sort_keys=True)})
|
|
16128
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16148
|
+
except (GAPI.badRequest, GAPI.notFound) as e:
|
|
16129
16149
|
accessErrorExit(cd, str(e))
|
|
16150
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16151
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16130
16152
|
if csvPF:
|
|
16131
16153
|
csvPF.writeCSVfile('Domain Aliases')
|
|
16132
16154
|
|
|
@@ -16137,15 +16159,19 @@ def doCreateDomain():
|
|
|
16137
16159
|
checkForExtraneousArguments()
|
|
16138
16160
|
try:
|
|
16139
16161
|
callGAPI(cd.domains(), 'insert',
|
|
16140
|
-
throwReasons=[GAPI.DUPLICATE, GAPI.
|
|
16162
|
+
throwReasons=[GAPI.DUPLICATE, GAPI.CONFLICT,
|
|
16163
|
+
GAPI.DOMAIN_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16164
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16141
16165
|
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='')
|
|
16142
16166
|
entityActionPerformed([Ent.DOMAIN, body['domainName']])
|
|
16143
16167
|
except GAPI.duplicate:
|
|
16144
16168
|
entityDuplicateWarning([Ent.DOMAIN, body['domainName']])
|
|
16145
16169
|
except GAPI.conflict as e:
|
|
16146
16170
|
entityActionFailedWarning([Ent.DOMAIN, body['domainName']], str(e))
|
|
16147
|
-
except (GAPI.domainNotFound, GAPI.badRequest, GAPI.notFound
|
|
16171
|
+
except (GAPI.domainNotFound, GAPI.badRequest, GAPI.notFound) as e:
|
|
16148
16172
|
accessErrorExit(cd, str(e))
|
|
16173
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16174
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16149
16175
|
|
|
16150
16176
|
# gam update domain <DomainName> primary
|
|
16151
16177
|
def doUpdateDomain():
|
|
@@ -16162,13 +16188,17 @@ def doUpdateDomain():
|
|
|
16162
16188
|
missingArgumentExit('primary')
|
|
16163
16189
|
try:
|
|
16164
16190
|
callGAPI(cd.customers(), 'update',
|
|
16165
|
-
throwReasons=[GAPI.DOMAIN_NOT_VERIFIED_SECONDARY, GAPI.BAD_REQUEST,
|
|
16191
|
+
throwReasons=[GAPI.DOMAIN_NOT_VERIFIED_SECONDARY, GAPI.BAD_REQUEST,
|
|
16192
|
+
GAPI.RESOURCE_NOT_FOUND, GAPI.INVALID_INPUT,
|
|
16193
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16166
16194
|
customerKey=GC.Values[GC.CUSTOMER_ID], body=body, fields='')
|
|
16167
16195
|
entityActionPerformedMessage([Ent.DOMAIN, domainName], Msg.NOW_THE_PRIMARY_DOMAIN)
|
|
16168
16196
|
except GAPI.domainNotVerifiedSecondary:
|
|
16169
16197
|
entityActionFailedWarning([Ent.DOMAIN, domainName], Msg.DOMAIN_NOT_VERIFIED_SECONDARY)
|
|
16170
|
-
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.
|
|
16198
|
+
except (GAPI.badRequest, GAPI.resourceNotFound, GAPI.invalidInput) as e:
|
|
16171
16199
|
accessErrorExit(cd, str(e))
|
|
16200
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16201
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16172
16202
|
|
|
16173
16203
|
# gam delete domain <DomainName>
|
|
16174
16204
|
def doDeleteDomain():
|
|
@@ -16177,11 +16207,14 @@ def doDeleteDomain():
|
|
|
16177
16207
|
checkForExtraneousArguments()
|
|
16178
16208
|
try:
|
|
16179
16209
|
callGAPI(cd.domains(), 'delete',
|
|
16180
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16210
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16211
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16181
16212
|
customer=GC.Values[GC.CUSTOMER_ID], domainName=domainName)
|
|
16182
16213
|
entityActionPerformed([Ent.DOMAIN, domainName])
|
|
16183
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16214
|
+
except (GAPI.badRequest, GAPI.notFound) as e:
|
|
16184
16215
|
accessErrorExit(cd, str(e))
|
|
16216
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16217
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16185
16218
|
|
|
16186
16219
|
CUSTOMER_LICENSE_MAP = {
|
|
16187
16220
|
'accounts:num_users': 'Total Users',
|
|
@@ -16210,7 +16243,7 @@ def _showCustomerLicenseInfo(customerInfo, FJQC):
|
|
|
16210
16243
|
while True:
|
|
16211
16244
|
try:
|
|
16212
16245
|
result = callGAPI(rep.customerUsageReports(), 'get',
|
|
16213
|
-
throwReasons=[GAPI.INVALID, GAPI.FORBIDDEN],
|
|
16246
|
+
throwReasons=[GAPI.INVALID, GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16214
16247
|
date=tryDate, customerId=customerInfo['id'],
|
|
16215
16248
|
fields='warnings,usageReports', parameters=parameters)
|
|
16216
16249
|
usageReports = numUsersAvailable(result)
|
|
@@ -16228,8 +16261,8 @@ def _showCustomerLicenseInfo(customerInfo, FJQC):
|
|
|
16228
16261
|
if not tryDate:
|
|
16229
16262
|
return
|
|
16230
16263
|
continue
|
|
16231
|
-
except GAPI.forbidden:
|
|
16232
|
-
|
|
16264
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16265
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16233
16266
|
if not FJQC.formatJSON:
|
|
16234
16267
|
printKeyValueList([f'User counts as of {tryDate}:'])
|
|
16235
16268
|
Ind.Increment()
|
|
@@ -16250,12 +16283,15 @@ def setTrueCustomerId(cd=None):
|
|
|
16250
16283
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
16251
16284
|
try:
|
|
16252
16285
|
customerInfo = callGAPI(cd.customers(), 'get',
|
|
16253
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
16286
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
16287
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16254
16288
|
customerKey=GC.MY_CUSTOMER,
|
|
16255
16289
|
fields='id')
|
|
16256
16290
|
GC.Values[GC.CUSTOMER_ID] = customerInfo['id']
|
|
16257
|
-
except (GAPI.badRequest, GAPI.invalidInput, GAPI.resourceNotFound
|
|
16291
|
+
except (GAPI.badRequest, GAPI.invalidInput, GAPI.resourceNotFound):
|
|
16258
16292
|
pass
|
|
16293
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16294
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16259
16295
|
|
|
16260
16296
|
def _getCustomerId():
|
|
16261
16297
|
customerId = GC.Values[GC.CUSTOMER_ID]
|
|
@@ -16289,7 +16325,8 @@ def doInfoCustomer(returnCustomerInfo=None, FJQC=None):
|
|
|
16289
16325
|
FJQC = FormatJSONQuoteChar(formatJSONOnly=True)
|
|
16290
16326
|
try:
|
|
16291
16327
|
customerInfo = callGAPI(cd.customers(), 'get',
|
|
16292
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
16328
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_INPUT, GAPI.RESOURCE_NOT_FOUND,
|
|
16329
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16293
16330
|
customerKey=customerId)
|
|
16294
16331
|
if 'customerCreationTime' in customerInfo:
|
|
16295
16332
|
customerInfo['customerCreationTime'] = formatLocalTime(customerInfo['customerCreationTime'])
|
|
@@ -16298,7 +16335,8 @@ def doInfoCustomer(returnCustomerInfo=None, FJQC=None):
|
|
|
16298
16335
|
primaryDomain = {'domainName': UNKNOWN, 'verified': UNKNOWN}
|
|
16299
16336
|
try:
|
|
16300
16337
|
domains = callGAPIitems(cd.domains(), 'list', 'domains',
|
|
16301
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16338
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16339
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16302
16340
|
customer=customerInfo['id'], fields='domains(creationTime,domainName,isPrimary,verified)')
|
|
16303
16341
|
for domain in domains:
|
|
16304
16342
|
if domain.get('isPrimary'):
|
|
@@ -16334,8 +16372,8 @@ def doInfoCustomer(returnCustomerInfo=None, FJQC=None):
|
|
|
16334
16372
|
_showCustomerLicenseInfo(customerInfo, FJQC)
|
|
16335
16373
|
except (GAPI.badRequest, GAPI.invalidInput, GAPI.domainNotFound, GAPI.notFound, GAPI.resourceNotFound):
|
|
16336
16374
|
accessErrorExit(cd)
|
|
16337
|
-
except GAPI.forbidden as e:
|
|
16338
|
-
|
|
16375
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16376
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16339
16377
|
|
|
16340
16378
|
# gam update customer [primary <DomainName>] [adminsecondaryemail|alternateemail <EmailAddress>] [language <LanguageCode] [phone|phonenumber <String>]
|
|
16341
16379
|
# [contact|contactname <String>] [name|organizationname <String>]
|
|
@@ -16363,15 +16401,18 @@ def doUpdateCustomer():
|
|
|
16363
16401
|
if body:
|
|
16364
16402
|
try:
|
|
16365
16403
|
callGAPI(cd.customers(), 'patch',
|
|
16366
|
-
throwReasons=[GAPI.DOMAIN_NOT_VERIFIED_SECONDARY, GAPI.INVALID, GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
16404
|
+
throwReasons=[GAPI.DOMAIN_NOT_VERIFIED_SECONDARY, GAPI.INVALID, GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
16405
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16367
16406
|
customerKey=customerId, body=body, fields='')
|
|
16368
16407
|
entityActionPerformed([Ent.CUSTOMER_ID, GC.Values[GC.CUSTOMER_ID]])
|
|
16369
16408
|
except GAPI.domainNotVerifiedSecondary:
|
|
16370
16409
|
entityActionFailedWarning([Ent.CUSTOMER_ID, GC.Values[GC.CUSTOMER_ID], Ent.DOMAIN, body['customerDomain']], Msg.DOMAIN_NOT_VERIFIED_SECONDARY)
|
|
16371
16410
|
except (GAPI.invalid, GAPI.invalidInput) as e:
|
|
16372
16411
|
entityActionFailedWarning([Ent.CUSTOMER_ID, GC.Values[GC.CUSTOMER_ID]], str(e))
|
|
16373
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
16412
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
16374
16413
|
accessErrorExit(cd)
|
|
16414
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16415
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16375
16416
|
|
|
16376
16417
|
# gam info instance [formatjson]
|
|
16377
16418
|
def doInfoInstance():
|
|
@@ -16418,13 +16459,16 @@ def doInfoDomain():
|
|
|
16418
16459
|
FJQC = FormatJSONQuoteChar(formatJSONOnly=True)
|
|
16419
16460
|
try:
|
|
16420
16461
|
result = callGAPI(cd.domains(), 'get',
|
|
16421
|
-
throwReasons=[GAPI.DOMAIN_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16462
|
+
throwReasons=[GAPI.DOMAIN_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.NOT_FOUND,
|
|
16463
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16422
16464
|
customer=GC.Values[GC.CUSTOMER_ID], domainName=domainName)
|
|
16423
16465
|
_showDomain(result, FJQC)
|
|
16424
16466
|
except GAPI.domainNotFound:
|
|
16425
16467
|
entityActionFailedWarning([Ent.DOMAIN, domainName], Msg.DOES_NOT_EXIST)
|
|
16426
|
-
except (GAPI.badRequest, GAPI.notFound
|
|
16468
|
+
except (GAPI.badRequest, GAPI.notFound):
|
|
16427
16469
|
accessErrorExit(cd)
|
|
16470
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16471
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16428
16472
|
|
|
16429
16473
|
DOMAIN_SORT_TITLES = ['domainName', 'parentDomainName', 'creationTime', 'type', 'verified']
|
|
16430
16474
|
|
|
@@ -16472,8 +16516,10 @@ def doPrintShowDomains():
|
|
|
16472
16516
|
csvPF.WriteRowNoFilter({'domainName': domain['domainName'],
|
|
16473
16517
|
'JSON': json.dumps(cleanJSON(domain, timeObjects=DOMAIN_TIME_OBJECTS),
|
|
16474
16518
|
ensure_ascii=False, sort_keys=True)})
|
|
16475
|
-
except (GAPI.badRequest, GAPI.notFound, GAPI.
|
|
16519
|
+
except (GAPI.badRequest, GAPI.notFound, GAPI.domainNotFound) as e:
|
|
16476
16520
|
accessErrorExit(cd, str(e))
|
|
16521
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16522
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16477
16523
|
if csvPF:
|
|
16478
16524
|
csvPF.writeCSVfile('Domains')
|
|
16479
16525
|
|
|
@@ -16483,10 +16529,13 @@ def _listPrivileges(cd):
|
|
|
16483
16529
|
fields = f'items({",".join(PRINT_PRIVILEGES_FIELDS)})'
|
|
16484
16530
|
try:
|
|
16485
16531
|
return callGAPIitems(cd.privileges(), 'list', 'items',
|
|
16486
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16532
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16533
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16487
16534
|
customer=GC.Values[GC.CUSTOMER_ID], fields=fields)
|
|
16488
|
-
except (GAPI.badRequest, GAPI.customerNotFound
|
|
16535
|
+
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16489
16536
|
accessErrorExit(cd)
|
|
16537
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16538
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16490
16539
|
|
|
16491
16540
|
# gam print privileges [todrive <ToDriveAttribute>*]
|
|
16492
16541
|
# gam show privileges
|
|
@@ -16532,12 +16581,15 @@ def makeRoleIdNameMap():
|
|
|
16532
16581
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
16533
16582
|
try:
|
|
16534
16583
|
result = callGAPIpages(cd.roles(), 'list', 'items',
|
|
16535
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16584
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16585
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16536
16586
|
customer=GC.Values[GC.CUSTOMER_ID],
|
|
16537
16587
|
fields='nextPageToken,items(roleId,roleName)',
|
|
16538
16588
|
maxResults=100)
|
|
16539
|
-
except (GAPI.badRequest, GAPI.customerNotFound
|
|
16589
|
+
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16540
16590
|
accessErrorExit(cd)
|
|
16591
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16592
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16541
16593
|
for role in result:
|
|
16542
16594
|
GM.Globals[GM.MAP_ROLE_ID_TO_NAME][role['roleId']] = role['roleName']
|
|
16543
16595
|
GM.Globals[GM.MAP_ROLE_NAME_TO_ID][role['roleName'].lower()] = role['roleId']
|
|
@@ -16627,19 +16679,23 @@ def doCreateUpdateAdminRoles():
|
|
|
16627
16679
|
try:
|
|
16628
16680
|
if not updateCmd:
|
|
16629
16681
|
result = callGAPI(cd.roles(), 'insert',
|
|
16630
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16682
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16683
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED]+[GAPI.DUPLICATE],
|
|
16631
16684
|
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='roleId,roleName')
|
|
16632
16685
|
else:
|
|
16633
16686
|
result = callGAPI(cd.roles(), 'patch',
|
|
16634
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16687
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16688
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED]+[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION, GAPI.CONFLICT],
|
|
16635
16689
|
customer=GC.Values[GC.CUSTOMER_ID], roleId=roleId, body=body, fields='roleId,roleName')
|
|
16636
16690
|
entityActionPerformed([Ent.ADMIN_ROLE, f"{result['roleName']}({result['roleId']})"])
|
|
16637
16691
|
except GAPI.duplicate as e:
|
|
16638
16692
|
entityActionFailedWarning([Ent.ADMIN_ROLE, f"{body['roleName']}"], str(e))
|
|
16639
|
-
except (GAPI.notFound, GAPI.
|
|
16693
|
+
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.conflict) as e:
|
|
16640
16694
|
entityActionFailedWarning([Ent.ADMIN_ROLE, roleId], str(e))
|
|
16641
16695
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16642
16696
|
accessErrorExit(cd)
|
|
16697
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16698
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16643
16699
|
|
|
16644
16700
|
# gam delete adminrole <RoleItem>
|
|
16645
16701
|
def doDeleteAdminRole():
|
|
@@ -16648,13 +16704,16 @@ def doDeleteAdminRole():
|
|
|
16648
16704
|
checkForExtraneousArguments()
|
|
16649
16705
|
try:
|
|
16650
16706
|
callGAPI(cd.roles(), 'delete',
|
|
16651
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16707
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16708
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED]+[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION],
|
|
16652
16709
|
customer=GC.Values[GC.CUSTOMER_ID], roleId=roleId)
|
|
16653
16710
|
entityActionPerformed([Ent.ADMIN_ROLE, f"{role}({roleId})"])
|
|
16654
|
-
except (GAPI.notFound, GAPI.
|
|
16711
|
+
except (GAPI.notFound, GAPI.failedPrecondition) as e:
|
|
16655
16712
|
entityActionFailedWarning([Ent.ADMIN_ROLE, roleId], str(e))
|
|
16656
16713
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16657
16714
|
accessErrorExit(cd)
|
|
16715
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16716
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16658
16717
|
|
|
16659
16718
|
PRINT_ADMIN_ROLES_FIELDS = ['roleId', 'roleName', 'roleDescription', 'isSuperAdminRole', 'isSystemRole']
|
|
16660
16719
|
|
|
@@ -16715,18 +16774,22 @@ def doInfoPrintShowAdminRoles():
|
|
|
16715
16774
|
printGettingAllAccountEntities(Ent.ADMIN_ROLE)
|
|
16716
16775
|
roles = callGAPIpages(cd.roles(), 'list', 'items',
|
|
16717
16776
|
pageMessage=getPageMessage(),
|
|
16718
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16777
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16778
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16719
16779
|
customer=GC.Values[GC.CUSTOMER_ID], fields=fields)
|
|
16720
16780
|
else:
|
|
16721
16781
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
16722
16782
|
roles = [callGAPI(cd.roles(), 'get',
|
|
16723
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
16724
|
-
GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND
|
|
16783
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION,
|
|
16784
|
+
GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16785
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16725
16786
|
customer=GC.Values[GC.CUSTOMER_ID], roleId=roleId, fields=fields)]
|
|
16726
|
-
except (GAPI.notFound, GAPI.
|
|
16787
|
+
except (GAPI.notFound, GAPI.failedPrecondition) as e:
|
|
16727
16788
|
entityActionFailedWarning([Ent.ADMIN_ROLE, roleId], str(e))
|
|
16728
16789
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16729
16790
|
accessErrorExit(cd)
|
|
16791
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16792
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16730
16793
|
for role in roles:
|
|
16731
16794
|
role.setdefault('isSuperAdminRole', False)
|
|
16732
16795
|
role.setdefault('isSystemRole', False)
|
|
@@ -16785,8 +16848,9 @@ def doCreateAdmin():
|
|
|
16785
16848
|
try:
|
|
16786
16849
|
result = callGAPI(cd.roleAssignments(), 'insert',
|
|
16787
16850
|
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16788
|
-
GAPI.
|
|
16789
|
-
GAPI.INVALID_ORGUNIT, GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET
|
|
16851
|
+
GAPI.CUSTOMER_EXCEEDED_ROLE_ASSIGNMENTS_LIMIT, GAPI.SERVICE_NOT_AVAILABLE,
|
|
16852
|
+
GAPI.INVALID_ORGUNIT, GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET,
|
|
16853
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16790
16854
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
16791
16855
|
customer=GC.Values[GC.CUSTOMER_ID], body=body, fields='roleAssignmentId,assigneeType')
|
|
16792
16856
|
assigneeType = result.get('assigneeType')
|
|
@@ -16800,14 +16864,16 @@ def doCreateAdmin():
|
|
|
16800
16864
|
f'{Ent.Singular(entityType)} {user}, {Ent.Singular(Ent.ADMIN_ROLE)} {role}, {Ent.Singular(Ent.SCOPE)} {scope}')
|
|
16801
16865
|
except GAPI.internalError:
|
|
16802
16866
|
pass
|
|
16803
|
-
except (GAPI.
|
|
16804
|
-
accessErrorExit(cd)
|
|
16805
|
-
except (GAPI.forbidden, GAPI.customerExceededRoleAssignmentsLimit, GAPI.serviceNotAvailable, GAPI.conditionNotMet) as e:
|
|
16867
|
+
except (GAPI.customerExceededRoleAssignmentsLimit, GAPI.serviceNotAvailable, GAPI.conditionNotMet) as e:
|
|
16806
16868
|
entityActionFailedWarning([Ent.ADMINISTRATOR, user, Ent.ADMIN_ROLE, role], str(e))
|
|
16807
16869
|
except GAPI.invalidOrgunit:
|
|
16808
16870
|
entityActionFailedWarning([Ent.ADMINISTRATOR, user], Msg.INVALID_ORGUNIT)
|
|
16809
16871
|
except GAPI.duplicate:
|
|
16810
16872
|
entityActionFailedWarning([Ent.ADMINISTRATOR, user, Ent.ADMIN_ROLE, role], Msg.DUPLICATE)
|
|
16873
|
+
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16874
|
+
accessErrorExit(cd)
|
|
16875
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16876
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16811
16877
|
|
|
16812
16878
|
# gam delete admin <RoleAssignmentId>
|
|
16813
16879
|
def doDeleteAdmin():
|
|
@@ -16816,17 +16882,20 @@ def doDeleteAdmin():
|
|
|
16816
16882
|
checkForExtraneousArguments()
|
|
16817
16883
|
try:
|
|
16818
16884
|
callGAPI(cd.roleAssignments(), 'delete',
|
|
16819
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.OPERATION_NOT_SUPPORTED,
|
|
16885
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.OPERATION_NOT_SUPPORTED,
|
|
16820
16886
|
GAPI.INVALID_INPUT, GAPI.SERVICE_NOT_AVAILABLE, GAPI.RESOURCE_NOT_FOUND,
|
|
16821
|
-
GAPI.FAILED_PRECONDITION, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND
|
|
16887
|
+
GAPI.FAILED_PRECONDITION, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16888
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16822
16889
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
16823
16890
|
customer=GC.Values[GC.CUSTOMER_ID], roleAssignmentId=roleAssignmentId)
|
|
16824
16891
|
entityActionPerformed([Ent.ADMIN_ROLE_ASSIGNMENT, roleAssignmentId])
|
|
16825
|
-
except (GAPI.notFound, GAPI.operationNotSupported, GAPI.
|
|
16826
|
-
GAPI.
|
|
16892
|
+
except (GAPI.notFound, GAPI.operationNotSupported, GAPI.invalidInput,
|
|
16893
|
+
GAPI.serviceNotAvailable, GAPI.resourceNotFound, GAPI.failedPrecondition) as e:
|
|
16827
16894
|
entityActionFailedWarning([Ent.ADMIN_ROLE_ASSIGNMENT, roleAssignmentId], str(e))
|
|
16828
16895
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16829
16896
|
accessErrorExit(cd)
|
|
16897
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16898
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16830
16899
|
|
|
16831
16900
|
ASSIGNEE_EMAILTYPE_TOFIELD_MAP = {
|
|
16832
16901
|
'user': 'assignedToUser',
|
|
@@ -16850,17 +16919,20 @@ def doPrintShowAdmins():
|
|
|
16850
16919
|
if roleId not in rolePrivileges:
|
|
16851
16920
|
try:
|
|
16852
16921
|
rolePrivileges[roleId] = callGAPI(cd.roles(), 'get',
|
|
16853
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
16854
|
-
GAPI.SERVICE_NOT_AVAILABLE, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND
|
|
16922
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION,
|
|
16923
|
+
GAPI.SERVICE_NOT_AVAILABLE, GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
16924
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16855
16925
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
16856
16926
|
customer=GC.Values[GC.CUSTOMER_ID],
|
|
16857
16927
|
roleId=roleId,
|
|
16858
16928
|
fields='rolePrivileges')
|
|
16859
|
-
except (GAPI.notFound, GAPI.
|
|
16929
|
+
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.serviceNotAvailable) as e:
|
|
16860
16930
|
entityActionFailedExit([Ent.USER, userKey, Ent.ADMIN_ROLE, admin['roleId']], str(e))
|
|
16861
16931
|
rolePrivileges[roleId] = None
|
|
16862
16932
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16863
16933
|
accessErrorExit(cd)
|
|
16934
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
16935
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16864
16936
|
return rolePrivileges[roleId]
|
|
16865
16937
|
|
|
16866
16938
|
def _setNamesFromIds(admin, privileges):
|
|
@@ -16870,9 +16942,7 @@ def doPrintShowAdmins():
|
|
|
16870
16942
|
if assignedTo not in assignedToIdEmailMap:
|
|
16871
16943
|
assigneeType = admin.get('assigneeType')
|
|
16872
16944
|
assignedToField = ASSIGNEE_EMAILTYPE_TOFIELD_MAP.get(assigneeType, None)
|
|
16873
|
-
assigneeEmail, assigneeType = convertUIDtoEmailAddressWithType(f'uid:{assignedTo}',
|
|
16874
|
-
cd,
|
|
16875
|
-
sal,
|
|
16945
|
+
assigneeEmail, assigneeType = convertUIDtoEmailAddressWithType(f'uid:{assignedTo}', cd, sal,
|
|
16876
16946
|
emailTypes=list(ASSIGNEE_EMAILTYPE_TOFIELD_MAP.keys()))
|
|
16877
16947
|
if not assignedToField and assigneeType in ASSIGNEE_EMAILTYPE_TOFIELD_MAP:
|
|
16878
16948
|
assignedToField = ASSIGNEE_EMAILTYPE_TOFIELD_MAP[assigneeType]
|
|
@@ -16929,16 +16999,19 @@ def doPrintShowAdmins():
|
|
|
16929
16999
|
pageMessage=getPageMessage(),
|
|
16930
17000
|
throwReasons=[GAPI.INVALID, GAPI.USER_NOT_FOUND,
|
|
16931
17001
|
GAPI.FORBIDDEN, GAPI.SERVICE_NOT_AVAILABLE,
|
|
16932
|
-
GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND
|
|
17002
|
+
GAPI.BAD_REQUEST, GAPI.CUSTOMER_NOT_FOUND,
|
|
17003
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
16933
17004
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
16934
17005
|
customer=GC.Values[GC.CUSTOMER_ID], fields=fields, **kwargs)
|
|
16935
17006
|
except (GAPI.invalid, GAPI.userNotFound):
|
|
16936
17007
|
entityUnknownWarning(Ent.ADMINISTRATOR, userKey)
|
|
16937
17008
|
return
|
|
16938
|
-
except (GAPI.
|
|
17009
|
+
except (GAPI.serviceNotAvailable) as e:
|
|
16939
17010
|
entityActionFailedExit([Ent.ADMINISTRATOR, userKey, Ent.ADMIN_ROLE, roleId], str(e))
|
|
16940
17011
|
except (GAPI.badRequest, GAPI.customerNotFound):
|
|
16941
17012
|
accessErrorExit(cd)
|
|
17013
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
17014
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
16942
17015
|
if not csvPF:
|
|
16943
17016
|
count = len(admins)
|
|
16944
17017
|
performActionNumItems(count, Ent.ADMIN_ROLE_ASSIGNMENT)
|
|
@@ -21429,7 +21502,9 @@ def queryPeopleOtherContacts(people, contactQuery, fields, entityType, user, i=0
|
|
|
21429
21502
|
return entityList
|
|
21430
21503
|
except GAPI.permissionDenied as e:
|
|
21431
21504
|
ClientAPIAccessDeniedExit(str(e))
|
|
21432
|
-
except
|
|
21505
|
+
except GAPI.forbidden:
|
|
21506
|
+
userPeopleServiceNotEnabledWarning(user, i, count)
|
|
21507
|
+
except GAPI.serviceNotAvailable:
|
|
21433
21508
|
entityUnknownWarning(entityType, user, i, count)
|
|
21434
21509
|
return None
|
|
21435
21510
|
|
|
@@ -21549,10 +21624,8 @@ def createUserPeopleContact(users):
|
|
|
21549
21624
|
csvPF.WriteRow(row)
|
|
21550
21625
|
except GAPI.invalidArgument as e:
|
|
21551
21626
|
entityActionFailedWarning([entityType, user, peopleEntityType, None], str(e), i, count)
|
|
21552
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21627
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21553
21628
|
ClientAPIAccessDeniedExit(str(e))
|
|
21554
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
21555
|
-
ClientAPIAccessDeniedExit()
|
|
21556
21629
|
if csvPF:
|
|
21557
21630
|
csvPF.writeCSVfile('People Contacts')
|
|
21558
21631
|
|
|
@@ -21714,10 +21787,8 @@ def _clearUpdatePeopleContacts(users, updateContacts):
|
|
|
21714
21787
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
21715
21788
|
except (GAPI.notFound, GAPI.internalError):
|
|
21716
21789
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
21717
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21790
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21718
21791
|
ClientAPIAccessDeniedExit(str(e))
|
|
21719
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
21720
|
-
ClientAPIAccessDeniedExit()
|
|
21721
21792
|
Ind.Decrement()
|
|
21722
21793
|
|
|
21723
21794
|
# gam <UserTypeEntity> clear contacts <PeopleResourceNameEntity>|<PeopleUserContactSelection>
|
|
@@ -21864,10 +21935,8 @@ def dedupReplaceDomainUserPeopleContacts(users):
|
|
|
21864
21935
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
21865
21936
|
except (GAPI.notFound, GAPI.internalError):
|
|
21866
21937
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
21867
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21938
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21868
21939
|
ClientAPIAccessDeniedExit(str(e))
|
|
21869
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
21870
|
-
ClientAPIAccessDeniedExit()
|
|
21871
21940
|
Ind.Decrement()
|
|
21872
21941
|
|
|
21873
21942
|
# gam <UserTypeEntity> delete contacts <PeopleResourceNameEntity>|<PeopleUserContactSelection>
|
|
@@ -21919,10 +21988,8 @@ def deleteUserPeopleContacts(users):
|
|
|
21919
21988
|
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
|
|
21920
21989
|
except (GAPI.notFound, GAPI.internalError):
|
|
21921
21990
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
21922
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21991
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
21923
21992
|
ClientAPIAccessDeniedExit(str(e))
|
|
21924
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
21925
|
-
ClientAPIAccessDeniedExit()
|
|
21926
21993
|
Ind.Decrement()
|
|
21927
21994
|
|
|
21928
21995
|
def _initPersonMetadataParameters():
|
|
@@ -22216,10 +22283,8 @@ def _infoPeople(users, entityType, source):
|
|
|
22216
22283
|
except GAPI.invalidArgument as e:
|
|
22217
22284
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
22218
22285
|
continue
|
|
22219
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22286
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22220
22287
|
ClientAPIAccessDeniedExit(str(e))
|
|
22221
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22222
|
-
ClientAPIAccessDeniedExit()
|
|
22223
22288
|
if showContactGroups and contactGroupIDs:
|
|
22224
22289
|
addContactGroupNamesToContacts([result], contactGroupIDs, False)
|
|
22225
22290
|
_showPerson(entityType, user, peopleEntityType, result, j, jcount, FJQC, parameters)
|
|
@@ -22396,10 +22461,8 @@ def copyUserPeopleOtherContacts(users):
|
|
|
22396
22461
|
except (GAPI.notFound, GAPI.internalError):
|
|
22397
22462
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
22398
22463
|
continue
|
|
22399
|
-
except GAPI.permissionDenied as e:
|
|
22464
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22400
22465
|
ClientAPIAccessDeniedExit(str(e))
|
|
22401
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22402
|
-
ClientAPIAccessDeniedExit()
|
|
22403
22466
|
Ind.Decrement()
|
|
22404
22467
|
|
|
22405
22468
|
# gam <UserTypeEntity> delete othercontacts
|
|
@@ -22512,10 +22575,8 @@ def processUserPeopleOtherContacts(users):
|
|
|
22512
22575
|
except (GAPI.notFound, GAPI.internalError):
|
|
22513
22576
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
22514
22577
|
continue
|
|
22515
|
-
except GAPI.permissionDenied as e:
|
|
22578
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22516
22579
|
ClientAPIAccessDeniedExit(str(e))
|
|
22517
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22518
|
-
ClientAPIAccessDeniedExit()
|
|
22519
22580
|
Ind.Decrement()
|
|
22520
22581
|
|
|
22521
22582
|
# gam <UserTypeEntity> print othercontacts [todrive <ToDriveAttribute>*] <OtherContactSelection>
|
|
@@ -22631,10 +22692,8 @@ def _printShowPeople(source):
|
|
|
22631
22692
|
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
|
|
22632
22693
|
sources=sources, mergeSources=mergeSources,
|
|
22633
22694
|
readMask=fields, fields='nextPageToken,people', **kwargs)
|
|
22634
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22695
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22635
22696
|
ClientAPIAccessDeniedExit(str(e))
|
|
22636
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22637
|
-
ClientAPIAccessDeniedExit()
|
|
22638
22697
|
if not countsOnly:
|
|
22639
22698
|
_printPersonEntityList(peopleEntityType, entityList, Ent.DOMAIN, GC.Values[GC.DOMAIN], 0, 0, csvPF, FJQC, parameters, None)
|
|
22640
22699
|
else:
|
|
@@ -22753,10 +22812,8 @@ def printShowUserPeopleProfiles(users):
|
|
|
22753
22812
|
except GAPI.notFound:
|
|
22754
22813
|
entityUnknownWarning(Ent.PEOPLE_PROFILE, user, i, count)
|
|
22755
22814
|
continue
|
|
22756
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22815
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22757
22816
|
ClientAPIAccessDeniedExit(str(e))
|
|
22758
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22759
|
-
ClientAPIAccessDeniedExit()
|
|
22760
22817
|
if not csvPF:
|
|
22761
22818
|
_showPerson(entityType, user, Ent.PEOPLE_PROFILE, result, i, count, FJQC, parameters)
|
|
22762
22819
|
else:
|
|
@@ -22909,10 +22966,8 @@ def _processPeopleContactPhotos(users, function):
|
|
|
22909
22966
|
entityDoesNotHaveItemWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], j, jcount)
|
|
22910
22967
|
except (GAPI.invalidArgument, OSError, IOError) as e:
|
|
22911
22968
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], str(e), j, jcount)
|
|
22912
|
-
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22969
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
22913
22970
|
ClientAPIAccessDeniedExit(str(e))
|
|
22914
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
22915
|
-
ClientAPIAccessDeniedExit()
|
|
22916
22971
|
break
|
|
22917
22972
|
Ind.Decrement()
|
|
22918
22973
|
|
|
@@ -23234,10 +23289,8 @@ def printShowUserPeopleContactGroups(users):
|
|
|
23234
23289
|
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS,
|
|
23235
23290
|
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
|
|
23236
23291
|
groupFields=fields, fields='nextPageToken,contactGroups')
|
|
23237
|
-
except GAPI.permissionDenied as e:
|
|
23292
|
+
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
23238
23293
|
ClientAPIAccessDeniedExit(str(e))
|
|
23239
|
-
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
23240
|
-
ClientAPIAccessDeniedExit()
|
|
23241
23294
|
_printPersonEntityList(Ent.PEOPLE_CONTACT_GROUP, entityList, entityType, user, i, count, csvPF, FJQC, parameters, None)
|
|
23242
23295
|
if csvPF:
|
|
23243
23296
|
csvPF.writeCSVfile('People Contact Groups')
|
|
@@ -31782,15 +31835,18 @@ def getMobileDeviceEntity():
|
|
|
31782
31835
|
printGettingAllAccountEntities(Ent.MOBILE_DEVICE, query)
|
|
31783
31836
|
devices = callGAPIpages(cd.mobiledevices(), 'list', 'mobiledevices',
|
|
31784
31837
|
pageMessage=getPageMessage(),
|
|
31785
|
-
throwReasons=[GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
31838
|
+
throwReasons=[GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
31839
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
31786
31840
|
customerId=GC.Values[GC.CUSTOMER_ID], query=query,
|
|
31787
31841
|
fields='nextPageToken,mobiledevices(resourceId,email)')
|
|
31842
|
+
return ([{'resourceId': device['resourceId'], 'email': device.get('email', [])} for device in devices], cd, False)
|
|
31788
31843
|
except GAPI.invalidInput:
|
|
31789
31844
|
Cmd.Backup()
|
|
31790
31845
|
usageErrorExit(Msg.INVALID_QUERY)
|
|
31791
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
31846
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
31792
31847
|
accessErrorExit(cd)
|
|
31793
|
-
|
|
31848
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
31849
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
31794
31850
|
|
|
31795
31851
|
def _getUpdateDeleteMobileOptions(myarg, options):
|
|
31796
31852
|
if myarg in {'matchusers', 'ifusers'}:
|
|
@@ -31843,14 +31899,17 @@ def doUpdateMobileDevices():
|
|
|
31843
31899
|
callGAPI(cd.mobiledevices(), 'action',
|
|
31844
31900
|
bailOnInternalError=True,
|
|
31845
31901
|
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.RESOURCE_ID_NOT_FOUND,
|
|
31846
|
-
GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
31902
|
+
GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
31903
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
31847
31904
|
customerId=GC.Values[GC.CUSTOMER_ID], resourceId=resourceId, body=body)
|
|
31848
31905
|
printEntityKVList([Ent.MOBILE_DEVICE, resourceId, Ent.USER, deviceUser],
|
|
31849
31906
|
[Msg.ACTION_APPLIED, body['action']], i, count)
|
|
31850
31907
|
except GAPI.internalError:
|
|
31851
31908
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], Msg.DOES_NOT_EXIST, i, count)
|
|
31852
|
-
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound
|
|
31909
|
+
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound) as e:
|
|
31853
31910
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], str(e), i, count)
|
|
31911
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
31912
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
31854
31913
|
|
|
31855
31914
|
# gam delete mobile|mobiles <MobileDeviceEntity>
|
|
31856
31915
|
# [doit] [matchusers <UserTypeEntity>]
|
|
@@ -31874,14 +31933,16 @@ def doDeleteMobileDevices():
|
|
|
31874
31933
|
try:
|
|
31875
31934
|
callGAPI(cd.mobiledevices(), 'delete',
|
|
31876
31935
|
bailOnInternalError=True,
|
|
31877
|
-
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.RESOURCE_ID_NOT_FOUND, GAPI.BAD_REQUEST,
|
|
31878
|
-
GAPI.
|
|
31936
|
+
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.RESOURCE_ID_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
31937
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
31879
31938
|
customerId=GC.Values[GC.CUSTOMER_ID], resourceId=resourceId)
|
|
31880
31939
|
entityActionPerformed([Ent.MOBILE_DEVICE, resourceId, Ent.USER, deviceUser], i, count)
|
|
31881
31940
|
except GAPI.internalError:
|
|
31882
31941
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], Msg.DOES_NOT_EXIST, i, count)
|
|
31883
|
-
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound
|
|
31942
|
+
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound) as e:
|
|
31884
31943
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], str(e), i, count)
|
|
31944
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
31945
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
31885
31946
|
|
|
31886
31947
|
MOBILE_FIELDS_CHOICE_MAP = {
|
|
31887
31948
|
'adbstatus': 'adbStatus',
|
|
@@ -31963,8 +32024,8 @@ def doInfoMobileDevices():
|
|
|
31963
32024
|
try:
|
|
31964
32025
|
mobile = callGAPI(cd.mobiledevices(), 'get',
|
|
31965
32026
|
bailOnInternalError=True,
|
|
31966
|
-
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.RESOURCE_ID_NOT_FOUND,
|
|
31967
|
-
GAPI.
|
|
32027
|
+
throwReasons=[GAPI.INTERNAL_ERROR, GAPI.RESOURCE_ID_NOT_FOUND, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
32028
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
31968
32029
|
customerId=GC.Values[GC.CUSTOMER_ID], resourceId=resourceId, projection=parameters['projection'], fields=fields)
|
|
31969
32030
|
if FJQC.formatJSON:
|
|
31970
32031
|
printLine(json.dumps(cleanJSON(mobile, timeObjects=MOBILE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True))
|
|
@@ -31981,8 +32042,10 @@ def doInfoMobileDevices():
|
|
|
31981
32042
|
Ind.Decrement()
|
|
31982
32043
|
except GAPI.internalError:
|
|
31983
32044
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], Msg.DOES_NOT_EXIST, i, count)
|
|
31984
|
-
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound
|
|
32045
|
+
except (GAPI.resourceIdNotFound, GAPI.badRequest, GAPI.resourceNotFound) as e:
|
|
31985
32046
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, resourceId], str(e), i, count)
|
|
32047
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
32048
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
31986
32049
|
|
|
31987
32050
|
MOBILE_ORDERBY_CHOICE_MAP = {
|
|
31988
32051
|
'deviceid': 'deviceId',
|
|
@@ -32111,7 +32174,8 @@ def doPrintMobileDevices():
|
|
|
32111
32174
|
try:
|
|
32112
32175
|
feed = yieldGAPIpages(cd.mobiledevices(), 'list', 'mobiledevices',
|
|
32113
32176
|
pageMessage=pageMessage,
|
|
32114
|
-
throwReasons=[GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
32177
|
+
throwReasons=[GAPI.INVALID_INPUT, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
32178
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
32115
32179
|
customerId=GC.Values[GC.CUSTOMER_ID], query=query, projection=parameters['projection'],
|
|
32116
32180
|
orderBy=orderBy, sortOrder=sortOrder, fields=fields, maxResults=GC.Values[GC.MOBILE_MAX_RESULTS])
|
|
32117
32181
|
for mobiles in feed:
|
|
@@ -32125,8 +32189,10 @@ def doPrintMobileDevices():
|
|
|
32125
32189
|
except GAPI.invalidInput:
|
|
32126
32190
|
entityActionFailedWarning([Ent.MOBILE_DEVICE, None], invalidQuery(query))
|
|
32127
32191
|
return
|
|
32128
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
32192
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
32129
32193
|
accessErrorExit(cd)
|
|
32194
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
32195
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
32130
32196
|
if showItemCountOnly:
|
|
32131
32197
|
writeStdout(f'{itemCount}\n')
|
|
32132
32198
|
return
|
|
@@ -36452,8 +36518,8 @@ def doPrintShowCIPolicies():
|
|
|
36452
36518
|
sort_keys=True)})
|
|
36453
36519
|
|
|
36454
36520
|
_checkPoliciesWithDASA()
|
|
36455
|
-
groups_ci = buildGAPIObject(API.CLOUDIDENTITY_GROUPS)
|
|
36456
36521
|
ci = buildGAPIObject(API.CLOUDIDENTITY_POLICY)
|
|
36522
|
+
groups_ci = buildGAPIObject(API.CLOUDIDENTITY_GROUPS)
|
|
36457
36523
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
36458
36524
|
csvPF = CSVPrintFile(['name']) if Act.csvFormat() else None
|
|
36459
36525
|
FJQC = FormatJSONQuoteChar(csvPF)
|
|
@@ -38464,10 +38530,13 @@ def doPrintShowResourceCalendars():
|
|
|
38464
38530
|
try:
|
|
38465
38531
|
resources = callGAPIpages(cd.resources().calendars(), 'list', 'items',
|
|
38466
38532
|
pageMessage=getPageMessage(showFirstLastItems=True), messageAttribute='resourceName',
|
|
38467
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN,
|
|
38533
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FORBIDDEN,
|
|
38534
|
+
GAPI.PERMISSION_DENIED, GAPI.INVALID_INPUT],
|
|
38468
38535
|
query=query, customer=GC.Values[GC.CUSTOMER_ID], fields=fields)
|
|
38469
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
38536
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
38470
38537
|
accessErrorExit(cd)
|
|
38538
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
38539
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
38471
38540
|
except GAPI.invalidInput as e:
|
|
38472
38541
|
entityActionFailedWarning([Ent.RESOURCE_CALENDAR, ''], str(e))
|
|
38473
38542
|
return
|
|
@@ -40706,7 +40775,8 @@ def doCreateUpdateUserSchemas():
|
|
|
40706
40775
|
try:
|
|
40707
40776
|
if updateCmd:
|
|
40708
40777
|
oldBody = callGAPI(cd.schemas(), 'get',
|
|
40709
|
-
throwReasons=[GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40778
|
+
throwReasons=[GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40779
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
40710
40780
|
customerId=GC.Values[GC.CUSTOMER_ID], schemaKey=schemaName, fields='schemaName,displayName,fields')
|
|
40711
40781
|
for field in oldBody['fields']:
|
|
40712
40782
|
field.pop('etag', None)
|
|
@@ -40745,15 +40815,18 @@ def doCreateUpdateUserSchemas():
|
|
|
40745
40815
|
addBody['schemaName'] = schemaName.replace(' ', '_')
|
|
40746
40816
|
addBody['displayName'] = schemaDisplayName if schemaDisplayName else schemaName
|
|
40747
40817
|
result = callGAPI(cd.schemas(), 'insert',
|
|
40748
|
-
throwReasons=[GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40818
|
+
throwReasons=[GAPI.DUPLICATE, GAPI.CONDITION_NOT_MET, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40819
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
40749
40820
|
customerId=GC.Values[GC.CUSTOMER_ID], body=addBody, fields='schemaName')
|
|
40750
40821
|
entityActionPerformed([Ent.USER_SCHEMA, result['schemaName']], i, count)
|
|
40751
40822
|
except GAPI.duplicate:
|
|
40752
40823
|
entityDuplicateWarning([Ent.USER_SCHEMA, schemaName], i, count)
|
|
40753
|
-
except (GAPI.conditionNotMet, GAPI.fieldInUse
|
|
40824
|
+
except (GAPI.conditionNotMet, GAPI.fieldInUse) as e:
|
|
40754
40825
|
entityActionFailedWarning([Ent.USER_SCHEMA, schemaName], str(e), i, count)
|
|
40755
40826
|
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
40756
40827
|
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaName, i, count)
|
|
40828
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
40829
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
40757
40830
|
|
|
40758
40831
|
# gam delete schema|schemas <SchemaEntity>
|
|
40759
40832
|
def doDeleteUserSchemas():
|
|
@@ -40766,13 +40839,16 @@ def doDeleteUserSchemas():
|
|
|
40766
40839
|
i += 1
|
|
40767
40840
|
try:
|
|
40768
40841
|
callGAPI(cd.schemas(), 'delete',
|
|
40769
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.
|
|
40842
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND, GAPI.FIELD_IN_USE,
|
|
40843
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
40770
40844
|
customerId=GC.Values[GC.CUSTOMER_ID], schemaKey=schemaKey)
|
|
40771
40845
|
entityActionPerformed([Ent.USER_SCHEMA, schemaKey], i, count)
|
|
40772
40846
|
except GAPI.fieldInUse as e:
|
|
40773
40847
|
entityActionFailedWarning([Ent.USER_SCHEMA, schemaKey], str(e), i, count)
|
|
40774
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
40848
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
40775
40849
|
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
|
40850
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
40851
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
40776
40852
|
|
|
40777
40853
|
# gam info schema|schemas <SchemaEntity>
|
|
40778
40854
|
def doInfoUserSchemas():
|
|
@@ -40785,11 +40861,14 @@ def doInfoUserSchemas():
|
|
|
40785
40861
|
i += 1
|
|
40786
40862
|
try:
|
|
40787
40863
|
schema = callGAPI(cd.schemas(), 'get',
|
|
40788
|
-
throwReasons=[GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40864
|
+
throwReasons=[GAPI.INVALID, GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40865
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
40789
40866
|
customerId=GC.Values[GC.CUSTOMER_ID], schemaKey=schemaKey)
|
|
40790
40867
|
_showSchema(schema, i, count)
|
|
40791
|
-
except (GAPI.invalid, GAPI.badRequest, GAPI.resourceNotFound
|
|
40868
|
+
except (GAPI.invalid, GAPI.badRequest, GAPI.resourceNotFound):
|
|
40792
40869
|
checkEntityAFDNEorAccessErrorExit(cd, Ent.USER_SCHEMA, schemaKey, i, count)
|
|
40870
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
40871
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
40793
40872
|
|
|
40794
40873
|
SCHEMAS_SORT_TITLES = ['schemaId', 'schemaName', 'displayName']
|
|
40795
40874
|
SCHEMAS_INDEXED_TITLES = ['fields']
|
|
@@ -40802,7 +40881,8 @@ def doPrintShowUserSchemas():
|
|
|
40802
40881
|
getTodriveOnly(csvPF)
|
|
40803
40882
|
try:
|
|
40804
40883
|
result = callGAPI(cd.schemas(), 'list',
|
|
40805
|
-
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40884
|
+
throwReasons=[GAPI.BAD_REQUEST, GAPI.RESOURCE_NOT_FOUND,
|
|
40885
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
40806
40886
|
customerId=GC.Values[GC.CUSTOMER_ID])
|
|
40807
40887
|
jcount = len(result.get('schemas', [])) if (result) else 0
|
|
40808
40888
|
if not csvPF:
|
|
@@ -40820,8 +40900,10 @@ def doPrintShowUserSchemas():
|
|
|
40820
40900
|
else:
|
|
40821
40901
|
for schema in result['schemas']:
|
|
40822
40902
|
csvPF.WriteRowTitles(flattenJSON(schema))
|
|
40823
|
-
except (GAPI.badRequest, GAPI.resourceNotFound
|
|
40903
|
+
except (GAPI.badRequest, GAPI.resourceNotFound):
|
|
40824
40904
|
accessErrorExit(cd)
|
|
40905
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
40906
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
40825
40907
|
if csvPF:
|
|
40826
40908
|
csvPF.writeCSVfile('User Schemas')
|
|
40827
40909
|
|
|
@@ -41082,11 +41164,14 @@ def convertExportNameToID(v, nameOrId, matterId, matterNameId):
|
|
|
41082
41164
|
if cg:
|
|
41083
41165
|
try:
|
|
41084
41166
|
export = callGAPI(v.matters().exports(), 'get',
|
|
41085
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41167
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41168
|
+
GAPI.INVALID_ARGUMENT, GAPI.FAILED_PRECONDITION],
|
|
41086
41169
|
matterId=matterId, exportId=cg.group(1))
|
|
41087
41170
|
return (export['id'], export['name'], formatVaultNameId(export['id'], export['name']))
|
|
41088
41171
|
except (GAPI.notFound, GAPI.badRequest):
|
|
41089
41172
|
entityDoesNotHaveItemExit([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, nameOrId])
|
|
41173
|
+
except (GAPI.failedPrecondition) as e:
|
|
41174
|
+
entityActionFailedExit([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, nameOrId], str(e))
|
|
41090
41175
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
41091
41176
|
ClientAPIAccessDeniedExit(str(e))
|
|
41092
41177
|
nameOrIdlower = nameOrId.lower()
|
|
@@ -41582,10 +41667,11 @@ def doInfoVaultExport():
|
|
|
41582
41667
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
41583
41668
|
try:
|
|
41584
41669
|
export = callGAPI(v.matters().exports(), 'get',
|
|
41585
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41670
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41671
|
+
GAPI.INVALID_ARGUMENT, GAPI.FAILED_PRECONDITION],
|
|
41586
41672
|
matterId=matterId, exportId=exportId, fields=fields)
|
|
41587
41673
|
_showVaultExport(matterNameId, export, cd, FJQC)
|
|
41588
|
-
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
41674
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument, GAPI.failedPrecondition) as e:
|
|
41589
41675
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
41590
41676
|
|
|
41591
41677
|
VAULT_EXPORT_STATUS_MAP = {'completed': 'COMPLETED', 'failed': 'FAILED', 'inprogress': 'IN_PROGRESS'}
|
|
@@ -41778,9 +41864,10 @@ def doCopyVaultExport():
|
|
|
41778
41864
|
while True:
|
|
41779
41865
|
try:
|
|
41780
41866
|
export = callGAPI(v.matters().exports(), 'get',
|
|
41781
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41867
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41868
|
+
GAPI.INVALID_ARGUMENT, GAPI.FAILED_PRECONDITION],
|
|
41782
41869
|
matterId=matterId, exportId=exportId)
|
|
41783
|
-
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
41870
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument, GAPI.failedPrecondition) as e:
|
|
41784
41871
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
41785
41872
|
return
|
|
41786
41873
|
if export['status'] == 'COMPLETED':
|
|
@@ -41878,9 +41965,10 @@ def doDownloadVaultExport():
|
|
|
41878
41965
|
while True:
|
|
41879
41966
|
try:
|
|
41880
41967
|
export = callGAPI(v.matters().exports(), 'get',
|
|
41881
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41968
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN,
|
|
41969
|
+
GAPI.INVALID_ARGUMENT, GAPI.FAILED_PRECONDITION],
|
|
41882
41970
|
matterId=matterId, exportId=exportId)
|
|
41883
|
-
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
41971
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument, GAPI.failedPrecondition) as e:
|
|
41884
41972
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
41885
41973
|
return
|
|
41886
41974
|
if export['status'] == 'COMPLETED':
|
|
@@ -44306,6 +44394,28 @@ def doUndeleteUsers():
|
|
|
44306
44394
|
def doUndeleteUser():
|
|
44307
44395
|
undeleteUsers(getStringReturnInList(Cmd.OB_USER_ITEM))
|
|
44308
44396
|
|
|
44397
|
+
# gam check suspended <UserItem>
|
|
44398
|
+
def doCheckUserSuspended():
|
|
44399
|
+
cd = buildGAPIObject(API.DIRECTORY)
|
|
44400
|
+
user = getEmailAddress()
|
|
44401
|
+
checkForExtraneousArguments()
|
|
44402
|
+
try:
|
|
44403
|
+
result = callGAPI(cd.users(), 'get',
|
|
44404
|
+
throwReasons=GAPI.USER_GET_THROW_REASONS,
|
|
44405
|
+
userKey=user, fields='suspended,suspensionReason', projection='basic')
|
|
44406
|
+
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden):
|
|
44407
|
+
entityDoesNotExistExit(Ent.USER, user)
|
|
44408
|
+
except (GAPI.badRequest, GAPI.invalidCustomerId, GAPI.loginRequired):
|
|
44409
|
+
accessErrorExit(cd)
|
|
44410
|
+
kvList = [Ent.Singular(Ent.USER), user]
|
|
44411
|
+
up = 'suspended'
|
|
44412
|
+
kvList.extend([UProp.PROPERTIES[up][UProp.TITLE], result[up]])
|
|
44413
|
+
if result[up]:
|
|
44414
|
+
up = 'suspensionReason'
|
|
44415
|
+
kvList.extend([UProp.PROPERTIES[up][UProp.TITLE], result[up]])
|
|
44416
|
+
setSysExitRC(USER_SUSPENDED_RC)
|
|
44417
|
+
printKeyValueList(kvList)
|
|
44418
|
+
|
|
44309
44419
|
# gam <UserTypeEntity> suspend users [noactionifalias]
|
|
44310
44420
|
# gam <UserTypeEntity> unsuspend users [noactionifalias]
|
|
44311
44421
|
def suspendUnsuspendUsers(entityList):
|
|
@@ -44359,13 +44469,13 @@ def signoutTurnoff2SVUsers(entityList):
|
|
|
44359
44469
|
callGAPI(service, function,
|
|
44360
44470
|
throwReasons=[GAPI.NOT_FOUND, GAPI.USER_NOT_FOUND, GAPI.INVALID, GAPI.INVALID_INPUT,
|
|
44361
44471
|
GAPI.DOMAIN_NOT_FOUND, GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
44362
|
-
GAPI.FORBIDDEN, GAPI.AUTH_ERROR],
|
|
44472
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED, GAPI.AUTH_ERROR],
|
|
44363
44473
|
userKey=user)
|
|
44364
44474
|
entityActionPerformed([Ent.USER, user], i, count)
|
|
44365
44475
|
except (GAPI.notFound, GAPI.userNotFound):
|
|
44366
44476
|
entityUnknownWarning(Ent.USER, user, i, count)
|
|
44367
44477
|
except (GAPI.invalid, GAPI.invalidInput, GAPI.domainNotFound, GAPI.domainCannotUseApis,
|
|
44368
|
-
GAPI.forbidden, GAPI.authError) as e:
|
|
44478
|
+
GAPI.forbidden, GAPI.permissionDenied, GAPI.authError) as e:
|
|
44369
44479
|
entityActionFailedWarning([Ent.USER, user], str(e), i, count)
|
|
44370
44480
|
|
|
44371
44481
|
# gam <UserTypeEntity> waitformailbox [retries <Number>]
|
|
@@ -47229,10 +47339,7 @@ class CourseAttributes():
|
|
|
47229
47339
|
newTopicsByName[topicName] = result['topicId']
|
|
47230
47340
|
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_TOPIC, topicName], Act.MODIFIER_FROM,
|
|
47231
47341
|
[Ent.COURSE, self.courseId], j, jcount)
|
|
47232
|
-
except GAPI.notFound as e:
|
|
47233
|
-
entityActionFailedWarning([Ent.COURSE, newCourseId], str(e), i, count)
|
|
47234
|
-
return
|
|
47235
|
-
except (GAPI.failedPrecondition, GAPI.invalidArgument, GAPI.forbidden, GAPI.serviceNotAvailable) as e:
|
|
47342
|
+
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.invalidArgument, GAPI.forbidden, GAPI.serviceNotAvailable) as e:
|
|
47236
47343
|
entityModifierItemValueListActionFailedWarning([Ent.COURSE, newCourseId], Act.MODIFIER_FROM,
|
|
47237
47344
|
[Ent.COURSE, self.courseId, Ent.COURSE_TOPIC, topicName], str(e), j, jcount)
|
|
47238
47345
|
if self.courseAnnouncements:
|
|
@@ -47255,10 +47362,7 @@ class CourseAttributes():
|
|
|
47255
47362
|
courseId=newCourseId, body=body, fields='id')
|
|
47256
47363
|
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_ANNOUNCEMENT_ID, result['id']], Act.MODIFIER_FROM,
|
|
47257
47364
|
[Ent.COURSE, self.courseId, Ent.COURSE_ANNOUNCEMENT, courseAnnouncementId], j, jcount)
|
|
47258
|
-
except GAPI.notFound
|
|
47259
|
-
entityActionFailedWarning([Ent.COURSE, newCourseId], str(e), i, count)
|
|
47260
|
-
return
|
|
47261
|
-
except (GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError,
|
|
47365
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError,
|
|
47262
47366
|
GAPI.permissionDenied, GAPI.forbidden, GAPI.serviceNotAvailable) as e:
|
|
47263
47367
|
entityModifierItemValueListActionFailedWarning([Ent.COURSE, newCourseId], Act.MODIFIER_FROM,
|
|
47264
47368
|
[Ent.COURSE, self.courseId, Ent.COURSE_ANNOUNCEMENT, courseAnnouncementId], str(e), j, jcount)
|
|
@@ -47290,10 +47394,7 @@ class CourseAttributes():
|
|
|
47290
47394
|
courseId=newCourseId, body=body, fields='id')
|
|
47291
47395
|
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_MATERIAL_ID, result['id']], Act.MODIFIER_FROM,
|
|
47292
47396
|
[Ent.COURSE, self.courseId, Ent.COURSE_MATERIAL, courseMaterialId], j, jcount)
|
|
47293
|
-
except GAPI.notFound
|
|
47294
|
-
entityActionFailedWarning([Ent.COURSE, newCourseId], str(e), i, count)
|
|
47295
|
-
return
|
|
47296
|
-
except (GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError,
|
|
47397
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError,
|
|
47297
47398
|
GAPI.permissionDenied, GAPI.forbidden, GAPI.serviceNotAvailable) as e:
|
|
47298
47399
|
entityModifierItemValueListActionFailedWarning([Ent.COURSE, newCourseId], Act.MODIFIER_FROM,
|
|
47299
47400
|
[Ent.COURSE, self.courseId, Ent.COURSE_MATERIAL, courseMaterialId], str(e), j, jcount)
|
|
@@ -47330,10 +47431,7 @@ class CourseAttributes():
|
|
|
47330
47431
|
courseId=newCourseId, body=body, fields='id')
|
|
47331
47432
|
entityModifierItemValueListActionPerformed([Ent.COURSE, newCourseId, Ent.COURSE_WORK_ID, result['id']], Act.MODIFIER_FROM,
|
|
47332
47433
|
[Ent.COURSE, self.courseId, Ent.COURSE_WORK, courseWorkId], j, jcount)
|
|
47333
|
-
except GAPI.notFound
|
|
47334
|
-
entityActionFailedWarning([Ent.COURSE, newCourseId], str(e), i, count)
|
|
47335
|
-
return
|
|
47336
|
-
except (GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError, GAPI.invalidArgument,
|
|
47434
|
+
except (GAPI.notFound, GAPI.badRequest, GAPI.failedPrecondition, GAPI.backendError, GAPI.internalError, GAPI.invalidArgument,
|
|
47337
47435
|
GAPI.permissionDenied, GAPI.forbidden, GAPI.serviceNotAvailable) as e:
|
|
47338
47436
|
entityModifierItemValueListActionFailedWarning([Ent.COURSE, newCourseId], Act.MODIFIER_FROM,
|
|
47339
47437
|
[Ent.COURSE, self.courseId, Ent.COURSE_WORK, courseWorkId], str(e), j, jcount)
|
|
@@ -47688,7 +47786,8 @@ def _getCoursesOwnerInfo(croom, courseIds, useOwnerAccess, addCIIdScope=True):
|
|
|
47688
47786
|
if courseId not in coursesInfo:
|
|
47689
47787
|
try:
|
|
47690
47788
|
course = callGAPI(croom.courses(), 'get',
|
|
47691
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
47789
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE,
|
|
47790
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
47692
47791
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
47693
47792
|
id=courseId, fields='name,ownerId')
|
|
47694
47793
|
if useOwnerAccess:
|
|
@@ -47699,10 +47798,10 @@ def _getCoursesOwnerInfo(croom, courseIds, useOwnerAccess, addCIIdScope=True):
|
|
|
47699
47798
|
coursesInfo[ciCourseId] = {'name': course['name'], 'croom': ocroom}
|
|
47700
47799
|
except GAPI.notFound:
|
|
47701
47800
|
entityDoesNotExistWarning(Ent.COURSE, courseId)
|
|
47702
|
-
except
|
|
47801
|
+
except GAPI.serviceNotAvailable as e:
|
|
47703
47802
|
entityActionFailedWarning([Ent.COURSE, courseId], str(e))
|
|
47704
|
-
except GAPI.forbidden:
|
|
47705
|
-
ClientAPIAccessDeniedExit()
|
|
47803
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
47804
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47706
47805
|
return 0, len(coursesInfo), coursesInfo
|
|
47707
47806
|
|
|
47708
47807
|
def _getCourseAliasesMembers(croom, ocroom, courseId, courseShowProperties, teachersFields, studentsFields, showGettings=False, i=0, count=0):
|
|
@@ -47718,13 +47817,14 @@ def _getCourseAliasesMembers(croom, ocroom, courseId, courseShowProperties, teac
|
|
|
47718
47817
|
try:
|
|
47719
47818
|
aliases = callGAPIpages(croom.courses().aliases(), 'list', 'aliases',
|
|
47720
47819
|
pageMessage=pageMessage,
|
|
47721
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
47820
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE, GAPI.NOT_IMPLEMENTED,
|
|
47821
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
47722
47822
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
47723
47823
|
courseId=courseId, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
|
|
47724
47824
|
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.notImplemented):
|
|
47725
47825
|
pass
|
|
47726
|
-
except GAPI.forbidden:
|
|
47727
|
-
ClientAPIAccessDeniedExit()
|
|
47826
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
47827
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47728
47828
|
if courseShowProperties['members'] != 'none':
|
|
47729
47829
|
if courseShowProperties['members'] != 'students':
|
|
47730
47830
|
if showGettings:
|
|
@@ -47733,13 +47833,14 @@ def _getCourseAliasesMembers(croom, ocroom, courseId, courseShowProperties, teac
|
|
|
47733
47833
|
try:
|
|
47734
47834
|
teachers = callGAPIpages(ocroom.courses().teachers(), 'list', 'teachers',
|
|
47735
47835
|
pageMessage=pageMessage,
|
|
47736
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
47836
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE,
|
|
47837
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
47737
47838
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
47738
47839
|
courseId=courseId, fields=teachersFields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
|
|
47739
47840
|
except (GAPI.notFound, GAPI.serviceNotAvailable):
|
|
47740
47841
|
pass
|
|
47741
|
-
except GAPI.forbidden:
|
|
47742
|
-
ClientAPIAccessDeniedExit()
|
|
47842
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
47843
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47743
47844
|
if courseShowProperties['members'] != 'teachers':
|
|
47744
47845
|
if showGettings:
|
|
47745
47846
|
printGettingEntityItemForWhom(Ent.STUDENT, formatKeyValueList('', [Ent.Singular(Ent.COURSE), courseId], currentCount(i, count)))
|
|
@@ -47747,13 +47848,14 @@ def _getCourseAliasesMembers(croom, ocroom, courseId, courseShowProperties, teac
|
|
|
47747
47848
|
try:
|
|
47748
47849
|
students = callGAPIpages(ocroom.courses().students(), 'list', 'students',
|
|
47749
47850
|
pageMessage=pageMessage,
|
|
47750
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
47851
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE,
|
|
47852
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
47751
47853
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
47752
47854
|
courseId=courseId, fields=studentsFields, pageSize=GC.Values[GC.CLASSROOM_MAX_RESULTS])
|
|
47753
47855
|
except (GAPI.notFound, GAPI.serviceNotAvailable):
|
|
47754
47856
|
pass
|
|
47755
|
-
except GAPI.forbidden:
|
|
47756
|
-
ClientAPIAccessDeniedExit()
|
|
47857
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
47858
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47757
47859
|
return (aliases, teachers, students)
|
|
47758
47860
|
|
|
47759
47861
|
def _doInfoCourses(courseIdList):
|
|
@@ -47849,10 +47951,10 @@ def _doInfoCourses(courseIdList):
|
|
|
47849
47951
|
Ind.Decrement()
|
|
47850
47952
|
except GAPI.notFound:
|
|
47851
47953
|
entityActionFailedWarning([Ent.COURSE, removeCourseIdScope(courseId)], Msg.DOES_NOT_EXIST, i, count)
|
|
47852
|
-
except
|
|
47954
|
+
except GAPI.serviceNotAvailable as e:
|
|
47853
47955
|
entityActionFailedWarning([Ent.COURSE, removeCourseIdScope(courseId)], str(e), i, count)
|
|
47854
|
-
except GAPI.forbidden:
|
|
47855
|
-
ClientAPIAccessDeniedExit()
|
|
47956
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
47957
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47856
47958
|
|
|
47857
47959
|
# gam info courses <CourseEntity> [owneraccess]
|
|
47858
47960
|
# [owneremail] [alias|aliases] [show none|all|students|teachers] [countsonly]
|
|
@@ -47959,7 +48061,8 @@ def _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getO
|
|
|
47959
48061
|
courseId = addCourseIdScope(courseId)
|
|
47960
48062
|
try:
|
|
47961
48063
|
info = callGAPI(croom.courses(), 'get',
|
|
47962
|
-
throwReasons=[GAPI.NOT_FOUND, GAPI.
|
|
48064
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE,
|
|
48065
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
47963
48066
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
|
47964
48067
|
id=courseId, fields=fields)
|
|
47965
48068
|
coursesInfo.append(info)
|
|
@@ -47967,8 +48070,8 @@ def _getCoursesInfo(croom, courseSelectionParameters, courseShowProperties, getO
|
|
|
47967
48070
|
entityDoesNotExistWarning(Ent.COURSE, courseId)
|
|
47968
48071
|
except GAPI.serviceNotAvailable as e:
|
|
47969
48072
|
entityActionFailedWarning([Ent.COURSE, courseId], str(e))
|
|
47970
|
-
except GAPI.forbidden:
|
|
47971
|
-
ClientAPIAccessDeniedExit()
|
|
48073
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
48074
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
47972
48075
|
return coursesInfo
|
|
47973
48076
|
|
|
47974
48077
|
# gam print courses [todrive <ToDriveAttribute>*] (course|class <CourseEntity>)*|([teacher <UserItem>] [student <UserItem>] [states <CourseStateList>])
|
|
@@ -48931,43 +49034,73 @@ def doPrintCourseParticipants():
|
|
|
48931
49034
|
csvPF.writeCSVfile('Course Participants')
|
|
48932
49035
|
|
|
48933
49036
|
def _batchAddItemsToCourse(croom, courseId, i, count, addItems, addType):
|
|
49037
|
+
def _addIdToResponse(response, riItem):
|
|
49038
|
+
if addType == Ent.COURSE_ANNOUNCEMENT:
|
|
49039
|
+
respId = response.get('id', '')
|
|
49040
|
+
elif addType == Ent.COURSE_TOPIC:
|
|
49041
|
+
respId = response.get('topicId', '')
|
|
49042
|
+
else:
|
|
49043
|
+
respId = ''
|
|
49044
|
+
if respId:
|
|
49045
|
+
return riItem + f'({respId})'
|
|
49046
|
+
return riItem
|
|
49047
|
+
|
|
48934
49048
|
_ADD_PART_REASON_TO_MESSAGE_MAP = {GAPI.NOT_FOUND: Msg.DOES_NOT_EXIST,
|
|
48935
49049
|
GAPI.ALREADY_EXISTS: Msg.DUPLICATE,
|
|
48936
49050
|
GAPI.FAILED_PRECONDITION: Msg.NOT_ALLOWED}
|
|
48937
|
-
def _callbackAddItemsToCourse(request_id,
|
|
49051
|
+
def _callbackAddItemsToCourse(request_id, response, exception):
|
|
48938
49052
|
ri = request_id.splitlines()
|
|
49053
|
+
if addType == Ent.COURSE_ANNOUNCEMENT:
|
|
49054
|
+
mg = re.match(r"^{'text': '(.+)'}$", ri[RI_ITEM])
|
|
49055
|
+
if mg:
|
|
49056
|
+
riText = mg.group(1)
|
|
49057
|
+
else:
|
|
49058
|
+
riText = ''
|
|
49059
|
+
if len(riText) > 100:
|
|
49060
|
+
riItem = riText[0:100]+'...'
|
|
49061
|
+
else:
|
|
49062
|
+
riItem = riText
|
|
49063
|
+
else:
|
|
49064
|
+
riItem = ri[RI_ITEM]
|
|
48939
49065
|
if exception is None:
|
|
48940
|
-
|
|
49066
|
+
riItem = _addIdToResponse(response, riItem)
|
|
49067
|
+
entityActionPerformed([Ent.COURSE, ri[RI_ENTITY], addType, riItem], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48941
49068
|
else:
|
|
48942
49069
|
http_status, reason, message = checkGAPIError(exception)
|
|
48943
|
-
if (reason not in {GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE}) and ((reason != GAPI.NOT_FOUND) or (
|
|
49070
|
+
if (reason not in {GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE}) and ((reason != GAPI.NOT_FOUND) or (addType == Ent.COURSE_ALIAS)):
|
|
48944
49071
|
if reason in [GAPI.FORBIDDEN, GAPI.BACKEND_ERROR]:
|
|
48945
|
-
errMsg = getPhraseDNEorSNA(
|
|
49072
|
+
errMsg = getPhraseDNEorSNA(riItem)
|
|
48946
49073
|
else:
|
|
48947
49074
|
errMsg = getHTTPError(_ADD_PART_REASON_TO_MESSAGE_MAP, http_status, reason, message)
|
|
48948
|
-
if (reason == GAPI.PERMISSION_DENIED) and (
|
|
48949
|
-
errMsg += f' Add external user with: gam user {
|
|
48950
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49075
|
+
if (reason == GAPI.PERMISSION_DENIED) and (addType in {Ent.STUDENT, Ent.TEACHER}) and ('CannotDirectAddUser' in errMsg):
|
|
49076
|
+
errMsg += f' Add external user with: gam user {riItem} create classroominvitation courses {ri[RI_ENTITY]} addType {Ent.Singular(addType)}'
|
|
49077
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], addType, riItem], errMsg, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48951
49078
|
return
|
|
48952
49079
|
waitOnFailure(1, 10, reason, message)
|
|
49080
|
+
if addType in {Ent.STUDENT, Ent.TEACHER, Ent.COURSE_TOPIC}:
|
|
49081
|
+
rbody = {attribute: riItem}
|
|
49082
|
+
elif addType == Ent.COURSE_ALIAS:
|
|
49083
|
+
rbody = {attribute: addCourseAliasScope(riItem)}
|
|
49084
|
+
else: # addType == Ent.COURSE_ANNOUNCEMENT:
|
|
49085
|
+
rbody = ri[RI_ITEM]
|
|
48953
49086
|
try:
|
|
48954
|
-
callGAPI(service, 'create',
|
|
48955
|
-
|
|
48956
|
-
|
|
48957
|
-
|
|
48958
|
-
|
|
48959
|
-
|
|
48960
|
-
|
|
48961
|
-
fields='')
|
|
49087
|
+
result = callGAPI(service, 'create',
|
|
49088
|
+
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.BACKEND_ERROR,
|
|
49089
|
+
GAPI.ALREADY_EXISTS, GAPI.FAILED_PRECONDITION,
|
|
49090
|
+
GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE],
|
|
49091
|
+
retryReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE], triesLimit=0 if reason != GAPI.NOT_FOUND else 3,
|
|
49092
|
+
courseId=addCourseIdScope(ri[RI_ENTITY]), body=rbody, fields=returnFields)
|
|
49093
|
+
riItem = _addIdToResponse(result, riItem)
|
|
48962
49094
|
except (GAPI.notFound, GAPI.backendError, GAPI.forbidden):
|
|
48963
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49095
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], addType, riItem], getPhraseDNEorSNA(riItem), int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48964
49096
|
except GAPI.alreadyExists:
|
|
48965
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49097
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], addType, riItem], Msg.DUPLICATE, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48966
49098
|
except GAPI.failedPrecondition:
|
|
48967
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49099
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], addType, riItem], Msg.NOT_ALLOWED, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48968
49100
|
except (GAPI.quotaExceeded, GAPI.serviceNotAvailable) as e:
|
|
48969
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49101
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], addType, riItem], str(e), int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
48970
49102
|
|
|
49103
|
+
returnFields = ''
|
|
48971
49104
|
if addType == Ent.STUDENT:
|
|
48972
49105
|
service = croom.courses().students()
|
|
48973
49106
|
attribute = 'userId'
|
|
@@ -48980,16 +49113,18 @@ def _batchAddItemsToCourse(croom, courseId, i, count, addItems, addType):
|
|
|
48980
49113
|
elif addType == Ent.COURSE_TOPIC:
|
|
48981
49114
|
service = croom.courses().topics()
|
|
48982
49115
|
attribute = 'name'
|
|
49116
|
+
returnFields = 'topicId'
|
|
48983
49117
|
else: # addType == Ent.COURSE_ANNOUNCEMENT:
|
|
48984
49118
|
service = croom.courses().announcements()
|
|
48985
49119
|
attribute = 'text'
|
|
49120
|
+
returnFields = 'id'
|
|
48986
49121
|
method = getattr(service, 'create')
|
|
48987
49122
|
Act.Set(Act.ADD)
|
|
48988
49123
|
jcount = len(addItems)
|
|
48989
49124
|
noScopeCourseId = removeCourseIdScope(courseId)
|
|
48990
49125
|
entityPerformActionNumItems([Ent.COURSE, noScopeCourseId], jcount, addType, i, count)
|
|
48991
49126
|
Ind.Increment()
|
|
48992
|
-
svcargs = dict([('courseId', courseId), ('body', {attribute: None}), ('fields',
|
|
49127
|
+
svcargs = dict([('courseId', courseId), ('body', {attribute: None}), ('fields', returnFields)]+GM.Globals[GM.EXTRA_ARGS_LIST])
|
|
48993
49128
|
dbatch = croom.new_batch_http_request(callback=_callbackAddItemsToCourse)
|
|
48994
49129
|
bcount = 0
|
|
48995
49130
|
j = 0
|
|
@@ -49021,34 +49156,37 @@ def _batchRemoveItemsFromCourse(croom, courseId, i, count, removeItems, removeTy
|
|
|
49021
49156
|
GAPI.PERMISSION_DENIED: Msg.PERMISSION_DENIED}
|
|
49022
49157
|
def _callbackRemoveItemsFromCourse(request_id, _, exception):
|
|
49023
49158
|
ri = request_id.splitlines()
|
|
49159
|
+
riItem = ri[RI_ITEM]
|
|
49024
49160
|
if exception is None:
|
|
49025
|
-
entityActionPerformed([Ent.COURSE, ri[RI_ENTITY],
|
|
49161
|
+
entityActionPerformed([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49026
49162
|
else:
|
|
49027
49163
|
http_status, reason, message = checkGAPIError(exception)
|
|
49028
49164
|
if reason not in {GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE}:
|
|
49029
|
-
if reason == GAPI.NOT_FOUND and
|
|
49030
|
-
errMsg = f'{Msg.NOT_A} {Ent.Singular(
|
|
49165
|
+
if reason == GAPI.NOT_FOUND and removeType != Ent.COURSE_ALIAS:
|
|
49166
|
+
errMsg = f'{Msg.NOT_A} {Ent.Singular(removeType)}'
|
|
49031
49167
|
else:
|
|
49032
49168
|
errMsg = getHTTPError(_REMOVE_PART_REASON_TO_MESSAGE_MAP, http_status, reason, message)
|
|
49033
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49169
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], errMsg, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49034
49170
|
return
|
|
49035
49171
|
waitOnFailure(1, 10, reason, message)
|
|
49172
|
+
if removeType in {Ent.STUDENT, Ent.TEACHER, Ent.COURSE_TOPIC, Ent.COURSE_ANNOUNCEMENT}:
|
|
49173
|
+
rbody = {attribute: riItem}
|
|
49174
|
+
else: # removeType == Ent.COURSE_ALIAS:
|
|
49175
|
+
rbody = {attribute: addCourseAliasScope(riItem)}
|
|
49036
49176
|
try:
|
|
49037
49177
|
callGAPI(service, 'delete',
|
|
49038
49178
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED,
|
|
49039
49179
|
GAPI.QUOTA_EXCEEDED, GAPI.SERVICE_NOT_AVAILABLE, GAPI.FAILED_PRECONDITION],
|
|
49040
49180
|
retryReasons=[GAPI.NOT_FOUND, GAPI.SERVICE_NOT_AVAILABLE], triesLimit=0 if reason != GAPI.NOT_FOUND else 3,
|
|
49041
|
-
courseId=addCourseIdScope(ri[RI_ENTITY]),
|
|
49042
|
-
body={attribute: ri[RI_ITEM] if ri[RI_ROLE] != Ent.COURSE_ALIAS else addCourseAliasScope(ri[RI_ITEM])},
|
|
49043
|
-
fields='')
|
|
49181
|
+
courseId=addCourseIdScope(ri[RI_ENTITY]), body=rbody, fields='')
|
|
49044
49182
|
except GAPI.notFound:
|
|
49045
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49183
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], Msg.DOES_NOT_EXIST, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49046
49184
|
except GAPI.forbidden:
|
|
49047
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49185
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], Msg.FORBIDDEN, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49048
49186
|
except GAPI.permissionDenied:
|
|
49049
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49187
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], Msg.PERMISSION_DENIED, int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49050
49188
|
except (GAPI.quotaExceeded, GAPI.serviceNotAvailable, GAPI.failedPrecondition) as e:
|
|
49051
|
-
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY],
|
|
49189
|
+
entityActionFailedWarning([Ent.COURSE, ri[RI_ENTITY], removeType, riItem], str(e), int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
49052
49190
|
|
|
49053
49191
|
if removeType == Ent.STUDENT:
|
|
49054
49192
|
service = croom.courses().students()
|
|
@@ -49121,8 +49259,8 @@ def getCourseAnnouncement(createCmd):
|
|
|
49121
49259
|
body = {}
|
|
49122
49260
|
while Cmd.ArgumentsRemaining():
|
|
49123
49261
|
myarg = getArgument()
|
|
49124
|
-
if myarg
|
|
49125
|
-
body['text'] =
|
|
49262
|
+
if myarg in SORF_TEXT_ARGUMENTS:
|
|
49263
|
+
body['text'] = getStringOrFile(myarg, minLen=1, unescapeCRLF=True)[0]
|
|
49126
49264
|
elif myarg == 'scheduledtime':
|
|
49127
49265
|
body['scheduledTime'] = getTimeOrDeltaFromNow()
|
|
49128
49266
|
elif myarg == 'state':
|
|
@@ -49160,9 +49298,9 @@ PARTICIPANT_EN_MAP = {
|
|
|
49160
49298
|
# gam courses <CourseEntity> create alias <CourseAliasEntity>
|
|
49161
49299
|
# gam course <CourseID> create alias <CourseAlias>
|
|
49162
49300
|
# gam courses <CourseEntity> create announcement
|
|
49163
|
-
#
|
|
49301
|
+
# <CourseAnnouncementContent> [scheduledtime <Time>] [state draft|published]
|
|
49164
49302
|
# gam course <CourseID> create announcement
|
|
49165
|
-
#
|
|
49303
|
+
# <CourseAnnouncementContent> [scheduledtime <Time>] [state draft|published]
|
|
49166
49304
|
# gam courses <CourseEntity> create topic <CourseTopicEntity>
|
|
49167
49305
|
# gam course <CourseID> create topic <CourseTopic>
|
|
49168
49306
|
# gam courses <CourseEntity> create students <UserTypeEntity>
|
|
@@ -49270,9 +49408,9 @@ def doCourseRemoveItems(courseIdList, getEntityListArg):
|
|
|
49270
49408
|
_batchRemoveItemsFromCourse(courseInfo['croom'], courseId, i, count, removeItems, removeType)
|
|
49271
49409
|
|
|
49272
49410
|
# gam courses <CourseEntity> update announcement <CourseAnnouncemntIDEntity>
|
|
49273
|
-
# [
|
|
49411
|
+
# [<CourseAnnouncementContent>] [scheduledtime <Time>] [state published]
|
|
49274
49412
|
# gam course <CourseID> update announcement <CourseAnnouncementID>
|
|
49275
|
-
# [
|
|
49413
|
+
# [<CourseAnnouncementContent>] [scheduledtime <Time>] [state published]
|
|
49276
49414
|
# gam courses <CourseEntity> update topic <CourseTopicIDEntity> <CourseTopic>
|
|
49277
49415
|
# gam course <CourseID> update topic <CourseTopicID> <CourseTopic>
|
|
49278
49416
|
def doCourseUpdateItems(courseIdList, getEntityListArg):
|
|
@@ -49520,7 +49658,8 @@ def _cancelGuardianInvitation(croom, studentId, invitationId, i=0, count=0, j=0,
|
|
|
49520
49658
|
entityActionFailedWarning([Ent.STUDENT, studentId, Ent.GUARDIAN_INVITATION, invitationId], str(e), j, jcount)
|
|
49521
49659
|
return -1
|
|
49522
49660
|
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
49523
|
-
|
|
49661
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
49662
|
+
# studentUnknownWarning(studentId, str(e), i, count)
|
|
49524
49663
|
return -1
|
|
49525
49664
|
|
|
49526
49665
|
# gam cancel guardianinvitation|guardianinvitations <GuardianInvitationID> <StudentItem>
|
|
@@ -49565,7 +49704,8 @@ def _deleteGuardian(croom, studentId, guardianId, guardianEmail, i, count, j, jc
|
|
|
49565
49704
|
entityActionFailedWarning([Ent.STUDENT, studentId, Ent.GUARDIAN, guardianEmail], str(e), j, jcount)
|
|
49566
49705
|
return -1
|
|
49567
49706
|
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
49568
|
-
|
|
49707
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
49708
|
+
# studentUnknownWarning(studentId, str(e), i, count)
|
|
49569
49709
|
return -1
|
|
49570
49710
|
|
|
49571
49711
|
def _doDeleteGuardian(croom, studentId, guardianId, guardianClass, i=0, count=0, j=0, jcount=0):
|
|
@@ -52675,7 +52815,8 @@ def doSharedDriveSearch(drive, user, i, count, query, useDomainAdminAccess):
|
|
|
52675
52815
|
pageMessage=getPageMessageForWhom(),
|
|
52676
52816
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
|
52677
52817
|
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
|
52678
|
-
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE
|
|
52818
|
+
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
52819
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
|
52679
52820
|
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
|
52680
52821
|
fields='nextPageToken,drives(id)', pageSize=100)
|
|
52681
52822
|
if files:
|
|
@@ -52683,7 +52824,7 @@ def doSharedDriveSearch(drive, user, i, count, query, useDomainAdminAccess):
|
|
|
52683
52824
|
entityActionNotPerformedWarning([Ent.USER, user, Ent.DRIVE_FILE, None], emptyQuery(query, Ent.SHAREDDRIVE), i, count)
|
|
52684
52825
|
except (GAPI.invalidQuery, GAPI.invalid):
|
|
52685
52826
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], invalidQuery(query), i, count)
|
|
52686
|
-
except (GAPI.queryRequiresAdminCredentials, GAPI.noListTeamDrivesAdministratorPrivilege) as e:
|
|
52827
|
+
except (GAPI.queryRequiresAdminCredentials, GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
|
52687
52828
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
|
52688
52829
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
52689
52830
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
@@ -52986,7 +53127,11 @@ def _convertSharedDriveNameToId(drive, user, i, count, fileIdEntity, useDomainAd
|
|
|
52986
53127
|
else:
|
|
52987
53128
|
name = fileIdEntity['shareddrivename'].replace("'", "\\'")
|
|
52988
53129
|
tdlist = callGAPIpages(drive.drives(), 'list', 'drives',
|
|
52989
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
|
53130
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
|
53131
|
+
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
|
53132
|
+
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
53133
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES,
|
|
53134
|
+
GAPI.FILE_NOT_FOUND],
|
|
52990
53135
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
52991
53136
|
q=f"name='{name}'",
|
|
52992
53137
|
fields='nextPageToken,drives(id,name)', pageSize=100)
|
|
@@ -52995,13 +53140,19 @@ def _convertSharedDriveNameToId(drive, user, i, count, fileIdEntity, useDomainAd
|
|
|
52995
53140
|
if not tdlist:
|
|
52996
53141
|
name = fileIdEntity['shareddrivename'].lower()
|
|
52997
53142
|
feed = callGAPIpages(drive.drives(), 'list', 'drives',
|
|
52998
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
|
53143
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
53144
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
|
52999
53145
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
53000
53146
|
fields='nextPageToken,drives(id,name)', pageSize=100)
|
|
53001
53147
|
tdlist = [td for td in feed if td['name'].lower() == name]
|
|
53002
53148
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
|
53003
53149
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_NAME, fileIdEntity['shareddrivename']], Msg.DOES_NOT_EXIST, i, count)
|
|
53004
53150
|
return False
|
|
53151
|
+
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
|
53152
|
+
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges,
|
|
53153
|
+
GAPI.fileNotFound) as e:
|
|
53154
|
+
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_NAME, fileIdEntity['shareddrivename']], str(e), i, count)
|
|
53155
|
+
return False
|
|
53005
53156
|
jcount = len(tdlist)
|
|
53006
53157
|
if jcount == 1:
|
|
53007
53158
|
fileIdEntity['shareddrive']['driveId'] = tdlist[0]['id']
|
|
@@ -53019,10 +53170,10 @@ def _getSharedDriveNameFromId(drive, sharedDriveId, useDomainAdminAccess=False):
|
|
|
53019
53170
|
if not sharedDriveName:
|
|
53020
53171
|
try:
|
|
53021
53172
|
sharedDriveName = callGAPI(drive.drives(), 'get',
|
|
53022
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
53173
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
53023
53174
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
53024
53175
|
driveId=sharedDriveId, fields='name')['name']
|
|
53025
|
-
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
|
53176
|
+
except (GAPI.fileNotFound, GAPI.notFound, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
|
53026
53177
|
sharedDriveName = TEAM_DRIVE
|
|
53027
53178
|
GM.Globals[GM.MAP_SHAREDDRIVE_ID_TO_NAME][sharedDriveId] = sharedDriveName
|
|
53028
53179
|
return sharedDriveName
|
|
@@ -53043,7 +53194,7 @@ def _getDriveFileNameFromId(drive, fileId, combineTitleId=True, useDomainAdminAc
|
|
|
53043
53194
|
if useDomainAdminAccess:
|
|
53044
53195
|
try:
|
|
53045
53196
|
result = callGAPI(drive.drives(), 'get',
|
|
53046
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
53197
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
53047
53198
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
53048
53199
|
driveId=fileId, fields='name')
|
|
53049
53200
|
if result:
|
|
@@ -53051,7 +53202,7 @@ def _getDriveFileNameFromId(drive, fileId, combineTitleId=True, useDomainAdminAc
|
|
|
53051
53202
|
if combineTitleId:
|
|
53052
53203
|
fileName += '('+fileId+')'
|
|
53053
53204
|
return (fileName, Ent.DRIVE_FOLDER, MIMETYPE_GA_FOLDER)
|
|
53054
|
-
except GAPI.notFound:
|
|
53205
|
+
except (GAPI.fileNotFound, GAPI.notFound):
|
|
53055
53206
|
pass
|
|
53056
53207
|
except (GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.internalError,
|
|
53057
53208
|
GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
|
@@ -53217,7 +53368,7 @@ def _getDriveFileParentInfo(drive, user, i, count, body, parameters, emptyQueryO
|
|
|
53217
53368
|
_setSearchArgs(result['driveId'])
|
|
53218
53369
|
else:
|
|
53219
53370
|
result = callGAPI(drive.drives(), 'get',
|
|
53220
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
53371
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
53221
53372
|
driveId=parameters[DFA_SHAREDDRIVE_PARENTID], fields='id')
|
|
53222
53373
|
parameters[DFA_KWARGS]['corpora'] = 'drive'
|
|
53223
53374
|
parameters[DFA_KWARGS]['driveId'] = result['id']
|
|
@@ -54427,6 +54578,7 @@ DRIVE_CAPABILITIES_SUBFIELDS_CHOICE_MAP = {
|
|
|
54427
54578
|
'canaddmydriveparent': 'canAddMyDriveParent',
|
|
54428
54579
|
'canchangecopyrequireswriterpermission': 'canChangeCopyRequiresWriterPermission',
|
|
54429
54580
|
'canchangecopyrequireswriterpermissionrestriction': 'canChangeCopyRequiresWriterPermissionRestriction',
|
|
54581
|
+
'canchangedownloadrestriction': 'canChangeDownloadRestriction',
|
|
54430
54582
|
'canchangedomainusersonlyrestriction': 'canChangeDomainUsersOnlyRestriction',
|
|
54431
54583
|
'canchangedrivebackground': 'canChangeDriveBackground',
|
|
54432
54584
|
'canchangedrivemembersonlyrestriction': 'canChangeDriveMembersOnlyRestriction',
|
|
@@ -55443,7 +55595,7 @@ def initFileTree(drive, shareddrive, DLP, shareddriveFields, showParent, user, i
|
|
|
55443
55595
|
f_file['parents'] = []
|
|
55444
55596
|
fileTree[f_file['id']] = {'info': f_file, 'noParents': True, 'children': []}
|
|
55445
55597
|
name = callGAPI(drive.drives(), 'get',
|
|
55446
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
55598
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
55447
55599
|
driveId=fileId, fields='name')['name']
|
|
55448
55600
|
fileTree[f_file['id']]['info']['name'] = f'{SHARED_DRIVES}/{name}'
|
|
55449
55601
|
else:
|
|
@@ -56629,12 +56781,12 @@ def printFileList(users):
|
|
|
56629
56781
|
rootFolderId = fileIdEntity['shareddrive']['driveId']
|
|
56630
56782
|
if not fileIdEntity['shareddrivename']:
|
|
56631
56783
|
fileIdEntity['shareddrivename'] = callGAPI(drive.drives(), 'get',
|
|
56632
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.
|
|
56784
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
56633
56785
|
driveId=rootFolderId, fields='name')['name']
|
|
56634
56786
|
rootFolderName = fileIdEntity['shareddrivename']
|
|
56635
56787
|
if not showParentsIdsAsList and DFF.parentsSubFields['isRoot']:
|
|
56636
56788
|
DFF.parentsSubFields['rootFolderId'] = rootFolderId
|
|
56637
|
-
except (GAPI.
|
|
56789
|
+
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
|
56638
56790
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, fileIdEntity['shareddrive']['driveId']], str(e), i, count)
|
|
56639
56791
|
continue
|
|
56640
56792
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
@@ -65496,6 +65648,8 @@ SHAREDDRIVE_RESTRICTIONS_MAP = {
|
|
|
65496
65648
|
'allowcontentmanagerstosharefolders': 'sharingFoldersRequiresOrganizerPermission',
|
|
65497
65649
|
'copyrequireswriterpermission': 'copyRequiresWriterPermission',
|
|
65498
65650
|
'domainusersonly': 'domainUsersOnly',
|
|
65651
|
+
'downloadrestrictedforreaders': 'restrictedForReaders',
|
|
65652
|
+
'downloadrestrictedforwriters': 'restrictedForWriters',
|
|
65499
65653
|
'drivemembersonly': 'driveMembersOnly',
|
|
65500
65654
|
'sharingfoldersrequiresorganizerpermission': 'sharingFoldersRequiresOrganizerPermission',
|
|
65501
65655
|
'teammembersonly': 'driveMembersOnly',
|
|
@@ -65504,7 +65658,10 @@ SHAREDDRIVE_RESTRICTIONS_MAP = {
|
|
|
65504
65658
|
def _getSharedDriveRestrictions(myarg, body):
|
|
65505
65659
|
def _setRestriction(restriction):
|
|
65506
65660
|
body.setdefault('restrictions', {})
|
|
65507
|
-
if restriction
|
|
65661
|
+
if restriction in {'downloadrestrictedforreaders', 'downloadrestrictedforwriters'}:
|
|
65662
|
+
body['restrictions'].setdefault('downloadRestriction', {})
|
|
65663
|
+
body['restrictions']['downloadRestriction'][SHAREDDRIVE_RESTRICTIONS_MAP[restriction]] = getBoolean()
|
|
65664
|
+
elif restriction != 'allowcontentmanagerstosharefolders':
|
|
65508
65665
|
body['restrictions'][SHAREDDRIVE_RESTRICTIONS_MAP[restriction]] = getBoolean()
|
|
65509
65666
|
else:
|
|
65510
65667
|
body['restrictions'][SHAREDDRIVE_RESTRICTIONS_MAP[restriction]] = not getBoolean()
|
|
@@ -65657,12 +65814,12 @@ def createSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65657
65814
|
while not created:
|
|
65658
65815
|
try:
|
|
65659
65816
|
callGAPI(drive.drives(), 'get',
|
|
65660
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
65817
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
65661
65818
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
65662
65819
|
driveId=driveId, fields='id')
|
|
65663
65820
|
created = True
|
|
65664
65821
|
break
|
|
65665
|
-
except GAPI.notFound as e:
|
|
65822
|
+
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
|
65666
65823
|
retry += 1
|
|
65667
65824
|
if retry > errorRetries:
|
|
65668
65825
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
|
@@ -65678,6 +65835,7 @@ def createSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65678
65835
|
bailOnInternalError=True,
|
|
65679
65836
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND, GAPI.FORBIDDEN,
|
|
65680
65837
|
GAPI.NO_MANAGE_TEAMDRIVE_ADMINISTRATOR_PRIVILEGE,
|
|
65838
|
+
GAPI.OUTSIDE_DOMAIN_MEMBER_CANNOT_CHANGE_TEAMDRIVE_RESTRICTIONS,
|
|
65681
65839
|
GAPI.BAD_REQUEST, GAPI.INTERNAL_ERROR, GAPI.PERMISSION_DENIED,
|
|
65682
65840
|
GAPI.FILE_NOT_FOUND],
|
|
65683
65841
|
useDomainAdminAccess=useDomainAdminAccess, driveId=driveId, body=updateBody)
|
|
@@ -65697,7 +65855,8 @@ def createSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65697
65855
|
if orgUnit:
|
|
65698
65856
|
waitingForCreationToComplete(moveToOrgUnitDelay)
|
|
65699
65857
|
ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci, returnIdOnly or csvPF)
|
|
65700
|
-
except (GAPI.notFound, GAPI.forbidden, GAPI.badRequest,
|
|
65858
|
+
except (GAPI.notFound, GAPI.forbidden, GAPI.badRequest,
|
|
65859
|
+
GAPI.noManageTeamDriveAdministratorPrivilege, GAPI.outsideDomainMemberCannotChangeTeamDriveRestrictions) as e:
|
|
65701
65860
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
|
65702
65861
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
65703
65862
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
@@ -65752,6 +65911,7 @@ def updateSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65752
65911
|
bailOnInternalError=True,
|
|
65753
65912
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.BAD_REQUEST,
|
|
65754
65913
|
GAPI.NO_MANAGE_TEAMDRIVE_ADMINISTRATOR_PRIVILEGE,
|
|
65914
|
+
GAPI.OUTSIDE_DOMAIN_MEMBER_CANNOT_CHANGE_TEAMDRIVE_RESTRICTIONS,
|
|
65755
65915
|
GAPI.INTERNAL_ERROR, GAPI.FILE_NOT_FOUND],
|
|
65756
65916
|
useDomainAdminAccess=useDomainAdminAccess, driveId=driveId, body=body, fields='name')
|
|
65757
65917
|
entityActionPerformed([Ent.USER, user, Ent.SHAREDDRIVE_NAME, result['name'], Ent.SHAREDDRIVE_ID, driveId], i, count)
|
|
@@ -65769,7 +65929,7 @@ def updateSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65769
65929
|
if orgUnit:
|
|
65770
65930
|
ci = _moveSharedDriveToOU(orgUnit, orgUnitId, driveId, user, i, count, ci, False)
|
|
65771
65931
|
except (GAPI.notFound, GAPI.forbidden, GAPI.badRequest, GAPI.internalError,
|
|
65772
|
-
GAPI.noManageTeamDriveAdministratorPrivilege) as e:
|
|
65932
|
+
GAPI.noManageTeamDriveAdministratorPrivilege, GAPI.outsideDomainMemberCannotChangeTeamDriveRestrictions) as e:
|
|
65773
65933
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
|
65774
65934
|
except GAPI.fileNotFound as e:
|
|
65775
65935
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId,
|
|
@@ -65898,14 +66058,6 @@ def _getSharedDriveRole(shareddrive):
|
|
|
65898
66058
|
return role
|
|
65899
66059
|
|
|
65900
66060
|
def _showSharedDrive(user, shareddrive, j, jcount, FJQC):
|
|
65901
|
-
def _showCapabilitiesRestrictions(field):
|
|
65902
|
-
if field in shareddrive:
|
|
65903
|
-
printKeyValueList([field, ''])
|
|
65904
|
-
Ind.Increment()
|
|
65905
|
-
for capability in sorted(shareddrive[field]):
|
|
65906
|
-
printKeyValueList([capability, shareddrive[field][capability]])
|
|
65907
|
-
Ind.Decrement()
|
|
65908
|
-
|
|
65909
66061
|
if FJQC.formatJSON:
|
|
65910
66062
|
printLine(json.dumps(cleanJSON(shareddrive, timeObjects=SHAREDDRIVE_TIME_OBJECTS), ensure_ascii=False, sort_keys=True))
|
|
65911
66063
|
return
|
|
@@ -65922,8 +66074,9 @@ def _showSharedDrive(user, shareddrive, j, jcount, FJQC):
|
|
|
65922
66074
|
printKeyValueList([setting, shareddrive[setting]])
|
|
65923
66075
|
if 'role' in shareddrive:
|
|
65924
66076
|
printKeyValueList(['role', shareddrive['role']])
|
|
65925
|
-
|
|
65926
|
-
|
|
66077
|
+
for setting in ['capabilities', 'restrictions']:
|
|
66078
|
+
if setting in shareddrive:
|
|
66079
|
+
showJSON(setting, shareddrive[setting])
|
|
65927
66080
|
Ind.Decrement()
|
|
65928
66081
|
|
|
65929
66082
|
# gam <UserTypeEntity> info shareddrive <SharedDriveEntity>
|
|
@@ -65955,14 +66108,14 @@ def infoSharedDrive(users, useDomainAdminAccess=False):
|
|
|
65955
66108
|
try:
|
|
65956
66109
|
driveId = fileIdEntity['shareddrive']['driveId']
|
|
65957
66110
|
shareddrive = callGAPI(drive.drives(), 'get',
|
|
65958
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
66111
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
65959
66112
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
65960
66113
|
driveId=driveId, fields=fields)
|
|
65961
66114
|
role = _getSharedDriveRole(shareddrive)
|
|
65962
66115
|
if role:
|
|
65963
66116
|
shareddrive['role'] = role if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[role]
|
|
65964
66117
|
_showSharedDrive(user, shareddrive, i, count, FJQC)
|
|
65965
|
-
except GAPI.notFound as e:
|
|
66118
|
+
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
|
65966
66119
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
|
65967
66120
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
65968
66121
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
@@ -66116,11 +66269,13 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
|
|
|
66116
66269
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
|
66117
66270
|
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
|
66118
66271
|
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
66272
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES,
|
|
66119
66273
|
GAPI.FILE_NOT_FOUND],
|
|
66120
66274
|
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
|
66121
66275
|
fields='*', pageSize=100)
|
|
66122
66276
|
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
|
66123
|
-
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.
|
|
66277
|
+
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges,
|
|
66278
|
+
GAPI.fileNotFound) as e:
|
|
66124
66279
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
|
66125
66280
|
continue
|
|
66126
66281
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
@@ -66455,8 +66610,10 @@ def printShowSharedDriveACLs(users, useDomainAdminAccess=False):
|
|
|
66455
66610
|
if userdrive is not None:
|
|
66456
66611
|
try:
|
|
66457
66612
|
feed = callGAPIpages(userdrive.drives(), 'list', 'drives',
|
|
66458
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
|
66613
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID, GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE],
|
|
66459
66614
|
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
|
66615
|
+
except (GAPI.invalid, GAPI.noListTeamDrivesAdministratorPrivilege):
|
|
66616
|
+
pass
|
|
66460
66617
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
|
66461
66618
|
pass
|
|
66462
66619
|
if feed is None:
|
|
@@ -66471,10 +66628,12 @@ def printShowSharedDriveACLs(users, useDomainAdminAccess=False):
|
|
|
66471
66628
|
pageMessage=pageMessage,
|
|
66472
66629
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
|
66473
66630
|
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
|
66474
|
-
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE
|
|
66631
|
+
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
66632
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
|
66475
66633
|
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
|
66476
66634
|
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
|
66477
|
-
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
|
66635
|
+
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
|
66636
|
+
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
|
66478
66637
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
|
66479
66638
|
continue
|
|
66480
66639
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
@@ -66705,11 +66864,11 @@ def printSharedDriveOrganizers(users, useDomainAdminAccess=False):
|
|
|
66705
66864
|
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
|
66706
66865
|
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
|
66707
66866
|
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
|
66708
|
-
GAPI.
|
|
66867
|
+
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
|
66709
66868
|
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
|
66710
66869
|
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
|
66711
66870
|
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
|
66712
|
-
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.
|
|
66871
|
+
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
|
66713
66872
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
|
66714
66873
|
continue
|
|
66715
66874
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
@@ -66723,7 +66882,7 @@ def printSharedDriveOrganizers(users, useDomainAdminAccess=False):
|
|
|
66723
66882
|
j +=1
|
|
66724
66883
|
try:
|
|
66725
66884
|
feed.append(callGAPI(drive.drives(), 'get',
|
|
66726
|
-
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
|
66885
|
+
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
|
66727
66886
|
useDomainAdminAccess=useDomainAdminAccess,
|
|
66728
66887
|
driveId=driveId, fields='id,name,createdTime,orgUnitId'))
|
|
66729
66888
|
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
|
@@ -67179,7 +67338,7 @@ def _addUserToGroups(cd, user, addGroupsSet, addGroups, i, count):
|
|
|
67179
67338
|
retryReasons=GAPI.MEMBERS_RETRY_REASONS,
|
|
67180
67339
|
groupKey=group, body=body, fields='')
|
|
67181
67340
|
entityActionPerformed([Ent.GROUP, group, role, user], j, jcount)
|
|
67182
|
-
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid
|
|
67341
|
+
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid):
|
|
67183
67342
|
entityUnknownWarning(Ent.GROUP, group, j, jcount)
|
|
67184
67343
|
except (GAPI.duplicate, GAPI.cyclicMembershipsNotAllowed, GAPI.conditionNotMet, GAPI.serviceNotAvailable) as e:
|
|
67185
67344
|
entityActionFailedWarning([Ent.GROUP, group, role, user], str(e), j, jcount)
|
|
@@ -67187,6 +67346,8 @@ def _addUserToGroups(cd, user, addGroupsSet, addGroups, i, count):
|
|
|
67187
67346
|
entityActionPerformedMessage([Ent.GROUP, group, role, user], Msg.ACTION_MAY_BE_DELAYED, j, jcount)
|
|
67188
67347
|
except (GAPI.memberNotFound, GAPI.resourceNotFound, GAPI.invalidMember) as e:
|
|
67189
67348
|
entityActionFailedWarning([Ent.USER, user], str(e), i, count)
|
|
67349
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67350
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67190
67351
|
Ind.Decrement()
|
|
67191
67352
|
|
|
67192
67353
|
# gam <UserTypeEntity> add group|groups
|
|
@@ -67246,12 +67407,14 @@ def _deleteUserFromGroups(cd, user, deleteGroupsSet, deleteGroups, i, count):
|
|
|
67246
67407
|
retryReasons=GAPI.MEMBERS_RETRY_REASONS,
|
|
67247
67408
|
groupKey=group, memberKey=user)
|
|
67248
67409
|
entityActionPerformed([Ent.GROUP, group, role, user], j, jcount)
|
|
67249
|
-
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid
|
|
67410
|
+
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid):
|
|
67250
67411
|
entityUnknownWarning(Ent.GROUP, group, j, jcount)
|
|
67251
67412
|
except (GAPI.memberNotFound, GAPI.invalidMember, GAPI.conditionNotMet, GAPI.serviceNotAvailable) as e:
|
|
67252
67413
|
entityActionFailedWarning([Ent.USER, user, Ent.GROUP, group], str(e), j, jcount)
|
|
67253
67414
|
except GAPI.conflict:
|
|
67254
67415
|
entityActionPerformedMessage([Ent.GROUP, group, role, user], Msg.ACTION_MAY_BE_DELAYED, j, jcount)
|
|
67416
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67417
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67255
67418
|
Ind.Decrement()
|
|
67256
67419
|
|
|
67257
67420
|
def _getUserGroupOptionalDomainCustomerId():
|
|
@@ -67318,8 +67481,10 @@ def deleteUserFromGroups(users):
|
|
|
67318
67481
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67319
67482
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, user)
|
|
67320
67483
|
continue
|
|
67321
|
-
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.
|
|
67484
|
+
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.badRequest):
|
|
67322
67485
|
accessErrorExit(cd)
|
|
67486
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67487
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67323
67488
|
deleteGroups = {}
|
|
67324
67489
|
for group in result:
|
|
67325
67490
|
if not matchPattern or checkUserGroupMatchPattern(group['email'], matchPattern):
|
|
@@ -67348,10 +67513,12 @@ def _updateUserGroups(cd, user, updateGroupsSet, updateGroups, i, count):
|
|
|
67348
67513
|
retryReasons=GAPI.MEMBERS_RETRY_REASONS,
|
|
67349
67514
|
groupKey=group, memberKey=user, body=body, fields='')
|
|
67350
67515
|
entityActionPerformed([Ent.GROUP, group, role, user], j, jcount)
|
|
67351
|
-
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid
|
|
67516
|
+
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid):
|
|
67352
67517
|
entityUnknownWarning(Ent.GROUP, group, j, jcount)
|
|
67353
67518
|
except (GAPI.memberNotFound, GAPI.invalidMember, GAPI.conditionNotMet, GAPI.serviceNotAvailable) as e:
|
|
67354
67519
|
entityActionFailedWarning([Ent.USER, user, Ent.GROUP, group], str(e), j, jcount)
|
|
67520
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67521
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67355
67522
|
Ind.Decrement()
|
|
67356
67523
|
|
|
67357
67524
|
# gam <UserTypeEntity> update group|groups
|
|
@@ -67398,8 +67565,10 @@ def updateUserGroups(users):
|
|
|
67398
67565
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67399
67566
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, user)
|
|
67400
67567
|
continue
|
|
67401
|
-
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.
|
|
67568
|
+
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.badRequest):
|
|
67402
67569
|
accessErrorExit(cd)
|
|
67570
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67571
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67403
67572
|
updateGroups = {}
|
|
67404
67573
|
for group in result:
|
|
67405
67574
|
updateGroups[group['email']] = {'role': baseRole, 'delivery_settings': baseDeliverySettings}
|
|
@@ -67473,8 +67642,10 @@ def syncUserWithGroups(users):
|
|
|
67473
67642
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67474
67643
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, user)
|
|
67475
67644
|
continue
|
|
67476
|
-
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.
|
|
67645
|
+
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.badRequest):
|
|
67477
67646
|
accessErrorExit(cd)
|
|
67647
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67648
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67478
67649
|
for groupEntity in entityList:
|
|
67479
67650
|
groupEmail = groupEntity['email']
|
|
67480
67651
|
try:
|
|
@@ -67593,7 +67764,7 @@ def checkUserInGroups(users):
|
|
|
67593
67764
|
retryReasons=GAPI.MEMBERS_RETRY_REASONS,
|
|
67594
67765
|
groupKey=groupEmail, memberKey=user, fields='role')
|
|
67595
67766
|
_checkMember(result)
|
|
67596
|
-
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid
|
|
67767
|
+
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid):
|
|
67597
67768
|
entityUnknownWarning(Ent.GROUP, groupEmail, j, jcount)
|
|
67598
67769
|
_setCheckError()
|
|
67599
67770
|
except GAPI.memberNotFound:
|
|
@@ -67605,6 +67776,8 @@ def checkUserInGroups(users):
|
|
|
67605
67776
|
except (GAPI.invalidMember, GAPI.conditionNotMet, GAPI.serviceNotAvailable) as e:
|
|
67606
67777
|
entityActionFailedWarning([Ent.USER, user, Ent.GROUP, groupEmail], str(e), j, jcount)
|
|
67607
67778
|
_setCheckError()
|
|
67779
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67780
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67608
67781
|
else:
|
|
67609
67782
|
try:
|
|
67610
67783
|
result = callGAPIpages(cd.members(), 'list', 'members',
|
|
@@ -67622,12 +67795,14 @@ def checkUserInGroups(users):
|
|
|
67622
67795
|
else:
|
|
67623
67796
|
csvPF.WriteRow({'user': user, 'group': groupEmail, 'role': notMemberOrRole})
|
|
67624
67797
|
_setCheckError()
|
|
67625
|
-
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid
|
|
67798
|
+
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid):
|
|
67626
67799
|
entityUnknownWarning(Ent.GROUP, groupEmail, j, jcount)
|
|
67627
67800
|
_setCheckError()
|
|
67628
67801
|
except (GAPI.invalidMember, GAPI.conditionNotMet, GAPI.serviceNotAvailable) as e:
|
|
67629
67802
|
entityActionFailedWarning([Ent.USER, user, Ent.GROUP, groupEmail], str(e), j, jcount)
|
|
67630
67803
|
_setCheckError()
|
|
67804
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67805
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67631
67806
|
Ind.Decrement()
|
|
67632
67807
|
if csvPF:
|
|
67633
67808
|
csvPF.writeCSVfile('User Check Groups')
|
|
@@ -67706,11 +67881,13 @@ def printShowUserGroups(users):
|
|
|
67706
67881
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67707
67882
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, user)
|
|
67708
67883
|
continue
|
|
67709
|
-
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.
|
|
67884
|
+
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.badRequest):
|
|
67710
67885
|
if kwargs.get('domain'):
|
|
67711
67886
|
badRequestWarning(Ent.GROUP, Ent.DOMAIN, kwargs['domain'])
|
|
67712
67887
|
return
|
|
67713
67888
|
accessErrorExit(cd)
|
|
67889
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
67890
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67714
67891
|
jcount = len(entityList)
|
|
67715
67892
|
if totalOnly:
|
|
67716
67893
|
if not csvPF:
|
|
@@ -67840,6 +68017,8 @@ def printShowGroupTree(users):
|
|
|
67840
68017
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67841
68018
|
entityUnknownWarning(Ent.USER, user, i, count)
|
|
67842
68019
|
continue
|
|
68020
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
68021
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67843
68022
|
j = 0
|
|
67844
68023
|
jcount = len(groups)
|
|
67845
68024
|
if not csvPF and not FJQC.formatJSON:
|
|
@@ -67932,11 +68111,13 @@ def printUserGroupsList(users):
|
|
|
67932
68111
|
except (GAPI.invalidMember, GAPI.invalidInput):
|
|
67933
68112
|
badRequestWarning(Ent.GROUP, Ent.MEMBER, user)
|
|
67934
68113
|
continue
|
|
67935
|
-
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.
|
|
68114
|
+
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.badRequest):
|
|
67936
68115
|
if kwargs.get('domain'):
|
|
67937
68116
|
badRequestWarning(Ent.GROUP, Ent.DOMAIN, kwargs['domain'])
|
|
67938
68117
|
return
|
|
67939
68118
|
accessErrorExit(cd)
|
|
68119
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
68120
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
67940
68121
|
csvPF.WriteRow({'User': user, 'Groups': len(entityList), 'GroupsList': delimiter.join([group['email'] for group in entityList])})
|
|
67941
68122
|
csvPF.writeCSVfile('User GroupsList')
|
|
67942
68123
|
|
|
@@ -69119,19 +69300,23 @@ def deleteTokens(users):
|
|
|
69119
69300
|
try:
|
|
69120
69301
|
callGAPI(cd.tokens(), 'get',
|
|
69121
69302
|
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
|
69122
|
-
GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
69123
|
-
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND
|
|
69303
|
+
GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
69304
|
+
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND,
|
|
69305
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
69124
69306
|
userKey=user, clientId=clientId, fields='')
|
|
69125
69307
|
callGAPI(cd.tokens(), 'delete',
|
|
69126
69308
|
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
|
69127
|
-
GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
69128
|
-
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND
|
|
69309
|
+
GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
69310
|
+
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND,
|
|
69311
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
69129
69312
|
userKey=user, clientId=clientId)
|
|
69130
69313
|
entityActionPerformed([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], i, count)
|
|
69131
69314
|
except (GAPI.notFound, GAPI.resourceNotFound) as e:
|
|
69132
69315
|
entityActionFailedWarning([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], str(e), i, count)
|
|
69133
|
-
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis
|
|
69316
|
+
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis):
|
|
69134
69317
|
entityUnknownWarning(Ent.USER, user, i, count)
|
|
69318
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
69319
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
69135
69320
|
|
|
69136
69321
|
TOKENS_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'userKey', 'scopes']
|
|
69137
69322
|
TOKENS_AGGREGATE_FIELDS_TITLES = ['clientId', 'displayText', 'anonymous', 'nativeApp', 'users', 'scopes']
|
|
@@ -69225,13 +69410,15 @@ def _printShowTokens(entityType, users):
|
|
|
69225
69410
|
if clientId:
|
|
69226
69411
|
results = [callGAPI(cd.tokens(), 'get',
|
|
69227
69412
|
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
|
69228
|
-
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.
|
|
69229
|
-
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND
|
|
69413
|
+
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.BAD_REQUEST,
|
|
69414
|
+
GAPI.NOT_FOUND, GAPI.RESOURCE_NOT_FOUND,
|
|
69415
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
69230
69416
|
userKey=user, clientId=clientId, fields=fields)]
|
|
69231
69417
|
else:
|
|
69232
69418
|
results = callGAPIitems(cd.tokens(), 'list', 'items',
|
|
69233
69419
|
throwReasons=[GAPI.USER_NOT_FOUND, GAPI.DOMAIN_NOT_FOUND,
|
|
69234
|
-
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.
|
|
69420
|
+
GAPI.DOMAIN_CANNOT_USE_APIS, GAPI.BAD_REQUEST,
|
|
69421
|
+
GAPI.FORBIDDEN, GAPI.PERMISSION_DENIED],
|
|
69235
69422
|
userKey=user, fields=f'items({fields})')
|
|
69236
69423
|
jcount = len(results)
|
|
69237
69424
|
if not aggregateUsersBy:
|
|
@@ -69271,8 +69458,10 @@ def _printShowTokens(entityType, users):
|
|
|
69271
69458
|
aggregateTokensById[user] = jcount
|
|
69272
69459
|
except (GAPI.notFound, GAPI.resourceNotFound) as e:
|
|
69273
69460
|
entityActionFailedWarning([Ent.USER, user, Ent.ACCESS_TOKEN, clientId], str(e), i, count)
|
|
69274
|
-
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.
|
|
69461
|
+
except (GAPI.userNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.badRequest):
|
|
69275
69462
|
entityUnknownWarning(Ent.USER, user, i, count)
|
|
69463
|
+
except (GAPI.forbidden, GAPI.permissionDenied) as e:
|
|
69464
|
+
ClientAPIAccessDeniedExit(str(e))
|
|
69276
69465
|
if aggregateUsersBy == 'clientId':
|
|
69277
69466
|
if not csvPF:
|
|
69278
69467
|
jcount = len(aggregateTokensById)
|
|
@@ -76487,6 +76676,7 @@ MAIN_COMMANDS_WITH_OBJECTS = {
|
|
|
76487
76676
|
Cmd.ARG_USERINVITATION: doCheckCIUserInvitations,
|
|
76488
76677
|
Cmd.ARG_ISINVITABLE: doCheckCIUserInvitations,
|
|
76489
76678
|
Cmd.ARG_ORG: doCheckOrgUnit,
|
|
76679
|
+
Cmd.ARG_SUSPENDED: doCheckUserSuspended,
|
|
76490
76680
|
}
|
|
76491
76681
|
),
|
|
76492
76682
|
'clear':
|