def get_settings()

in src/es_pii_tool/helpers/elastic_api.py [0:0]


def get_settings(client: 'Elasticsearch', index: str) -> t.Dict:
    """Get the settings for an index

    :param client: A client connection object
    :param index: The index to check

    :type client: :py:class:`~.elasticsearch.Elasticsearch`
    :type index: str

    :returns: The settings object for the named index
    """
    logger.debug('Getting settings for index: %s', index)
    try:
        response = dict(
            client.indices.get_settings(
                index=index, expand_wildcards=['open', 'hidden']
            )
        )
        logger.debug(response)
    except (ApiError, NotFoundError, TransportError, BadRequestError) as err:
        logger.error("Index: '%s' not found. Error: %s", index, err)
        raise MissingIndex(f'Index "{index}" not found', err, index)
    logger.debug('Index settings collected.')
    return response