luminoso_api/v4_client.py
def connect(cls, url=None, username=None, password=None, token=None,
                token_file=None):
        """
        Returns an object that makes requests to the API, authenticated
        with the provided username/password, at URLs beginning with `url`.

        You can leave out the URL and get your 'default URL', a base path
        that is probably appropriate for creating projects on your
        account:

            client = LuminosoClient.connect(username=username)

        If the URL is simply a path, omitting the scheme and domain, then
        it will default to https://analytics.luminoso.com/api/v4/, which is
        probably what you want:

            client = LuminosoClient.connect('/projects/public', username=username)

        If you leave out the username, it will use your system username,
        which is convenient if it matches your Luminoso username:

            client = LuminosoClient.connect()
        """
        auto_account = False
        if url is None:
            auto_account = True
            url = '/'

        if url.startswith('http'):
            root_url = get_root_url(url)
        else:
            url = URL_BASE + '/' + url.lstrip('/')
            root_url = URL_BASE

        auth = cls._get_token_auth(username, password, token, token_file,
                                   root_url)
        session = requests.session()
        session.auth = auth
        client = cls(session, url)
        if auto_account:
            client = client.change_path('/projects/%s' %
                client._get_default_account())
        return client
def connect(cls, url=None, username=None, password=None, token=None,
                token_file=None):
        """
        Returns an object that makes requests to the API, authenticated
        with the provided username/password, at URLs beginning with `url`.

        You can leave out the URL and get your 'default URL', a base path
        that is probably appropriate for creating projects on your
        account:

            client = LuminosoClient.connect(username=username)

        If the URL is simply a path, omitting the scheme and domain, then
        it will default to https://analytics.luminoso.com/api/v4/, which is
        probably what you want:

            client = LuminosoClient.connect('/projects/public', username=username)

        If you leave out the username, it will use your system username,
        which is convenient if it matches your Luminoso username:

            client = LuminosoClient.connect()
        """
        auto_account = False
        if url is None:
            auto_account = True
            url = '/'

        if url.startswith('http'):
            root_url = get_root_url(url)
        else:
            url = URL_BASE + '/' + url.lstrip('/')
            root_url = URL_BASE

        auth = cls._get_token_auth(username, password, token, token_file,
                                   root_url)
        session = requests.session()
        session.auth = auth
        client = cls(session, url)
        if auto_account:
            client = client.change_path('/projects/%s' %
                client._get_default_account())
        return client
Returns an object that makes requests to the API, authenticated
        with the provided username/password, at URLs beginning with `url`.

        You can leave out the URL and get your 'default URL', a base path
        that is probably appropriate for creating projects on your
        account:

            client = LuminosoClient.connect(username=username)

        If the URL is simply a path, omitting the scheme and domain, then
        it will default to https://analytics.luminoso.com/api/v4/, which is
        probably what you want:

            client = LuminosoClient.connect('/projects/public', username=username)

        If you leave out the username, it will use your system username,
        which is convenient if it matches your Luminoso username:

            client = LuminosoClient.connect()