summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/cli
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2018-03-21 15:46:30 +0530
committerthuva4 <tharma.thuva@gmail.com>2018-03-23 12:12:56 +0530
commite5e56ebd95f24b337ec2b7140bb477c749459573 (patch)
tree960328556f7e997d09e4d541b2a3359b805a3db0 /testapi/testapi-client/testapiclient/cli
parentb8176c7026e9b7f50905cdad140bd16990eaba29 (diff)
Add installers CRUD in testapiclient
implement interface to do CRUD operations for installers in testapiclient Tests are added Change-Id: I025b01c5b48d5b04cfcead8ee7818c0a1752cec0 Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/testapi-client/testapiclient/cli')
-rw-r--r--testapi/testapi-client/testapiclient/cli/scenarios.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/scenarios.py b/testapi/testapi-client/testapiclient/cli/scenarios.py
index fc6a2db..3f70772 100644
--- a/testapi/testapi-client/testapiclient/cli/scenarios.py
+++ b/testapi/testapi-client/testapiclient/cli/scenarios.py
@@ -12,6 +12,10 @@ def scenario_url(parsed_args):
return urlparse.path_join(scenarios_url(), parsed_args.name)
+def resources_url(name, resuorce):
+ return urlparse.resource_join('scenarios', name, resuorce)
+
+
class ScenarioGet(command.Lister):
def get_parser(self, prog_name):
@@ -129,3 +133,64 @@ class ScenarioPut(command.ShowOne):
return self.format_output(
self.app.client_manager.put(
scenario_url(parsed_args), parsed_args.scenario))
+
+
+class InstallerCreate(command.Command):
+
+ def get_parser(self, prog_name):
+ parser = super(InstallerCreate, self).get_parser(prog_name)
+ parser.add_argument('--scenario-name',
+ required=True,
+ help='Create installer under scenario name')
+ parser.add_argument('installer',
+ type=json.loads,
+ help='Intaller create request format :\n'
+ '\'[{"installer": "","versions": []}]\',\n')
+ return parser
+
+ def take_action(self, parsed_args):
+ return self.app.client_manager.post(
+ resources_url(
+ parsed_args.scenario_name,
+ 'installers'), parsed_args.installer)
+
+
+class InstallerDelete(command.Command):
+
+ def get_parser(self, prog_name):
+ parser = super(InstallerDelete, self).get_parser(prog_name)
+ parser.add_argument('--scenario-name',
+ required=True,
+ type=str,
+ help='Delete installer by scenario name')
+ parser.add_argument('name',
+ nargs='+',
+ help='Delete installer by name')
+ return parser
+
+ def take_action(self, parsed_args):
+ return self.app.client_manager.delete(
+ resources_url(
+ parsed_args.scenario_name,
+ 'installers'), parsed_args.name)
+
+
+class InstallerPut(command.Command):
+
+ def get_parser(self, prog_name):
+ parser = super(InstallerPut, self).get_parser(prog_name)
+ parser.add_argument('--scenario-name',
+ type=str,
+ required=True,
+ help='Update installer by scenario name')
+ parser.add_argument('installer',
+ type=json.loads,
+ help='Intaller create request format :\n'
+ '\'[{"installer": "","versions": []}]\',\n')
+ return parser
+
+ def take_action(self, parsed_args):
+ return self.app.client_manager.put(
+ resources_url(
+ parsed_args.scenario_name,
+ 'installers'), parsed_args.installer)