docs: def atomic_swap(alias_name, new_index_name, index_client):
      """Points an alias to a new index, then delete the old index if needed
  
      Uses client.update_aliases to perform this with zero downtime
  
      Args:
          alias_name (str) Name of the alias
          new_index_name (str) The new index that the alias should point to
          index_client (Elasticsearch.IndicesClient) Elasticsearch index client
      """
      logging.info('Performing atomic index alias swap')
      if index_client.exists_alias(name=alias_name):
          old_index_name = get_index_from_alias(alias_name, index_client)
          logging.info('Removing old as well as adding new')
          actions = {'actions': [
              {'remove': {'index': old_index_name, 'alias': alias_name}},
              {'add': {'index': new_index_name, 'alias': alias_name}}
          ]}
          index_client.update_aliases(body=actions)
          index_client.delete(index=old_index_name)
      else:
          logging.info('Old alias not found, only adding new')
          actions = {'actions': [
              {'add': {'index': new_index_name, 'alias': alias_name}}
          ]}
          index_client.update_aliases(body=actions)