Пример #1
0
    def get(self, uuid=None, perimeter_id=None, category_id=None,
            data_id=None, user_id=None):
        """Retrieve all subject assignments or a specific one for a given policy

        :param uuid: uuid of the policy
        :param perimeter_id: uuid of the subject
        :param category_id: uuid of the subject category
        :param data_id: uuid of the subject scope
        :param user_id: user ID who do the request
        :return: {
            "subject_data_id": {
                "policy_id": "ID of the policy",
                "subject_id": "ID of the subject",
                "category_id": "ID of the category",
                "assignments": "Assignments list (list of data_id)",
            }
        }
        :internal_api: get_subject_assignments
        """
        try:
            data = PolicyManager.get_subject_assignments(
                user_id=user_id, policy_id=uuid,
                subject_id=perimeter_id, category_id=category_id)
        except Exception as e:
            logger.error(e, exc_info=True)
            return {"result": False,
                    "error": str(e)}, 500
        return {"subject_assignments": data}
Пример #2
0
def get_subject_assignments(policy_id, subject_id=None, category_id=None):
    from python_moondb.core import PolicyManager
    return PolicyManager.get_subject_assignments("", policy_id, subject_id,
                                                 category_id)