From: Asteroide Date: Wed, 9 May 2018 09:28:32 +0000 (+0000) Subject: Merge "continue integrating validation" X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=d28f8e68ac176a15dbbd7873f757f5a9f221d118;p=moon.git Merge "continue integrating validation" --- d28f8e68ac176a15dbbd7873f757f5a9f221d118 diff --cc moon_manager/moon_manager/api/assignments.py index a090aa63,2ff9e218..a1d10ccb --- a/moon_manager/moon_manager/api/assignments.py +++ b/moon_manager/moon_manager/api/assignments.py @@@ -31,8 -32,9 +32,9 @@@ class SubjectAssignments(Resource) "/policies//subject_assignments///", ) + @validate_input("get", kwargs_state=[True, False, False,False,False]) @check_auth - def get(self, uuid=None, perimeter_id=None, category_id=None, + def get(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Retrieve all subject assignments or a specific one for a given policy @@@ -61,8 -63,9 +63,9 @@@ "error": str(e)}, 500 return {"subject_assignments": data} + @validate_input("post", kwargs_state=[True, False, False, False, False], body_state=[True, True, True]) @check_auth - def post(self, uuid=None, perimeter_id=None, category_id=None, + def post(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Create a subject assignment. @@@ -100,8 -103,9 +103,9 @@@ "error": str(e)}, 500 return {"subject_assignments": data} + @validate_input("delete", kwargs_state=[True, True, True, True, False]) @check_auth - def delete(self, uuid=None, perimeter_id=None, category_id=None, + def delete(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Delete a subject assignment for a given policy @@@ -141,8 -145,9 +145,9 @@@ class ObjectAssignments(Resource) "/policies//object_assignments///", ) + @validate_input("get", kwargs_state=[True, False, False,False,False]) @check_auth - def get(self, uuid=None, perimeter_id=None, category_id=None, + def get(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Retrieve all object assignment or a specific one for a given policy @@@ -171,8 -176,9 +176,9 @@@ "error": str(e)}, 500 return {"object_assignments": data} + @validate_input("post", kwargs_state=[True, False, False, False, False], body_state=[True, True, True]) @check_auth - def post(self, uuid=None, perimeter_id=None, category_id=None, + def post(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Create an object assignment. @@@ -210,8 -216,9 +216,9 @@@ "error": str(e)}, 500 return {"object_assignments": data} + @validate_input("delete", kwargs_state=[True, True, True, True, False]) @check_auth - def delete(self, uuid=None, perimeter_id=None, category_id=None, + def delete(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Delete a object assignment for a given policy @@@ -251,8 -258,9 +258,9 @@@ class ActionAssignments(Resource) "/policies//action_assignments///", ) + @validate_input("get", kwargs_state=[True, False, False,False,False]) @check_auth - def get(self, uuid=None, perimeter_id=None, category_id=None, + def get(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Retrieve all action assignment or a specific one for a given policy @@@ -281,8 -289,9 +289,9 @@@ "error": str(e)}, 500 return {"action_assignments": data} + @validate_input("post", kwargs_state=[True, False, False, False, False], body_state=[True, True, True]) @check_auth - def post(self, uuid=None, perimeter_id=None, category_id=None, + def post(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Create an action assignment. @@@ -320,8 -329,9 +329,9 @@@ "error": str(e)}, 500 return {"action_assignments": data} + @validate_input("delete", kwargs_state=[True, True, True, True, False]) @check_auth - def delete(self, uuid=None, perimeter_id=None, category_id=None, + def delete(self, uuid, perimeter_id=None, category_id=None, data_id=None, user_id=None): """Delete a action assignment for a given policy diff --cc moon_manager/moon_manager/api/data.py index 05e30236,2bf8d530..4b22f9dc --- a/moon_manager/moon_manager/api/data.py +++ b/moon_manager/moon_manager/api/data.py @@@ -31,9 -32,10 +32,10 @@@ class SubjectData(Resource) "", ) + @validate_input("get", kwargs_state=[True, False, False, False]) @check_auth - 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 + def get(self, uuid, 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 @@@ -63,8 -65,9 +65,9 @@@ "error": str(e)}, 500 return {"subject_data": data} + @validate_input("post", kwargs_state=[True, True, False, False], body_state=[True, False]) @check_auth - def post(self, uuid=None, category_id=None, data_id=None, user_id=None): + def post(self, uuid, category_id=None, data_id=None, user_id=None): """Create or update a subject. :param uuid: uuid of the policy @@@ -98,8 -101,9 +101,9 @@@ "error": str(e)}, 500 return {"subject_data": data} + @validate_input("delete", kwargs_state=[True, False, False, False]) @check_auth - def delete(self, uuid=None, category_id=None, data_id=None, user_id=None): + def delete(self, uuid, category_id=None, data_id=None, user_id=None): """Delete a subject for a given policy :param uuid: uuid of the policy @@@ -136,8 -140,9 +140,9 @@@ class ObjectData(Resource) "", ) + @validate_input("get", kwargs_state=[True, False, False, False]) @check_auth - def get(self, uuid=None, category_id=None, data_id=None, user_id=None): + def get(self, uuid, category_id=None, data_id=None, user_id=None): """Retrieve all object categories or a specific one if sid is given for a given policy @@@ -168,8 -173,9 +173,9 @@@ "error": str(e)}, 500 return {"object_data": data} + @validate_input("post", kwargs_state=[True, True, False, False], body_state=[True, False]) @check_auth - def post(self, uuid=None, category_id=None, data_id=None, user_id=None): + def post(self, uuid, category_id=None, data_id=None, user_id=None): """Create or update a object. :param uuid: uuid of the policy @@@ -203,8 -209,9 +209,9 @@@ "error": str(e)}, 500 return {"object_data": data} + @validate_input("delete", kwargs_state=[True, False, False, False]) @check_auth - def delete(self, uuid=None, category_id=None, data_id=None, user_id=None): + def delete(self, uuid, category_id=None, data_id=None, user_id=None): """Delete a object for a given policy :param uuid: uuid of the policy @@@ -241,8 -248,9 +248,9 @@@ class ActionData(Resource) "", ) + @validate_input("get", kwargs_state=[True, False, False, False]) @check_auth - def get(self, uuid=None, category_id=None, data_id=None, user_id=None): + def get(self, uuid, category_id=None, data_id=None, user_id=None): """Retrieve all action categories or a specific one if sid is given for a given policy @@@ -273,8 -281,9 +281,9 @@@ "error": str(e)}, 500 return {"action_data": data} + @validate_input("post", kwargs_state=[True, True, False, False], body_state=[True, False]) @check_auth - def post(self, uuid=None, category_id=None, data_id=None, user_id=None): + def post(self, uuid, category_id=None, data_id=None, user_id=None): """Create or update a action. :param uuid: uuid of the policy @@@ -308,8 -317,9 +317,9 @@@ "error": str(e)}, 500 return {"action_data": data} + @validate_input("delete", kwargs_state=[True, False, False, False]) @check_auth - def delete(self, uuid=None, category_id=None, data_id=None, user_id=None): + def delete(self, uuid, category_id=None, data_id=None, user_id=None): """Delete a action for a given policy :param uuid: uuid of the policy diff --cc moon_manager/moon_manager/api/meta_rules.py index 0728a447,7bec2ddf..afc11eba --- a/moon_manager/moon_manager/api/meta_rules.py +++ b/moon_manager/moon_manager/api/meta_rules.py @@@ -93,8 -96,9 +96,9 @@@ class MetaRules(Resource) "error": str(e)}, 500 return {"meta_rules": data} + @validate_input("patch", kwargs_state=[True, False], body_state=[True, True, True, True]) @check_auth - def patch(self, meta_rule_id=None, user_id=None): + def patch(self, meta_rule_id, user_id=None): """Update a meta rule :param meta_rule_id: Meta rule ID @@@ -128,8 -132,9 +132,9 @@@ "error": str(e)}, 500 return {"meta_rules": data} + @validate_input("delete", kwargs_state=[True, False]) @check_auth - def delete(self, meta_rule_id=None, user_id=None): + def delete(self, meta_rule_id, user_id=None): """Delete a meta rule :param meta_rule_id: Meta rule ID diff --cc moon_manager/moon_manager/api/models.py index 2dec13dc,37e96e47..440a4d2b --- a/moon_manager/moon_manager/api/models.py +++ b/moon_manager/moon_manager/api/models.py @@@ -81,8 -84,9 +84,9 @@@ class Models(Resource) "error": str(e)}, 500 return {"models": data} + @validate_input("delete", kwargs_state=[True, False]) @check_auth - def delete(self, uuid=None, user_id=None): + def delete(self, uuid, user_id=None): """Delete a model :param uuid: uuid of the model to delete @@@ -101,8 -105,9 +105,9 @@@ "error": str(e)}, 500 return {"result": True} + @validate_input("patch", kwargs_state=[True, False], body_state=[True, False, True]) @check_auth - def patch(self, uuid=None, user_id=None): + def patch(self, uuid, user_id=None): """Update a model :param uuid: uuid of the model to update diff --cc moon_manager/moon_manager/api/pdp.py index fba5c8ac,5ffd2ab0..fd20c85f --- a/moon_manager/moon_manager/api/pdp.py +++ b/moon_manager/moon_manager/api/pdp.py @@@ -161,8 -164,9 +164,9 @@@ class PDP(Resource) "error": str(e)}, 500 return {"pdps": data} + @validate_input("delete", kwargs_state=[True, False]) @check_auth - def delete(self, uuid=None, user_id=None): + def delete(self, uuid, user_id=None): """Delete a pdp :param uuid: uuid of the pdp to delete @@@ -182,8 -186,9 +186,9 @@@ "error": str(e)}, 500 return {"result": True} + @validate_input("patch", kwargs_state=[True, False], body_state=[True, True, True, False]) @check_auth - def patch(self, uuid=None, user_id=None): + def patch(self, uuid, user_id=None): """Update a pdp :param uuid: uuid of the pdp to update diff --cc moon_manager/moon_manager/api/perimeter.py index c69d623c,15f0dac3..014aa4b9 --- a/moon_manager/moon_manager/api/perimeter.py +++ b/moon_manager/moon_manager/api/perimeter.py @@@ -106,8 -110,9 +110,9 @@@ class Subjects(Resource) "error": str(e)}, 500 return {"subjects": data} + @validate_input("patch", kwargs_state=[False, True, False], body_state=[True, False, False, False]) @check_auth - def patch(self, uuid=None, perimeter_id=None, user_id=None): + def patch(self, uuid, perimeter_id=None, user_id=None): """Create or update a subject. :param uuid: uuid of the policy @@@ -253,8 -261,9 +261,9 @@@ class Objects(Resource) "error": str(e)}, 500 return {"objects": data} + @validate_input("patch", kwargs_state=[False, True, False], body_state=[True, False, False, False]) @check_auth - def patch(self, uuid=None, perimeter_id=None, user_id=None): + def patch(self, uuid, perimeter_id=None, user_id=None): """Create or update a object. :param uuid: uuid of the policy @@@ -387,8 -399,9 +399,9 @@@ class Actions(Resource) "error": str(e)}, 500 return {"actions": data} + @validate_input("patch", kwargs_state=[False, True, False], body_state=[True, False, False, False]) @check_auth - def patch(self, uuid=None, perimeter_id=None, user_id=None): + def patch(self, uuid, perimeter_id=None, user_id=None): """Create or update a action. :param uuid: uuid of the policy