|
|
|
|
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
|
|
|
|
__version__ = '7.05.02'
|
|
|
|
|
__version__ = '7.05.06'
|
|
|
|
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
|
|
|
|
|
|
|
|
|
#pylint: disable=wrong-import-position
|
|
|
|
|
@@ -5751,14 +5751,18 @@ def convertUIDtoEmailAddressWithType(emailAddressOrUID, cd=None, sal=None, email
|
|
|
|
|
return (uid, 'serviceaccount')
|
|
|
|
|
return (normalizedEmailAddressOrUID, 'unknown')
|
|
|
|
|
|
|
|
|
|
NON_EMAIL_MEMBER_PREFIXES = (
|
|
|
|
|
"cbcm-browser.",
|
|
|
|
|
"chrome-os-device.",
|
|
|
|
|
)
|
|
|
|
|
# Convert UID to email address
|
|
|
|
|
def convertUIDtoEmailAddress(emailAddressOrUID, cd=None, emailTypes=None,
|
|
|
|
|
checkForCustomerId=False, ciGroupsAPI=False, aliasAllowed=True):
|
|
|
|
|
if ciGroupsAPI:
|
|
|
|
|
if emailAddressOrUID.startswith('cbcm-browser.') or emailAddressOrUID.startswith('chrome-os-device.'):
|
|
|
|
|
if emailAddressOrUID.startswith(NON_EMAIL_MEMBER_PREFIXES):
|
|
|
|
|
return emailAddressOrUID
|
|
|
|
|
normalizedEmailAddressOrUID = normalizeEmailAddressOrUID(emailAddressOrUID, ciGroupsAPI=ciGroupsAPI)
|
|
|
|
|
if normalizedEmailAddressOrUID.startswith('cbcm-browser.') or normalizedEmailAddressOrUID.startswith('chrome-os-device.'):
|
|
|
|
|
if normalizedEmailAddressOrUID.startswith(NON_EMAIL_MEMBER_PREFIXES):
|
|
|
|
|
return normalizedEmailAddressOrUID
|
|
|
|
|
email, _ = convertUIDtoEmailAddressWithType(emailAddressOrUID, cd, emailTypes,
|
|
|
|
|
checkForCustomerId, ciGroupsAPI, aliasAllowed)
|
|
|
|
|
@@ -18918,6 +18922,7 @@ CONTACT_USER_DEFINED_FIELDS = 'User Defined Fields'
|
|
|
|
|
CONTACT_WEBSITES = 'Websites'
|
|
|
|
|
#
|
|
|
|
|
class ContactsManager():
|
|
|
|
|
|
|
|
|
|
CONTACT_ARGUMENT_TO_PROPERTY_MAP = {
|
|
|
|
|
'json': CONTACT_JSON,
|
|
|
|
|
'name': CONTACT_NAME,
|
|
|
|
|
@@ -21298,7 +21303,7 @@ def queryPeopleContacts(people, contactQuery, fields, sortOrder, entityType, use
|
|
|
|
|
showMessage = pageMessage.replace(TOTAL_ITEMS_MARKER, str(totalItems))
|
|
|
|
|
writeGotMessage(showMessage.replace('{0}', str(Ent.Choose(Ent.PEOPLE_CONTACT, totalItems))))
|
|
|
|
|
return entityList
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
entityUnknownWarning(entityType, user, i, count)
|
|
|
|
|
@@ -21448,7 +21453,7 @@ def createUserPeopleContact(users):
|
|
|
|
|
csvPF.WriteRow(row)
|
|
|
|
|
except GAPI.invalidArgument as e:
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, None], str(e), i, count)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -21613,7 +21618,7 @@ def _clearUpdatePeopleContacts(users, updateContacts):
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
|
|
|
except (GAPI.notFound, GAPI.internalError):
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -21763,7 +21768,7 @@ def dedupReplaceDomainUserPeopleContacts(users):
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
|
|
|
except (GAPI.notFound, GAPI.internalError):
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -21818,7 +21823,7 @@ def deleteUserPeopleContacts(users):
|
|
|
|
|
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
|
|
|
|
|
except (GAPI.notFound, GAPI.internalError):
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -22115,7 +22120,7 @@ def _infoPeople(users, entityType, source):
|
|
|
|
|
except GAPI.invalidArgument as e:
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
|
|
|
|
continue
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -22530,7 +22535,7 @@ def _printShowPeople(source):
|
|
|
|
|
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
|
|
|
|
|
sources=sources, mergeSources=mergeSources,
|
|
|
|
|
readMask=fields, fields='nextPageToken,people', **kwargs)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -22569,14 +22574,14 @@ def doInfoDomainPeopleContacts():
|
|
|
|
|
# [countsonly]
|
|
|
|
|
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
|
|
|
|
|
# [formatjson]
|
|
|
|
|
# gam print peoplecontacts [todrive <ToDriveAttribute>*]
|
|
|
|
|
# gam print domaincontacts|peoplecontacts [todrive <ToDriveAttribute>*]
|
|
|
|
|
# [sources <PeopleSourceName>]
|
|
|
|
|
# [query <String>]
|
|
|
|
|
# [mergesources <PeopleMergeSourceName>]
|
|
|
|
|
# [countsonly]
|
|
|
|
|
# [allfields|(fields <PeopleFieldNameList>)] [showmetadata]
|
|
|
|
|
# [formatjson [quotechar <Character>]]
|
|
|
|
|
# gam show peoplecontacts
|
|
|
|
|
# gam show domaincontacts|peoplecontacts
|
|
|
|
|
# [sources <PeopleSourceName>]
|
|
|
|
|
# [query <String>]
|
|
|
|
|
# [mergesources <PeopleMergeSourceName>]
|
|
|
|
|
@@ -22652,7 +22657,7 @@ def printShowUserPeopleProfiles(users):
|
|
|
|
|
except GAPI.notFound:
|
|
|
|
|
entityUnknownWarning(Ent.PEOPLE_PROFILE, user, i, count)
|
|
|
|
|
continue
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -22808,7 +22813,7 @@ def _processPeopleContactPhotos(users, function):
|
|
|
|
|
entityDoesNotHaveItemWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], j, jcount)
|
|
|
|
|
except (GAPI.invalidArgument, OSError, IOError) as e:
|
|
|
|
|
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], str(e), j, jcount)
|
|
|
|
|
except GAPI.permissionDenied as e:
|
|
|
|
|
except (GAPI.permissionDenied, GAPI.failedPrecondition) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
@@ -34182,7 +34187,7 @@ def doPrintGroupMembers():
|
|
|
|
|
for name in info['names']:
|
|
|
|
|
if name['metadata']['source']['type'] == sourceType:
|
|
|
|
|
return name['displayName']
|
|
|
|
|
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied):
|
|
|
|
|
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied, GAPI.failedPrecondition):
|
|
|
|
|
pass
|
|
|
|
|
return unknownName
|
|
|
|
|
|
|
|
|
|
@@ -35729,10 +35734,16 @@ def _showPolicies(policies, FJQC, add_warnings, no_appnames,
|
|
|
|
|
_showPolicy(policy, FJQC, i, count)
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
|
|
|
|
|
def _checkPoliciesWithDASA():
|
|
|
|
|
if GC.Values[GC.ENABLE_DASA]:
|
|
|
|
|
systemErrorExit(USAGE_ERROR_RC,
|
|
|
|
|
Msg.COMMAND_NOT_COMPATIBLE_WITH_ENABLE_DASA.format(Act.ToPerform().lower(), Cmd.ARG_CIPOLICIES))
|
|
|
|
|
|
|
|
|
|
# gam info policies <CIPolicyNameEntity>
|
|
|
|
|
# [nowarnings] [noappnames]
|
|
|
|
|
# [formatjson]
|
|
|
|
|
def doInfoCIPolicies():
|
|
|
|
|
_checkPoliciesWithDASA()
|
|
|
|
|
groups_ci = buildGAPIObject(API.CLOUDIDENTITY_GROUPS)
|
|
|
|
|
ci = buildGAPIObject(API.CLOUDIDENTITY_POLICY)
|
|
|
|
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
|
|
|
@@ -35791,6 +35802,7 @@ def doPrintShowCIPolicies():
|
|
|
|
|
ensure_ascii=False,
|
|
|
|
|
sort_keys=True)})
|
|
|
|
|
|
|
|
|
|
_checkPoliciesWithDASA()
|
|
|
|
|
groups_ci = buildGAPIObject(API.CLOUDIDENTITY_GROUPS)
|
|
|
|
|
ci = buildGAPIObject(API.CLOUDIDENTITY_POLICY)
|
|
|
|
|
cd = buildGAPIObject(API.DIRECTORY)
|
|
|
|
|
@@ -39054,7 +39066,8 @@ def _updateCalendarEvents(origUser, user, origCal, calIds, count, calendarEventE
|
|
|
|
|
event = callGAPI(cal.events(), 'patch',
|
|
|
|
|
throwReasons=GAPI.CALENDAR_THROW_REASONS+[GAPI.NOT_FOUND, GAPI.DELETED, GAPI.FORBIDDEN,
|
|
|
|
|
GAPI.INVALID, GAPI.REQUIRED, GAPI.TIME_RANGE_EMPTY, GAPI.EVENT_DURATION_EXCEEDS_LIMIT,
|
|
|
|
|
GAPI.REQUIRED_ACCESS_LEVEL, GAPI.CANNOT_CHANGE_ORGANIZER_OF_INSTANCE],
|
|
|
|
|
GAPI.REQUIRED_ACCESS_LEVEL, GAPI.CANNOT_CHANGE_ORGANIZER_OF_INSTANCE,
|
|
|
|
|
GAPI.MALFORMED_WORKING_LOCATION_EVENT],
|
|
|
|
|
calendarId=calId, eventId=eventId, conferenceDataVersion=1, sendUpdates=parameters['sendUpdates'], supportsAttachments=True,
|
|
|
|
|
body=body, fields=pfields)
|
|
|
|
|
if parameters['csvPF'] is None:
|
|
|
|
|
@@ -39069,7 +39082,7 @@ def _updateCalendarEvents(origUser, user, origCal, calIds, count, calendarEventE
|
|
|
|
|
break
|
|
|
|
|
entityActionFailedWarning([Ent.CALENDAR, calId, Ent.EVENT, eventId], str(e), j, jcount)
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalid, GAPI.required, GAPI.timeRangeEmpty, GAPI.eventDurationExceedsLimit,
|
|
|
|
|
GAPI.requiredAccessLevel, GAPI.cannotChangeOrganizerOfInstance) as e:
|
|
|
|
|
GAPI.requiredAccessLevel, GAPI.cannotChangeOrganizerOfInstance, GAPI.malformedWorkingLocationEvent) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.CALENDAR, calId, Ent.EVENT, eventId], str(e), j, jcount)
|
|
|
|
|
except GAPI.notACalendarUser:
|
|
|
|
|
userCalServiceNotEnabledWarning(calId, i, count)
|
|
|
|
|
@@ -40378,20 +40391,20 @@ def convertExportNameToID(v, nameOrId, matterId, matterNameId):
|
|
|
|
|
if cg:
|
|
|
|
|
try:
|
|
|
|
|
export = callGAPI(v.matters().exports(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, exportId=cg.group(1))
|
|
|
|
|
return (export['id'], export['name'], formatVaultNameId(export['id'], export['name']))
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest):
|
|
|
|
|
entityDoesNotHaveItemExit([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, nameOrId])
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
nameOrIdlower = nameOrId.lower()
|
|
|
|
|
try:
|
|
|
|
|
exports = callGAPIpages(v.matters().exports(), 'list', 'exports',
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields='exports(id,name),nextPageToken')
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
for export in exports:
|
|
|
|
|
if export['name'].lower() == nameOrIdlower:
|
|
|
|
|
return (export['id'], export['name'], formatVaultNameId(export['id'], export['name']))
|
|
|
|
|
@@ -40402,20 +40415,20 @@ def convertHoldNameToID(v, nameOrId, matterId, matterNameId):
|
|
|
|
|
if cg:
|
|
|
|
|
try:
|
|
|
|
|
hold = callGAPI(v.matters().holds(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=cg.group(1))
|
|
|
|
|
return (hold['holdId'], hold['name'], formatVaultNameId(hold['holdId'], hold['name']))
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest):
|
|
|
|
|
entityDoesNotHaveItemExit([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, nameOrId])
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
nameOrIdlower = nameOrId.lower()
|
|
|
|
|
try:
|
|
|
|
|
holds = callGAPIpages(v.matters().holds(), 'list', 'holds',
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields='holds(holdId,name),nextPageToken')
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
for hold in holds:
|
|
|
|
|
if hold['name'].lower() == nameOrIdlower:
|
|
|
|
|
return (hold['holdId'], hold['name'], formatVaultNameId(hold['holdId'], hold['name']))
|
|
|
|
|
@@ -40426,17 +40439,17 @@ def convertMatterNameToID(v, nameOrId, state=None):
|
|
|
|
|
if cg:
|
|
|
|
|
try:
|
|
|
|
|
matter = callGAPI(v.matters(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=cg.group(1), view='BASIC', fields='matterId,name,state')
|
|
|
|
|
return (matter['matterId'], matter['name'], formatVaultNameId(matter['name'], matter['matterId']), matter['state'])
|
|
|
|
|
except (GAPI.notFound, GAPI.forbidden):
|
|
|
|
|
entityDoesNotExistExit(Ent.VAULT_MATTER, nameOrId)
|
|
|
|
|
try:
|
|
|
|
|
matters = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view='BASIC', state=state, fields='matters(matterId,name,state),nextPageToken')
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
nameOrIdlower = nameOrId.lower()
|
|
|
|
|
ids = []
|
|
|
|
|
states = []
|
|
|
|
|
@@ -40457,20 +40470,20 @@ def convertQueryNameToID(v, nameOrId, matterId, matterNameId):
|
|
|
|
|
if cg:
|
|
|
|
|
try:
|
|
|
|
|
query = callGAPI(v.matters().savedQueries(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, savedQueryId=cg.group(1))
|
|
|
|
|
return (query['savedQueryId'], query['displayName'], formatVaultNameId(query['savedQueryId'], query['displayName']))
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest):
|
|
|
|
|
entityDoesNotHaveItemExit([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_QUERY, nameOrId])
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
nameOrIdlower = nameOrId.lower()
|
|
|
|
|
try:
|
|
|
|
|
queries = callGAPIpages(v.matters().savedQueries(), 'list', 'savedQueries',
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields='savedQueries(savedQueryId,displayName),nextPageToken')
|
|
|
|
|
except GAPI.forbidden:
|
|
|
|
|
ClientAPIAccessDeniedExit()
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
ClientAPIAccessDeniedExit(str(e))
|
|
|
|
|
for query in queries:
|
|
|
|
|
if query['displayName'].lower() == nameOrIdlower:
|
|
|
|
|
return (query['savedQueryId'], query['displayName'], formatVaultNameId(query['savedQueryId'], query['displayName']))
|
|
|
|
|
@@ -40484,9 +40497,9 @@ def warnMatterNotOpen(v, matter, matterNameId, j, jcount):
|
|
|
|
|
if v is not None:
|
|
|
|
|
try:
|
|
|
|
|
matter['state'] = callGAPI(v.matters(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matter['matterId'], view='BASIC', fields='state')['state']
|
|
|
|
|
except (GAPI.notFound, GAPI.forbidden):
|
|
|
|
|
except (GAPI.notFound, GAPI.forbidden, GAPI.invalidArgument):
|
|
|
|
|
matter['state'] = 'Unknown'
|
|
|
|
|
else:
|
|
|
|
|
setSysExitRC(DATA_NOT_AVALIABLE_RC)
|
|
|
|
|
@@ -40802,10 +40815,10 @@ def doDeleteVaultExport():
|
|
|
|
|
unknownArgumentExit()
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters().exports(), 'delete',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, exportId=exportId)
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId])
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
|
|
|
|
|
|
|
|
VAULT_EXPORT_FIELDS_CHOICE_MAP = {
|
|
|
|
|
@@ -40856,10 +40869,10 @@ def doInfoVaultExport():
|
|
|
|
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
|
|
|
try:
|
|
|
|
|
export = callGAPI(v.matters().exports(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, exportId=exportId, fields=fields)
|
|
|
|
|
_showVaultExport(matterNameId, export, cd, FJQC)
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
|
|
|
|
|
|
|
|
VAULT_EXPORT_STATUS_MAP = {'completed': 'COMPLETED', 'failed': 'FAILED', 'inprogress': 'IN_PROGRESS'}
|
|
|
|
|
@@ -40922,9 +40935,9 @@ def doPrintShowVaultExports():
|
|
|
|
|
try:
|
|
|
|
|
results = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
pageMessage=getPageMessage(),
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view='BASIC', state='OPEN', fields='matters(matterId,name,state),nextPageToken')
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_EXPORT, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
@@ -40952,12 +40965,12 @@ def doPrintShowVaultExports():
|
|
|
|
|
try:
|
|
|
|
|
exports = callGAPIpages(v.matters().exports(), 'list', 'exports',
|
|
|
|
|
pageMessage=pageMessage,
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields=fields)
|
|
|
|
|
except GAPI.failedPrecondition:
|
|
|
|
|
warnMatterNotOpen(v, matter, matterNameId, j, jcount)
|
|
|
|
|
continue
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_EXPORT, None], str(e))
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
@@ -41052,9 +41065,9 @@ def doCopyVaultExport():
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
export = callGAPI(v.matters().exports(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, exportId=exportId)
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
|
|
|
return
|
|
|
|
|
if export['status'] == 'COMPLETED':
|
|
|
|
|
@@ -41152,9 +41165,9 @@ def doDownloadVaultExport():
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
export = callGAPI(v.matters().exports(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, exportId=exportId)
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_EXPORT, exportNameId], str(e))
|
|
|
|
|
return
|
|
|
|
|
if export['status'] == 'COMPLETED':
|
|
|
|
|
@@ -41342,7 +41355,8 @@ def doCreateVaultHold():
|
|
|
|
|
body['accounts'].append({'accountId': convertEmailAddressToUID(account, cd, accountType, accountsLocation)})
|
|
|
|
|
try:
|
|
|
|
|
hold = callGAPI(v.matters().holds(), 'create',
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.BAD_REQUEST, GAPI.BACKEND_ERROR, GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.BAD_REQUEST, GAPI.BACKEND_ERROR, GAPI.FAILED_PRECONDITION,
|
|
|
|
|
GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, body=body)
|
|
|
|
|
if not returnIdOnly:
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, formatVaultNameId(hold['name'], hold['holdId'])])
|
|
|
|
|
@@ -41350,7 +41364,8 @@ def doCreateVaultHold():
|
|
|
|
|
_showVaultHold(None, hold, None, None)
|
|
|
|
|
else:
|
|
|
|
|
writeStdout(f'{hold["holdId"]}\n')
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.badRequest, GAPI.backendError, GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.badRequest, GAPI.backendError, GAPI.failedPrecondition,
|
|
|
|
|
GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, body.get('name')], str(e))
|
|
|
|
|
|
|
|
|
|
# gam update vaulthold|hold <HoldItem> matter <MatterItem>
|
|
|
|
|
@@ -41395,9 +41410,9 @@ def doUpdateVaultHold():
|
|
|
|
|
missingArgumentExit('matter')
|
|
|
|
|
try:
|
|
|
|
|
old_body = callGAPI(v.matters().holds(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId, fields='name,corpus,query,orgUnit')
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId], str(e))
|
|
|
|
|
return
|
|
|
|
|
accountType = 'group' if old_body['corpus'] == 'GROUPS' else 'user'
|
|
|
|
|
@@ -41423,10 +41438,10 @@ def doUpdateVaultHold():
|
|
|
|
|
if body:
|
|
|
|
|
try:
|
|
|
|
|
hold = callGAPI(v.matters().holds(), 'update',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReas=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId, body=body)
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId])
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId], str(e))
|
|
|
|
|
return
|
|
|
|
|
jcount = len(addAccountIds)
|
|
|
|
|
@@ -41439,12 +41454,12 @@ def doUpdateVaultHold():
|
|
|
|
|
j += 1
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters().holds().accounts(), 'create',
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.BACKEND_ERROR, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.BACKEND_ERROR, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId, body={'accountId': account['id']})
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId, Ent.ACCOUNT, account['email']], j, jcount)
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.backendError) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId, Ent.ACCOUNT, account['email']], str(e), j, jcount)
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
@@ -41460,12 +41475,12 @@ def doUpdateVaultHold():
|
|
|
|
|
j += 1
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters().holds().accounts(), 'delete',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BACKEND_ERROR, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BACKEND_ERROR, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId, accountId=account['id'])
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId, Ent.ACCOUNT, account['email']], j, jcount)
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.backendError) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId, Ent.ACCOUNT, account['email']], str(e), j, jcount)
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
@@ -41490,10 +41505,10 @@ def doDeleteVaultHold():
|
|
|
|
|
unknownArgumentExit()
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters().holds(), 'delete',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId)
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId])
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId], str(e))
|
|
|
|
|
|
|
|
|
|
VAULT_HOLD_FIELDS_CHOICE_MAP = {
|
|
|
|
|
@@ -41543,10 +41558,10 @@ def doInfoVaultHold():
|
|
|
|
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
|
|
|
try:
|
|
|
|
|
hold = callGAPI(v.matters().holds(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, holdId=holdId, fields=fields)
|
|
|
|
|
_showVaultHold(matterNameId, hold, cd, FJQC)
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_HOLD, holdNameId], str(e))
|
|
|
|
|
|
|
|
|
|
PRINT_VAULT_HOLDS_TITLES = ['matterId', 'matterName', 'holdId', 'name', 'updateTime']
|
|
|
|
|
@@ -41597,9 +41612,9 @@ def doPrintShowVaultHolds():
|
|
|
|
|
try:
|
|
|
|
|
results = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
pageMessage=getPageMessage(),
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view='BASIC', state='OPEN', fields='matters(matterId,name,state),nextPageToken')
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_HOLD, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
@@ -41626,12 +41641,12 @@ def doPrintShowVaultHolds():
|
|
|
|
|
try:
|
|
|
|
|
holds = callGAPIpages(v.matters().holds(), 'list', 'holds',
|
|
|
|
|
pageMessage=pageMessage,
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields=fields)
|
|
|
|
|
except GAPI.failedPrecondition:
|
|
|
|
|
warnMatterNotOpen(v, matter, matterNameId, j, jcount)
|
|
|
|
|
continue
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_HOLD, None], str(e))
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
@@ -41677,9 +41692,9 @@ def printShowUserVaultHolds(entityList):
|
|
|
|
|
try:
|
|
|
|
|
matters = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
pageMessage=getPageMessage(),
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view='BASIC', state='OPEN', fields='matters(matterId,name,state),nextPageToken')
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_HOLD, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
jcount = len(matters)
|
|
|
|
|
@@ -41693,11 +41708,11 @@ def printShowUserVaultHolds(entityList):
|
|
|
|
|
try:
|
|
|
|
|
matter['holds'] = callGAPIpages(v.matters().holds(), 'list', 'holds',
|
|
|
|
|
pageMessage=getPageMessageForWhom(),
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields='holds(holdId,name,accounts(accountId,email),orgUnit(orgUnitId)),nextPageToken')
|
|
|
|
|
except GAPI.failedPrecondition:
|
|
|
|
|
warnMatterNotOpen(v, matter, matterNameId, j, jcount)
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_HOLD, None], str(e), j, jcount)
|
|
|
|
|
totalHolds = 0
|
|
|
|
|
_, _, entityList = getEntityArgument(entityList)
|
|
|
|
|
@@ -41808,10 +41823,10 @@ def doInfoVaultQuery():
|
|
|
|
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
|
|
|
try:
|
|
|
|
|
query = callGAPI(v.matters().savedQueries(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.BAD_REQUEST, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, savedQueryId=queryId, fields=fields)
|
|
|
|
|
_showVaultQuery(matterNameId, query, cd, FJQC)
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.badRequest, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId, Ent.VAULT_QUERY, queryNameId], str(e))
|
|
|
|
|
|
|
|
|
|
PRINT_VAULT_QUERIES_TITLES = ['matterId', 'matterName', 'savedQueryId', 'displayName']
|
|
|
|
|
@@ -41852,9 +41867,9 @@ def doPrintShowVaultQueries():
|
|
|
|
|
try:
|
|
|
|
|
results = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
pageMessage=getPageMessage(),
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view='BASIC', state='OPEN', fields='matters(matterId,name,state),nextPageToken')
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_QUERY, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
@@ -41881,12 +41896,12 @@ def doPrintShowVaultQueries():
|
|
|
|
|
try:
|
|
|
|
|
queries = callGAPIpages(v.matters().savedQueries(), 'list', 'savedQueries',
|
|
|
|
|
pageMessage=pageMessage,
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, fields=fields)
|
|
|
|
|
except GAPI.failedPrecondition:
|
|
|
|
|
warnMatterNotOpen(v, matter, matterNameId, j, jcount)
|
|
|
|
|
continue
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_QUERY, None], str(e))
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
@@ -41973,7 +41988,7 @@ def doCreateVaultMatter():
|
|
|
|
|
body['name'] = f'GAM Matter - {ISOformatTimeStamp(todaysTime())}'
|
|
|
|
|
try:
|
|
|
|
|
matter = callGAPI(v.matters(), 'create',
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.ALREADY_EXISTS, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
body=body)
|
|
|
|
|
matterId = matter['matterId']
|
|
|
|
|
matterNameId = formatVaultNameId(matter['name'], matterId)
|
|
|
|
|
@@ -41981,7 +41996,7 @@ def doCreateVaultMatter():
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId])
|
|
|
|
|
else:
|
|
|
|
|
writeStdout(f'{matterId}\n')
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.alreadyExists, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, body['name']], str(e))
|
|
|
|
|
return
|
|
|
|
|
jcount = len(collaborators)
|
|
|
|
|
@@ -41996,11 +42011,11 @@ def doCreateVaultMatter():
|
|
|
|
|
cbody['matterPermission']['accountId'] = collaborator['id']
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters(), 'addPermissions',
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, body=cbody)
|
|
|
|
|
if not returnIdOnly:
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.COLLABORATOR, collaborator['email']], j, jcount)
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
break
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
@@ -42024,10 +42039,10 @@ def doActionVaultMatter(action, matterId=None, matterNameId=None, v=None):
|
|
|
|
|
action_kwargs = {} if action == 'delete' else {'body': {}}
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters(), action,
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, **action_kwargs)
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId])
|
|
|
|
|
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
|
|
|
|
|
# gam close vaultmatter|matter <MatterItem>
|
|
|
|
|
@@ -42080,7 +42095,7 @@ def doUpdateVaultMatter():
|
|
|
|
|
if 'name' not in body or 'description' not in body:
|
|
|
|
|
# bah, API requires name/description to be sent on update even when it's not changing
|
|
|
|
|
result = callGAPI(v.matters(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, view='BASIC')
|
|
|
|
|
body.setdefault('name', result['name'])
|
|
|
|
|
body.setdefault('description', result.get('description'))
|
|
|
|
|
@@ -42088,7 +42103,7 @@ def doUpdateVaultMatter():
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
matterId=matterId, body=body)
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId])
|
|
|
|
|
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.failedPrecondition, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
return
|
|
|
|
|
jcount = len(addCollaborators)
|
|
|
|
|
@@ -42101,10 +42116,10 @@ def doUpdateVaultMatter():
|
|
|
|
|
j += 1
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters(), 'addPermissions',
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, body={'matterPermission': {'role': 'COLLABORATOR', 'accountId': collaborator['id']}})
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.COLLABORATOR, collaborator['email']], j, jcount)
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
break
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
@@ -42118,10 +42133,10 @@ def doUpdateVaultMatter():
|
|
|
|
|
j += 1
|
|
|
|
|
try:
|
|
|
|
|
callGAPI(v.matters(), 'removePermissions',
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FAILED_PRECONDITION, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, body={'accountId': collaborator['id']})
|
|
|
|
|
entityActionPerformed([Ent.VAULT_MATTER, matterNameId, Ent.COLLABORATOR, collaborator['email']], j, jcount)
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.failedPrecondition, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
break
|
|
|
|
|
Ind.Decrement()
|
|
|
|
|
@@ -42154,11 +42169,11 @@ def doInfoVaultMatter():
|
|
|
|
|
fields = getFieldsFromFieldsList(fieldsList)
|
|
|
|
|
try:
|
|
|
|
|
matter = callGAPI(v.matters(), 'get',
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.NOT_FOUND, GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
matterId=matterId, view=view, fields=fields)
|
|
|
|
|
cd = buildGAPIObject(API.DIRECTORY) if 'matterPermissions' in matter else None
|
|
|
|
|
_showVaultMatter(matter, cd, FJQC)
|
|
|
|
|
except (GAPI.notFound, GAPI.forbidden) as e:
|
|
|
|
|
except (GAPI.notFound, GAPI.forbidden, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, matterNameId], str(e))
|
|
|
|
|
|
|
|
|
|
VAULT_MATTER_STATE_MAP = {'open': 'OPEN', 'closed': 'CLOSED', 'deleted': 'DELETED'}
|
|
|
|
|
@@ -42214,9 +42229,9 @@ def doPrintShowVaultMatters():
|
|
|
|
|
try:
|
|
|
|
|
matters = callGAPIpages(v.matters(), 'list', 'matters',
|
|
|
|
|
pageMessage=getPageMessage(),
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN],
|
|
|
|
|
throwReasons=[GAPI.FORBIDDEN, GAPI.INVALID_ARGUMENT, GAPI.INVALID_ARGUMENT],
|
|
|
|
|
view=view, state=stateParm, fields=fields)
|
|
|
|
|
except GAPI.forbidden as e:
|
|
|
|
|
except (GAPI.forbidden, GAPI.invalidArgument, GAPI.invalidArgument) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.VAULT_MATTER, None], str(e))
|
|
|
|
|
return
|
|
|
|
|
jcount = len(matters)
|
|
|
|
|
@@ -42407,6 +42422,8 @@ class PasswordOptions():
|
|
|
|
|
self.makeCleanPassword = True
|
|
|
|
|
self.cleanPasswordLen = 25
|
|
|
|
|
self.randomPasswordChars = None
|
|
|
|
|
self.promptForPassword = False
|
|
|
|
|
self.promptForUniquePassword = False
|
|
|
|
|
self.notifyPasswordSet = False
|
|
|
|
|
self.updateCmd = updateCmd
|
|
|
|
|
self.filename = ''
|
|
|
|
|
@@ -42453,7 +42470,7 @@ class PasswordOptions():
|
|
|
|
|
self.makeCleanPassword = True
|
|
|
|
|
notFoundBody[up] = self.CreateRandomPassword()
|
|
|
|
|
self.notFoundPassword = notFoundBody[up]
|
|
|
|
|
elif myarg == 'lograndompassword':
|
|
|
|
|
elif myarg in {'lograndompassword', 'logpassword'}:
|
|
|
|
|
self.filename = getString(Cmd.OB_FILE_NAME)
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
@@ -42474,7 +42491,8 @@ class PasswordOptions():
|
|
|
|
|
password = self.GetPassword()
|
|
|
|
|
if password:
|
|
|
|
|
body[up] = password
|
|
|
|
|
self.makeRandomPassword = self.makeUniqueRandomPassword = False
|
|
|
|
|
self.makeRandomPassword = self.makeUniqueRandomPassword =\
|
|
|
|
|
self.promptForPassword = self.promptForUniquePassword = False
|
|
|
|
|
if password.lower() == 'blocklogin':
|
|
|
|
|
self.makeRandomPassword = True
|
|
|
|
|
self.makeCleanPassword = False
|
|
|
|
|
@@ -42487,6 +42505,13 @@ class PasswordOptions():
|
|
|
|
|
self.makeUniqueRandomPassword = self.makeCleanPassword = True
|
|
|
|
|
else:
|
|
|
|
|
self.makeRandomPassword = self.makeCleanPassword = True
|
|
|
|
|
elif password.lower() == 'prompt':
|
|
|
|
|
self.promptForPassword = True
|
|
|
|
|
elif password.lower() == 'uniqueprompt':
|
|
|
|
|
if self.updateCmd:
|
|
|
|
|
self.promptForUniquePassword = True
|
|
|
|
|
else:
|
|
|
|
|
self.promptForPassword = True
|
|
|
|
|
elif up == 'hashFunction':
|
|
|
|
|
body[up] = self.HASH_FUNCTION_MAP[myarg]
|
|
|
|
|
self.clearPassword = self.hashPassword = False
|
|
|
|
|
@@ -42509,11 +42534,17 @@ class PasswordOptions():
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def AssignPassword(self, body, notify, notFoundBody, createIfNotFound):
|
|
|
|
|
def AssignPassword(self, body, notify, notFoundBody, createIfNotFound, user=None):
|
|
|
|
|
up = 'password'
|
|
|
|
|
if self.makeRandomPassword or self.makeUniqueRandomPassword:
|
|
|
|
|
body[up] = self.CreateRandomPassword()
|
|
|
|
|
self.password = body[up]
|
|
|
|
|
elif user and (self.promptForPassword or self.promptForUniquePassword):
|
|
|
|
|
body[up] = readStdin(f'Enter password for {user}: ')
|
|
|
|
|
self.password = body[up]
|
|
|
|
|
elif self.promptForPassword:
|
|
|
|
|
body[up] = readStdin('Enter password: ')
|
|
|
|
|
self.password = body[up]
|
|
|
|
|
if up in body:
|
|
|
|
|
self.FinalizePassword(body, notify, up)
|
|
|
|
|
elif 'hashFunction' in body:
|
|
|
|
|
@@ -43147,7 +43178,12 @@ def getUserAttributes(cd, updateCmd, noUid=False):
|
|
|
|
|
body[up][schemaName][fieldName] = None
|
|
|
|
|
else:
|
|
|
|
|
unknownArgumentExit()
|
|
|
|
|
if not PwdOpts.makeUniqueRandomPassword:
|
|
|
|
|
if PwdOpts.promptForPassword or PwdOpts.promptForUniquePassword:
|
|
|
|
|
if not updateCmd:
|
|
|
|
|
PwdOpts.AssignPassword(body, notify, notFoundBody, parameters['createIfNotFound'], body['primaryEmail'])
|
|
|
|
|
elif not PwdOpts.promptForUniquePassword:
|
|
|
|
|
PwdOpts.AssignPassword(body, notify, notFoundBody, parameters['createIfNotFound'])
|
|
|
|
|
elif not PwdOpts.makeUniqueRandomPassword:
|
|
|
|
|
PwdOpts.AssignPassword(body, notify, notFoundBody, parameters['createIfNotFound'])
|
|
|
|
|
return (body, notify, tagReplacements, addGroups, addAliases, PwdOpts,
|
|
|
|
|
updatePrimaryEmail, notFoundBody, groupOrgUnitMap, parameters,
|
|
|
|
|
@@ -43181,7 +43217,7 @@ def createUserAddAliases(cd, user, aliasList, i, count):
|
|
|
|
|
# [replyto <EmailAaddress>]
|
|
|
|
|
# [<NotifyMessageContent>]
|
|
|
|
|
# (replace <Tag> <UserReplacement>)*]
|
|
|
|
|
# [lograndompassword <FileName>] [ignorenullpassword]
|
|
|
|
|
# [logpassword <FileName>] [ignorenullpassword]
|
|
|
|
|
# [verifynotinvitable]
|
|
|
|
|
# [addnumericsuffixonduplicate <Number>]
|
|
|
|
|
def doCreateUser():
|
|
|
|
|
@@ -43286,7 +43322,7 @@ def verifyUserPrimaryEmail(cd, user, createIfNotFound, i, count):
|
|
|
|
|
# [<NotifyMessageContent>]
|
|
|
|
|
# (replace <Tag> <UserReplacement>)*]
|
|
|
|
|
# [notifyonupdate [<Boolean>]]
|
|
|
|
|
# [lograndompassword <FileName>] [ignorenullpassword]
|
|
|
|
|
# [logpassword <FileName>] [ignorenullpassword]
|
|
|
|
|
def updateUsers(entityList):
|
|
|
|
|
def waitingForCreationToComplete(sleep_time):
|
|
|
|
|
writeStderr(Ind.Spaces()+Msg.WAITING_FOR_ITEM_CREATION_TO_COMPLETE_SLEEPING.format(Ent.Singular(Ent.USER), sleep_time))
|
|
|
|
|
@@ -43368,8 +43404,8 @@ def updateUsers(entityList):
|
|
|
|
|
if isInvitableUser:
|
|
|
|
|
entityActionNotPerformedWarning([Ent.USER, body['primaryEmail']], Msg.EMAIL_ADDRESS_IS_UNMANAGED_ACCOUNT, i, count)
|
|
|
|
|
continue
|
|
|
|
|
if PwdOpts.makeUniqueRandomPassword:
|
|
|
|
|
PwdOpts.AssignPassword(body, notify, notFoundBody, parameters['createIfNotFound'])
|
|
|
|
|
if PwdOpts.makeUniqueRandomPassword or PwdOpts.promptForUniquePassword:
|
|
|
|
|
PwdOpts.AssignPassword(body, notify, notFoundBody, parameters['createIfNotFound'], userKey)
|
|
|
|
|
retry = 0
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
@@ -43546,14 +43582,16 @@ def undeleteUsers(entityList):
|
|
|
|
|
callGAPI(cd.users(), 'undelete',
|
|
|
|
|
throwReasons=[GAPI.DELETED_USER_NOT_FOUND, GAPI.INVALID_ORGUNIT,
|
|
|
|
|
GAPI.DOMAIN_NOT_FOUND, GAPI.DOMAIN_CANNOT_USE_APIS,
|
|
|
|
|
GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.INVALID, GAPI.DUPLICATE],
|
|
|
|
|
GAPI.FORBIDDEN, GAPI.BAD_REQUEST, GAPI.INVALID, GAPI.DUPLICATE,
|
|
|
|
|
GAPI.LIMIT_EXCEEDED],
|
|
|
|
|
userKey=user_uid, body={'orgUnitPath': makeOrgUnitPathAbsolute(orgUnitPaths[0])})
|
|
|
|
|
entityActionPerformed([Ent.DELETED_USER, user], i, count)
|
|
|
|
|
except GAPI.deletedUserNotFound:
|
|
|
|
|
entityUnknownWarning(Ent.DELETED_USER, user, i, count)
|
|
|
|
|
except GAPI.invalidOrgunit:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, user], Msg.INVALID_ORGUNIT, i, count)
|
|
|
|
|
except (GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden, GAPI.badRequest, GAPI.invalid, GAPI.duplicate) as e:
|
|
|
|
|
except (GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.forbidden, GAPI.badRequest,
|
|
|
|
|
GAPI.invalid, GAPI.duplicate, GAPI.limitExceeded) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, user], str(e), i, count)
|
|
|
|
|
|
|
|
|
|
# gam undelete users <UserEntity> [ou|org|orgunit <OrgUnitPath>]
|
|
|
|
|
@@ -44792,7 +44830,7 @@ def doPrintUsers(entityList=None):
|
|
|
|
|
return
|
|
|
|
|
sortRows = True
|
|
|
|
|
# If no individual fields were specified (allfields, basic, full) or individual fields other than primaryEmail were specified, look up each user
|
|
|
|
|
if isSuspended is not None:
|
|
|
|
|
if isSuspended is not None and fieldsList:
|
|
|
|
|
fieldsList.append('suspended')
|
|
|
|
|
if projectionSet or len(set(fieldsList)) > 1 or showValidColumn:
|
|
|
|
|
jcount = len(entityList)
|
|
|
|
|
|