# coding: utf-8

"""
    Graphiant APIs

    Graphiant API documentation.

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_backbone_health_device_device_id_post200_response_control_plane_control_transitions_transitions_inner_transitions_inner import V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner
from graphiant_sdk.models.v1_backbone_health_device_device_id_post200_response_system_plane_crashes_inner import V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneCrashesInner
from graphiant_sdk.models.v1_backbone_health_device_device_id_post200_response_system_plane_last_crash import V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneLastCrash
from graphiant_sdk.models.v2_notificationlist_post_request import V2NotificationlistPostRequest
from typing import Optional, Set
from typing_extensions import Self

class V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlane(BaseModel):
    """
    V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlane
    """ # noqa: E501
    cpu: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner]] = None
    crashes: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneCrashesInner]] = None
    disk: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner]] = None
    last_crash: Optional[V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneLastCrash] = Field(default=None, alias="lastCrash")
    maintenance_windows: Optional[List[V2NotificationlistPostRequest]] = Field(default=None, alias="maintenanceWindows")
    memory: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner]] = None
    overheating: Optional[List[V2NotificationlistPostRequest]] = None
    status: Optional[StrictStr] = None
    temperature_series: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner]] = Field(default=None, alias="temperatureSeries")
    __properties: ClassVar[List[str]] = ["cpu", "crashes", "disk", "lastCrash", "maintenanceWindows", "memory", "overheating", "status", "temperatureSeries"]

    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 V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlane 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 each item in cpu (list)
        _items = []
        if self.cpu:
            for _item_cpu in self.cpu:
                if _item_cpu:
                    _items.append(_item_cpu.to_dict())
            _dict['cpu'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in crashes (list)
        _items = []
        if self.crashes:
            for _item_crashes in self.crashes:
                if _item_crashes:
                    _items.append(_item_crashes.to_dict())
            _dict['crashes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in disk (list)
        _items = []
        if self.disk:
            for _item_disk in self.disk:
                if _item_disk:
                    _items.append(_item_disk.to_dict())
            _dict['disk'] = _items
        # override the default output from pydantic by calling `to_dict()` of last_crash
        if self.last_crash:
            _dict['lastCrash'] = self.last_crash.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in maintenance_windows (list)
        _items = []
        if self.maintenance_windows:
            for _item_maintenance_windows in self.maintenance_windows:
                if _item_maintenance_windows:
                    _items.append(_item_maintenance_windows.to_dict())
            _dict['maintenanceWindows'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in memory (list)
        _items = []
        if self.memory:
            for _item_memory in self.memory:
                if _item_memory:
                    _items.append(_item_memory.to_dict())
            _dict['memory'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in overheating (list)
        _items = []
        if self.overheating:
            for _item_overheating in self.overheating:
                if _item_overheating:
                    _items.append(_item_overheating.to_dict())
            _dict['overheating'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in temperature_series (list)
        _items = []
        if self.temperature_series:
            for _item_temperature_series in self.temperature_series:
                if _item_temperature_series:
                    _items.append(_item_temperature_series.to_dict())
            _dict['temperatureSeries'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "cpu": [V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner.from_dict(_item) for _item in obj["cpu"]] if obj.get("cpu") is not None else None,
            "crashes": [V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneCrashesInner.from_dict(_item) for _item in obj["crashes"]] if obj.get("crashes") is not None else None,
            "disk": [V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner.from_dict(_item) for _item in obj["disk"]] if obj.get("disk") is not None else None,
            "lastCrash": V1BackboneHealthDeviceDeviceIdPost200ResponseSystemPlaneLastCrash.from_dict(obj["lastCrash"]) if obj.get("lastCrash") is not None else None,
            "maintenanceWindows": [V2NotificationlistPostRequest.from_dict(_item) for _item in obj["maintenanceWindows"]] if obj.get("maintenanceWindows") is not None else None,
            "memory": [V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner.from_dict(_item) for _item in obj["memory"]] if obj.get("memory") is not None else None,
            "overheating": [V2NotificationlistPostRequest.from_dict(_item) for _item in obj["overheating"]] if obj.get("overheating") is not None else None,
            "status": obj.get("status"),
            "temperatureSeries": [V1BackboneHealthDeviceDeviceIdPost200ResponseControlPlaneControlTransitionsTransitionsInnerTransitionsInner.from_dict(_item) for _item in obj["temperatureSeries"]] if obj.get("temperatureSeries") is not None else None
        })
        return _obj


