def __init__(self, token, auth_url, retry=0, use_pool=False, pool_size=8, logger=None, headers=None): """Initialize AstakosClient Class Keyword arguments: token -- user's/service's token (string) auth_url -- i.e https://accounts.example.com/identity/v2.0 retry -- how many time to retry (integer) use_pool -- use objpool for http requests (boolean) pool_size -- if using pool, define the pool size logger -- pass a different logger """ # Get logger if logger is None: logger = logging.getLogger("astakosclient") logger.setLevel(logging.INFO) logger.debug( "Intialize AstakosClient: auth_url = %s, " "use_pool = %s, pool_size = %s", auth_url, use_pool, pool_size) # Check that token and auth_url (mandatory options) are given check_input("__init__", logger, token=token, auth_url=auth_url) # Initialize connection class parsed_auth_url = urlparse.urlparse(auth_url) conn_class = \ scheme_to_class(parsed_auth_url.scheme, use_pool, pool_size) if conn_class is None: msg = "Unsupported scheme: %s" % parsed_auth_url.scheme logger.error(msg) raise BadValue(msg) # Save astakos base url, logger, connection class etc in our class self.retry = retry self.logger = logger self.token = token self.astakos_base_url = parsed_auth_url.netloc self.scheme = parsed_auth_url.scheme self.conn_class = conn_class if headers is not None: self.headers = copy(headers) else: self.headers = None # Initialize astakos api prefixes # API urls under auth_url self.auth_prefix = parsed_auth_url.path self.api_tokens = join_urls(self.auth_prefix, "tokens")
def __init__(self, token, auth_url, retry=0, use_pool=False, pool_size=8, logger=None): """Initialize AstakosClient Class Keyword arguments: token -- user's/service's token (string) auth_url -- i.e https://accounts.example.com/identity/v2.0 retry -- how many time to retry (integer) use_pool -- use objpool for http requests (boolean) pool_size -- if using pool, define the pool size logger -- pass a different logger """ # Get logger if logger is None: logger = logging.getLogger("astakosclient") logger.setLevel(logging.INFO) logger.debug("Intialize AstakosClient: auth_url = %s, " "use_pool = %s, pool_size = %s", auth_url, use_pool, pool_size) # Check that token and auth_url (mandatory options) are given check_input("__init__", logger, token=token, auth_url=auth_url) # Initialize connection class parsed_auth_url = urlparse.urlparse(auth_url) conn_class = \ scheme_to_class(parsed_auth_url.scheme, use_pool, pool_size) if conn_class is None: msg = "Unsupported scheme: %s" % parsed_auth_url.scheme logger.error(msg) raise BadValue(msg) # Save astakos base url, logger, connection class etc in our class self.retry = retry self.logger = logger self.token = token self.astakos_base_url = parsed_auth_url.netloc self.scheme = parsed_auth_url.scheme self.conn_class = conn_class # Initialize astakos api prefixes # API urls under auth_url self.auth_prefix = parsed_auth_url.path self.api_tokens = join_urls(self.auth_prefix, "tokens")
def __init__(self, astakos_url, retry=0, use_pool=False, pool_size=8, logger=None): """Initialize AstakosClient Class Keyword arguments: astakos_url -- i.e https://accounts.example.com (string) use_pool -- use objpool for http requests (boolean) retry -- how many time to retry (integer) logger -- pass a different logger """ if logger is None: logging.basicConfig( format='%(asctime)s [%(levelname)s] %(name)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO) logger = logging.getLogger("astakosclient") logger.debug("Intialize AstakosClient: astakos_url = %s, " "use_pool = %s" % (astakos_url, use_pool)) check_input("__init__", logger, astakos_url=astakos_url) # Check for supported scheme p = urlparse.urlparse(astakos_url) conn_class = scheme_to_class(p.scheme, use_pool, pool_size) if conn_class is None: m = "Unsupported scheme: %s" % p.scheme logger.error(m) raise BadValue(m) # Save astakos_url etc. in our class self.retry = retry self.logger = logger self.netloc = p.netloc self.scheme = p.scheme self.path = p.path.rstrip('/') self.conn_class = conn_class