summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/pods.py
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/testapi-client/testapiclient/pods.py')
-rw-r--r--testapi/testapi-client/testapiclient/pods.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/testapi/testapi-client/testapiclient/pods.py b/testapi/testapi-client/testapiclient/pods.py
index 0e58324..c49f254 100644
--- a/testapi/testapi-client/testapiclient/pods.py
+++ b/testapi/testapi-client/testapiclient/pods.py
@@ -1,11 +1,17 @@
import json
-import os
from testapiclient import command
from testapiclient import http_client
from testapiclient import identity
+from testapiclient import url_parse
-PODS_URL = os.environ.get('testapi_url') + "/pods"
+
+def pods_url():
+ return url_parse.resource_join('pods')
+
+
+def pod_url(parsed_args):
+ return url_parse.path_join(pods_url(), parsed_args.name)
class PodGet(command.Lister):
@@ -19,10 +25,8 @@ class PodGet(command.Lister):
return parser
def take_action(self, parsed_args):
- url = PODS_URL
- if(parsed_args.name):
- url = PODS_URL + "?name=" + parsed_args.name
- pods = http_client.get(url)
+ pods = http_client.get(self.filter_by_name(pods_url(),
+ parsed_args))
print pods
@@ -38,7 +42,7 @@ class PodGetOne(command.ShowOne):
return parser
def take_action(self, parsed_args):
- pods = http_client.get(PODS_URL + "/" + parsed_args.name)
+ pods = http_client.get(pod_url(parsed_args))
print pods
@@ -58,8 +62,7 @@ class PodCreate(command.Command):
@identity.authenticate
def take_action(self, parsed_args):
- response = http_client.post(PODS_URL,
- parsed_args.pod)
+ response = http_client.post(pods_url(), parsed_args.pod)
if response.status_code == 200:
print "Pod has been successfully created!"
else:
@@ -79,4 +82,4 @@ class PodDelete(command.Command):
@identity.authenticate
def take_action(self, parsed_args):
- print http_client.delete(PODS_URL + "/" + parsed_args.name)
+ print http_client.delete(pod_url(parsed_args))