# 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 Annotated
from typing_extensions import Self

from okta.models.test_info_oidc_test_configuration import TestInfoOidcTestConfiguration
from okta.models.test_info_saml_test_configuration import TestInfoSamlTestConfiguration
from okta.models.test_info_scim_test_configuration import TestInfoScimTestConfiguration
from okta.models.test_info_test_account import TestInfoTestAccount


class TestInfo(BaseModel):
    """
    Integration Testing Information
    """  # noqa: E501

    escalation_support_contact: Annotated[str, Field(strict=True, max_length=255)] = (
        Field(
            description="An email for Okta to contact your company about your integration. This email isn't shared with "
            "customers.",
            alias="escalationSupportContact",
        )
    )
    oidc_test_configuration: Optional[TestInfoOidcTestConfiguration] = Field(
        default=None, alias="oidcTestConfiguration"
    )
    saml_test_configuration: Optional[TestInfoSamlTestConfiguration] = Field(
        default=None, alias="samlTestConfiguration"
    )
    scim_test_configuration: Optional[TestInfoScimTestConfiguration] = Field(
        default=None, alias="scimTestConfiguration"
    )
    test_account: Optional[TestInfoTestAccount] = Field(
        default=None, alias="testAccount"
    )
    __properties: ClassVar[List[str]] = [
        "escalationSupportContact",
        "oidcTestConfiguration",
        "samlTestConfiguration",
        "scimTestConfiguration",
        "testAccount",
    ]

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "escalationSupportContact": obj.get("escalationSupportContact"),
                "oidcTestConfiguration": (
                    TestInfoOidcTestConfiguration.from_dict(
                        obj["oidcTestConfiguration"]
                    )
                    if obj.get("oidcTestConfiguration") is not None
                    else None
                ),
                "samlTestConfiguration": (
                    TestInfoSamlTestConfiguration.from_dict(
                        obj["samlTestConfiguration"]
                    )
                    if obj.get("samlTestConfiguration") is not None
                    else None
                ),
                "scimTestConfiguration": (
                    TestInfoScimTestConfiguration.from_dict(
                        obj["scimTestConfiguration"]
                    )
                    if obj.get("scimTestConfiguration") is not None
                    else None
                ),
                "testAccount": (
                    TestInfoTestAccount.from_dict(obj["testAccount"])
                    if obj.get("testAccount") is not None
                    else None
                ),
            }
        )
        return _obj
