def meta_getter()

in curator/helpers/getters.py [0:0]


def meta_getter(client, idx, get=None):
    """Meta Getter
    Calls :py:meth:`~.elasticsearch.client.IndicesClient.get_settings` or
    :py:meth:`~.elasticsearch.client.IndicesClient.get_alias`

    :param client: A client connection object
    :param idx: An Elasticsearch index
    :param get: The kind of get to perform, e.g. settings or alias

    :type client: :py:class:`~.elasticsearch.Elasticsearch`
    :type idx: str
    :type get: str

    :returns: The settings from the get call to the named index
    :rtype: dict
    """
    logger = logging.getLogger(__name__)
    acceptable = ['settings', 'alias']
    if not get:
        raise ConfigurationError('"get" can not be a NoneType')
    if get not in acceptable:
        raise ConfigurationError(f'"get" must be one of {acceptable}')
    retval = {}
    try:
        if get == 'settings':
            retval = client.indices.get_settings(index=idx)[idx]['settings']['index']
        elif get == 'alias':
            retval = client.indices.get_alias(index=idx)[idx]['aliases']
    except es8exc.NotFoundError as missing:
        logger.error('Index %s was not found!', idx)
        raise es8exc.NotFoundError from missing
    except KeyError as err:
        logger.error('Key not found: %s', err)
        raise KeyError from err
    # pylint: disable=broad-except
    except Exception as exc:
        logger.error('Exception encountered: %s', exc)
    return retval