// authentik
//
// Making authentication simple.
//
// The version of the OpenAPI document: 2026.5.0-rc1
// Contact: hello@goauthentik.io
// Generated by: https://openapi-generator.tech

use serde::{Deserialize, Serialize};

use crate::models;

/// Provider : Provider Serializer
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Provider {
    #[serde(rename = "pk")]
    pub pk: i32,
    #[serde(rename = "name")]
    pub name: String,
    /// Flow used for authentication when the associated application is accessed by an
    /// un-authenticated user.
    #[serde(
        rename = "authentication_flow",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub authentication_flow: Option<Option<uuid::Uuid>>,
    /// Flow used when authorizing this provider.
    #[serde(rename = "authorization_flow")]
    pub authorization_flow: uuid::Uuid,
    /// Flow used ending the session from a provider.
    #[serde(rename = "invalidation_flow")]
    pub invalidation_flow: uuid::Uuid,
    #[serde(rename = "property_mappings", skip_serializing_if = "Option::is_none")]
    pub property_mappings: Option<Vec<uuid::Uuid>>,
    /// Get object component so that we know how to edit the object
    #[serde(rename = "component")]
    pub component: String,
    /// Internal application name, used in URLs.
    #[serde(
        rename = "assigned_application_slug",
        deserialize_with = "Option::deserialize"
    )]
    pub assigned_application_slug: Option<String>,
    /// Application's display Name.
    #[serde(
        rename = "assigned_application_name",
        deserialize_with = "Option::deserialize"
    )]
    pub assigned_application_name: Option<String>,
    /// Internal application name, used in URLs.
    #[serde(
        rename = "assigned_backchannel_application_slug",
        deserialize_with = "Option::deserialize"
    )]
    pub assigned_backchannel_application_slug: Option<String>,
    /// Application's display Name.
    #[serde(
        rename = "assigned_backchannel_application_name",
        deserialize_with = "Option::deserialize"
    )]
    pub assigned_backchannel_application_name: Option<String>,
    /// Return object's verbose_name
    #[serde(rename = "verbose_name")]
    pub verbose_name: String,
    /// Return object's plural verbose_name
    #[serde(rename = "verbose_name_plural")]
    pub verbose_name_plural: String,
    /// Return internal model name
    #[serde(rename = "meta_model_name")]
    pub meta_model_name: String,
}

impl Provider {
    /// Provider Serializer
    pub fn new(
        pk: i32,
        name: String,
        authorization_flow: uuid::Uuid,
        invalidation_flow: uuid::Uuid,
        component: String,
        assigned_application_slug: Option<String>,
        assigned_application_name: Option<String>,
        assigned_backchannel_application_slug: Option<String>,
        assigned_backchannel_application_name: Option<String>,
        verbose_name: String,
        verbose_name_plural: String,
        meta_model_name: String,
    ) -> Provider {
        Provider {
            pk,
            name,
            authentication_flow: None,
            authorization_flow,
            invalidation_flow,
            property_mappings: None,
            component,
            assigned_application_slug,
            assigned_application_name,
            assigned_backchannel_application_slug,
            assigned_backchannel_application_name,
            verbose_name,
            verbose_name_plural,
            meta_model_name,
        }
    }
}
