/*
 * Artifact Keeper API
 *
 * REST API for Artifact Keeper, an open-source universal artifact registry. Covers user management, repositories, artifacts, search, security scanning, SBOM, dependency tracking, SSO, analytics, monitoring, telemetry, lifecycle policies, plugins, edge nodes, migration, and administration. Format-specific protocol endpoints (npm, PyPI, Maven, Docker/OCI, etc.) are not included; those follow their respective upstream specifications.
 *
 * The version of the OpenAPI document: 1.0.0-a2
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LdapConfigResponse {
    /// LDAP configuration UUID
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Display name for the LDAP provider
    #[serde(rename = "name")]
    pub name: String,
    /// LDAP server URL (ldap:// or ldaps://)
    #[serde(rename = "server_url")]
    pub server_url: String,
    /// Distinguished name used for binding to the LDAP server
    #[serde(rename = "bind_dn", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub bind_dn: Option<Option<String>>,
    /// Whether a bind password has been configured
    #[serde(rename = "has_bind_password")]
    pub has_bind_password: bool,
    /// Base DN for user searches
    #[serde(rename = "user_base_dn")]
    pub user_base_dn: String,
    /// LDAP filter for user lookups
    #[serde(rename = "user_filter")]
    pub user_filter: String,
    /// Base DN for group searches
    #[serde(rename = "group_base_dn", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub group_base_dn: Option<Option<String>>,
    /// LDAP filter for group lookups
    #[serde(rename = "group_filter", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub group_filter: Option<Option<String>>,
    /// LDAP attribute containing the user email
    #[serde(rename = "email_attribute")]
    pub email_attribute: String,
    /// LDAP attribute containing the user display name
    #[serde(rename = "display_name_attribute")]
    pub display_name_attribute: String,
    /// LDAP attribute containing the username
    #[serde(rename = "username_attribute")]
    pub username_attribute: String,
    /// LDAP attribute containing group membership
    #[serde(rename = "groups_attribute")]
    pub groups_attribute: String,
    /// DN of the group whose members are granted admin privileges
    #[serde(rename = "admin_group_dn", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub admin_group_dn: Option<Option<String>>,
    /// Whether to use STARTTLS for the LDAP connection
    #[serde(rename = "use_starttls")]
    pub use_starttls: bool,
    /// Whether this LDAP configuration is active
    #[serde(rename = "is_enabled")]
    pub is_enabled: bool,
    /// Timestamp when the configuration was created
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Timestamp when the configuration was last modified
    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

impl LdapConfigResponse {
    pub fn new(id: uuid::Uuid, name: String, server_url: String, has_bind_password: bool, user_base_dn: String, user_filter: String, email_attribute: String, display_name_attribute: String, username_attribute: String, groups_attribute: String, use_starttls: bool, is_enabled: bool, created_at: String, updated_at: String) -> LdapConfigResponse {
        LdapConfigResponse {
            id,
            name,
            server_url,
            bind_dn: None,
            has_bind_password,
            user_base_dn,
            user_filter,
            group_base_dn: None,
            group_filter: None,
            email_attribute,
            display_name_attribute,
            username_attribute,
            groups_attribute,
            admin_group_dn: None,
            use_starttls,
            is_enabled,
            created_at,
            updated_at,
        }
    }
}

