def update_alias(elastic_client, alias, index, action):
    """
    Update an alias in Elastic, either adding or removing an index
    :param elastic_client: Elastic client
    :param alias: Alias on which to operate
    :param index: Index with which to operate
    :param action: "add" or "remove"
    :return: Response from Elastic
    """
    body = {'actions': [{action: {'alias': alias, 'index': index}}]}
    response = elastic_client.indices.update_aliases(body=body)
    if response is None:
        raise Exception('Problem occurred updating alias. Alias: {}. Index: {}'
            .format(alias, index))
    return response
