#!/bin/python3

from query_request import ElasticQuery


def calculate_differentials(samples):
    pass


def get_samples(ts_from, ts_until):
    query = ElasticQuery()
    query.match_from_timestamp(ts_from, ts_until)
    index = "index_Ecosat-1234-5678_metrics"
    return query.send(index.lower())


def get_all_samples():
    query = ElasticQuery()
    query.match_all()
    index = "index_Ecosat-1234-5678_metrics"
    return query.send(index.lower())


def main():
    ts_from = '2022-05-22T09:13:28'
    ts_until = '2022-05-23T17:14:03'
    _, samples = get_samples(ts_from, ts_until)
    print(samples)
    print(samples[0]["_source"]["disk_usage"]["used"])
    calculate_differentials(samples)


if __name__ == "__main__":
    main()

# deltas, gradientes, varianza, media, maximo, minimo, percentiles
