Exemple #1
0
    def add_to_matter(self, user_uid, legal_hold_uid):
        """Add a user (Custodian) to a Legal Hold Matter.

        Args:
            user_uid (str): The identifier of the user.
            legal_hold_uid (str): The identifier of the Legal Hold Matter.

        Returns:
            :class:`py42.response.Py42Response`
        """
        uri = "/api/v1/LegalHoldMembership"
        data = {"legalHoldUid": legal_hold_uid, "userUid": user_uid}
        try:
            return self._connection.post(uri, json=data)
        except Py42BadRequestError as err:
            if "USER_ALREADY_IN_HOLD" in err.response.text:
                matter = self.get_matter_by_uid(legal_hold_uid)
                matter_id_and_name_text = (
                    f"legal hold matter id={legal_hold_uid}, name={matter['name']}"
                )
                raise Py42UserAlreadyAddedError(err, user_uid, matter_id_and_name_text)
            raise
Exemple #2
0
    def add_to_matter(self, user_uid, legal_hold_uid):
        """Add a user (Custodian) to a Legal Hold Matter.
        `REST Documentation <https://console.us.code42.com/apidocviewer/#LegalHoldMembership-post>`__

        Args:
            user_uid (str): The identifier of the user.
            legal_hold_uid (str): The identifier of the Legal Hold Matter.

        Returns:
            :class:`py42.response.Py42Response`
        """
        uri = u"/api/LegalHoldMembership"
        data = {u"legalHoldUid": legal_hold_uid, u"userUid": user_uid}
        try:
            return self._connection.post(uri, json=data)
        except Py42BadRequestError as err:
            if u"USER_ALREADY_IN_HOLD" in err.response.text:
                matter = self.get_matter_by_uid(legal_hold_uid)
                matter_id_and_name_text = u"legal hold matter id={}, name={}".format(
                    legal_hold_uid, matter[u"name"]
                )
                raise Py42UserAlreadyAddedError(err, user_uid, matter_id_and_name_text)
            raise
Exemple #3
0
def user_already_added_error(mocker):
    err = mocker.MagicMock(spec=HTTPError)
    resp = mocker.MagicMock(spec=Response)
    resp.text = "TEST_ERR"
    err.response = resp
    return Py42UserAlreadyAddedError(err, TEST_ID, "detection list")
Exemple #4
0
def handle_user_already_added_error(bad_request_err, username_tried_adding,
                                    list_name):
    if u"User already on list" in bad_request_err.response.text:
        raise Py42UserAlreadyAddedError(bad_request_err, username_tried_adding,
                                        list_name)
Exemple #5
0
def user_already_added_error(custom_error):
    return Py42UserAlreadyAddedError(custom_error, TEST_ID, "detection list")