summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/client/pods.py
blob: d08114f8fc4fda508eaf88a2c9c930859dfd5233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json

from testapiclient.client import base
from testapiclient.utils import urlparse


class PodsClient(base.Client):
    resource = 'pods'

    def __init__(self, **kwargs):
        super(PodsClient, self).__init__(**kwargs)

    def create(self, pod_req):
        return self.clientmanager.post(self.url, pod_req)

    def get(self, **queries):
        if queries:
            return json.dumps(
                self.clientmanager.get(
                    urlparse.query_join(self.url, **queries))['pods'])
        else:
            return json.dumps(
                self.clientmanager.get(self.url)['pods'])

    def get_one(self, name):
        return json.dumps(self.clientmanager.get(
            urlparse.path_join(self.url, name)))

    def delete(self, name):
        return self.clientmanager.delete(
            urlparse.path_join(self.url, name))