luminoso_api/v5_client.py
def connect(cls, url=None, token_file=None, token=None):
        """
        Returns an object that makes requests to the API, authenticated
        with a saved or specified long-lived token, at URLs beginning with
        `url`.

        If no URL is specified, or if the specified URL is a path such as
        '/projects' without a scheme and domain, the client will default to
        https://analytics.luminoso.com/api/v5/.

        If neither token nor token_file are specified, the client will look
        for a token in $HOME/.luminoso/tokens.json. The file should contain
        a single json dictionary of the format
        `{'root_url': 'token', 'root_url2': 'token2', ...}`.
        """
        if url is None:
            url = '/'

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

        if token is None:
            token_file = token_file or get_token_filename()
            try:
                with open(token_file) as tf:
                    token_dict = json.load(tf)
            except FileNotFoundError:
                raise LuminosoAuthError('No token file at %s' % token_file)
            try:
                token = token_dict[urlparse(root_url).netloc]
            except KeyError:
                raise LuminosoAuthError('No token stored for %s' % root_url)

        session = requests.session()
        session.auth = _TokenAuth(token)
        return cls(session, url)
def connect(cls, url=None, token_file=None, token=None):
        if url is None:
            url = '/'

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

        if token is None:
            token_file = token_file or get_token_filename()
            try:
                with open(token_file) as tf:
                    token_dict = json.load(tf)
            except FileNotFoundError:
                raise LuminosoAuthError('No token file at %s' % token_file)
            try:
                token = token_dict[urlparse(root_url).netloc]
            except KeyError:
                raise LuminosoAuthError('No token stored for %s' % root_url)

        session = requests.session()
        session.auth = _TokenAuth(token)
        return cls(session, url)
def connect ( cls , url = None , token_file = None , token = None ) : if url is None : url = '/' if url . startswith ( 'http' ) : root_url = get_root_url ( url ) else : url = URL_BASE + '/' + url . lstrip ( '/' ) root_url = URL_BASE if token is None : token_file = token_file or get_token_filename ( ) try : with open ( token_file ) as tf : token_dict = json . load ( tf ) except FileNotFoundError : raise LuminosoAuthError ( 'No token file at %s' % token_file ) try : token = token_dict [ urlparse ( root_url ) . netloc ] except KeyError : raise LuminosoAuthError ( 'No token stored for %s' % root_url ) session = requests . session ( ) session . auth = _TokenAuth ( token ) return cls ( session , url )
Returns an object that makes requests to the API, authenticated
        with a saved or specified long-lived token, at URLs beginning with
        `url`.

        If no URL is specified, or if the specified URL is a path such as
        '/projects' without a scheme and domain, the client will default to
        https://analytics.luminoso.com/api/v5/.

        If neither token nor token_file are specified, the client will look
        for a token in $HOME/.luminoso/tokens.json. The file should contain
        a single json dictionary of the format
        `{'root_url': 'token', 'root_url2': 'token2', ...}`.
Returns an object that makes requests to the API authenticated with a saved or specified long - lived token at URLs beginning with url .