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

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

/// OperatorHealthReply is a representation of the overall health of the cluster
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct OperatorHealthReply {
    /// FailureTolerance is the number of healthy servers that could be lost without
    /// an outage occurring.
    #[serde(rename = "FailureTolerance")]
    pub failure_tolerance: i64,

    /// List of servers that are voters in the Raft configuration.
    #[serde(
        rename = "Voters",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub voters: Vec<String>,

    /// ReadReplicas holds the list of servers that are
    /// read replicas in the Raft configuration. (Enterprise only)
    #[serde(rename = "ReadReplicas", skip_serializing_if = "Option::is_none")]
    pub read_replicas: Option<Vec<String>>,

    /// Upgrade holds the current upgrade status.
    #[serde(rename = "Upgrade", skip_serializing_if = "Option::is_none")]
    pub upgrade: Option<super::AutopilotUpgrade>,

    /// The number of servers that could be lost without an outage
    /// occurring if all the voters don't fail at once.  (Enterprise only)
    #[serde(
        rename = "OptimisticFailureTolerance",
        skip_serializing_if = "Option::is_none"
    )]
    pub optimistic_failure_tolerance: Option<i64>,

    /// Healthy is true if all the servers in the cluster are healthy.
    #[serde(rename = "Healthy")]
    pub healthy: bool,

    /// Servers holds the health of each server.
    #[serde(
        rename = "Servers",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub servers: Vec<super::ServerHealth>,

    /// The ID of the current leader.
    #[serde(rename = "Leader")]
    pub leader: String,

    /// RedundancyZones holds the list of servers in each redundancy zone.
    /// (Enterprise only)
    #[serde(rename = "RedundancyZones", skip_serializing_if = "Option::is_none")]
    pub redundancy_zones: Option<std::collections::HashMap<String, super::AutopilotZone>>,
}
