# 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, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class AuthUser(BaseModel):
    """
    AuthUser
    """ # noqa: E501
    tenant: Optional[StrictStr] = Field(default=None, description="Tenant name.")
    id: Optional[StrictStr] = Field(default=None, description="Identity ID.")
    uid: Optional[StrictStr] = Field(default=None, description="Identity's unique identitifier.")
    profile: Optional[StrictStr] = Field(default=None, description="ID of the auth profile associated with the auth user.")
    identification_number: Optional[StrictStr] = Field(default=None, description="Auth user's employee number.", alias="identificationNumber")
    email: Optional[StrictStr] = Field(default=None, description="Auth user's email.")
    phone: Optional[StrictStr] = Field(default=None, description="Auth user's phone number.")
    work_phone: Optional[StrictStr] = Field(default=None, description="Auth user's work phone number.", alias="workPhone")
    personal_email: Optional[StrictStr] = Field(default=None, description="Auth user's personal email.", alias="personalEmail")
    firstname: Optional[StrictStr] = Field(default=None, description="Auth user's first name.")
    lastname: Optional[StrictStr] = Field(default=None, description="Auth user's last name.")
    display_name: Optional[StrictStr] = Field(default=None, description="Auth user's name in displayed format.", alias="displayName")
    alias: Optional[StrictStr] = Field(default=None, description="Auth user's alias.")
    last_password_change_date: Optional[datetime] = Field(default=None, description="Date of last password change.", alias="lastPasswordChangeDate")
    last_login_timestamp: Optional[StrictInt] = Field(default=None, description="Timestamp of the last login (long type value).", alias="lastLoginTimestamp")
    current_login_timestamp: Optional[StrictInt] = Field(default=None, description="Timestamp of the current login (long type value).", alias="currentLoginTimestamp")
    last_unlock_timestamp: Optional[datetime] = Field(default=None, description="The date and time when the user was last unlocked.", alias="lastUnlockTimestamp")
    capabilities: Optional[List[StrictStr]] = Field(default=None, description="Array of the auth user's capabilities.")
    __properties: ClassVar[List[str]] = ["tenant", "id", "uid", "profile", "identificationNumber", "email", "phone", "workPhone", "personalEmail", "firstname", "lastname", "displayName", "alias", "lastPasswordChangeDate", "lastLoginTimestamp", "currentLoginTimestamp", "lastUnlockTimestamp", "capabilities"]

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

        for i in value:
            if i not in set(['CERT_ADMIN', 'CLOUD_GOV_ADMIN', 'CLOUD_GOV_USER', 'HELPDESK', 'ORG_ADMIN', 'REPORT_ADMIN', 'ROLE_ADMIN', 'ROLE_SUBADMIN', 'SAAS_MANAGEMENT_ADMIN', 'SAAS_MANAGEMENT_READER', 'SOURCE_ADMIN', 'SOURCE_SUBADMIN', 'das:ui-administrator', 'das:ui-compliance_manager', 'das:ui-auditor', 'das:ui-data-scope', 'sp:aic-dashboard-read', 'sp:aic-dashboard-write', 'sp:ui-config-hub-admin', 'sp:ui-config-hub-backup-admin', 'sp:ui-config-hub-read']):
                warnings.warn(f"each list item must be one of ('CERT_ADMIN', 'CLOUD_GOV_ADMIN', 'CLOUD_GOV_USER', 'HELPDESK', 'ORG_ADMIN', 'REPORT_ADMIN', 'ROLE_ADMIN', 'ROLE_SUBADMIN', 'SAAS_MANAGEMENT_ADMIN', 'SAAS_MANAGEMENT_READER', 'SOURCE_ADMIN', 'SOURCE_SUBADMIN', 'das:ui-administrator', 'das:ui-compliance_manager', 'das:ui-auditor', 'das:ui-data-scope', 'sp:aic-dashboard-read', 'sp:aic-dashboard-write', 'sp:ui-config-hub-admin', 'sp:ui-config-hub-backup-admin', 'sp:ui-config-hub-read') unknown value: {i}")
        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 AuthUser 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,
        )
        # set to None if identification_number (nullable) is None
        # and model_fields_set contains the field
        if self.identification_number is None and "identification_number" in self.model_fields_set:
            _dict['identificationNumber'] = None

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "tenant": obj.get("tenant"),
            "id": obj.get("id"),
            "uid": obj.get("uid"),
            "profile": obj.get("profile"),
            "identificationNumber": obj.get("identificationNumber"),
            "email": obj.get("email"),
            "phone": obj.get("phone"),
            "workPhone": obj.get("workPhone"),
            "personalEmail": obj.get("personalEmail"),
            "firstname": obj.get("firstname"),
            "lastname": obj.get("lastname"),
            "displayName": obj.get("displayName"),
            "alias": obj.get("alias"),
            "lastPasswordChangeDate": obj.get("lastPasswordChangeDate"),
            "lastLoginTimestamp": obj.get("lastLoginTimestamp"),
            "currentLoginTimestamp": obj.get("currentLoginTimestamp"),
            "lastUnlockTimestamp": obj.get("lastUnlockTimestamp"),
            "capabilities": obj.get("capabilities")
        })
        return _obj


