Merge "utils/jenkins-jnlp-connect.sh: Make sure the pid directory exists"
[releng.git] / utils / test / testapi / opnfv_testapi / resources / scenario_handlers.py
1 from opnfv_testapi.resources.handlers import GenericApiHandler
2 from opnfv_testapi.resources.scenario_models import Scenario
3 from opnfv_testapi.tornado_swagger import swagger
4
5
6 class GenericScenarioHandler(GenericApiHandler):
7     def __init__(self, application, request, **kwargs):
8         super(GenericScenarioHandler, self).__init__(application,
9                                                      request,
10                                                      **kwargs)
11         self.table = self.db_scenarios
12         self.table_cls = Scenario
13
14
15 class ScenariosCLHandler(GenericScenarioHandler):
16     @swagger.operation(nickname="List scenarios by queries")
17     def get(self):
18         """
19             @description: Retrieve scenario(s).
20             @notes: Retrieve scenario(s)
21             @return 200: all scenarios consist with query,
22                          empty list if no scenario is found
23             @rtype: L{Scenarios}
24         """
25         self._list()
26
27     @swagger.operation(nickname="Create a new scenario")
28     def post(self):
29         """
30             @description: create a new scenario by name
31             @param body: scenario to be created
32             @type body: L{string}
33             @rtype: L{CreateResponse}
34         """
35         pass
36
37
38 class ScenarioGURHandler(GenericScenarioHandler):
39     @swagger.operation(nickname='Get the scenario by name')
40     def get(self, name):
41         """
42             @description: get a single scenario by name
43             @rtype: L{Scenario}
44             @return 200: scenario exist
45             @raise 404: scenario not exist
46         """
47         pass
48
49     @swagger.operation(nickname="Update the scenario by name")
50     def put(self, name):
51         """
52             @description: update a single scenario by name
53             @param body: fields to be updated
54             @type body: L{string}
55             @in body: body
56             @rtype: L{Scenario}
57             @return 200: update success
58             @raise 404: scenario not exist
59             @raise 403: nothing to update
60         """
61         pass