# coding: utf-8

"""
    Artifact Keeper API

    Enterprise artifact registry supporting 45+ package formats.

    The version of the OpenAPI document: 1.0.0-rc.3
    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 pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class UpdateSamlConfigRequest(BaseModel):
    """
    UpdateSamlConfigRequest
    """ # noqa: E501
    admin_group: Optional[StrictStr] = None
    attribute_mapping: Optional[Dict[str, Any]] = None
    certificate: Optional[StrictStr] = None
    entity_id: Optional[StrictStr] = None
    is_enabled: Optional[StrictBool] = None
    name: Optional[StrictStr] = None
    name_id_format: Optional[StrictStr] = None
    require_signed_assertions: Optional[StrictBool] = None
    sign_requests: Optional[StrictBool] = None
    slo_url: Optional[StrictStr] = None
    sp_entity_id: Optional[StrictStr] = None
    sso_url: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["admin_group", "attribute_mapping", "certificate", "entity_id", "is_enabled", "name", "name_id_format", "require_signed_assertions", "sign_requests", "slo_url", "sp_entity_id", "sso_url"]

    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 UpdateSamlConfigRequest 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 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

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

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

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

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

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

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

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

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

        # 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 sp_entity_id (nullable) is None
        # and model_fields_set contains the field
        if self.sp_entity_id is None and "sp_entity_id" in self.model_fields_set:
            _dict['sp_entity_id'] = None

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

        return _dict

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

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

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


