def get_phase()

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


def get_phase(client: 'Elasticsearch', index: str) -> t.Union[str, None]:
    """Get the index's ILM phase

    :param client: A client connection object
    :param index: The index name

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

    :returns: The ILM phase of ``index``
    """
    phase = None
    ilm = get_ilm(client, index)
    try:
        phase = ilm['indices'][index]['phase']
    except KeyError:  # Perhaps in cold/frozen but not ILM affiliated
        settings = get_settings(client, index)[index]['settings']['index']
        if "store" in settings:
            # Checking if it's a mounted searchable snapshot
            if settings["store"]["type"] == "snapshot":
                phase = get_phase_from_tier_pref(settings)
        else:
            phase = None
    return phase