# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v2_assurance_applicationdetailsbyname_post200_response_app_id_record import V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord
from graphiant_sdk.models.v2_assurance_applicationdetailsbyname_post200_response_app_name_record import V2AssuranceApplicationdetailsbynamePost200ResponseAppNameRecord
from graphiant_sdk.models.v2_assurance_bucketdetails_post200_response_bucket_details_trend_value_list_inner import V2AssuranceBucketdetailsPost200ResponseBucketDetailsTrendValueListInner
from typing import Optional, Set
from typing_extensions import Self

class V2AssuranceBucketdetailsPost200ResponseBucketDetails(BaseModel):
    """
    V2AssuranceBucketdetailsPost200ResponseBucketDetails
    """ # noqa: E501
    app_count_threat_high: Optional[StrictInt] = Field(default=None, alias="appCountThreatHigh")
    app_count_threat_low: Optional[StrictInt] = Field(default=None, alias="appCountThreatLow")
    app_count_threat_medium: Optional[StrictInt] = Field(default=None, alias="appCountThreatMedium")
    app_id_records: Optional[List[V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord]] = Field(default=None, alias="appIdRecords")
    app_name_records: Optional[List[V2AssuranceApplicationdetailsbynamePost200ResponseAppNameRecord]] = Field(default=None, alias="appNameRecords")
    bucket_name_to_display: Optional[StrictStr] = Field(default=None, alias="bucketNameToDisplay")
    description: Optional[StrictStr] = None
    display_ip_port: Optional[StrictBool] = Field(default=None, alias="displayIpPort")
    flow_count: Optional[StrictInt] = Field(default=None, alias="flowCount")
    new_ip_hint: Optional[StrictBool] = Field(default=None, alias="newIpHint")
    recommendation: Optional[StrictStr] = None
    trend_value_list: Optional[List[V2AssuranceBucketdetailsPost200ResponseBucketDetailsTrendValueListInner]] = Field(default=None, alias="trendValueList")
    unique_app_count: Optional[StrictInt] = Field(default=None, alias="uniqueAppCount")
    __properties: ClassVar[List[str]] = ["appCountThreatHigh", "appCountThreatLow", "appCountThreatMedium", "appIdRecords", "appNameRecords", "bucketNameToDisplay", "description", "displayIpPort", "flowCount", "newIpHint", "recommendation", "trendValueList", "uniqueAppCount"]

    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 V2AssuranceBucketdetailsPost200ResponseBucketDetails 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 app_id_records (list)
        _items = []
        if self.app_id_records:
            for _item_app_id_records in self.app_id_records:
                if _item_app_id_records:
                    _items.append(_item_app_id_records.to_dict())
            _dict['appIdRecords'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in app_name_records (list)
        _items = []
        if self.app_name_records:
            for _item_app_name_records in self.app_name_records:
                if _item_app_name_records:
                    _items.append(_item_app_name_records.to_dict())
            _dict['appNameRecords'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in trend_value_list (list)
        _items = []
        if self.trend_value_list:
            for _item_trend_value_list in self.trend_value_list:
                if _item_trend_value_list:
                    _items.append(_item_trend_value_list.to_dict())
            _dict['trendValueList'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "appCountThreatHigh": obj.get("appCountThreatHigh"),
            "appCountThreatLow": obj.get("appCountThreatLow"),
            "appCountThreatMedium": obj.get("appCountThreatMedium"),
            "appIdRecords": [V2AssuranceApplicationdetailsbynamePost200ResponseAppIdRecord.from_dict(_item) for _item in obj["appIdRecords"]] if obj.get("appIdRecords") is not None else None,
            "appNameRecords": [V2AssuranceApplicationdetailsbynamePost200ResponseAppNameRecord.from_dict(_item) for _item in obj["appNameRecords"]] if obj.get("appNameRecords") is not None else None,
            "bucketNameToDisplay": obj.get("bucketNameToDisplay"),
            "description": obj.get("description"),
            "displayIpPort": obj.get("displayIpPort"),
            "flowCount": obj.get("flowCount"),
            "newIpHint": obj.get("newIpHint"),
            "recommendation": obj.get("recommendation"),
            "trendValueList": [V2AssuranceBucketdetailsPost200ResponseBucketDetailsTrendValueListInner.from_dict(_item) for _item in obj["trendValueList"]] if obj.get("trendValueList") is not None else None,
            "uniqueAppCount": obj.get("uniqueAppCount")
        })
        return _obj


