# 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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from sailpoint.v2025.models.managed_client_health_indicators_body_health_indicators import ManagedClientHealthIndicatorsBodyHealthIndicators
from typing import Optional, Set
from typing_extensions import Self

class ManagedClientHealthIndicatorsBody(BaseModel):
    """
    Health indicator details from the Managed Client
    """ # noqa: E501
    alert_key: Optional[StrictStr] = Field(default=None, description="Health indicator alert key", alias="alertKey")
    id: StrictStr = Field(description="Unique identifier for the health report")
    cluster_id: StrictStr = Field(description="Cluster ID the health report belongs to", alias="clusterId")
    api_user: StrictStr = Field(description="API user ID sending the health data", alias="apiUser")
    ccg_etag: Optional[StrictStr] = Field(default=None, description="ETag value for CCG version control")
    ccg_pin: Optional[StrictStr] = Field(default=None, description="PIN value for CCG validation")
    cookbook_etag: Optional[StrictStr] = Field(default=None, description="ETag for cookbook version")
    hostname: StrictStr = Field(description="Hostname of the Managed Client")
    internal_ip: Optional[StrictStr] = Field(default=None, description="Internal IP address of the Managed Client")
    last_seen: Optional[StrictStr] = Field(default=None, description="Epoch timestamp (in millis) when last seen", alias="lastSeen")
    since_seen: Optional[StrictStr] = Field(default=None, description="Seconds since last seen", alias="sinceSeen")
    since_seen_millis: Optional[StrictStr] = Field(default=None, description="Milliseconds since last seen", alias="sinceSeenMillis")
    local_dev: Optional[StrictBool] = Field(default=False, description="Indicates if this is a local development instance", alias="localDev")
    stacktrace: Optional[StrictStr] = Field(default=None, description="Stacktrace associated with any error, if available")
    state: Optional[StrictStr] = Field(default=None, description="Optional state value from the client")
    status: StrictStr = Field(description="Status of the client at the time of report")
    uuid: Optional[StrictStr] = Field(default=None, description="Optional UUID from the client")
    product: StrictStr = Field(description="Product type (e.g., idn)")
    va_version: Optional[StrictStr] = Field(default=None, description="VA version installed on the client")
    platform_version: StrictStr = Field(description="Version of the platform on which VA is running")
    os_version: StrictStr = Field(description="Operating system version")
    os_type: StrictStr = Field(description="Operating system type")
    hypervisor: StrictStr = Field(description="Virtualization platform used")
    consolidated_health_indicators_status: StrictStr = Field(description="Consolidated health indicator status", alias="consolidatedHealthIndicatorsStatus")
    last_notified_ccg_version: Optional[StrictStr] = Field(default=None, description="The last CCG version for which notification was sent", alias="lastNotifiedCcgVersion")
    deployed_processes: Optional[StrictStr] = Field(default=None, description="Information about deployed processes")
    health_indicators: ManagedClientHealthIndicatorsBodyHealthIndicators
    __properties: ClassVar[List[str]] = ["alertKey", "id", "clusterId", "apiUser", "ccg_etag", "ccg_pin", "cookbook_etag", "hostname", "internal_ip", "lastSeen", "sinceSeen", "sinceSeenMillis", "localDev", "stacktrace", "state", "status", "uuid", "product", "va_version", "platform_version", "os_version", "os_type", "hypervisor", "consolidatedHealthIndicatorsStatus", "lastNotifiedCcgVersion", "deployed_processes", "health_indicators"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['NORMAL', 'UNDEFINED', 'WARNING', 'ERROR', 'FAILED']):
            warnings.warn(f"must be one of enum values ('NORMAL', 'UNDEFINED', 'WARNING', 'ERROR', 'FAILED') unknown value: {value}")
        return value

    @field_validator('consolidated_health_indicators_status')
    def consolidated_health_indicators_status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['NORMAL', 'WARNING', 'ERROR']):
            warnings.warn(f"must be one of enum values ('NORMAL', 'WARNING', 'ERROR') 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 ManagedClientHealthIndicatorsBody 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.
        """
        excluded_fields: Set[str] = set([
            "alert_key",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of health_indicators
        if self.health_indicators:
            _dict['health_indicators'] = self.health_indicators.to_dict()
        # 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 ccg_etag (nullable) is None
        # and model_fields_set contains the field
        if self.ccg_etag is None and "ccg_etag" in self.model_fields_set:
            _dict['ccg_etag'] = None

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "alertKey": obj.get("alertKey"),
            "id": obj.get("id"),
            "clusterId": obj.get("clusterId"),
            "apiUser": obj.get("apiUser"),
            "ccg_etag": obj.get("ccg_etag"),
            "ccg_pin": obj.get("ccg_pin"),
            "cookbook_etag": obj.get("cookbook_etag"),
            "hostname": obj.get("hostname"),
            "internal_ip": obj.get("internal_ip"),
            "lastSeen": obj.get("lastSeen"),
            "sinceSeen": obj.get("sinceSeen"),
            "sinceSeenMillis": obj.get("sinceSeenMillis"),
            "localDev": obj.get("localDev") if obj.get("localDev") is not None else False,
            "stacktrace": obj.get("stacktrace"),
            "state": obj.get("state"),
            "status": obj.get("status"),
            "uuid": obj.get("uuid"),
            "product": obj.get("product"),
            "va_version": obj.get("va_version"),
            "platform_version": obj.get("platform_version"),
            "os_version": obj.get("os_version"),
            "os_type": obj.get("os_type"),
            "hypervisor": obj.get("hypervisor"),
            "consolidatedHealthIndicatorsStatus": obj.get("consolidatedHealthIndicatorsStatus"),
            "lastNotifiedCcgVersion": obj.get("lastNotifiedCcgVersion"),
            "deployed_processes": obj.get("deployed_processes"),
            "health_indicators": ManagedClientHealthIndicatorsBodyHealthIndicators.from_dict(obj["health_indicators"]) if obj.get("health_indicators") is not None else None
        })
        return _obj


