use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct Account {
pub provider: &'static str,
pub id: String, pub source: CredentialSource,
pub label: Option<String>,
#[allow(dead_code)] pub display: Option<String>,
}
#[derive(Debug, Clone)]
pub enum CredentialSource {
FilePath(PathBuf),
#[allow(dead_code)] Keychain(String),
#[allow(dead_code)] Env(String),
#[allow(dead_code)] Loopback(u16),
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WindowKind {
Rolling,
Calendar,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Unit {
Percent,
Requests,
Credits,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Window {
pub key: String, pub kind: WindowKind,
pub unit: Unit,
pub used_pct: f64, pub used: Option<f64>,
pub limit: Option<f64>,
pub unlimited: bool,
pub resets_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Status {
Ok,
Stale,
AuthMissing,
NotDetected,
Error,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Snapshot {
pub provider: String,
pub account: String, #[serde(skip_serializing_if = "Option::is_none", default)]
pub label: Option<String>,
pub plan: Option<String>,
pub windows: Vec<Window>,
pub fetched_at: DateTime<Utc>,
pub status: Status,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub error: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub raw: Option<serde_json::Value>, }
#[derive(Debug, Serialize)]
pub struct Output {
pub v: u32,
pub generated_at: DateTime<Utc>,
pub snapshots: Vec<Snapshot>,
}