# 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 typing_extensions import Annotated
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_neighbors_inner_bfd import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfd
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_neighbors_inner_bfd_neighbor import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfdNeighbor
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2ProcessAreasInnerInterfacesInner(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2ProcessAreasInnerInterfacesInner
    """ # noqa: E501
    bfd: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfd] = None
    bfd_neighbors: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfdNeighbor]] = Field(default=None, alias="bfdNeighbors")
    cost: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    dead_interval: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="deadInterval")
    dead_interval_value: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="deadIntervalValue")
    dr_priority: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="drPriority")
    hello_interval: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="helloInterval")
    hello_interval_value: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="helloIntervalValue")
    id: Optional[StrictInt] = None
    if_index: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="ifIndex")
    interface: Optional[StrictStr] = None
    max_transmission_unit: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="maxTransmissionUnit")
    mtu_ignore: Optional[StrictBool] = Field(default=None, alias="mtuIgnore")
    prefix_sid: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="prefixSid")
    retransmit_interval: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="retransmitInterval")
    retransmit_interval_value: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="retransmitIntervalValue")
    type: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["bfd", "bfdNeighbors", "cost", "deadInterval", "deadIntervalValue", "drPriority", "helloInterval", "helloIntervalValue", "id", "ifIndex", "interface", "maxTransmissionUnit", "mtuIgnore", "prefixSid", "retransmitInterval", "retransmitIntervalValue", "type"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2ProcessAreasInnerInterfacesInner 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 bfd
        if self.bfd:
            _dict['bfd'] = self.bfd.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in bfd_neighbors (list)
        _items = []
        if self.bfd_neighbors:
            for _item_bfd_neighbors in self.bfd_neighbors:
                if _item_bfd_neighbors:
                    _items.append(_item_bfd_neighbors.to_dict())
            _dict['bfdNeighbors'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "bfd": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfd.from_dict(obj["bfd"]) if obj.get("bfd") is not None else None,
            "bfdNeighbors": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfdNeighbor.from_dict(_item) for _item in obj["bfdNeighbors"]] if obj.get("bfdNeighbors") is not None else None,
            "cost": obj.get("cost"),
            "deadInterval": obj.get("deadInterval"),
            "deadIntervalValue": obj.get("deadIntervalValue"),
            "drPriority": obj.get("drPriority"),
            "helloInterval": obj.get("helloInterval"),
            "helloIntervalValue": obj.get("helloIntervalValue"),
            "id": obj.get("id"),
            "ifIndex": obj.get("ifIndex"),
            "interface": obj.get("interface"),
            "maxTransmissionUnit": obj.get("maxTransmissionUnit"),
            "mtuIgnore": obj.get("mtuIgnore"),
            "prefixSid": obj.get("prefixSid"),
            "retransmitInterval": obj.get("retransmitInterval"),
            "retransmitIntervalValue": obj.get("retransmitIntervalValue"),
            "type": obj.get("type")
        })
        return _obj


