From 30d7e5ef5091144ea22185bb27c7e3900d7b6a45 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 23 Aug 2017 15:54:45 +0800 Subject: update scenario name url PUT /api/v1/scenarios/ if new_name already exist, return Forbidden if new_name == name, return Forbidden Change-Id: If3b82b3df4a763d60dad110caca2659c5f39ab50 Signed-off-by: SerenaFeng --- .../testapi/opnfv_testapi/resources/scenario_handlers.py | 15 ++++++++++++++- .../testapi/opnfv_testapi/resources/scenario_models.py | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'utils/test/testapi/opnfv_testapi/resources') diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py index 6cdf99ea0..e9c19a7a4 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py @@ -114,8 +114,21 @@ class ScenarioGURHandler(GenericScenarioHandler): self._get_one(query={'name': name}) pass + @swagger.operation(nickname="updateScenarioName") def put(self, name): - pass + """ + @description: update scenario, only rename is supported currently + @param body: fields to be updated + @type body: L{ScenarioUpdateRequest} + @in body: body + @rtype: L{Scenario} + @return 200: update success + @raise 404: scenario not exist + @raise 403: nothing to update + """ + query = {'name': name} + db_keys = ['name'] + self._update(query=query, db_keys=db_keys) @swagger.operation(nickname="deleteScenarioByName") def delete(self, name): diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py index c6da76b81..d950ed1d7 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py @@ -166,6 +166,12 @@ class ScenarioChangeOwnerRequest(models.ModelBase): self.owner = owner +@swagger.model() +class ScenarioUpdateRequest(models.ModelBase): + def __init__(self, name=None): + self.name = name + + @swagger.model() class Scenario(models.ModelBase): """ -- cgit 1.2.3-korg