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

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

/// TaskGroup is the unit of scheduling.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct TaskGroup {
    #[serde(
        rename = "Constraints",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub constraints: Vec<super::Constraint>,

    #[serde(
        rename = "Spreads",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub spreads: Vec<super::Spread>,

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

    #[serde(rename = "Update", skip_serializing_if = "Option::is_none")]
    pub update: Option<super::UpdateStrategy>,

    #[serde(
        rename = "Services",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub services: Vec<super::Service>,

    /// Deprecated: StopAfterClientDisconnect is deprecated in Nomad 1.8. Use Disconnect.StopOnClientAfter instead.
    #[serde(
        rename = "stop_after_client_disconnect",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub stop_after_client_disconnect: Option<chrono::TimeDelta>,

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

    #[serde(
        rename = "Affinities",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub affinities: Vec<super::Affinity>,

    #[serde(
        rename = "Tasks",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub tasks: Vec<super::Task>,

    #[serde(rename = "Volumes")]
    pub volumes: std::collections::HashMap<String, super::VolumeRequest>,

    /// To be deprecated after 1.8.0 infavour of Disconnect.LostAfter
    #[serde(
        rename = "max_client_disconnect",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub max_client_disconnect: Option<chrono::TimeDelta>,

    #[serde(rename = "Disconnect", skip_serializing_if = "Option::is_none")]
    pub disconnect: Option<super::DisconnectStrategy>,

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

    #[serde(
        rename = "Networks",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub networks: Vec<super::NetworkResource>,

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

    #[serde(rename = "Scaling", skip_serializing_if = "Option::is_none")]
    pub scaling: Option<super::ScalingPolicy>,

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

    #[serde(rename = "Count", skip_serializing_if = "Option::is_none")]
    pub count: Option<i64>,

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

    #[serde(rename = "Migrate", skip_serializing_if = "Option::is_none")]
    pub migrate: Option<super::MigrateStrategy>,

    #[serde(
        rename = "shutdown_delay",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub shutdown_delay: Option<chrono::TimeDelta>,

    /// To be deprecated after 1.8.0 infavour of Disconnect.Replace
    #[serde(
        rename = "PreventRescheduleOnLost",
        skip_serializing_if = "Option::is_none"
    )]
    pub prevent_reschedule_on_lost: Option<bool>,
}
