def get(self, uuid=None, category_id=None, data_id=None, user_id=None): """Retrieve all subject categories or a specific one if sid is given for a given policy :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 :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: get_subject_data """ try: data = PolicyManager.get_subject_data(user_id=user_id, policy_id=uuid, category_id=category_id, data_id=data_id) except Exception as e: logger.error(e, exc_info=True) return {"result": False, "error": str(e)}, 500 return {"subject_data": data}
def get(self, uuid=None, category_id=None, data_id=None, user_id=None): """Retrieve all subject categories or a specific one if data_id is given for a given policy :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 :return: [{ "policy_id": "policy_id1", "category_id": "category_id1", "data": { "subject_data_id": { "name": "name of the data", "description": "description of the data (optional)" } } }] :internal_api: get_subject_data """ logger.info("api.get {} {} {}".format(uuid, category_id, data_id)) data = PolicyManager.get_subject_data(user_id=user_id, policy_id=uuid, category_id=category_id, data_id=data_id) logger.info("api.get data = {}".format(data)) return {"subject_data": data}
def get_subject_data(policy_id, data_id=None, category_id=None): from python_moondb.core import PolicyManager return PolicyManager.get_subject_data("", policy_id, data_id, category_id)