// 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;

/// Group : Group Serializer
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Group {
    #[serde(rename = "pk")]
    pub pk: uuid::Uuid,
    #[serde(rename = "num_pk")]
    pub num_pk: i32,
    #[serde(rename = "name")]
    pub name: String,
    /// Users added to this group will be superusers.
    #[serde(rename = "is_superuser", skip_serializing_if = "Option::is_none")]
    pub is_superuser: Option<bool>,
    #[serde(rename = "parents", skip_serializing_if = "Option::is_none")]
    pub parents: Option<Vec<uuid::Uuid>>,
    #[serde(rename = "parents_obj", deserialize_with = "Option::deserialize")]
    pub parents_obj: Option<Vec<models::RelatedGroup>>,
    #[serde(rename = "users", skip_serializing_if = "Option::is_none")]
    pub users: Option<Vec<i32>>,
    #[serde(rename = "users_obj", deserialize_with = "Option::deserialize")]
    pub users_obj: Option<Vec<models::PartialUser>>,
    #[serde(rename = "attributes", skip_serializing_if = "Option::is_none")]
    pub attributes: Option<std::collections::HashMap<String, serde_json::Value>>,
    #[serde(rename = "roles", skip_serializing_if = "Option::is_none")]
    pub roles: Option<Vec<uuid::Uuid>>,
    #[serde(rename = "roles_obj")]
    pub roles_obj: Vec<models::Role>,
    #[serde(
        rename = "inherited_roles_obj",
        deserialize_with = "Option::deserialize"
    )]
    pub inherited_roles_obj: Option<Vec<models::Role>>,
    #[serde(rename = "children")]
    pub children: Vec<uuid::Uuid>,
    #[serde(rename = "children_obj", deserialize_with = "Option::deserialize")]
    pub children_obj: Option<Vec<models::RelatedGroup>>,
}

impl Group {
    /// Group Serializer
    pub fn new(
        pk: uuid::Uuid,
        num_pk: i32,
        name: String,
        parents_obj: Option<Vec<models::RelatedGroup>>,
        users_obj: Option<Vec<models::PartialUser>>,
        roles_obj: Vec<models::Role>,
        inherited_roles_obj: Option<Vec<models::Role>>,
        children: Vec<uuid::Uuid>,
        children_obj: Option<Vec<models::RelatedGroup>>,
    ) -> Group {
        Group {
            pk,
            num_pk,
            name,
            is_superuser: None,
            parents: None,
            parents_obj,
            users: None,
            users_obj,
            attributes: None,
            roles: None,
            roles_obj,
            inherited_roles_obj,
            children,
            children_obj,
        }
    }
}
