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

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

/// ACLToken represents a client token which is used to Authenticate
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct AclToken {
    #[serde(rename = "AccessorID")]
    pub accessor_id: String,

    #[serde(rename = "SecretID")]
    pub secret_id: String,

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

    /// Roles represents the ACL roles that this token is tied to. The token
    /// will inherit the permissions of all policies detailed within the role.
    #[serde(
        rename = "Roles",
        deserialize_with = "crate::deserialize_null_as_default"
    )]
    pub roles: Vec<super::AclTokenRoleLink>,

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

    #[serde(rename = "Type")]
    pub r#type: String,

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

    #[serde(rename = "Global")]
    pub global: bool,

    /// ExpirationTime represents the point after which a token should be
    /// considered revoked and is eligible for destruction. The zero value of
    /// time.Time does not respect json omitempty directives, so we must use a
    /// pointer.
    #[serde(rename = "ExpirationTime", skip_serializing_if = "Option::is_none")]
    pub expiration_time: Option<chrono::DateTime<chrono::Utc>>,

    /// ExpirationTTL is a convenience field for helping set ExpirationTime to a
    /// value of CreateTime+ExpirationTTL. This can only be set during token
    /// creation. This is a string version of a time.Duration like "2m".
    #[serde(
        rename = "ExpirationTTL",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub expiration_ttl: Option<chrono::TimeDelta>,

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

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