# 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_aggregations_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpAggregationsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_multipath import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpMultipath
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_neighbors_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_bgp_redistributions import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpRedistributions
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_core_logical_interfaces_v2_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerCoreLogicalInterfacesV2Inner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_profile import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerProfile
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_circuits_inner_static_routes_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInner(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInner
    """ # noqa: E501
    bgp_aggregations: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpAggregationsInner]] = Field(default=None, alias="bgpAggregations")
    bgp_multipath: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpMultipath] = Field(default=None, alias="bgpMultipath")
    bgp_neighbors: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner]] = Field(default=None, alias="bgpNeighbors")
    bgp_redistributions: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpRedistributions] = Field(default=None, alias="bgpRedistributions")
    carrier: Optional[StrictStr] = None
    circuit_type: Optional[StrictStr] = Field(default=None, alias="circuitType")
    connection_type: Optional[StrictStr] = Field(default=None, alias="connectionType")
    core_logical_interfaces_v2: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerCoreLogicalInterfacesV2Inner]] = Field(default=None, alias="coreLogicalInterfacesV2")
    description: Optional[StrictStr] = None
    dia_enabled: Optional[StrictBool] = Field(default=None, alias="diaEnabled")
    dia_snmp_index: Optional[StrictInt] = Field(default=None, alias="diaSnmpIndex")
    discovered_public_ip: Optional[StrictStr] = Field(default=None, alias="discoveredPublicIp")
    drop_mechanism: Optional[StrictStr] = Field(default=None, alias="dropMechanism")
    id: Optional[StrictInt] = None
    interface_name: Optional[StrictStr] = Field(default=None, alias="interfaceName")
    label: Optional[StrictStr] = None
    last_resort: Optional[StrictBool] = Field(default=None, alias="lastResort")
    link_down_speed_mbps: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="linkDownSpeedMbps")
    link_up_speed_mbps: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="linkUpSpeedMbps")
    loopback: Optional[StrictBool] = None
    name: Optional[StrictStr] = None
    pat_addresses: Optional[List[StrictStr]] = Field(default=None, alias="patAddresses")
    private_ip: Optional[StrictStr] = Field(default=None, alias="privateIp")
    profile: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerProfile] = None
    qos_profile: Optional[StrictStr] = Field(default=None, alias="qosProfile")
    qos_profile_type: Optional[StrictStr] = Field(default=None, alias="qosProfileType")
    snmp_index: Optional[StrictInt] = Field(default=None, alias="snmpIndex")
    static_routes: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner]] = Field(default=None, alias="staticRoutes")
    wan_interface_v2: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerCoreLogicalInterfacesV2Inner] = Field(default=None, alias="wanInterfaceV2")
    __properties: ClassVar[List[str]] = ["bgpAggregations", "bgpMultipath", "bgpNeighbors", "bgpRedistributions", "carrier", "circuitType", "connectionType", "coreLogicalInterfacesV2", "description", "diaEnabled", "diaSnmpIndex", "discoveredPublicIp", "dropMechanism", "id", "interfaceName", "label", "lastResort", "linkDownSpeedMbps", "linkUpSpeedMbps", "loopback", "name", "patAddresses", "privateIp", "profile", "qosProfile", "qosProfileType", "snmpIndex", "staticRoutes", "wanInterfaceV2"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInner 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 bgp_aggregations (list)
        _items = []
        if self.bgp_aggregations:
            for _item_bgp_aggregations in self.bgp_aggregations:
                if _item_bgp_aggregations:
                    _items.append(_item_bgp_aggregations.to_dict())
            _dict['bgpAggregations'] = _items
        # override the default output from pydantic by calling `to_dict()` of bgp_multipath
        if self.bgp_multipath:
            _dict['bgpMultipath'] = self.bgp_multipath.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in bgp_neighbors (list)
        _items = []
        if self.bgp_neighbors:
            for _item_bgp_neighbors in self.bgp_neighbors:
                if _item_bgp_neighbors:
                    _items.append(_item_bgp_neighbors.to_dict())
            _dict['bgpNeighbors'] = _items
        # override the default output from pydantic by calling `to_dict()` of bgp_redistributions
        if self.bgp_redistributions:
            _dict['bgpRedistributions'] = self.bgp_redistributions.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in core_logical_interfaces_v2 (list)
        _items = []
        if self.core_logical_interfaces_v2:
            for _item_core_logical_interfaces_v2 in self.core_logical_interfaces_v2:
                if _item_core_logical_interfaces_v2:
                    _items.append(_item_core_logical_interfaces_v2.to_dict())
            _dict['coreLogicalInterfacesV2'] = _items
        # override the default output from pydantic by calling `to_dict()` of profile
        if self.profile:
            _dict['profile'] = self.profile.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in static_routes (list)
        _items = []
        if self.static_routes:
            for _item_static_routes in self.static_routes:
                if _item_static_routes:
                    _items.append(_item_static_routes.to_dict())
            _dict['staticRoutes'] = _items
        # override the default output from pydantic by calling `to_dict()` of wan_interface_v2
        if self.wan_interface_v2:
            _dict['wanInterfaceV2'] = self.wan_interface_v2.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "bgpAggregations": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpAggregationsInner.from_dict(_item) for _item in obj["bgpAggregations"]] if obj.get("bgpAggregations") is not None else None,
            "bgpMultipath": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpMultipath.from_dict(obj["bgpMultipath"]) if obj.get("bgpMultipath") is not None else None,
            "bgpNeighbors": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpNeighborsInner.from_dict(_item) for _item in obj["bgpNeighbors"]] if obj.get("bgpNeighbors") is not None else None,
            "bgpRedistributions": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerBgpRedistributions.from_dict(obj["bgpRedistributions"]) if obj.get("bgpRedistributions") is not None else None,
            "carrier": obj.get("carrier"),
            "circuitType": obj.get("circuitType"),
            "connectionType": obj.get("connectionType"),
            "coreLogicalInterfacesV2": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerCoreLogicalInterfacesV2Inner.from_dict(_item) for _item in obj["coreLogicalInterfacesV2"]] if obj.get("coreLogicalInterfacesV2") is not None else None,
            "description": obj.get("description"),
            "diaEnabled": obj.get("diaEnabled"),
            "diaSnmpIndex": obj.get("diaSnmpIndex"),
            "discoveredPublicIp": obj.get("discoveredPublicIp"),
            "dropMechanism": obj.get("dropMechanism"),
            "id": obj.get("id"),
            "interfaceName": obj.get("interfaceName"),
            "label": obj.get("label"),
            "lastResort": obj.get("lastResort"),
            "linkDownSpeedMbps": obj.get("linkDownSpeedMbps"),
            "linkUpSpeedMbps": obj.get("linkUpSpeedMbps"),
            "loopback": obj.get("loopback"),
            "name": obj.get("name"),
            "patAddresses": obj.get("patAddresses"),
            "privateIp": obj.get("privateIp"),
            "profile": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerProfile.from_dict(obj["profile"]) if obj.get("profile") is not None else None,
            "qosProfile": obj.get("qosProfile"),
            "qosProfileType": obj.get("qosProfileType"),
            "snmpIndex": obj.get("snmpIndex"),
            "staticRoutes": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner.from_dict(_item) for _item in obj["staticRoutes"]] if obj.get("staticRoutes") is not None else None,
            "wanInterfaceV2": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerCoreLogicalInterfacesV2Inner.from_dict(obj["wanInterfaceV2"]) if obj.get("wanInterfaceV2") is not None else None
        })
        return _obj


