# coding: utf-8

"""
    Identity Security Cloud V3 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: 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
import warnings

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sailpoint.v3.models.base_access_owner import BaseAccessOwner
from sailpoint.v3.models.base_access_profile import BaseAccessProfile
from sailpoint.v3.models.base_segment import BaseSegment
from sailpoint.v3.models.role_document_all_of_dimension_schema_attributes import RoleDocumentAllOfDimensionSchemaAttributes
from sailpoint.v3.models.role_document_all_of_dimensions import RoleDocumentAllOfDimensions
from sailpoint.v3.models.role_document_all_of_entitlements import RoleDocumentAllOfEntitlements
from typing import Optional, Set
from typing_extensions import Self

class RoleDocument(BaseModel):
    """
    Role
    """ # noqa: E501
    description: Optional[StrictStr] = Field(default=None, description="Access item's description.")
    created: Optional[datetime] = Field(default=None, description="ISO-8601 date-time referring to the time when the object was created.")
    modified: Optional[datetime] = Field(default=None, description="ISO-8601 date-time referring to the time when the object was last modified.")
    synced: Optional[datetime] = Field(default=None, description="ISO-8601 date-time referring to the date-time when object was queued to be synced into search database for use in the search API.   This date-time changes anytime there is an update to the object, which triggers a synchronization event being sent to the search database.  There may be some delay between the `synced` time and the time when the updated data is actually available in the search API. ")
    enabled: Optional[StrictBool] = Field(default=False, description="Indicates whether the access item is currently enabled.")
    requestable: Optional[StrictBool] = Field(default=True, description="Indicates whether the access item can be requested.")
    request_comments_required: Optional[StrictBool] = Field(default=False, description="Indicates whether comments are required for requests to access the item.", alias="requestCommentsRequired")
    owner: Optional[BaseAccessOwner] = None
    id: StrictStr = Field(description="ID of the role.")
    name: StrictStr = Field(description="Name of the role.")
    access_profiles: Optional[List[BaseAccessProfile]] = Field(default=None, description="Access profiles included with the role.", alias="accessProfiles")
    access_profile_count: Optional[StrictInt] = Field(default=None, description="Number of access profiles included with the role.", alias="accessProfileCount")
    tags: Optional[List[StrictStr]] = Field(default=None, description="Tags that have been applied to the object.")
    segments: Optional[List[BaseSegment]] = Field(default=None, description="Segments with the role.")
    segment_count: Optional[StrictInt] = Field(default=None, description="Number of segments with the role.", alias="segmentCount")
    entitlements: Optional[List[RoleDocumentAllOfEntitlements]] = Field(default=None, description="Entitlements included with the role.")
    entitlement_count: Optional[StrictInt] = Field(default=None, description="Number of entitlements included with the role.", alias="entitlementCount")
    dimensional: Optional[StrictBool] = False
    dimension_schema_attribute_count: Optional[StrictInt] = Field(default=None, description="Number of dimension attributes included with the role.", alias="dimensionSchemaAttributeCount")
    dimension_schema_attributes: Optional[List[RoleDocumentAllOfDimensionSchemaAttributes]] = Field(default=None, description="Dimension attributes included with the role.", alias="dimensionSchemaAttributes")
    dimensions: Optional[List[RoleDocumentAllOfDimensions]] = None
    __properties: ClassVar[List[str]] = ["description", "created", "modified", "synced", "enabled", "requestable", "requestCommentsRequired", "owner", "id", "name", "accessProfiles", "accessProfileCount", "tags", "segments", "segmentCount", "entitlements", "entitlementCount", "dimensional", "dimensionSchemaAttributeCount", "dimensionSchemaAttributes", "dimensions"]

    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 RoleDocument 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 owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in access_profiles (list)
        _items = []
        if self.access_profiles:
            for _item_access_profiles in self.access_profiles:
                if _item_access_profiles:
                    _items.append(_item_access_profiles.to_dict())
            _dict['accessProfiles'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in segments (list)
        _items = []
        if self.segments:
            for _item_segments in self.segments:
                if _item_segments:
                    _items.append(_item_segments.to_dict())
            _dict['segments'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in entitlements (list)
        _items = []
        if self.entitlements:
            for _item_entitlements in self.entitlements:
                if _item_entitlements:
                    _items.append(_item_entitlements.to_dict())
            _dict['entitlements'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dimension_schema_attributes (list)
        _items = []
        if self.dimension_schema_attributes:
            for _item_dimension_schema_attributes in self.dimension_schema_attributes:
                if _item_dimension_schema_attributes:
                    _items.append(_item_dimension_schema_attributes.to_dict())
            _dict['dimensionSchemaAttributes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dimensions (list)
        _items = []
        if self.dimensions:
            for _item_dimensions in self.dimensions:
                if _item_dimensions:
                    _items.append(_item_dimensions.to_dict())
            _dict['dimensions'] = _items
        # set to None if created (nullable) is None
        # and model_fields_set contains the field
        if self.created is None and "created" in self.model_fields_set:
            _dict['created'] = None

        # 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 synced (nullable) is None
        # and model_fields_set contains the field
        if self.synced is None and "synced" in self.model_fields_set:
            _dict['synced'] = None

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "description": obj.get("description"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "synced": obj.get("synced"),
            "enabled": obj.get("enabled") if obj.get("enabled") is not None else False,
            "requestable": obj.get("requestable") if obj.get("requestable") is not None else True,
            "requestCommentsRequired": obj.get("requestCommentsRequired") if obj.get("requestCommentsRequired") is not None else False,
            "owner": BaseAccessOwner.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "id": obj.get("id"),
            "name": obj.get("name"),
            "accessProfiles": [BaseAccessProfile.from_dict(_item) for _item in obj["accessProfiles"]] if obj.get("accessProfiles") is not None else None,
            "accessProfileCount": obj.get("accessProfileCount"),
            "tags": obj.get("tags"),
            "segments": [BaseSegment.from_dict(_item) for _item in obj["segments"]] if obj.get("segments") is not None else None,
            "segmentCount": obj.get("segmentCount"),
            "entitlements": [RoleDocumentAllOfEntitlements.from_dict(_item) for _item in obj["entitlements"]] if obj.get("entitlements") is not None else None,
            "entitlementCount": obj.get("entitlementCount"),
            "dimensional": obj.get("dimensional") if obj.get("dimensional") is not None else False,
            "dimensionSchemaAttributeCount": obj.get("dimensionSchemaAttributeCount"),
            "dimensionSchemaAttributes": [RoleDocumentAllOfDimensionSchemaAttributes.from_dict(_item) for _item in obj["dimensionSchemaAttributes"]] if obj.get("dimensionSchemaAttributes") is not None else None,
            "dimensions": [RoleDocumentAllOfDimensions.from_dict(_item) for _item in obj["dimensions"]] if obj.get("dimensions") is not None else None
        })
        return _obj


