Ejemplo n.º 1
0
    def post(self, uuid=None, category_id=None, data_id=None, user_id=None):
        """Create or update a subject.

        :param uuid: uuid of the policy
        :param category_id: uuid of the subject category
        :param data_id: uuid of the subject data
        :param user_id: user ID who do the request
        :request body: {
            "name": "name of the data",
            "description": "description of the data"
        }
        :return: {
            "policy_id": "policy_id1",
            "category_id": "category_id1",
            "data": {
                "subject_data_id": {
                    "name": "name of the data",
                    "description": "description of the data"
                }
            }
        }
        :internal_api: add_subject_data
        """
        try:
            data = PolicyManager.set_subject_data(user_id=user_id,
                                                  policy_id=uuid,
                                                  category_id=category_id,
                                                  value=request.json)
        except Exception as e:
            logger.error(e, exc_info=True)
            return {"result": False, "error": str(e)}, 500
        return {"subject_data": data}
Ejemplo n.º 2
0
    def post(self, uuid=None, category_id=None, data_id=None, user_id=None):
        """Create or update a subject.

        :param uuid: uuid of the policy
        :param category_id: uuid of the subject category
        :param data_id: uuid of the subject data (not used here)
        :param user_id: user ID who do the request
        :request body: {
            "name": "name of the data (mandatory)",
            "description": "description of the data (optional)"
        }
        :return: {
            "policy_id": "policy_id1",
            "category_id": "category_id1",
            "data": {
                "subject_data_id": {
                    "name": "name of the data (mandatory)",
                    "description": "description of the data (optional)"
                }
            }
        }
        :internal_api: add_subject_data
        """
        data = PolicyManager.set_subject_data(user_id=user_id,
                                              policy_id=uuid,
                                              category_id=category_id,
                                              value=request.json)

        return {"subject_data": data}
Ejemplo n.º 3
0
def add_subject_data(policy_id, data_id=None, category_id=None, value=None):
    from python_moondb.core import PolicyManager
    return PolicyManager.set_subject_data("", policy_id, data_id, category_id, value)