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

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

/// ACLAuthMethod is used to capture the properties of an authentication method
/// used for single sing-on.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct AclAuthMethod {
    /// Type is the SSO identifier this auth-method is. Nomad currently only
    /// supports "oidc" and the API contains ACLAuthMethodTypeOIDC for
    /// convenience.
    #[serde(rename = "Type")]
    pub r#type: String,

    /// TokenNameFormat defines the HIL template to use when building the token name
    #[serde(rename = "TokenNameFormat")]
    pub token_name_format: String,

    /// MaxTokenTTL is the maximum life of a token created by this method.
    #[serde(
        rename = "MaxTokenTTL",
        serialize_with = "crate::serialize_duration",
        deserialize_with = "crate::deserialize_duration"
    )]
    pub max_token_ttl: chrono::TimeDelta,

    /// Default identifies whether this is the default auth-method to use when
    /// attempting to login without specifying an auth-method name to use.
    #[serde(rename = "Default")]
    pub default: bool,

    /// Config contains the detailed configuration which is specific to the
    /// auth-method.
    #[serde(rename = "Config", skip_serializing_if = "Option::is_none")]
    pub config: Option<super::AclAuthMethodConfig>,

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

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

    /// Name is the identifier for this auth-method and is a required parameter.
    #[serde(rename = "Name")]
    pub name: String,

    /// Defines whether the auth-method creates a local or global token when
    /// performing SSO login. This should be set to either "local" or "global"
    /// and the API contains ACLAuthMethodTokenLocalityLocal and
    /// ACLAuthMethodTokenLocalityGlobal for convenience.
    #[serde(rename = "TokenLocality")]
    pub token_locality: String,

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

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