/*
 * This is an auto-generated file.
 * Any manual changes may be overwritten without notice!
 */

use derive_builder::Builder;
use serde::{Deserialize, Serialize};

/// ServerHealth is the health (from the leader's point of view) of a server.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct ServerHealth {
    /// The status of the SerfHealth check for the server.
    #[serde(rename = "SerfStatus")]
    pub serf_status: String,

    /// Leader is whether this server is currently the leader.
    #[serde(rename = "Leader")]
    pub leader: bool,

    /// LastIndex is the last log index this server has a record of in its Raft log.
    #[serde(rename = "LastIndex")]
    pub last_index: u64,

    /// Healthy is whether or not the server is healthy according to the current
    /// Autopilot config.
    #[serde(rename = "Healthy")]
    pub healthy: bool,

    /// Voter is whether this is a voting server.
    #[serde(rename = "Voter")]
    pub voter: bool,

    /// ID is the raft ID of the server.
    #[serde(rename = "ID")]
    pub id: String,

    /// Name is the node name of the server.
    #[serde(rename = "Name")]
    pub name: String,

    /// Address is the address of the server.
    #[serde(rename = "Address")]
    pub address: String,

    /// StableSince is the last time this server's Healthy value changed.
    #[serde(rename = "StableSince")]
    pub stable_since: chrono::DateTime<chrono::Utc>,

    /// Version is the Nomad version of the server.
    #[serde(rename = "Version")]
    pub version: String,

    /// LastContact is the time since this node's last contact with the leader.
    #[serde(
        rename = "LastContact",
        serialize_with = "crate::serialize_duration",
        deserialize_with = "crate::deserialize_duration"
    )]
    pub last_contact: chrono::TimeDelta,

    /// LastTerm is the highest leader term this server has a record of in its Raft log.
    #[serde(rename = "LastTerm")]
    pub last_term: u64,
}
