summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py53
1 files changed, 46 insertions, 7 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index 7bf3d5d53..a9b89eb89 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -14,18 +14,56 @@ class GenericScenarioHandler(GenericApiHandler):
class ScenariosCLHandler(GenericScenarioHandler):
- @swagger.operation(nickname="List scenarios by queries")
+ @swagger.operation(nickname="queryScenarios")
def get(self):
"""
@description: Retrieve scenario(s).
@notes: Retrieve scenario(s)
- @return 200: all scenarios consist with query,
+ Available filters for this request are :
+ - name : scenario name
+
+ GET /scenarios?name=scenario_1
+ @param name: scenario name
+ @type name: L{string}
+ @in name: query
+ @required name: False
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: False
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: False
+ @param project: project name
+ @type project: L{string}
+ @in project: query
+ @required project: False
+ @return 200: all scenarios satisfy queries,
empty list if no scenario is found
@rtype: L{Scenarios}
"""
- self._list()
- @swagger.operation(nickname="Create a new scenario")
+ def _set_query():
+ query = dict()
+ elem_query = dict()
+ for k in self.request.query_arguments.keys():
+ v = self.get_query_argument(k)
+ if k == 'installer':
+ elem_query["installer"] = v
+ elif k == 'version':
+ elem_query["versions.version"] = v
+ elif k == 'project':
+ elem_query["versions.projects.project"] = v
+ else:
+ query[k] = v
+ if elem_query:
+ query['installers'] = {'$elemMatch': elem_query}
+ return query
+
+ self._list(_set_query())
+
+ @swagger.operation(nickname="createScenario")
def post(self):
"""
@description: create a new scenario by name
@@ -50,7 +88,7 @@ class ScenariosCLHandler(GenericScenarioHandler):
class ScenarioGURHandler(GenericScenarioHandler):
- @swagger.operation(nickname='Get the scenario by name')
+ @swagger.operation(nickname='getScenarioByName')
def get(self, name):
"""
@description: get a single scenario by name
@@ -58,14 +96,15 @@ class ScenarioGURHandler(GenericScenarioHandler):
@return 200: scenario exist
@raise 404: scenario not exist
"""
+ self._get_one({'name': name})
pass
- @swagger.operation(nickname="Update the scenario by name")
+ @swagger.operation(nickname="updateScenarioByName")
def put(self, name):
"""
@description: update a single scenario by name
@param body: fields to be updated
- @type body: L{string}
+ @type body: L{ScenarioCreateRequest}
@in body: body
@rtype: L{Scenario}
@return 200: update success