# 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_alarm_history_get200_response_history_inner_time import V1AlarmHistoryGet200ResponseHistoryInnerTime
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_neighbors_inner_address_families_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerAddressFamiliesInner
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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner
    """ # noqa: E501
    address_families: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerAddressFamiliesInner]] = Field(default=None, alias="addressFamilies")
    allow_as_in: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="allowAsIn")
    as_override: Optional[StrictBool] = Field(default=None, alias="asOverride")
    bfd: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfd] = None
    bfd_neighbor: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfdNeighbor] = Field(default=None, alias="bfdNeighbor")
    bgp_type: Optional[StrictStr] = Field(default=None, alias="bgpType")
    default_originate: Optional[StrictStr] = Field(default=None, alias="defaultOriginate")
    enabled: Optional[StrictBool] = None
    hold_timer: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="holdTimer")
    id: Optional[StrictInt] = None
    keepalive_timer: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="keepaliveTimer")
    local_address: Optional[StrictStr] = Field(default=None, alias="localAddress")
    local_interface: Optional[StrictStr] = Field(default=None, alias="localInterface")
    max_prefix: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="maxPrefix")
    md5_password: Optional[StrictStr] = Field(default=None, alias="md5Password")
    multi_hop: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="multiHop")
    peer_asn: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="peerAsn")
    remote_address: Optional[StrictStr] = Field(default=None, alias="remoteAddress")
    remove_private_as: Optional[StrictBool] = Field(default=None, alias="removePrivateAs")
    send_community: Optional[StrictBool] = Field(default=None, alias="sendCommunity")
    state: Optional[StrictStr] = None
    time_since_last_oper_change: Optional[V1AlarmHistoryGet200ResponseHistoryInnerTime] = Field(default=None, alias="timeSinceLastOperChange")
    up: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["addressFamilies", "allowAsIn", "asOverride", "bfd", "bfdNeighbor", "bgpType", "defaultOriginate", "enabled", "holdTimer", "id", "keepaliveTimer", "localAddress", "localInterface", "maxPrefix", "md5Password", "multiHop", "peerAsn", "remoteAddress", "removePrivateAs", "sendCommunity", "state", "timeSinceLastOperChange", "up"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner 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 address_families (list)
        _items = []
        if self.address_families:
            for _item_address_families in self.address_families:
                if _item_address_families:
                    _items.append(_item_address_families.to_dict())
            _dict['addressFamilies'] = _items
        # 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 bfd_neighbor
        if self.bfd_neighbor:
            _dict['bfdNeighbor'] = self.bfd_neighbor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of time_since_last_oper_change
        if self.time_since_last_oper_change:
            _dict['timeSinceLastOperChange'] = self.time_since_last_oper_change.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "addressFamilies": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerAddressFamiliesInner.from_dict(_item) for _item in obj["addressFamilies"]] if obj.get("addressFamilies") is not None else None,
            "allowAsIn": obj.get("allowAsIn"),
            "asOverride": obj.get("asOverride"),
            "bfd": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfd.from_dict(obj["bfd"]) if obj.get("bfd") is not None else None,
            "bfdNeighbor": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInnerBfdNeighbor.from_dict(obj["bfdNeighbor"]) if obj.get("bfdNeighbor") is not None else None,
            "bgpType": obj.get("bgpType"),
            "defaultOriginate": obj.get("defaultOriginate"),
            "enabled": obj.get("enabled"),
            "holdTimer": obj.get("holdTimer"),
            "id": obj.get("id"),
            "keepaliveTimer": obj.get("keepaliveTimer"),
            "localAddress": obj.get("localAddress"),
            "localInterface": obj.get("localInterface"),
            "maxPrefix": obj.get("maxPrefix"),
            "md5Password": obj.get("md5Password"),
            "multiHop": obj.get("multiHop"),
            "peerAsn": obj.get("peerAsn"),
            "remoteAddress": obj.get("remoteAddress"),
            "removePrivateAs": obj.get("removePrivateAs"),
            "sendCommunity": obj.get("sendCommunity"),
            "state": obj.get("state"),
            "timeSinceLastOperChange": V1AlarmHistoryGet200ResponseHistoryInnerTime.from_dict(obj["timeSinceLastOperChange"]) if obj.get("timeSinceLastOperChange") is not None else None,
            "up": obj.get("up")
        })
        return _obj


