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

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

/// Service represents a Nomad job-submitters view of a Consul or Nomad service.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct Service {
    #[serde(rename = "Name")]
    pub name: String,

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

    #[serde(rename = "Connect", skip_serializing_if = "Option::is_none")]
    pub connect: Option<super::ConsulConnect>,

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

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

    /// Provider defines which backend system provides the service registration,
    /// either "consul" (default) or "nomad".
    #[serde(rename = "Provider")]
    pub provider: String,

    #[serde(rename = "Address")]
    pub address: String,

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

    #[serde(rename = "Identity", skip_serializing_if = "Option::is_none")]
    pub identity: Option<super::WorkloadIdentity>,

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

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

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

    /// Cluster is valid only for Nomad Enterprise with provider: consul
    #[serde(rename = "Cluster")]
    pub cluster: String,

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

    #[serde(
        rename = "Checks",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub checks: Vec<super::ServiceCheck>,

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

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

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

    #[serde(rename = "weights", skip_serializing_if = "Option::is_none")]
    pub weights: Option<super::ServiceWeights>,
}
