# coding: utf-8

"""
    Identity Security Cloud Beta API

    Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. 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.1.0-beta
    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.beta.models.access_profile_details_account_selector import AccessProfileDetailsAccountSelector
from typing import Optional, Set
from typing_extensions import Self

class AccessProfileDetails(BaseModel):
    """
    AccessProfileDetails
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="The ID of the Access Profile")
    name: Optional[StrictStr] = Field(default=None, description="Name of the Access Profile")
    description: Optional[StrictStr] = Field(default=None, description="Information about the Access Profile")
    created: Optional[datetime] = Field(default=None, description="Date the Access Profile was created")
    modified: Optional[datetime] = Field(default=None, description="Date the Access Profile was last modified.")
    disabled: Optional[StrictBool] = Field(default=True, description="Whether the Access Profile is enabled.")
    requestable: Optional[StrictBool] = Field(default=False, description="Whether the Access Profile is requestable via access request.")
    protected: Optional[StrictBool] = Field(default=False, description="Whether the Access Profile is protected.")
    owner_id: Optional[StrictStr] = Field(default=None, description="The owner ID of the Access Profile", alias="ownerId")
    source_id: Optional[StrictInt] = Field(default=None, description="The source ID of the Access Profile", alias="sourceId")
    source_name: Optional[StrictStr] = Field(default=None, description="The source name of the Access Profile", alias="sourceName")
    app_id: Optional[StrictInt] = Field(default=None, description="The source app ID of the Access Profile", alias="appId")
    app_name: Optional[StrictStr] = Field(default=None, description="The source app name of the Access Profile", alias="appName")
    application_id: Optional[StrictStr] = Field(default=None, description="The id of the application", alias="applicationId")
    type: Optional[StrictStr] = Field(default=None, description="The type of the access profile")
    entitlements: Optional[List[StrictStr]] = Field(default=None, description="List of IDs of entitlements")
    entitlement_count: Optional[StrictInt] = Field(default=None, description="The number of entitlements in the access profile", alias="entitlementCount")
    segments: Optional[List[StrictStr]] = Field(default=None, description="List of IDs of segments, if any, to which this Access Profile is assigned.")
    approval_schemes: Optional[StrictStr] = Field(default=None, description="Comma-separated list of approval schemes. Each approval scheme is one of - manager - appOwner - sourceOwner - accessProfileOwner - workgroup:&lt;workgroupId&gt; ", alias="approvalSchemes")
    revoke_request_approval_schemes: Optional[StrictStr] = Field(default=None, description="Comma-separated list of revoke request approval schemes. Each approval scheme is one of - manager - sourceOwner - accessProfileOwner - workgroup:&lt;workgroupId&gt; ", alias="revokeRequestApprovalSchemes")
    request_comments_required: Optional[StrictBool] = Field(default=False, description="Whether the access profile require request comment for access request.", alias="requestCommentsRequired")
    denied_comments_required: Optional[StrictBool] = Field(default=False, description="Whether denied comment is required when access request is denied.", alias="deniedCommentsRequired")
    account_selector: Optional[AccessProfileDetailsAccountSelector] = Field(default=None, alias="accountSelector")
    __properties: ClassVar[List[str]] = ["id", "name", "description", "created", "modified", "disabled", "requestable", "protected", "ownerId", "sourceId", "sourceName", "appId", "appName", "applicationId", "type", "entitlements", "entitlementCount", "segments", "approvalSchemes", "revokeRequestApprovalSchemes", "requestCommentsRequired", "deniedCommentsRequired", "accountSelector"]

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AccessProfileDetails 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"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "disabled": obj.get("disabled") if obj.get("disabled") is not None else True,
            "requestable": obj.get("requestable") if obj.get("requestable") is not None else False,
            "protected": obj.get("protected") if obj.get("protected") is not None else False,
            "ownerId": obj.get("ownerId"),
            "sourceId": obj.get("sourceId"),
            "sourceName": obj.get("sourceName"),
            "appId": obj.get("appId"),
            "appName": obj.get("appName"),
            "applicationId": obj.get("applicationId"),
            "type": obj.get("type"),
            "entitlements": obj.get("entitlements"),
            "entitlementCount": obj.get("entitlementCount"),
            "segments": obj.get("segments"),
            "approvalSchemes": obj.get("approvalSchemes"),
            "revokeRequestApprovalSchemes": obj.get("revokeRequestApprovalSchemes"),
            "requestCommentsRequired": obj.get("requestCommentsRequired") if obj.get("requestCommentsRequired") is not None else False,
            "deniedCommentsRequired": obj.get("deniedCommentsRequired") if obj.get("deniedCommentsRequired") is not None else False,
            "accountSelector": AccessProfileDetailsAccountSelector.from_dict(obj["accountSelector"]) if obj.get("accountSelector") is not None else None
        })
        return _obj


