/*
 * 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 CreateLdapConfigRequest {
    /// 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", skip_serializing_if = "Option::is_none")]
    pub bind_dn: Option<String>,
    /// Password for the bind DN
    #[serde(rename = "bind_password", skip_serializing_if = "Option::is_none")]
    pub bind_password: Option<String>,
    /// 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", skip_serializing_if = "Option::is_none")]
    pub group_base_dn: Option<String>,
    /// LDAP filter for group lookups
    #[serde(rename = "group_filter", skip_serializing_if = "Option::is_none")]
    pub group_filter: 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", skip_serializing_if = "Option::is_none")]
    pub admin_group_dn: Option<String>,
    /// Whether to use STARTTLS for the LDAP connection
    #[serde(rename = "use_starttls", skip_serializing_if = "Option::is_none")]
    pub use_starttls: Option<bool>,
    /// Whether to enable the configuration immediately
    #[serde(rename = "is_enabled", skip_serializing_if = "Option::is_none")]
    pub is_enabled: Option<bool>,
}

impl CreateLdapConfigRequest {
    pub fn new(name: String, server_url: String, user_base_dn: String, user_filter: String, email_attribute: String, display_name_attribute: String, username_attribute: String, groups_attribute: String) -> CreateLdapConfigRequest {
        CreateLdapConfigRequest {
            name,
            server_url,
            bind_dn: None,
            bind_password: None,
            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: None,
            is_enabled: None,
        }
    }
}

