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


class UserProfile(BaseModel):
    """
    UserProfile
    """  # noqa: E501

    city: Optional[Annotated[str, Field(strict=True, max_length=128)]] = None
    cost_center: Optional[StrictStr] = Field(default=None, alias="costCenter")
    country_code: Optional[Annotated[str, Field(strict=True, max_length=2)]] = Field(
        default=None, alias="countryCode"
    )
    department: Optional[StrictStr] = None
    display_name: Optional[StrictStr] = Field(default=None, alias="displayName")
    division: Optional[StrictStr] = None
    email: Optional[
        Annotated[str, Field(min_length=5, strict=True, max_length=100)]
    ] = None
    employee_number: Optional[StrictStr] = Field(default=None, alias="employeeNumber")
    first_name: Optional[
        Annotated[str, Field(min_length=1, strict=True, max_length=50)]
    ] = Field(default=None, alias="firstName")
    honorific_prefix: Optional[StrictStr] = Field(default=None, alias="honorificPrefix")
    honorific_suffix: Optional[StrictStr] = Field(default=None, alias="honorificSuffix")
    last_name: Optional[
        Annotated[str, Field(min_length=1, strict=True, max_length=50)]
    ] = Field(default=None, alias="lastName")
    locale: Optional[StrictStr] = Field(
        default=None,
        description="The language specified as an [IETF BCP 47 language tag]("
                    "https://datatracker.ietf.org/doc/html/rfc5646)",
    )
    login: Optional[Annotated[str, Field(strict=True, max_length=100)]] = None
    manager: Optional[StrictStr] = None
    manager_id: Optional[StrictStr] = Field(default=None, alias="managerId")
    middle_name: Optional[StrictStr] = Field(default=None, alias="middleName")
    mobile_phone: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
        default=None, alias="mobilePhone"
    )
    nick_name: Optional[StrictStr] = Field(default=None, alias="nickName")
    organization: Optional[StrictStr] = None
    postal_address: Optional[Annotated[str, Field(strict=True, max_length=4096)]] = (
        Field(default=None, alias="postalAddress")
    )
    preferred_language: Optional[StrictStr] = Field(
        default=None, alias="preferredLanguage"
    )
    primary_phone: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
        default=None, alias="primaryPhone"
    )
    profile_url: Optional[StrictStr] = Field(default=None, alias="profileUrl")
    second_email: Optional[
        Annotated[str, Field(min_length=5, strict=True, max_length=100)]
    ] = Field(default=None, alias="secondEmail")
    state: Optional[Annotated[str, Field(strict=True, max_length=128)]] = None
    street_address: Optional[Annotated[str, Field(strict=True, max_length=1024)]] = (
        Field(default=None, alias="streetAddress")
    )
    timezone: Optional[StrictStr] = None
    title: Optional[StrictStr] = None
    user_type: Optional[StrictStr] = Field(default=None, alias="userType")
    zip_code: Optional[Annotated[str, Field(strict=True, max_length=50)]] = Field(
        default=None, alias="zipCode"
    )
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = [
        "city",
        "costCenter",
        "countryCode",
        "department",
        "displayName",
        "division",
        "email",
        "employeeNumber",
        "firstName",
        "honorificPrefix",
        "honorificSuffix",
        "lastName",
        "locale",
        "login",
        "manager",
        "managerId",
        "middleName",
        "mobilePhone",
        "nickName",
        "organization",
        "postalAddress",
        "preferredLanguage",
        "primaryPhone",
        "profileUrl",
        "secondEmail",
        "state",
        "streetAddress",
        "timezone",
        "title",
        "userType",
        "zipCode",
    ]

    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 UserProfile 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.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set(
            [
                "additional_properties",
            ]
        )

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "city": obj.get("city"),
                "costCenter": obj.get("costCenter"),
                "countryCode": obj.get("countryCode"),
                "department": obj.get("department"),
                "displayName": obj.get("displayName"),
                "division": obj.get("division"),
                "email": obj.get("email"),
                "employeeNumber": obj.get("employeeNumber"),
                "firstName": obj.get("firstName"),
                "honorificPrefix": obj.get("honorificPrefix"),
                "honorificSuffix": obj.get("honorificSuffix"),
                "lastName": obj.get("lastName"),
                "locale": obj.get("locale"),
                "login": obj.get("login"),
                "manager": obj.get("manager"),
                "managerId": obj.get("managerId"),
                "middleName": obj.get("middleName"),
                "mobilePhone": obj.get("mobilePhone"),
                "nickName": obj.get("nickName"),
                "organization": obj.get("organization"),
                "postalAddress": obj.get("postalAddress"),
                "preferredLanguage": obj.get("preferredLanguage"),
                "primaryPhone": obj.get("primaryPhone"),
                "profileUrl": obj.get("profileUrl"),
                "secondEmail": obj.get("secondEmail"),
                "state": obj.get("state"),
                "streetAddress": obj.get("streetAddress"),
                "timezone": obj.get("timezone"),
                "title": obj.get("title"),
                "userType": obj.get("userType"),
                "zipCode": obj.get("zipCode"),
            }
        )
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj
