# 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
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_backbone_health_device_device_id_post200_response_qoe_matrix_devices_inner import V1BackboneHealthDeviceDeviceIdPost200ResponseQoeMatrixDevicesInner
from graphiant_sdk.models.v1_backbone_health_etet_sla_matrix_get200_response_region_status_inner import V1BackboneHealthEtetSlaMatrixGet200ResponseRegionStatusInner
from graphiant_sdk.models.v1_backbone_health_etet_sla_matrix_get200_response_sla_matrix_inner import V1BackboneHealthEtetSlaMatrixGet200ResponseSlaMatrixInner
from typing import Optional, Set
from typing_extensions import Self

class V1BackboneHealthEtetSlaMatrixGet200Response(BaseModel):
    """
    V1BackboneHealthEtetSlaMatrixGet200Response
    """ # noqa: E501
    devices: Optional[List[V1BackboneHealthDeviceDeviceIdPost200ResponseQoeMatrixDevicesInner]] = None
    region_status: Optional[List[V1BackboneHealthEtetSlaMatrixGet200ResponseRegionStatusInner]] = Field(default=None, alias="regionStatus")
    sla_matrix: Optional[List[V1BackboneHealthEtetSlaMatrixGet200ResponseSlaMatrixInner]] = Field(default=None, alias="slaMatrix")
    __properties: ClassVar[List[str]] = ["devices", "regionStatus", "slaMatrix"]

    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 V1BackboneHealthEtetSlaMatrixGet200Response 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 devices (list)
        _items = []
        if self.devices:
            for _item_devices in self.devices:
                if _item_devices:
                    _items.append(_item_devices.to_dict())
            _dict['devices'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in region_status (list)
        _items = []
        if self.region_status:
            for _item_region_status in self.region_status:
                if _item_region_status:
                    _items.append(_item_region_status.to_dict())
            _dict['regionStatus'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in sla_matrix (list)
        _items = []
        if self.sla_matrix:
            for _item_sla_matrix in self.sla_matrix:
                if _item_sla_matrix:
                    _items.append(_item_sla_matrix.to_dict())
            _dict['slaMatrix'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "devices": [V1BackboneHealthDeviceDeviceIdPost200ResponseQoeMatrixDevicesInner.from_dict(_item) for _item in obj["devices"]] if obj.get("devices") is not None else None,
            "regionStatus": [V1BackboneHealthEtetSlaMatrixGet200ResponseRegionStatusInner.from_dict(_item) for _item in obj["regionStatus"]] if obj.get("regionStatus") is not None else None,
            "slaMatrix": [V1BackboneHealthEtetSlaMatrixGet200ResponseSlaMatrixInner.from_dict(_item) for _item in obj["slaMatrix"]] if obj.get("slaMatrix") is not None else None
        })
        return _obj


