# Path: es_stats_zabbix/defaults/config.py
# def schema(key):
#     """Define voluptuous schemas by provided key"""
#     return Schema({Optional(key, default={}): DEFAULTS[key]})
# 
# Path: es_stats_zabbix/defaults/settings.py
# def apis():
#     """
#     Return constant APIS
#     """
#     return APIS
# 
# Path: es_stats_zabbix/exceptions.py
# class ConfigurationError(ESZException):
#     """
#     Exception raised when a misconfiguration is detected
#     """
# 
# Path: es_stats_zabbix/helpers/logtools.py
# def set_logging(log_opts):
#     """Set up the root handler"""
#     from logging import NullHandler
#     # Set up logging
#     loginfo = LogInfo(log_opts)
#     logging.root.addHandler(loginfo.handler)
#     logging.root.setLevel(loginfo.numeric_log_level)
#     # Set up NullHandler() to handle nested elasticsearch.trace Logger
#     # instance in elasticsearch python client
#     logging.getLogger('elasticsearch.trace').addHandler(NullHandler())
#     if log_opts['blacklist']:
#         for bl_entry in ensure_list(log_opts['blacklist']):
#             for handler in logging.root.handlers:
#                 handler.addFilter(Blacklist(bl_entry))


import logging
from es_client import Builder
from es_client.helpers.schemacheck import SchemaCheck
from es_client.helpers.utils import get_yaml, prune_nones
from es_stats_zabbix.defaults.config import schema
from es_stats_zabbix.defaults.settings import apis
from es_stats_zabbix.exceptions import ConfigurationError
from es_stats_zabbix.helpers.logtools import set_logging
    value = {'do_not_discover': {'health': ['status']}}
    for k in TOP_LEVEL:
        value[k] = {}
    return value

def get_client(cfg):
    """
    Return an Elasticsearch client object from a configuration dictionary
    """
    try:
        return Builder(cfg).client
    except Exception as err:
        msg = 'Failed to connect to Elasticsearch: Exception: {0}'.format(err)
        LOGGER.error(msg)
        raise ConfigurationError(msg)

def check_schema(cfg, key):
    """
    Ensure that the schema passes muster
    """
    try:
        return SchemaCheck(
            {key: prune_nones(cfg[key])},
            schema(key),
            '{0} Configuration'.format(key.title()),
            key
        ).result()
    except Exception as err:
        msg = 'Failed to configure {0}: Exception: {1}'.format(key, err)
        LOGGER.error(msg)

# Path: es_stats_zabbix/defaults/config.py
# def schema(key):
#     """Define voluptuous schemas by provided key"""
#     return Schema({Optional(key, default={}): DEFAULTS[key]})
# 
# Path: es_stats_zabbix/defaults/settings.py
# def apis():
#     """
#     Return constant APIS
#     """
#     return APIS
# 
# Path: es_stats_zabbix/exceptions.py
# class ConfigurationError(ESZException):
#     """
#     Exception raised when a misconfiguration is detected
#     """
# 
# Path: es_stats_zabbix/helpers/logtools.py
# def set_logging(log_opts):
#     """Set up the root handler"""
#     from logging import NullHandler
#     # Set up logging
#     loginfo = LogInfo(log_opts)
#     logging.root.addHandler(loginfo.handler)
#     logging.root.setLevel(loginfo.numeric_log_level)
#     # Set up NullHandler() to handle nested elasticsearch.trace Logger
#     # instance in elasticsearch python client
#     logging.getLogger('elasticsearch.trace').addHandler(NullHandler())
#     if log_opts['blacklist']:
#         for bl_entry in ensure_list(log_opts['blacklist']):
#             for handler in logging.root.handlers:
#                 handler.addFilter(Blacklist(bl_entry))


# Path: es_stats_zabbix/helpers/config.py
import logging
from es_client import Builder
from es_client.helpers.schemacheck import SchemaCheck
from es_client.helpers.utils import get_yaml, prune_nones
from es_stats_zabbix.defaults.config import schema
from es_stats_zabbix.defaults.settings import apis
from es_stats_zabbix.exceptions import ConfigurationError
from es_stats_zabbix.helpers.logtools import set_logging

    value = {'do_not_discover': {'health': ['status']}}
    for k in TOP_LEVEL:
        value[k] = {}
    return value

def get_client(cfg):
    """
    Return an Elasticsearch client object from a configuration dictionary
    """
    try:
        return Builder(cfg).client
    except Exception as err:
        msg = 'Failed to connect to Elasticsearch: Exception: {0}'.format(err)
        LOGGER.error(msg)
        raise ConfigurationError(msg)

def check_schema(cfg, key):
    """
    Ensure that the schema passes muster
    """
    try:
        return SchemaCheck(
            {key: prune_nones(cfg[key])},
            schema(key),
            '{0} Configuration'.format(key.title()),
            key
        ).result()
    except Exception as err:
        msg = 'Failed to configure {0}: Exception: {1}'.format(key, err)
        LOGGER.error(msg)

        raise ConfigurationError(msg)