def clean_indexes(ctx, days, es, username, password, ignore_certs): """Clean bulletins indexes older than n number of days""" conn_config = configure_es_connection(es, username, password, ignore_certs) conn = ElasticsearchConnector(conn_config) indexes = conn.get('{}*'.format(INDEX_BASENAME)) if indexes: indexes_to_delete = check_es_indexes_to_delete(indexes, days) if indexes_to_delete: click.echo('Deleting indexes {}'.format(indexes_to_delete)) conn.delete(','.join(indexes_to_delete)) click.echo('Done')
def clean_indexes(ctx, days, dataset, es, username, password, ignore_certs): """Delete old AQHI realtime indexes older than n days""" conn_config = configure_es_connection(es, username, password, ignore_certs) conn = ElasticsearchConnector(conn_config) if dataset == 'all': indexes_to_fetch = '{}*'.format(INDEX_BASENAME.format('*')) else: indexes_to_fetch = '{}*'.format(INDEX_BASENAME.format(dataset)) indexes = conn.get(indexes_to_fetch) if indexes: indexes_to_delete = check_es_indexes_to_delete(indexes, days) if indexes_to_delete: click.echo('Deleting indexes {}'.format(indexes_to_delete)) conn.delete(','.join(indexes)) click.echo('Done')