summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/resources/scenario_handlers.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-26 17:34:05 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-01-09 10:18:02 +0800
commit8663a79c63b0629bef62c89cdff296d59133d426 (patch)
tree5c154f4ebcc397f7120dd922b80027ba271d20e0 /testapi/opnfv_testapi/resources/scenario_handlers.py
parentcc234da58259069d40f502751a4793bc00dd4fb2 (diff)
add scenario models and framework
JIRA: RELENG-163 Change-Id: I36a51022c087621d9539dc40f7d9acee4db95dfb Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/resources/scenario_handlers.py')
-rw-r--r--testapi/opnfv_testapi/resources/scenario_handlers.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/resources/scenario_handlers.py b/testapi/opnfv_testapi/resources/scenario_handlers.py
new file mode 100644
index 0000000..75754d8
--- /dev/null
+++ b/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -0,0 +1,61 @@
+from opnfv_testapi.resources.handlers import GenericApiHandler
+from opnfv_testapi.resources.scenario_models import Scenario
+from opnfv_testapi.tornado_swagger import swagger
+
+
+class GenericScenarioHandler(GenericApiHandler):
+ def __init__(self, application, request, **kwargs):
+ super(GenericScenarioHandler, self).__init__(application,
+ request,
+ **kwargs)
+ self.table = self.db_scenarios
+ self.table_cls = Scenario
+
+
+class ScenariosCLHandler(GenericScenarioHandler):
+ @swagger.operation(nickname="List scenarios by queries")
+ def get(self):
+ """
+ @description: Retrieve scenario(s).
+ @notes: Retrieve scenario(s)
+ @return 200: all scenarios consist with query,
+ empty list if no scenario is found
+ @rtype: L{Scenarios}
+ """
+ self._list()
+
+ @swagger.operation(nickname="Create a new scenario")
+ def post(self):
+ """
+ @description: create a new scenario by name
+ @param body: scenario to be created
+ @type body: L{string}
+ @rtype: L{CreateResponse}
+ """
+ pass
+
+
+class ScenarioGURHandler(GenericScenarioHandler):
+ @swagger.operation(nickname='Get the scenario by name')
+ def get(self, name):
+ """
+ @description: get a single scenario by name
+ @rtype: L{Scenario}
+ @return 200: scenario exist
+ @raise 404: scenario not exist
+ """
+ pass
+
+ @swagger.operation(nickname="Update the scenario by name")
+ def put(self, name):
+ """
+ @description: update a single scenario by name
+ @param body: fields to be updated
+ @type body: L{string}
+ @in body: body
+ @rtype: L{Scenario}
+ @return 200: update success
+ @raise 404: scenario not exist
+ @raise 403: nothing to update
+ """
+ pass