# The Okta software accompanied by this notice is provided pursuant to the following terms:
# Copyright © 2025-Present, Okta, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
# License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
# coding: utf-8

"""
Okta Admin Management

Allows customers to easily access the Okta Management APIs

The version of the OpenAPI document: 5.1.0
Contact: devex-public@okta.com
Generated by OpenAPI Generator (https://openapi-generator.tech)

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

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar, Dict, List
from typing import Optional, Set

from pydantic import BaseModel, ConfigDict, Field
from typing_extensions import Self

from okta.models.org_general_setting_links_contacts import (
    OrgGeneralSettingLinksContacts,
)
from okta.models.org_general_setting_links_logo import OrgGeneralSettingLinksLogo
from okta.models.org_general_setting_links_okta_communication import (
    OrgGeneralSettingLinksOktaCommunication,
)
from okta.models.org_general_setting_links_okta_support import (
    OrgGeneralSettingLinksOktaSupport,
)
from okta.models.org_general_setting_links_preferences import (
    OrgGeneralSettingLinksPreferences,
)
from okta.models.org_general_setting_links_upload_logo import (
    OrgGeneralSettingLinksUploadLogo,
)


class OrgGeneralSettingLinks(BaseModel):
    """
    Specifies link relations (see [Web Linking](https://www.rfc-editor.org/rfc/rfc8288)) available for the org using the [
    JSON Hypertext Application Language](https://datatracker.ietf.org/doc/html/draft-kelly-json-hal-06) specification
    """  # noqa: E501

    contacts: Optional[OrgGeneralSettingLinksContacts] = None
    logo: Optional[OrgGeneralSettingLinksLogo] = None
    okta_communication: Optional[OrgGeneralSettingLinksOktaCommunication] = Field(
        default=None, alias="oktaCommunication"
    )
    okta_support: Optional[OrgGeneralSettingLinksOktaSupport] = Field(
        default=None, alias="oktaSupport"
    )
    preferences: Optional[OrgGeneralSettingLinksPreferences] = None
    upload_logo: Optional[OrgGeneralSettingLinksUploadLogo] = Field(
        default=None, alias="uploadLogo"
    )
    __properties: ClassVar[List[str]] = [
        "contacts",
        "logo",
        "oktaCommunication",
        "oktaSupport",
        "preferences",
        "uploadLogo",
    ]

    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 OrgGeneralSettingLinks 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 contacts
        if self.contacts:
            if not isinstance(self.contacts, dict):
                _dict["contacts"] = self.contacts.to_dict()
            else:
                _dict["contacts"] = self.contacts

        # override the default output from pydantic by calling `to_dict()` of logo
        if self.logo:
            if not isinstance(self.logo, dict):
                _dict["logo"] = self.logo.to_dict()
            else:
                _dict["logo"] = self.logo

        # override the default output from pydantic by calling `to_dict()` of okta_communication
        if self.okta_communication:
            if not isinstance(self.okta_communication, dict):
                _dict["oktaCommunication"] = self.okta_communication.to_dict()
            else:
                _dict["oktaCommunication"] = self.okta_communication

        # override the default output from pydantic by calling `to_dict()` of okta_support
        if self.okta_support:
            if not isinstance(self.okta_support, dict):
                _dict["oktaSupport"] = self.okta_support.to_dict()
            else:
                _dict["oktaSupport"] = self.okta_support

        # override the default output from pydantic by calling `to_dict()` of preferences
        if self.preferences:
            if not isinstance(self.preferences, dict):
                _dict["preferences"] = self.preferences.to_dict()
            else:
                _dict["preferences"] = self.preferences

        # override the default output from pydantic by calling `to_dict()` of upload_logo
        if self.upload_logo:
            if not isinstance(self.upload_logo, dict):
                _dict["uploadLogo"] = self.upload_logo.to_dict()
            else:
                _dict["uploadLogo"] = self.upload_logo

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "contacts": (
                    OrgGeneralSettingLinksContacts.from_dict(obj["contacts"])
                    if obj.get("contacts") is not None
                    else None
                ),
                "logo": (
                    OrgGeneralSettingLinksLogo.from_dict(obj["logo"])
                    if obj.get("logo") is not None
                    else None
                ),
                "oktaCommunication": (
                    OrgGeneralSettingLinksOktaCommunication.from_dict(
                        obj["oktaCommunication"]
                    )
                    if obj.get("oktaCommunication") is not None
                    else None
                ),
                "oktaSupport": (
                    OrgGeneralSettingLinksOktaSupport.from_dict(obj["oktaSupport"])
                    if obj.get("oktaSupport") is not None
                    else None
                ),
                "preferences": (
                    OrgGeneralSettingLinksPreferences.from_dict(obj["preferences"])
                    if obj.get("preferences") is not None
                    else None
                ),
                "uploadLogo": (
                    OrgGeneralSettingLinksUploadLogo.from_dict(obj["uploadLogo"])
                    if obj.get("uploadLogo") is not None
                    else None
                ),
            }
        )
        return _obj
