# 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

from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictInt, StrictStr, field_validator
from pydantic import Field
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ManagedClient(BaseModel):
    """
    Managed Client
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="ManagedClient ID")
    alert_key: Optional[StrictStr] = Field(default=None, description="ManagedClient alert key", alias="alertKey")
    cc_id: Optional[StrictInt] = Field(default=None, description="Previous CC ID to be used in data migration. (This field will be deleted after CC migration!)", alias="ccId")
    client_id: StrictStr = Field(description="The client ID used in API management", alias="clientId")
    cluster_id: StrictStr = Field(description="Cluster ID that the ManagedClient is linked to", alias="clusterId")
    description: StrictStr = Field(description="ManagedClient description")
    ip_address: Optional[StrictStr] = Field(default=None, description="The public IP address of the ManagedClient", alias="ipAddress")
    last_seen: Optional[datetime] = Field(default=None, description="When the ManagedClient was last seen by the server", alias="lastSeen")
    name: Optional[StrictStr] = Field(default='VA-$clientId', description="ManagedClient name")
    since_last_seen: Optional[StrictStr] = Field(default=None, description="Milliseconds since the ManagedClient has polled the server", alias="sinceLastSeen")
    status: Optional[StrictStr] = Field(default=None, description="Status of the ManagedClient")
    type: StrictStr = Field(description="Type of the ManagedClient (VA, CCG)")
    cluster_type: Optional[StrictStr] = Field(default=None, description="Cluster Type of the ManagedClient", alias="clusterType")
    va_download_url: Optional[StrictStr] = Field(default=None, description="ManagedClient VA download URL", alias="vaDownloadUrl")
    va_version: Optional[StrictStr] = Field(default=None, description="Version that the ManagedClient's VA is running", alias="vaVersion")
    secret: Optional[StrictStr] = Field(default=None, description="Client's apiKey")
    created_at: Optional[datetime] = Field(default=None, description="The date/time this ManagedClient was created", alias="createdAt")
    updated_at: Optional[datetime] = Field(default=None, description="The date/time this ManagedClient was last updated", alias="updatedAt")
    provision_status: Optional[StrictStr] = Field(default=None, description="The provisioning status of the ManagedClient", alias="provisionStatus")
    __properties: ClassVar[List[str]] = ["id", "alertKey", "ccId", "clientId", "clusterId", "description", "ipAddress", "lastSeen", "name", "sinceLastSeen", "status", "type", "clusterType", "vaDownloadUrl", "vaVersion", "secret", "createdAt", "updatedAt", "provisionStatus"]

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

        if value not in ('NORMAL', 'UNDEFINED', 'NOT_CONFIGURED', 'CONFIGURING', 'WARNING', 'ERROR', 'FAILED', 'null'):
            raise ValueError("must be one of enum values ('NORMAL', 'UNDEFINED', 'NOT_CONFIGURED', 'CONFIGURING', 'WARNING', 'ERROR', 'FAILED', 'null')")
        return value

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

        if value not in ('null', 'idn', 'iai', 'spConnectCluster', 'sqsCluster', 'das-rc', 'das-pc', 'das-dc'):
            raise ValueError("must be one of enum values ('null', 'idn', 'iai', 'spConnectCluster', 'sqsCluster', 'das-rc', 'das-pc', 'das-dc')")
        return value

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

        if value not in ('null', 'PROVISIONED', 'DRAFT'):
            raise ValueError("must be one of enum values ('null', 'PROVISIONED', 'DRAFT')")
        return value

    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 ManagedClient 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * 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",
                "alert_key",
                "ip_address",
                "last_seen",
                "since_last_seen",
                "status",
                "cluster_type",
                "va_download_url",
                "va_version",
                "provision_status",
            },
            exclude_none=True,
        )
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['id'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of ManagedClient 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"),
            "alertKey": obj.get("alertKey"),
            "ccId": obj.get("ccId"),
            "clientId": obj.get("clientId"),
            "clusterId": obj.get("clusterId"),
            "description": obj.get("description") if obj.get("description") is not None else '',
            "ipAddress": obj.get("ipAddress"),
            "lastSeen": obj.get("lastSeen"),
            "name": obj.get("name") if obj.get("name") is not None else 'VA-$clientId',
            "sinceLastSeen": obj.get("sinceLastSeen"),
            "status": obj.get("status"),
            "type": obj.get("type"),
            "clusterType": obj.get("clusterType"),
            "vaDownloadUrl": obj.get("vaDownloadUrl"),
            "vaVersion": obj.get("vaVersion"),
            "secret": obj.get("secret"),
            "createdAt": obj.get("createdAt"),
            "updatedAt": obj.get("updatedAt"),
            "provisionStatus": obj.get("provisionStatus")
        })
        return _obj


