diff options
author | thuva4 <tharma.thuva@gmail.com> | 2018-04-10 10:48:17 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2018-04-10 10:48:17 +0530 |
commit | 11fe6cc670696e5e9ae73b9501e05fa19eeb6e13 (patch) | |
tree | 362d21bbb0392e86b0bd8f945806c6f72f4e8f5b /testapi/testapi-client/testapiclient/cli | |
parent | f3fb89a2d0f32ad4deeac418aed543630045cea5 (diff) |
Add CRUD operations for deployresults with tests
Change-Id: I679b6c1b0723ed3df2a9b0e6af5d9a149ede9987
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/testapi-client/testapiclient/cli')
-rw-r--r-- | testapi/testapi-client/testapiclient/cli/deployresults.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/deployresults.py b/testapi/testapi-client/testapiclient/cli/deployresults.py new file mode 100644 index 0000000..a6fe13e --- /dev/null +++ b/testapi/testapi-client/testapiclient/cli/deployresults.py @@ -0,0 +1,100 @@ +import json + +from testapiclient.utils import command +from testapiclient.utils import urlparse + + +def deployresults_url(): + return urlparse.resource_join('deployresults') + + +def deployresult_url(parsed_args): + return urlparse.path_join(deployresults_url(), parsed_args.deployresult_id) + + +class DeployresultGet(command.Lister): + + def get_parser(self, prog_name): + parser = super(DeployresultGet, self).get_parser(prog_name) + parser.add_argument('-build-id', + help='Search deployresults using build tag') + parser.add_argument('-from', + help='Search deployresults using from date') + parser.add_argument('-scenario', + help='Search deployresults using scenario') + parser.add_argument('-period', + help='Search deployresults using period') + parser.add_argument('-page', + help='Search deployresults using page') + parser.add_argument('-to', + help='Search deployresults using to') + parser.add_argument('---version', + help='Search deployresults using version') + parser.add_argument('-last', + help='Search deployresults using last date') + parser.add_argument('-pod-name', + help='Search deployresults using pod') + parser.add_argument('-criteria', + help='Search deployresults using version') + parser.add_argument('-installer', + help='Search deployresults using installer') + parser.add_argument('-job-name', + help='Search deployresults using project') + + return parser + + def take_action(self, parsed_args): + columns = ( + '_id', + 'pod_name', + 'version', + 'criteria', + 'start_date', + 'stop_date', + 'scenario', + 'installer', + + ) + data = self.app.client_manager.get( + urlparse.query_by(deployresults_url(), + ['build_id', 'from', 'last', + 'scenario', 'period', 'job_name', + 'to', 'version', + 'criteria', 'installer', 'pod_name', 'page'], + parsed_args)) + return self.format_output(columns, data.get('deployresults', [])) + + +class DeployresultGetOne(command.ShowOne): + + def get_parser(self, prog_name): + parser = super(DeployresultGetOne, self).get_parser(prog_name) + parser.add_argument('deployresult_id', + help='Search deployresult by deployresult id') + return parser + + def take_action(self, parsed_args): + return self.format_output( + self.app.client_manager.get(deployresult_url(parsed_args))) + + +class DeployresultCreate(command.ShowOne): + + def get_parser(self, prog_name): + parser = super(DeployresultCreate, self).get_parser(prog_name) + parser.add_argument('deployresult', + type=json.loads, + help='Deployresult create request format:\n' + '\'{"job_name" : "","scenario" : "",' + '"stop_date" : "", "build_id" : "",' + '"upstream_job_name": "",' + '"version" : "", "pod_name" : "",' + '"criteria" : "", "installer" : "",' + '"upstream_build_id" : "",' + '"start_date" : "", "details" : ""}\'') + return parser + + def take_action(self, parsed_args): + return self.format_output( + self.app.client_manager.post( + deployresults_url(), parsed_args.deployresult)) |