# coding: utf-8

"""
    Logto API references

    API references for Logto services. To learn more about how to interact with Logto APIs, see [Interact with Management API](https://docs.logto.io/docs/recipes/interact-with-management-api/).

    The version of the OpenAPI document: Cloud
    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, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from py_logto.models.api_interaction_consent_get200_response_application_branding import ApiInteractionConsentGet200ResponseApplicationBranding
from py_logto.models.api_sign_in_exp_get200_response_color import ApiSignInExpGet200ResponseColor
from py_logto.models.api_sign_in_exp_get200_response_language_info import ApiSignInExpGet200ResponseLanguageInfo
from py_logto.models.api_sign_in_exp_get200_response_mfa import ApiSignInExpGet200ResponseMfa
from py_logto.models.api_sign_in_exp_get200_response_password_policy import ApiSignInExpGet200ResponsePasswordPolicy
from py_logto.models.api_sign_in_exp_get200_response_sign_in import ApiSignInExpGet200ResponseSignIn
from py_logto.models.api_sign_in_exp_get200_response_sign_up import ApiSignInExpGet200ResponseSignUp
from typing import Optional, Set
from typing_extensions import Self

class ApiSignInExpGet200Response(BaseModel):
    """
    ApiSignInExpGet200Response
    """ # noqa: E501
    id: Annotated[str, Field(min_length=1, strict=True, max_length=21)]
    color: ApiSignInExpGet200ResponseColor
    branding: ApiInteractionConsentGet200ResponseApplicationBranding
    language_info: ApiSignInExpGet200ResponseLanguageInfo = Field(alias="languageInfo")
    terms_of_use_url: Optional[Annotated[str, Field(strict=True, max_length=2048)]] = Field(alias="termsOfUseUrl")
    privacy_policy_url: Optional[Annotated[str, Field(strict=True, max_length=2048)]] = Field(alias="privacyPolicyUrl")
    sign_in: ApiSignInExpGet200ResponseSignIn = Field(alias="signIn")
    sign_up: ApiSignInExpGet200ResponseSignUp = Field(alias="signUp")
    social_sign_in_connector_targets: List[StrictStr] = Field(description="Enabled social sign-in connectors, will displayed on the sign-in page.", alias="socialSignInConnectorTargets")
    sign_in_mode: StrictStr = Field(alias="signInMode")
    custom_css: Optional[StrictStr] = Field(alias="customCss")
    custom_content: Dict[str, StrictStr] = Field(description="Custom content to display on experience flow pages. the page pathname will be the config key, the content will be the config value.", alias="customContent")
    password_policy: ApiSignInExpGet200ResponsePasswordPolicy = Field(alias="passwordPolicy")
    mfa: ApiSignInExpGet200ResponseMfa
    single_sign_on_enabled: StrictBool = Field(alias="singleSignOnEnabled")
    __properties: ClassVar[List[str]] = ["id", "color", "branding", "languageInfo", "termsOfUseUrl", "privacyPolicyUrl", "signIn", "signUp", "socialSignInConnectorTargets", "signInMode", "customCss", "customContent", "passwordPolicy", "mfa", "singleSignOnEnabled"]

    @field_validator('sign_in_mode')
    def sign_in_mode_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['SignIn', 'Register', 'SignInAndRegister']):
            raise ValueError("must be one of enum values ('SignIn', 'Register', 'SignInAndRegister')")
        return value

    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 ApiSignInExpGet200Response 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,
        )
        # override the default output from pydantic by calling `to_dict()` of color
        if self.color:
            _dict['color'] = self.color.to_dict()
        # override the default output from pydantic by calling `to_dict()` of branding
        if self.branding:
            _dict['branding'] = self.branding.to_dict()
        # override the default output from pydantic by calling `to_dict()` of language_info
        if self.language_info:
            _dict['languageInfo'] = self.language_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sign_in
        if self.sign_in:
            _dict['signIn'] = self.sign_in.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sign_up
        if self.sign_up:
            _dict['signUp'] = self.sign_up.to_dict()
        # override the default output from pydantic by calling `to_dict()` of password_policy
        if self.password_policy:
            _dict['passwordPolicy'] = self.password_policy.to_dict()
        # override the default output from pydantic by calling `to_dict()` of mfa
        if self.mfa:
            _dict['mfa'] = self.mfa.to_dict()
        # set to None if terms_of_use_url (nullable) is None
        # and model_fields_set contains the field
        if self.terms_of_use_url is None and "terms_of_use_url" in self.model_fields_set:
            _dict['termsOfUseUrl'] = None

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ApiSignInExpGet200Response 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"),
            "color": ApiSignInExpGet200ResponseColor.from_dict(obj["color"]) if obj.get("color") is not None else None,
            "branding": ApiInteractionConsentGet200ResponseApplicationBranding.from_dict(obj["branding"]) if obj.get("branding") is not None else None,
            "languageInfo": ApiSignInExpGet200ResponseLanguageInfo.from_dict(obj["languageInfo"]) if obj.get("languageInfo") is not None else None,
            "termsOfUseUrl": obj.get("termsOfUseUrl"),
            "privacyPolicyUrl": obj.get("privacyPolicyUrl"),
            "signIn": ApiSignInExpGet200ResponseSignIn.from_dict(obj["signIn"]) if obj.get("signIn") is not None else None,
            "signUp": ApiSignInExpGet200ResponseSignUp.from_dict(obj["signUp"]) if obj.get("signUp") is not None else None,
            "socialSignInConnectorTargets": obj.get("socialSignInConnectorTargets"),
            "signInMode": obj.get("signInMode"),
            "customCss": obj.get("customCss"),
            "customContent": obj.get("customContent"),
            "passwordPolicy": ApiSignInExpGet200ResponsePasswordPolicy.from_dict(obj["passwordPolicy"]) if obj.get("passwordPolicy") is not None else None,
            "mfa": ApiSignInExpGet200ResponseMfa.from_dict(obj["mfa"]) if obj.get("mfa") is not None else None,
            "singleSignOnEnabled": obj.get("singleSignOnEnabled")
        })
        return _obj


