Exceptions

exception py42.exceptions.Py42ActiveLegalHoldError(exception, resource, resource_id)

Bases: Py42BadRequestError

An exception raised when attempting to deactivate a user or device that is in an active legal hold.

add_note()

Exception.add_note(note) – add a note to the exception

property resource

The user or device resource.

property resource_id

The resource ID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42ArchiveFileNotFoundError(response, device_guid, file_path)

Bases: Py42ResponseError

An exception raised when a resource file is not found or the path is invalid.

add_note()

Exception.add_note(note) – add a note to the exception

property device_guid

The device GUID provided.

property file_path

The file path provided.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42BadRequestError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 400 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42BadRestoreRequestError(exception)

Bases: Py42BadRequestError

An error raised when the given restore arguments are not compatible and cause a bad request.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42CaseAlreadyHasEventError(exception)

Bases: Py42BadRequestError

An error raised when event is already associated to the case.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42CaseNameExistsError(exception, case_name)

Bases: Py42BadRequestError

An error raised when trying to create a case with a name that already exists.

add_note()

Exception.add_note(note) – add a note to the exception

property case_name

The case name.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42ChecksumNotFoundError(response, checksum_name, checksum_value)

Bases: Py42ResponseError

An exception raised when a user-supplied hash could not successfully locate its corresponding resource.

add_note()

Exception.add_note(note) – add a note to the exception

property checksum_name

The checksum name.

property checksum_value

The checksum value.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42CloudAliasCharacterLimitExceededError

Bases: Py42Error

An exception raised when trying to add a cloud alias to a user that exceeds the max character limit.

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42CloudAliasLimitExceededError(exception, message=None)

Bases: Py42BadRequestError

An Exception raised when trying to add a cloud alias to a user when that user already has the max amount of supported cloud aliases.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42ConflictError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 409 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42DescriptionLimitExceededError(exception)

Bases: Py42BadRequestError

An error raised when description of a case exceeds the allowed char length limit.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42DeviceNotConnectedError(response, device_guid)

Bases: Py42ResponseError

An exception raised when trying to push a restore to a device that is not connected to an Authority server.

add_note()

Exception.add_note(note) – add a note to the exception

property device_guid

The device GUID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42Error

Bases: Exception

A generic, Py42 custom base exception.

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42FeatureUnavailableError(response)

Bases: Py42ResponseError

An exception raised when a requested feature is not supported in your Code42 environment.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42ForbiddenError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 403 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42HTTPError(exception, message=None, *args)

Bases: Py42ResponseError

A base custom class to manage all HTTP errors raised by an API endpoint.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InternalServerError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 500 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidArchiveEncryptionKey(exception)

Bases: Py42HTTPError

An exception raised the encryption key for an archive is invalid.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidArchivePassword(exception)

Bases: Py42HTTPError

An exception raised when the password for unlocking an archive is invalid.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidCaseUserError(exception, user_uid)

Bases: Py42BadRequestError

An error raised when a case subject or assignee is not a valid user.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property user

The user UID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidEmailError(email, exception)

Bases: Py42InternalServerError

An exception raised when trying to set an invalid email as a user’s email.

add_note()

Exception.add_note(note) – add a note to the exception

property email

The email being assigned to a user.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidPageTokenError(exception, page_token)

Bases: Py42BadRequestError

An error raised when the page token given is invalid.

add_note()

Exception.add_note(note) – add a note to the exception

property page_token

The page token.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidPasswordError(exception)

Bases: Py42InternalServerError

An exception raised when trying to set an invalid password as a user’s password.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidRuleError(exception, rule_id)

Bases: Py42NotFoundError

An exception raised when the observer rule ID does not exist.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property rule_id

The observer rule ID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidRuleOperationError(exception, rule_id, source)

Bases: Py42HTTPError

An exception raised when trying to add or remove users to a system rule.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property rule_id

The rule ID.

property source

The rule source.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidUsernameError(exception)

Bases: Py42InternalServerError

An exception raised when trying to set an invalid username as a user’s username.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42InvalidWatchlistType(exception, watchlist_type)

Bases: Py42BadRequestError

An exception raised when an invalid watchlist type is specified.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property watchlist_type

The specified watchlist type.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42LegalHoldAlreadyActiveError(exception, legal_hold_matter_uid)

Bases: Py42BadRequestError

An exception raised when trying to activate a Legal Hold Matter that is already active.

add_note()

Exception.add_note(note) – add a note to the exception

property legal_hold_matter_uid

The legal hold matter UID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42LegalHoldAlreadyDeactivatedError(exception, legal_hold_matter_uid)

Bases: Py42BadRequestError

An exception raised when trying to deactivate a Legal Hold Matter that is already inactive.

add_note()

Exception.add_note(note) – add a note to the exception

property legal_hold_matter_uid

The legal hold matter UID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42LegalHoldCriteriaMissingError(exception)

Bases: Py42BadRequestError

An exception raised when a bad request was made to a Legal Hold endpoint.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42LegalHoldNotFoundOrPermissionDeniedError(exception, resource_uid, legal_hold_resource='matter')

Bases: Py42ForbiddenError

An exception raised when a legal hold matter is inaccessible from your account or the matter UID is not valid.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property uid

The UID of the legal hold resource.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42MFARequiredError(exception, message=None)

Bases: Py42UnauthorizedError

Deprecated: An exception raised when a request requires multi-factor authentication

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42NotFoundError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 404 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42OrgNotFoundError(exception, org_uid)

Bases: Py42BadRequestError

An exception raised when a 400 HTTP error message indicates that an organization was not found.

add_note()

Exception.add_note(note) – add a note to the exception

property org_uid

“ The org UID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42ResponseError(response, message, *args)

Bases: Py42Error

A base custom class to manage all errors raised because of an HTTP response.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42SessionInitializationError(exception)

Bases: Py42Error

An exception raised when a user connection is invalid. A connection might be invalid due to connection timeout, invalid token, etc.

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42StorageSessionInitializationError(exception, message)

Bases: Py42HTTPError

An exception raised when the user is not authorized to initialize a storage session. This may occur when trying to restore a file or trying to get events for file activity on removable media, in cloud sync folders, and browser uploads.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42TooManyRequestsError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 429 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42TrustedActivityConflictError(exception, value)

Bases: Py42ConflictError

An error raised when theres a conflict with a trusted activity domain URL.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property value

The domain, URL or workspace name.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42TrustedActivityIdNotFound(exception, resource_id)

Bases: Py42NotFoundError

An exception raised when the trusted activity ID does not exist.

add_note()

Exception.add_note(note) – add a note to the exception

property resource_id

The resource ID.

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42TrustedActivityInvalidChangeError(exception)

Bases: Py42BadRequestError

An error raised when an invalid change is being made to a trusted activity.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42TrustedActivityInvalidCharacterError(exception)

Bases: Py42BadRequestError

An error raised when an invalid character is in a trusted activity value.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UnableToCreateProfileError(exception, username)

Bases: Py42BadRequestError

An error raised when trying to call the method for creating a detection-list user when the user does not exist or is currently awaiting the profile to get created on the back-end. Note: you are no longer able to create detection-list profiles using the API; py42 only returns already existing profiles.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property username

The username of the user.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UnauthorizedError(exception, message=None, *args)

Bases: Py42HTTPError

A wrapper to represent an HTTP 401 error.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UpdateClosedCaseError(exception)

Bases: Py42BadRequestError

An error raised when trying to update a closed case.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UserAlreadyAddedError(exception, user_id, list_name)

Bases: Py42BadRequestError

An exception raised when the user is already added to group or list, such as the Departing Employee list.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property user_id

The user ID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UserAlreadyExistsError(exception, message=None)

Bases: Py42InternalServerError

An exception raised when a user already exists

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UserNotOnListError(exception, user_id, list_name)

Bases: Py42NotFoundError

An exception raised when the user is not on a detection list.

add_note()

Exception.add_note(note) – add a note to the exception

property list_name

The list name.

property response

The response prior to the error.

property user_id

The user ID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UserRiskProfileNotFound(exception, user_id, identifier='ID')

Bases: Py42NotFoundError

An exception raised when the user with the given ID for a user risk profile was not found.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property user

The user identifier.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42UsernameMustBeEmailError(exception)

Bases: Py42InternalServerError

An exception raised when trying to set a non-email as a user’s username in a cloud environment.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42WatchlistNotFound(exception, resource_id)

Bases: Py42NotFoundError

An exception raised when the watchlist with the given ID was not found.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property watchlist_id

The watchlist ID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception py42.exceptions.Py42WatchlistOrUserNotFound(exception, watchlist_id, user_id)

Bases: Py42NotFoundError

An exception raised when the watchlist ID or the User ID does not exist.

add_note()

Exception.add_note(note) – add a note to the exception

property response

The response prior to the error.

property user_id

The user ID.

property watchlist_id

The watchlist ID.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

py42.exceptions.raise_py42_error(raised_error)

Raises the appropriate py42.exceptions.Py42HttpError based on the given HTTPError’s response status code.