# coding: utf-8

"""
    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 OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class SamlConfigResponse(BaseModel):
    """
    SamlConfigResponse
    """ # noqa: E501
    id: StrictStr = Field(description="SAML configuration UUID")
    name: StrictStr = Field(description="Display name for the SAML provider")
    entity_id: StrictStr = Field(description="Identity provider entity ID")
    sso_url: StrictStr = Field(description="Identity provider SSO endpoint URL")
    slo_url: Optional[StrictStr] = Field(default=None, description="Identity provider single logout endpoint URL")
    has_certificate: StrictBool = Field(description="Whether an IdP signing certificate has been configured")
    name_id_format: StrictStr = Field(description="SAML NameID format (e.g. urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)")
    attribute_mapping: Dict[str, Any] = Field(description="Mapping of SAML attributes to user properties")
    sp_entity_id: StrictStr = Field(description="Service provider entity ID")
    sign_requests: StrictBool = Field(description="Whether to sign SAML authentication requests")
    require_signed_assertions: StrictBool = Field(description="Whether to require signed SAML assertions from the IdP")
    admin_group: Optional[StrictStr] = Field(default=None, description="SAML group value that grants admin privileges")
    is_enabled: StrictBool = Field(description="Whether this SAML configuration is active")
    created_at: datetime = Field(description="Timestamp when the configuration was created")
    updated_at: datetime = Field(description="Timestamp when the configuration was last modified")
    __properties: ClassVar[List[str]] = ["id", "name", "entity_id", "sso_url", "slo_url", "has_certificate", "name_id_format", "attribute_mapping", "sp_entity_id", "sign_requests", "require_signed_assertions", "admin_group", "is_enabled", "created_at", "updated_at"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of SamlConfigResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if slo_url (nullable) is None
        # and model_fields_set contains the field
        if self.slo_url is None and "slo_url" in self.model_fields_set:
            _dict['slo_url'] = None

        # set to None if admin_group (nullable) is None
        # and model_fields_set contains the field
        if self.admin_group is None and "admin_group" in self.model_fields_set:
            _dict['admin_group'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SamlConfigResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "name": obj.get("name"),
            "entity_id": obj.get("entity_id"),
            "sso_url": obj.get("sso_url"),
            "slo_url": obj.get("slo_url"),
            "has_certificate": obj.get("has_certificate"),
            "name_id_format": obj.get("name_id_format"),
            "attribute_mapping": obj.get("attribute_mapping"),
            "sp_entity_id": obj.get("sp_entity_id"),
            "sign_requests": obj.get("sign_requests"),
            "require_signed_assertions": obj.get("require_signed_assertions"),
            "admin_group": obj.get("admin_group"),
            "is_enabled": obj.get("is_enabled"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


