# coding: utf-8

"""
    IdentityNow V3 API

    Use these APIs to interact with the IdentityNow platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.

    The version of the OpenAPI document: 3.0.0
    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 datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictBool, StrictStr
from pydantic import Field
from sailpoint.v3.models.identity_reference_with_name_and_email import IdentityReferenceWithNameAndEmail
from sailpoint.v3.models.requestable_object_type import RequestableObjectType
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class RequestableObject(BaseModel):
    """
    RequestableObject
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Id of the requestable object itself")
    name: Optional[StrictStr] = Field(default=None, description="Human-readable display name of the requestable object")
    created: Optional[datetime] = Field(default=None, description="The time when the requestable object was created")
    modified: Optional[datetime] = Field(default=None, description="The time when the requestable object was last modified")
    description: Optional[StrictStr] = Field(default=None, description="Description of the requestable object.")
    type: Optional[RequestableObjectType] = None
    request_status: Optional[Any] = Field(default=None, alias="requestStatus")
    identity_request_id: Optional[StrictStr] = Field(default=None, description="If *requestStatus* is *PENDING*, indicates the id of the associated account activity.", alias="identityRequestId")
    owner_ref: Optional[IdentityReferenceWithNameAndEmail] = Field(default=None, alias="ownerRef")
    request_comments_required: Optional[StrictBool] = Field(default=None, description="Whether the requester must provide comments when requesting the object.", alias="requestCommentsRequired")
    __properties: ClassVar[List[str]] = ["id", "name", "created", "modified", "description", "type", "requestStatus", "identityRequestId", "ownerRef", "requestCommentsRequired"]

    model_config = {
        "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) -> Self:
        """Create an instance of RequestableObject 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of request_status
        if self.request_status:
            _dict['requestStatus'] = self.request_status.to_dict()
        # override the default output from pydantic by calling `to_dict()` of owner_ref
        if self.owner_ref:
            _dict['ownerRef'] = self.owner_ref.to_dict()
        # set to None if modified (nullable) is None
        # and model_fields_set contains the field
        if self.modified is None and "modified" in self.model_fields_set:
            _dict['modified'] = None

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of RequestableObject 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"),
            "name": obj.get("name"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "description": obj.get("description"),
            "type": obj.get("type"),
            "requestStatus": RequestableObjectRequestStatus.from_dict(obj.get("requestStatus")) if obj.get("requestStatus") is not None else None,
            "identityRequestId": obj.get("identityRequestId"),
            "ownerRef": IdentityReferenceWithNameAndEmail.from_dict(obj.get("ownerRef")) if obj.get("ownerRef") is not None else None,
            "requestCommentsRequired": obj.get("requestCommentsRequired")
        })
        return _obj


