/*
 * 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 SamlConfigResponse {
    /// SAML configuration UUID
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Display name for the SAML provider
    #[serde(rename = "name")]
    pub name: String,
    /// Identity provider entity ID
    #[serde(rename = "entity_id")]
    pub entity_id: String,
    /// Identity provider SSO endpoint URL
    #[serde(rename = "sso_url")]
    pub sso_url: String,
    /// Identity provider single logout endpoint URL
    #[serde(rename = "slo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub slo_url: Option<Option<String>>,
    /// Whether an IdP signing certificate has been configured
    #[serde(rename = "has_certificate")]
    pub has_certificate: bool,
    /// SAML NameID format (e.g. urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)
    #[serde(rename = "name_id_format")]
    pub name_id_format: String,
    /// Mapping of SAML attributes to user properties
    #[serde(rename = "attribute_mapping")]
    pub attribute_mapping: serde_json::Value,
    /// Service provider entity ID
    #[serde(rename = "sp_entity_id")]
    pub sp_entity_id: String,
    /// Whether to sign SAML authentication requests
    #[serde(rename = "sign_requests")]
    pub sign_requests: bool,
    /// Whether to require signed SAML assertions from the IdP
    #[serde(rename = "require_signed_assertions")]
    pub require_signed_assertions: bool,
    /// SAML group value that grants admin privileges
    #[serde(rename = "admin_group", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub admin_group: Option<Option<String>>,
    /// Whether this SAML 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 SamlConfigResponse {
    pub fn new(id: uuid::Uuid, name: String, entity_id: String, sso_url: String, has_certificate: bool, name_id_format: String, attribute_mapping: serde_json::Value, sp_entity_id: String, sign_requests: bool, require_signed_assertions: bool, is_enabled: bool, created_at: String, updated_at: String) -> SamlConfigResponse {
        SamlConfigResponse {
            id,
            name,
            entity_id,
            sso_url,
            slo_url: None,
            has_certificate,
            name_id_format,
            attribute_mapping,
            sp_entity_id,
            sign_requests,
            require_signed_assertions,
            admin_group: None,
            is_enabled,
            created_at,
            updated_at,
        }
    }
}

