summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/client/base.py
blob: c45c9b7cc323045ce997108be5ac297b7bcaabc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from testapiclient.utils import clientmanager
from testapiclient.utils import urlparse


class AuthOption(object):
    def __init__(self, user=None, password=None):
        self.u = user
        self.p = password


class Client(object):

    resource = ''

    def __init__(self, user=None, password=None, client_manager=None):
        self.url = urlparse.resource_join(self.resource)
        if client_manager:
            self.clientmanager = client_manager
        else:
            self.clientmanager = clientmanager.ClientManager(
                AuthOption(user, password))
            if self.clientmanager.auth_required:
                self.clientmanager.auth()