# coding: utf-8

"""
    Identity Security Cloud V2025 API

    Use these APIs to interact with the Identity Security Cloud 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: v2025
    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
import warnings

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from sailpoint.v2025.models.base_reference_dto import BaseReferenceDto
from sailpoint.v2025.models.right_set_dto import RightSetDTO
from typing import Optional, Set
from typing_extensions import Self

class UserLevelSummaryDTO(BaseModel):
    """
    It represents a summary of a user level, including its metadata, attributes, and associated properties.
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="The unique identifier of the UserLevel.")
    name: Optional[StrictStr] = Field(default=None, description="The human-readable name of the UserLevel.")
    description: Optional[StrictStr] = Field(default=None, description="A human-readable description of the UserLevel.")
    legacy_group: Optional[StrictStr] = Field(default=None, description="The legacy group associated with the UserLevel, used for backward compatibility for the UserLevel id.", alias="legacyGroup")
    right_sets: Optional[List[RightSetDTO]] = Field(default=None, description="List of RightSets associated with the UserLevel.", alias="rightSets")
    custom: Optional[StrictBool] = Field(default=True, description="Indicates whether the UserLevel is custom.")
    admin_assignable: Optional[StrictBool] = Field(default=True, description="Indicates whether the UserLevel is admin-assignable.", alias="adminAssignable")
    translated_name: Optional[StrictStr] = Field(default=None, description="The translated name of the UserLevel.", alias="translatedName")
    translated_grant: Optional[StrictStr] = Field(default=None, description="The translated grant message for the UserLevel.", alias="translatedGrant")
    translated_remove: Optional[StrictStr] = Field(default=None, description="The translated remove message for the UserLevel.", alias="translatedRemove")
    owner: Optional[BaseReferenceDto] = None
    status: Optional[StrictStr] = Field(default=None, description="The status of the UserLevel.")
    created: Optional[datetime] = Field(default=None, description="The creation timestamp of the UserLevel.")
    modified: Optional[datetime] = Field(default=None, description="The last modification timestamp of the UserLevel.")
    associated_identities_count: Optional[StrictInt] = Field(default=None, description="The count of associated identities for the UserLevel.", alias="associatedIdentitiesCount")
    __properties: ClassVar[List[str]] = ["id", "name", "description", "legacyGroup", "rightSets", "custom", "adminAssignable", "translatedName", "translatedGrant", "translatedRemove", "owner", "status", "created", "modified", "associatedIdentitiesCount"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['ACTIVE', 'DRAFT']):
            warnings.warn(f"must be one of enum values ('ACTIVE', 'DRAFT') unknown value: {value}")
        return value

    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 UserLevelSummaryDTO 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 each item in right_sets (list)
        _items = []
        if self.right_sets:
            for _item_right_sets in self.right_sets:
                if _item_right_sets:
                    _items.append(_item_right_sets.to_dict())
            _dict['rightSets'] = _items
        # override the default output from pydantic by calling `to_dict()` of owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        # 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 legacy_group (nullable) is None
        # and model_fields_set contains the field
        if self.legacy_group is None and "legacy_group" in self.model_fields_set:
            _dict['legacyGroup'] = None

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of UserLevelSummaryDTO 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"),
            "description": obj.get("description"),
            "legacyGroup": obj.get("legacyGroup"),
            "rightSets": [RightSetDTO.from_dict(_item) for _item in obj["rightSets"]] if obj.get("rightSets") is not None else None,
            "custom": obj.get("custom") if obj.get("custom") is not None else True,
            "adminAssignable": obj.get("adminAssignable") if obj.get("adminAssignable") is not None else True,
            "translatedName": obj.get("translatedName"),
            "translatedGrant": obj.get("translatedGrant"),
            "translatedRemove": obj.get("translatedRemove"),
            "owner": BaseReferenceDto.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "status": obj.get("status"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "associatedIdentitiesCount": obj.get("associatedIdentitiesCount")
        })
        return _obj


