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.py46
1 files changed, 17 insertions, 29 deletions
diff --git a/testapi/testapi-client/testapiclient/pods.py b/testapi/testapi-client/testapiclient/pods.py
index 6c8aaed..81d4b9e 100644
--- a/testapi/testapi-client/testapiclient/pods.py
+++ b/testapi/testapi-client/testapiclient/pods.py
@@ -1,17 +1,17 @@
import json
-from user import User
-from cliff.command import Command
-from httpClient import HTTPClient
-from authHandler import AuthHandler
+from testapiclient import identity
+from testapiclient import command
+
from config import Config
+from httpClient import HTTPClient
+from user import User
-class PodBase(Command):
- pods_url = Config.config.get("api", "url") + "/pods"
+PODS_URL = Config.config.get("api", "url") + "/pods"
-class PodGet(PodBase):
+class PodGet(command.Lister):
"Handle get request for pods"
def get_parser(self, prog_name):
@@ -23,14 +23,14 @@ class PodGet(PodBase):
def take_action(self, parsed_args):
http_client = HTTPClient.get_Instance()
- url = PodGet.pods_url
+ url = PODS_URL
if(parsed_args.name):
- url = PodGet.pods_url + "?name=" + parsed_args.name
+ url = PODS_URL + "?name=" + parsed_args.name
pods = http_client.get(url)
print pods
-class PodGetOne(PodBase):
+class PodGetOne(command.ShowOne):
"Handle get request for pod by name"
def get_parser(self, prog_name):
@@ -43,21 +43,15 @@ class PodGetOne(PodBase):
def take_action(self, parsed_args):
http_client = HTTPClient.get_Instance()
- pods = http_client.get(PodGetOne.pods_url + "/" + parsed_args.name)
+ pods = http_client.get(PODS_URL + "/" + parsed_args.name)
print pods
-class PodCreate(PodBase):
+class PodCreate(command.Command):
"Handle post request for pods"
def get_parser(self, prog_name):
parser = super(PodCreate, self).get_parser(prog_name)
- parser.add_argument('-u',
- type=str,
- help='Username for authentication')
- parser.add_argument('-p',
- type=str,
- help='Password for authentication')
parser.add_argument('pod',
type=json.loads,
help='Pod create request format :\n'
@@ -70,11 +64,11 @@ class PodCreate(PodBase):
def take_action(self, parsed_args):
http_client = HTTPClient.get_Instance()
if(parsed_args.u and parsed_args.p):
- response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
+ response = identity.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
print "Authentication has failed."
return
- response = http_client.post(PodCreate.pods_url,
+ response = http_client.post(PODS_URL,
User.session,
parsed_args.pod)
if response.status_code == 200:
@@ -83,17 +77,11 @@ class PodCreate(PodBase):
print response.text
-class PodDelete(PodBase):
+class PodDelete(command.Command):
"Handle delete request for pods"
def get_parser(self, prog_name):
parser = super(PodDelete, self).get_parser(prog_name)
- parser.add_argument('-u',
- type=str,
- help='Username for authentication')
- parser.add_argument('-p',
- type=str,
- help='Password for authentication')
parser.add_argument('-name',
type=str,
required=True,
@@ -103,10 +91,10 @@ class PodDelete(PodBase):
def take_action(self, parsed_args):
http_client = HTTPClient.get_Instance()
if(parsed_args.u and parsed_args.p):
- response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
+ response = identity.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
print "Authentication has failed."
return
- pods = http_client.delete(PodDelete.pods_url + "/" + parsed_args.name,
+ pods = http_client.delete(PODS_URL + "/" + parsed_args.name,
User.session)
print pods