@contextlib.contextmanager<EOL>def zero_downtime_index(index_name, index_config):
client = indices_client()<EOL>temporary_name = index_name + '<STR_LIT:_>' + str(uuid.uuid4())<EOL>logging.info('<STR_LIT>', index_config)<EOL>create_index(temporary_name, index_config, client)<EOL>try:<EOL><INDENT>yield temporary_name<EOL>atomic_swap(index_name, temporary_name, client)<EOL><DEDENT>except Exception:<EOL><INDENT>logging.error(<EOL>'<STR_LIT>',<EOL>temporary_name,<EOL>exc_info=True<EOL>)<EOL>client.delete(index=temporary_name)<EOL><DEDENT>
Context manager to create a new index based on a given alias,
    allow the caller to index it, and then point the alias to the new index

    Args:
        index_name (str) Name of an alias that should point to the new index
        index_config (dict) Configuration for the new index

    Yields: (name) The full name of the new index