3.3 KiB · text History bbb2a48
//! The response shapes, as much of them as the renderers read. Everything
//! not needed to draw a table is optional, so a server that adds or drops
//! a field doesn't break a listing; `--json` shows the rest.

use serde::Deserialize;

#[derive(Debug, Deserialize)]
pub struct Root {
    pub user: Option<User>,
    pub auth: Option<Auth>,
}

#[derive(Debug, Deserialize)]
pub struct User {
    pub id: String,
    pub email: Option<String>,
    pub name: Option<String>,
}

#[derive(Debug, Deserialize)]
pub struct Auth {
    pub label: Option<String>,
    #[serde(default)]
    pub scopes: Vec<String>,
}

#[derive(Debug, Deserialize)]
pub struct Organization {
    pub slug: String,
    pub name: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Team {
    pub slug: String,
    pub name: String,
    #[serde(default)]
    pub is_member: bool,
    #[serde(default)]
    pub member_count: Option<u64>,
    #[serde(default)]
    pub projects: Vec<ProjectRef>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct ProjectRef {
    pub slug: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct TeamRef {
    pub slug: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Project {
    pub id: String,
    pub slug: String,
    pub name: String,
    pub platform: Option<String>,
    pub date_created: Option<String>,
    pub first_event: Option<String>,
    #[serde(default)]
    pub teams: Vec<TeamRef>,
}

#[derive(Debug, Deserialize)]
pub struct Dsn {
    pub public: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RateLimit {
    pub window: u64,
    pub count: u64,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Key {
    pub id: String,
    pub name: Option<String>,
    pub is_active: bool,
    pub rate_limit: Option<RateLimit>,
    pub dsn: Dsn,
    pub date_created: Option<String>,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Issue {
    pub short_id: String,
    pub title: String,
    pub status: String,
    pub level: String,
    pub count: Option<String>,
    pub last_seen: Option<String>,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Release {
    pub version: String,
    pub short_version: Option<String>,
    pub status: Option<String>,
    pub date_created: Option<String>,
    pub date_released: Option<String>,
    #[serde(default)]
    pub new_groups: u64,
    #[serde(default)]
    pub commit_count: u64,
    #[serde(default)]
    pub deploy_count: u64,
    pub url: Option<String>,
    pub r#ref: Option<String>,
    #[serde(default)]
    pub projects: Vec<ProjectRef>,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Monitor {
    pub slug: String,
    pub name: String,
    pub status: String,
    pub health: Option<String>,
    pub schedule: Option<String>,
    pub next_check_in: Option<String>,
    pub last_check_in: Option<String>,
    pub project: Option<ProjectRef>,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UptimeMonitor {
    pub name: String,
    pub r#type: String,
    pub target: Option<String>,
    pub status: String,
    pub reason: Option<String>,
    pub response_ms: Option<u64>,
    pub last_check: Option<String>,
    pub project: Option<ProjectRef>,
}