# 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, StrictInt, StrictStr
from pydantic import Field
from sailpoint.v3.models.account_action import AccountAction
from sailpoint.v3.models.email_notification_option import EmailNotificationOption
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class LifecycleState(BaseModel):
    """
    LifecycleState
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="System-generated unique ID of the Object")
    name: StrictStr = Field(description="Name of the Object")
    created: Optional[datetime] = Field(default=None, description="Creation date of the Object")
    modified: Optional[datetime] = Field(default=None, description="Last modification date of the Object")
    enabled: Optional[StrictBool] = Field(default=None, description="Whether the lifecycle state is enabled or disabled.")
    technical_name: StrictStr = Field(description="The technical name for lifecycle state. This is for internal use.", alias="technicalName")
    description: Optional[StrictStr] = Field(default=None, description="Lifecycle state description.")
    identity_count: Optional[StrictInt] = Field(default=None, description="Number of identities that have the lifecycle state.", alias="identityCount")
    email_notification_option: Optional[EmailNotificationOption] = Field(default=None, alias="emailNotificationOption")
    account_actions: Optional[List[AccountAction]] = Field(default=None, alias="accountActions")
    access_profile_ids: Optional[List[StrictStr]] = Field(default=None, description="List of unique access-profile IDs that are associated with the lifecycle state.", alias="accessProfileIds")
    __properties: ClassVar[List[str]] = ["id", "name", "created", "modified", "enabled", "technicalName", "description", "identityCount", "emailNotificationOption", "accountActions", "accessProfileIds"]

    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 LifecycleState 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
                "id",
                "created",
                "modified",
                "identity_count",
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of email_notification_option
        if self.email_notification_option:
            _dict['emailNotificationOption'] = self.email_notification_option.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in account_actions (list)
        _items = []
        if self.account_actions:
            for _item in self.account_actions:
                if _item:
                    _items.append(_item.to_dict())
            _dict['accountActions'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of LifecycleState 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"),
            "enabled": obj.get("enabled"),
            "technicalName": obj.get("technicalName"),
            "description": obj.get("description"),
            "identityCount": obj.get("identityCount"),
            "emailNotificationOption": EmailNotificationOption.from_dict(obj.get("emailNotificationOption")) if obj.get("emailNotificationOption") is not None else None,
            "accountActions": [AccountAction.from_dict(_item) for _item in obj.get("accountActions")] if obj.get("accountActions") is not None else None,
            "accessProfileIds": obj.get("accessProfileIds")
        })
        return _obj


