Merge "continue integrating validation"
authorAsteroide <thomas.duval@orange.com>
Wed, 9 May 2018 09:28:32 +0000 (09:28 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Wed, 9 May 2018 09:28:32 +0000 (09:28 +0000)
1  2 
moon_manager/moon_manager/api/assignments.py
moon_manager/moon_manager/api/data.py
moon_manager/moon_manager/api/meta_data.py
moon_manager/moon_manager/api/meta_rules.py
moon_manager/moon_manager/api/models.py
moon_manager/moon_manager/api/pdp.py
moon_manager/moon_manager/api/perimeter.py
moon_manager/moon_manager/api/rules.py

@@@ -31,8 -32,9 +32,9 @@@ class SubjectAssignments(Resource)
          "/policies/<string:uuid>/subject_assignments/<string:perimeter_id>/<string:category_id>/<string:data_id>",
      )
  
+     @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.
  
                      "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/<string:uuid>/object_assignments/<string:perimeter_id>/<string:category_id>/<string:data_id>",
      )
  
+     @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
  
                      "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.
  
                      "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/<string:uuid>/action_assignments/<string:perimeter_id>/<string:category_id>/<string:data_id>",
      )
  
+     @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
  
                      "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.
  
                      "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
  
@@@ -31,9 -32,10 +32,10 @@@ class SubjectData(Resource)
          "<string:data_id>",
      )
  
+     @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
                      "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)
          "<string:data_id>",
      )
  
+     @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
  
                      "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
                      "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)
          "<string:data_id>",
      )
  
+     @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
  
                      "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
                      "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
@@@ -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
                      "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
@@@ -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
                      "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
@@@ -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
                      "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
@@@ -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