diff options
Diffstat (limited to 'testapi/testapi-client/testapiclient/cli/pods.py')
-rw-r--r-- | testapi/testapi-client/testapiclient/cli/pods.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/pods.py b/testapi/testapi-client/testapiclient/cli/pods.py index cdedc3e..9cadee7 100644 --- a/testapi/testapi-client/testapiclient/cli/pods.py +++ b/testapi/testapi-client/testapiclient/cli/pods.py @@ -3,15 +3,15 @@ import json from testapiclient.utils import command from testapiclient.utils import http_client as client from testapiclient.utils import identity -from testapiclient.utils import url_parse +from testapiclient.utils import url_parse as up def pods_url(): - return url_parse.resource_join('pods') + return up.resource_join('pods') def pod_url(parsed_args): - return url_parse.path_join(pods_url(), parsed_args.name) + return up.path_join(pods_url(), parsed_args.name) class PodGet(command.Lister): @@ -25,7 +25,17 @@ class PodGet(command.Lister): return parser def take_action(self, parsed_args): - self.show(client.get(self.filter_by_name(pods_url(), parsed_args))) + columns = ( + "name", + "_id", + "creator", + "role", + "mode", + "creation_date", + ) + + data = client.get(up.query_by(pods_url(), 'name', parsed_args)) + return self.format_output(columns, data.get('pods', [])) class PodGetOne(command.ShowOne): @@ -39,10 +49,10 @@ class PodGetOne(command.ShowOne): return parser def take_action(self, parsed_args): - self.show(client.get(pod_url(parsed_args))) + return self.format_output(client.get(pod_url(parsed_args))) -class PodCreate(command.Command): +class PodCreate(command.ShowOne): "Handle post request for pods" def get_parser(self, prog_name): @@ -58,8 +68,7 @@ class PodCreate(command.Command): @identity.authenticate def take_action(self, parsed_args): - self.show('Create', - client.post(pods_url(), parsed_args.pod)) + return self.format_output(client.post(pods_url(), parsed_args.pod)) class PodDelete(command.Command): @@ -74,5 +83,4 @@ class PodDelete(command.Command): @identity.authenticate def take_action(self, parsed_args): - self.show('Delete', - client.delete(pod_url(parsed_args))) + return client.delete(pod_url(parsed_args)) |