# 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.href_object import HrefObject


class UserLinks(BaseModel):
    """
    Specifies link relations (see [Web Linking](https://datatracker.ietf.org/doc/html/rfc8288) available for the current
    status of a user. The links object is used for dynamic discovery of related resources, lifecycle operations,
    and credential operations. The links object is read-only.  For an individual user result, the links object contains a
    full set of link relations available for that user as determined by your policies. For a collection of users,
    the links object contains only the `self` link. Operations that return a collection of users include [List all users](
    https://developer.okta.com/docs/api/openapi/okta-management/management/tag/User/#tag/User/operation/listUsers) and [List
    all group member users](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Group/#tag/Group
    /operation/listGroupUsers).
    """  # noqa: E501

    var_self: Optional[HrefObject] = Field(
        default=None, description="URL to the individual user", alias="self"
    )
    activate: Optional[HrefObject] = Field(
        default=None, description="URL to activate the user"
    )
    reset_password: Optional[HrefObject] = Field(
        default=None,
        description="URL to reset the user's password",
        alias="resetPassword",
    )
    reset_factors: Optional[HrefObject] = Field(
        default=None,
        description="URL to reset the user's factors",
        alias="resetFactors",
    )
    expire_password: Optional[HrefObject] = Field(
        default=None,
        description="URL to expire the user's password",
        alias="expirePassword",
    )
    forgot_password: Optional[HrefObject] = Field(
        default=None,
        description="URL to initiate a forgot password operation",
        alias="forgotPassword",
    )
    change_recovery_question: Optional[HrefObject] = Field(
        default=None,
        description="URL to change the user's recovery question",
        alias="changeRecoveryQuestion",
    )
    deactivate: Optional[HrefObject] = Field(
        default=None, description="URL to deactivate a user"
    )
    reactivate: Optional[HrefObject] = Field(
        default=None, description="URL to reactivate the user"
    )
    change_password: Optional[HrefObject] = Field(
        default=None,
        description="URL to change the user's password",
        alias="changePassword",
    )
    var_schema: Optional[HrefObject] = Field(
        default=None, description="URL to the user's profile schema", alias="schema"
    )
    suspend: Optional[HrefObject] = Field(
        default=None, description="URL to suspend the user"
    )
    unsuspend: Optional[HrefObject] = Field(
        default=None, description="URL to unsuspend the user"
    )
    unlock: Optional[HrefObject] = Field(
        default=None, description="URL to unlock the locked-out user"
    )
    type: Optional[HrefObject] = Field(default=None, description="URL to the user type")
    __properties: ClassVar[List[str]] = [
        "self",
        "activate",
        "resetPassword",
        "resetFactors",
        "expirePassword",
        "forgotPassword",
        "changeRecoveryQuestion",
        "deactivate",
        "reactivate",
        "changePassword",
        "schema",
        "suspend",
        "unsuspend",
        "unlock",
        "type",
    ]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "self": (
                    HrefObject.from_dict(obj["self"])
                    if obj.get("self") is not None
                    else None
                ),
                "activate": (
                    HrefObject.from_dict(obj["activate"])
                    if obj.get("activate") is not None
                    else None
                ),
                "resetPassword": (
                    HrefObject.from_dict(obj["resetPassword"])
                    if obj.get("resetPassword") is not None
                    else None
                ),
                "resetFactors": (
                    HrefObject.from_dict(obj["resetFactors"])
                    if obj.get("resetFactors") is not None
                    else None
                ),
                "expirePassword": (
                    HrefObject.from_dict(obj["expirePassword"])
                    if obj.get("expirePassword") is not None
                    else None
                ),
                "forgotPassword": (
                    HrefObject.from_dict(obj["forgotPassword"])
                    if obj.get("forgotPassword") is not None
                    else None
                ),
                "changeRecoveryQuestion": (
                    HrefObject.from_dict(obj["changeRecoveryQuestion"])
                    if obj.get("changeRecoveryQuestion") is not None
                    else None
                ),
                "deactivate": (
                    HrefObject.from_dict(obj["deactivate"])
                    if obj.get("deactivate") is not None
                    else None
                ),
                "reactivate": (
                    HrefObject.from_dict(obj["reactivate"])
                    if obj.get("reactivate") is not None
                    else None
                ),
                "changePassword": (
                    HrefObject.from_dict(obj["changePassword"])
                    if obj.get("changePassword") is not None
                    else None
                ),
                "schema": (
                    HrefObject.from_dict(obj["schema"])
                    if obj.get("schema") is not None
                    else None
                ),
                "suspend": (
                    HrefObject.from_dict(obj["suspend"])
                    if obj.get("suspend") is not None
                    else None
                ),
                "unsuspend": (
                    HrefObject.from_dict(obj["unsuspend"])
                    if obj.get("unsuspend") is not None
                    else None
                ),
                "unlock": (
                    HrefObject.from_dict(obj["unlock"])
                    if obj.get("unlock") is not None
                    else None
                ),
                "type": (
                    HrefObject.from_dict(obj["type"])
                    if obj.get("type") is not None
                    else None
                ),
            }
        )
        return _obj
