1from __future__ import unicode_literals
2
3from six.moves.urllib.parse import urlparse
4
5from rbtools.api.transport.sync import SyncTransport
6
7
8class RBClient(object):
9    """Entry point for accessing RB resources through the web API.
10
11    By default the synchronous transport will be used. To use a
12    different transport, provide the transport class in the
13    'transport_cls' parameter.
14    """
15    def __init__(self, url, transport_cls=SyncTransport, *args, **kwargs):
16        self.url = url
17        self.domain = urlparse(url)[1]
18        self._transport = transport_cls(url, *args, **kwargs)
19
20    def get_root(self, *args, **kwargs):
21        return self._transport.get_root(*args, **kwargs)
22
23    def get_path(self, path, *args, **kwargs):
24        return self._transport.get_path(path, *args, **kwargs)
25
26    def get_url(self, url, *args, **kwargs):
27        return self._transport.get_url(url, *args, **kwargs)
28
29    def login(self, *args, **kwargs):
30        return self._transport.login(*args, **kwargs)
31
32    def logout(self, *args, **kwargs):
33        return self._transport.logout(*args, **kwargs)
34