# 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 typing_extensions import Annotated
from graphiant_sdk.models.v1_devices_device_id_config_put_request_core_core_vrf_bgp_neighbors_value_neighbor_allow_as_in import V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborAllowAsIn
from graphiant_sdk.models.v1_devices_device_id_config_put_request_core_core_vrf_bgp_neighbors_value_neighbor_bfd import V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborBfd
from graphiant_sdk.models.v1_devices_device_id_config_put_request_core_core_vrf_bgp_neighbors_value_neighbor_ebgp_multihop_ttl import V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborEbgpMultihopTtl
from graphiant_sdk.models.v1_devices_device_id_config_put_request_core_core_vrf_bgp_neighbors_value_neighbor_hold_timer_value import V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborHoldTimerValue
from graphiant_sdk.models.v1_devices_device_id_config_put_request_core_core_vrf_bgp_neighbors_value_neighbor_max_prefix_value import V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborMaxPrefixValue
from graphiant_sdk.models.v1_gateways_put_request_details_ipsec_gateway_routing_bgp_address_families_value import V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpAddressFamiliesValue
from graphiant_sdk.models.v1_gateways_put_request_details_ipsec_gateway_routing_bgp_md5_password import V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpMd5Password
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_source_interface import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface
from typing import Optional, Set
from typing_extensions import Self

class V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighbor(BaseModel):
    """
    V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighbor
    """ # noqa: E501
    address_families: Optional[Dict[str, V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpAddressFamiliesValue]] = Field(default=None, alias="addressFamilies")
    allow_as_in: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborAllowAsIn] = Field(default=None, alias="allowAsIn")
    as_override: Optional[StrictBool] = Field(default=None, alias="asOverride")
    bfd: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborBfd] = None
    default_originate: Optional[StrictStr] = Field(default=None, alias="defaultOriginate")
    ebgp_multihop_ttl: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborEbgpMultihopTtl] = Field(default=None, alias="ebgpMultihopTtl")
    enabled: Optional[StrictBool] = None
    hold_timer: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="holdTimer")
    hold_timer_value: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborHoldTimerValue] = Field(default=None, alias="holdTimerValue")
    keepalive_timer: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="keepaliveTimer")
    keepalive_timer_value: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborHoldTimerValue] = Field(default=None, alias="keepaliveTimerValue")
    local_address: Optional[StrictStr] = Field(default=None, alias="localAddress")
    local_interface: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface] = Field(default=None, alias="localInterface")
    max_prefix_value: Optional[V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborMaxPrefixValue] = Field(default=None, alias="maxPrefixValue")
    md5_password: Optional[V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpMd5Password] = Field(default=None, alias="md5Password")
    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")
    __properties: ClassVar[List[str]] = ["addressFamilies", "allowAsIn", "asOverride", "bfd", "defaultOriginate", "ebgpMultihopTtl", "enabled", "holdTimer", "holdTimerValue", "keepaliveTimer", "keepaliveTimerValue", "localAddress", "localInterface", "maxPrefixValue", "md5Password", "peerAsn", "remoteAddress", "removePrivateAs", "sendCommunity"]

    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 V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighbor 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 value in address_families (dict)
        _field_dict = {}
        if self.address_families:
            for _key_address_families in self.address_families:
                if self.address_families[_key_address_families]:
                    _field_dict[_key_address_families] = self.address_families[_key_address_families].to_dict()
            _dict['addressFamilies'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of allow_as_in
        if self.allow_as_in:
            _dict['allowAsIn'] = self.allow_as_in.to_dict()
        # 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 ebgp_multihop_ttl
        if self.ebgp_multihop_ttl:
            _dict['ebgpMultihopTtl'] = self.ebgp_multihop_ttl.to_dict()
        # override the default output from pydantic by calling `to_dict()` of hold_timer_value
        if self.hold_timer_value:
            _dict['holdTimerValue'] = self.hold_timer_value.to_dict()
        # override the default output from pydantic by calling `to_dict()` of keepalive_timer_value
        if self.keepalive_timer_value:
            _dict['keepaliveTimerValue'] = self.keepalive_timer_value.to_dict()
        # override the default output from pydantic by calling `to_dict()` of local_interface
        if self.local_interface:
            _dict['localInterface'] = self.local_interface.to_dict()
        # override the default output from pydantic by calling `to_dict()` of max_prefix_value
        if self.max_prefix_value:
            _dict['maxPrefixValue'] = self.max_prefix_value.to_dict()
        # override the default output from pydantic by calling `to_dict()` of md5_password
        if self.md5_password:
            _dict['md5Password'] = self.md5_password.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "addressFamilies": dict(
                (_k, V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpAddressFamiliesValue.from_dict(_v))
                for _k, _v in obj["addressFamilies"].items()
            )
            if obj.get("addressFamilies") is not None
            else None,
            "allowAsIn": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborAllowAsIn.from_dict(obj["allowAsIn"]) if obj.get("allowAsIn") is not None else None,
            "asOverride": obj.get("asOverride"),
            "bfd": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborBfd.from_dict(obj["bfd"]) if obj.get("bfd") is not None else None,
            "defaultOriginate": obj.get("defaultOriginate"),
            "ebgpMultihopTtl": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborEbgpMultihopTtl.from_dict(obj["ebgpMultihopTtl"]) if obj.get("ebgpMultihopTtl") is not None else None,
            "enabled": obj.get("enabled"),
            "holdTimer": obj.get("holdTimer"),
            "holdTimerValue": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborHoldTimerValue.from_dict(obj["holdTimerValue"]) if obj.get("holdTimerValue") is not None else None,
            "keepaliveTimer": obj.get("keepaliveTimer"),
            "keepaliveTimerValue": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborHoldTimerValue.from_dict(obj["keepaliveTimerValue"]) if obj.get("keepaliveTimerValue") is not None else None,
            "localAddress": obj.get("localAddress"),
            "localInterface": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface.from_dict(obj["localInterface"]) if obj.get("localInterface") is not None else None,
            "maxPrefixValue": V1DevicesDeviceIdConfigPutRequestCoreCoreVrfBgpNeighborsValueNeighborMaxPrefixValue.from_dict(obj["maxPrefixValue"]) if obj.get("maxPrefixValue") is not None else None,
            "md5Password": V1GatewaysPutRequestDetailsIpsecGatewayRoutingBgpMd5Password.from_dict(obj["md5Password"]) if obj.get("md5Password") is not None else None,
            "peerAsn": obj.get("peerAsn"),
            "remoteAddress": obj.get("remoteAddress"),
            "removePrivateAs": obj.get("removePrivateAs"),
            "sendCommunity": obj.get("sendCommunity")
        })
        return _obj


