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

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

/// ServiceRegistration is an instance of a single allocation advertising itself
/// as a named service with a specific address. Each registration is constructed
/// from the job specification Service block. Whether the service is registered
/// within Nomad, and therefore generates a ServiceRegistration is controlled by
/// the Service.Provider parameter.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct ServiceRegistration {
    /// NodeID is Node.ID on which this service registration is currently
    /// running.
    #[serde(rename = "NodeID")]
    pub node_id: String,

    /// JobID is Job.ID and represents the job which contained the service block
    /// which resulted in this service registration.
    #[serde(rename = "JobID")]
    pub job_id: String,

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

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

    /// ServiceName is the human friendly identifier for this service
    /// registration.
    #[serde(rename = "ServiceName")]
    pub service_name: String,

    /// Namespace represents the namespace within which this service is
    /// registered.
    #[serde(rename = "Namespace")]
    pub namespace: String,

    /// AllocID is Allocation.ID and represents the allocation within which this
    /// service is running.
    #[serde(rename = "AllocID")]
    pub alloc_id: String,

    /// Tags are determined from either Service.Tags or Service.CanaryTags and
    /// help identify this service. Tags can also be used to perform lookups of
    /// services depending on their state and role.
    #[serde(
        rename = "Tags",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub tags: Vec<String>,

    /// Address is the IP address of this service registration. This information
    /// comes from the client and is not guaranteed to be routable; this depends
    /// on cluster network topology.
    #[serde(rename = "Address")]
    pub address: String,

    /// Port is the port number on which this service registration is bound. It
    /// is determined by a combination of factors on the client.
    #[serde(rename = "Port")]
    pub port: i64,

    /// ID is the unique identifier for this registration. It currently follows
    /// the Consul service registration format to provide consistency between
    /// the two solutions.
    #[serde(rename = "ID")]
    pub id: String,

    /// Datacenter is the DC identifier of the node as identified by
    /// Node.Datacenter.
    #[serde(rename = "Datacenter")]
    pub datacenter: String,
}
