%PDF- %PDF-
Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/apiclient/ |
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/apiclient/__init__.py |
import logging from xray import gettext as _ logger = logging.getLogger('api_client.init') def get_client(interface: str = 'api_task') -> 'Client object': """ Get a client according to given interface: 'api' --> MongoDB APIClient 'api_req' --> ClickHouse APIClient 'base' --> basic APIClient 'dbm' --> DBMClient :param interface: 'api'|'api_req'|'base'|'dbm' :return: a Client object """ if interface == 'api_task': logger.info('Initializing MongoDB API client') from .api_client import APIClient return APIClient elif interface == 'api_req': logger.info('Initializing ClickHouse API client') from .api_client import SendClient return SendClient elif interface == 'dbm': logger.info('Initializing DBM API client') from .api_client import DBMClient return DBMClient elif interface == 'auto_tasks': logger.info('Initializing MongoDB API client for auto tasks') from .api_client import TasksClient return TasksClient elif interface == 'lists': logger.info('Initializing MongoDB API client for UI') from .api_client import UIAPIClient return UIAPIClient elif interface == 'adviser': logger.info('Initializing Smart Advice API client') from .api_client import SmartAdviceAPIClient return SmartAdviceAPIClient elif interface == 'awp_provision': logger.info('Initializing AWP Provision API client') from .api_client import AWPProvisionAPIClient return AWPProvisionAPIClient else: logger.error('Unknown client to initialize', extra={'requested_client': interface}) raise RuntimeError(_("Do not know client of '%s' interface") % str(interface))