def _setup_kwargs(auth=None, use_config_file=False, config_file=None, timeout=DEFAULT_NETWORK_TIMEOUT_SEC): kwargs = {'auth': auth, 'timeout': timeout} config = None if use_config_file: config = read_evergreen_config() elif config_file is not None: config = read_evergreen_from_file(config_file) if config is not None: auth = get_auth_from_config(config) if auth: kwargs['auth'] = auth # If there is a value for api_server_host, then use it. if 'evergreen' in config and config['evergreen'].get( 'api_server_host', None): kwargs['api_server'] = config['evergreen']['api_server_host'] return kwargs
def get_api(cls, auth=None, use_config_file=False, config_file=None, timeout=DEFAULT_NETWORK_TIMEOUT_SEC): """ Get an evergreen api instance based on config file settings. :param auth: EvgAuth with authentication to use. :param use_config_file: attempt to read auth from default config file. :param config_file: config file with authentication information. :param timeout: Network timeout. :return: EvergreenApi instance. """ if not auth and use_config_file: config = read_evergreen_config() auth = get_auth_from_config(config) if not auth and config_file: config = read_evergreen_from_file(config_file) auth = get_auth_from_config(config) return cls(auth=auth, timeout=timeout)
def _setup_kwargs( auth: Optional[EvgAuth] = None, use_config_file: bool = False, config_file: Optional[str] = None, timeout: Optional[int] = DEFAULT_NETWORK_TIMEOUT_SEC, ) -> Dict: kwargs = {"auth": auth, "timeout": timeout} config = None if use_config_file: config = read_evergreen_config() elif config_file is not None: config = read_evergreen_from_file(config_file) if config is not None: auth = get_auth_from_config(config) if auth: kwargs["auth"] = auth # If there is a value for api_server_host, then use it. if "evergreen" in config and config["evergreen"].get("api_server_host", None): kwargs["api_server"] = config["evergreen"]["api_server_host"] return kwargs