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

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

/// Allocation is used for serialization of allocations.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct Allocation {
    #[serde(rename = "AllocModifyIndex")]
    pub alloc_modify_index: u64,

    #[serde(rename = "ModifyTime")]
    pub modify_time: i64,

    #[serde(rename = "DeploymentID")]
    pub deployment_id: String,

    #[serde(rename = "PreemptedByAllocation")]
    pub preempted_by_allocation: String,

    #[serde(rename = "ClientStatus")]
    pub client_status: String,

    #[serde(rename = "ClientDescription")]
    pub client_description: String,

    #[serde(rename = "TaskGroup")]
    pub task_group: String,

    #[serde(rename = "DesiredStatus")]
    pub desired_status: String,

    #[serde(rename = "Services")]
    pub services: std::collections::HashMap<String, String>,

    #[serde(rename = "TaskStates")]
    pub task_states: std::collections::HashMap<String, super::TaskState>,

    #[serde(rename = "RescheduleTracker", skip_serializing_if = "Option::is_none")]
    pub reschedule_tracker: Option<super::RescheduleTracker>,

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

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

    #[serde(rename = "Resources", skip_serializing_if = "Option::is_none")]
    pub resources: Option<super::Resources>,

    #[serde(rename = "AllocatedResources", skip_serializing_if = "Option::is_none")]
    pub allocated_resources: Option<super::AllocatedResources>,

    #[serde(rename = "DesiredTransition")]
    pub desired_transition: super::DesiredTransition,

    #[serde(rename = "FollowupEvalID")]
    pub followup_eval_id: String,

    #[serde(
        rename = "PreemptedAllocations",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub preempted_allocations: Vec<String>,

    #[serde(rename = "NodeName")]
    pub node_name: String,

    #[serde(rename = "Job", skip_serializing_if = "Option::is_none")]
    pub job: Option<super::Job>,

    #[serde(rename = "DesiredDescription")]
    pub desired_description: String,

    #[serde(rename = "NetworkStatus", skip_serializing_if = "Option::is_none")]
    pub network_status: Option<super::AllocNetworkStatus>,

    #[serde(rename = "JobID")]
    pub job_id: String,

    #[serde(rename = "PreviousAllocation")]
    pub previous_allocation: String,

    #[serde(rename = "CreateTime")]
    pub create_time: i64,

    #[serde(rename = "EvalID")]
    pub eval_id: String,

    #[serde(rename = "NodeID")]
    pub node_id: String,

    #[serde(rename = "DeploymentStatus", skip_serializing_if = "Option::is_none")]
    pub deployment_status: Option<super::AllocDeploymentStatus>,

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

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

    #[serde(rename = "TaskResources")]
    pub task_resources: std::collections::HashMap<String, super::Resources>,

    #[serde(rename = "NextAllocation")]
    pub next_allocation: String,

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

    #[serde(rename = "Metrics", skip_serializing_if = "Option::is_none")]
    pub metrics: Option<super::AllocationMetric>,
}
