# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v2_assurance_applicationprofilesummary_post200_response_application_profile_summary_bucket_summary_list_inner_bucket_stats import V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerBucketStats
from graphiant_sdk.models.v2_assurance_applicationprofilesummary_post200_response_application_profile_summary_bucket_summary_list_inner_child_bucket_stats_list_inner import V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerChildBucketStatsListInner
from typing import Optional, Set
from typing_extensions import Self

class V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInner(BaseModel):
    """
    V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInner
    """ # noqa: E501
    assurance_bucket: Optional[StrictStr] = Field(default=None, alias="assuranceBucket")
    bucket_color: Optional[StrictStr] = Field(default=None, alias="bucketColor")
    bucket_name_to_display: Optional[StrictStr] = Field(default=None, alias="bucketNameToDisplay")
    bucket_stats: Optional[V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerBucketStats] = Field(default=None, alias="bucketStats")
    child_bucket_list: Optional[List[StrictStr]] = Field(default=None, alias="childBucketList")
    child_bucket_stats_list: Optional[List[V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerChildBucketStatsListInner]] = Field(default=None, alias="childBucketStatsList")
    is_root: Optional[StrictBool] = Field(default=None, alias="isRoot")
    is_terminal: Optional[StrictBool] = Field(default=None, alias="isTerminal")
    parent_bucket_list: Optional[List[StrictStr]] = Field(default=None, alias="parentBucketList")
    __properties: ClassVar[List[str]] = ["assuranceBucket", "bucketColor", "bucketNameToDisplay", "bucketStats", "childBucketList", "childBucketStatsList", "isRoot", "isTerminal", "parentBucketList"]

    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 V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInner 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 bucket_stats
        if self.bucket_stats:
            _dict['bucketStats'] = self.bucket_stats.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in child_bucket_stats_list (list)
        _items = []
        if self.child_bucket_stats_list:
            for _item_child_bucket_stats_list in self.child_bucket_stats_list:
                if _item_child_bucket_stats_list:
                    _items.append(_item_child_bucket_stats_list.to_dict())
            _dict['childBucketStatsList'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "assuranceBucket": obj.get("assuranceBucket"),
            "bucketColor": obj.get("bucketColor"),
            "bucketNameToDisplay": obj.get("bucketNameToDisplay"),
            "bucketStats": V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerBucketStats.from_dict(obj["bucketStats"]) if obj.get("bucketStats") is not None else None,
            "childBucketList": obj.get("childBucketList"),
            "childBucketStatsList": [V2AssuranceApplicationprofilesummaryPost200ResponseApplicationProfileSummaryBucketSummaryListInnerChildBucketStatsListInner.from_dict(_item) for _item in obj["childBucketStatsList"]] if obj.get("childBucketStatsList") is not None else None,
            "isRoot": obj.get("isRoot"),
            "isTerminal": obj.get("isTerminal"),
            "parentBucketList": obj.get("parentBucketList")
        })
        return _obj


