def load_rest_client(self): """Loads ns1 rest client config""" opts = self.rest_cfg_opts # Create default config without any key cfg = Config() cfg.createFromAPIKey('') if opts.get('path', None): cfg.loadFromFile(opts['path']) elif opts.get('api_key'): cfg.createFromAPIKey(opts['api_key']) else: path = os.path.join(self.home_dir, self.DEFAULT_CONFIG_FILE) if os.path.exists(path): cfg.loadFromFile(path) if opts.get('api_key_id'): cfg.useKeyId(opts['api_key_id']) if opts.get('endpoint'): cfg['endpoint'] = opts['endpoint'] if opts.get('transport'): cfg['transport'] = opts['transport'] if opts.get('ignore_ssl'): cfg['ignore-ssl-errors'] = opts['ignore_ssl'] if cfg['ignore-ssl-errors']: import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # Store the cli cfg dict as an attr of the rest config instance. for k, v in self.cfg.items(): cfg['cli'][k] = v self.rest = NSONE(config=cfg)