using System;
using System.Collections.Generic;
using InfluxDB.Client;
using NodaTime;

namespace Monithor.api {
	public interface IMonitor {
		public string                Identifier { get; set; }
		public string                LastValue  { get; set; }
		public DateTime              StartedAt  { get; set; }
		public DateTime              ResolvedAt { get; set; }
		public MonitorStatus         Status     { get; set; }
		public string                Message    { get; set; }
		public IEnumerable<FluxItem> GetFluxItems(Influx          influx, string timespan);
		public bool                  Update(IEnumerable<FluxItem> data);
	}

	public enum MonitorStatus {
		Unknown,
		Up,
		Down,
		Validating,
		Recovering
	}

	public class Influx {
		public Influx(InfluxDBClient client, string org, string bucket) {
			Client = client;
			Org    = org;
			Bucket = bucket;
		}

		public readonly InfluxDBClient Client;
		public readonly string         Org;
		public readonly string         Bucket;
	}

	public class FluxItem {
		public Instant Time;
		public string  Status;
		public string  Message;
	}
}