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

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

/// CSIVolume is used for serialization, see also nomad/structs/csi.go
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct CsiVolume {
    #[serde(rename = "NodesHealthy")]
    pub nodes_healthy: i64,

    #[serde(rename = "Name")]
    pub name: String,

    /// RequestedTopologies are the topologies submitted as options to
    /// the storage provider at the time the volume was created. After
    /// volumes are created, this field is ignored.
    #[serde(
        rename = "RequestedTopologies",
        skip_serializing_if = "Option::is_none"
    )]
    pub requested_topologies: Option<super::CsiTopologyRequest>,

    #[serde(rename = "Capacity")]
    pub capacity: i64,

    #[serde(
        rename = "RequestedCapabilities",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub requested_capabilities: Vec<super::CsiVolumeCapability>,

    /// ReadAllocs is a map of allocation IDs for tracking reader claim status.
    /// The Allocation value will always be nil; clients can populate this data
    /// by iterating over the Allocations field.
    #[serde(rename = "ReadAllocs")]
    pub read_allocs: std::collections::HashMap<String, super::Allocation>,

    #[serde(rename = "Provider")]
    pub provider: String,

    #[serde(rename = "ControllerRequired")]
    pub controller_required: bool,

    #[serde(rename = "ResourceExhausted")]
    pub resource_exhausted: chrono::DateTime<chrono::Utc>,

    #[serde(rename = "parameters", skip_serializing_if = "Option::is_none")]
    pub parameters: Option<std::collections::HashMap<String, String>>,

    /// These fields are used as part of the volume creation request
    #[serde(rename = "RequestedCapacityMin")]
    pub requested_capacity_min: i64,

    #[serde(rename = "snapshot_id", skip_serializing_if = "Option::is_none")]
    pub snapshot_id: Option<String>,

    #[serde(rename = "ControllersExpected")]
    pub controllers_expected: i64,

    #[serde(rename = "CreateIndex")]
    pub create_index: u64,

    /// CreateTime stored as UnixNano
    #[serde(rename = "CreateTime")]
    pub create_time: i64,

    #[serde(rename = "external_id", skip_serializing_if = "Option::is_none")]
    pub external_id: Option<String>,

    #[serde(rename = "AccessMode")]
    pub access_mode: String,

    #[serde(rename = "secrets", skip_serializing_if = "Option::is_none")]
    pub secrets: Option<std::collections::HashMap<String, String>>,

    #[serde(rename = "ControllersHealthy")]
    pub controllers_healthy: i64,

    #[serde(rename = "NodesExpected")]
    pub nodes_expected: i64,

    /// Topologies are the topologies returned by the storage provider,
    /// based on the RequestedTopologies and what the storage provider
    /// could support. This value cannot be set by the user.
    #[serde(
        rename = "Topologies",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub topologies: Vec<super::CsiTopology>,

    #[serde(rename = "context", skip_serializing_if = "Option::is_none")]
    pub context: Option<std::collections::HashMap<String, String>>,

    #[serde(rename = "RequestedCapacityMax")]
    pub requested_capacity_max: i64,

    #[serde(rename = "clone_id", skip_serializing_if = "Option::is_none")]
    pub clone_id: Option<String>,

    /// WriteAllocs is a map of allocation IDs for tracking writer claim
    /// status. The Allocation value will always be nil; clients can populate
    /// this data by iterating over the Allocations field.
    #[serde(rename = "WriteAllocs")]
    pub write_allocs: std::collections::HashMap<String, super::Allocation>,

    /// ModifyTime stored as UnixNano
    #[serde(rename = "ModifyTime")]
    pub modify_time: i64,

    #[serde(rename = "ID")]
    pub id: String,

    #[serde(rename = "AttachmentMode")]
    pub attachment_mode: String,

    /// Allocations is a combined list of readers and writers
    #[serde(
        rename = "Allocations",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub allocations: Vec<super::AllocationListStub>,

    /// Schedulable is true if all the denormalized plugin health fields are true
    #[serde(rename = "Schedulable")]
    pub schedulable: bool,

    #[serde(rename = "ModifyIndex")]
    pub modify_index: u64,

    #[serde(rename = "Namespace")]
    pub namespace: String,

    #[serde(rename = "MountOptions", skip_serializing_if = "Option::is_none")]
    pub mount_options: Option<super::CsiMountOptions>,

    #[serde(rename = "plugin_id", skip_serializing_if = "Option::is_none")]
    pub plugin_id: Option<String>,

    #[serde(rename = "ProviderVersion")]
    pub provider_version: String,
}
