# 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 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_static_routes_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_ipfix_exporters_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerIpfixExportersInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_dhcp_subnets_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_ospfv2_process import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2Process
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_ospfv3_process import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv3Process
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_overlay_filters import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOverlayFilters
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_syslog_targets_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerSyslogTargetsInner
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInner(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInner
    """ # 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")
    description: Optional[StrictStr] = None
    dhcp_subnets: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner]] = Field(default=None, alias="dhcpSubnets")
    enterprise_id: Optional[StrictInt] = Field(default=None, alias="enterpriseId")
    function: Optional[StrictStr] = None
    id: Optional[StrictInt] = None
    ipfix_exporters: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerIpfixExportersInner]] = Field(default=None, alias="ipfixExporters")
    name: Optional[StrictStr] = None
    nat_ruleset: Optional[StrictStr] = Field(default=None, alias="natRuleset")
    networks: Optional[List[StrictStr]] = None
    ospfv2_process: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2Process] = Field(default=None, alias="ospfv2Process")
    ospfv3_process: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv3Process] = Field(default=None, alias="ospfv3Process")
    overlay_filters: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOverlayFilters] = Field(default=None, alias="overlayFilters")
    routable: Optional[StrictBool] = None
    route_distinguisher: Optional[StrictStr] = Field(default=None, alias="routeDistinguisher")
    static_routes: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner]] = Field(default=None, alias="staticRoutes")
    syslog_targets: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerSyslogTargetsInner]] = Field(default=None, alias="syslogTargets")
    traffic_ruleset: Optional[StrictStr] = Field(default=None, alias="trafficRuleset")
    __properties: ClassVar[List[str]] = ["bgpAggregations", "bgpMultipath", "bgpNeighbors", "bgpRedistributions", "description", "dhcpSubnets", "enterpriseId", "function", "id", "ipfixExporters", "name", "natRuleset", "networks", "ospfv2Process", "ospfv3Process", "overlayFilters", "routable", "routeDistinguisher", "staticRoutes", "syslogTargets", "trafficRuleset"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInner 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 dhcp_subnets (list)
        _items = []
        if self.dhcp_subnets:
            for _item_dhcp_subnets in self.dhcp_subnets:
                if _item_dhcp_subnets:
                    _items.append(_item_dhcp_subnets.to_dict())
            _dict['dhcpSubnets'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in ipfix_exporters (list)
        _items = []
        if self.ipfix_exporters:
            for _item_ipfix_exporters in self.ipfix_exporters:
                if _item_ipfix_exporters:
                    _items.append(_item_ipfix_exporters.to_dict())
            _dict['ipfixExporters'] = _items
        # override the default output from pydantic by calling `to_dict()` of ospfv2_process
        if self.ospfv2_process:
            _dict['ospfv2Process'] = self.ospfv2_process.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ospfv3_process
        if self.ospfv3_process:
            _dict['ospfv3Process'] = self.ospfv3_process.to_dict()
        # override the default output from pydantic by calling `to_dict()` of overlay_filters
        if self.overlay_filters:
            _dict['overlayFilters'] = self.overlay_filters.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 each item in syslog_targets (list)
        _items = []
        if self.syslog_targets:
            for _item_syslog_targets in self.syslog_targets:
                if _item_syslog_targets:
                    _items.append(_item_syslog_targets.to_dict())
            _dict['syslogTargets'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInner 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,
            "description": obj.get("description"),
            "dhcpSubnets": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner.from_dict(_item) for _item in obj["dhcpSubnets"]] if obj.get("dhcpSubnets") is not None else None,
            "enterpriseId": obj.get("enterpriseId"),
            "function": obj.get("function"),
            "id": obj.get("id"),
            "ipfixExporters": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerIpfixExportersInner.from_dict(_item) for _item in obj["ipfixExporters"]] if obj.get("ipfixExporters") is not None else None,
            "name": obj.get("name"),
            "natRuleset": obj.get("natRuleset"),
            "networks": obj.get("networks"),
            "ospfv2Process": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv2Process.from_dict(obj["ospfv2Process"]) if obj.get("ospfv2Process") is not None else None,
            "ospfv3Process": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOspfv3Process.from_dict(obj["ospfv3Process"]) if obj.get("ospfv3Process") is not None else None,
            "overlayFilters": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerOverlayFilters.from_dict(obj["overlayFilters"]) if obj.get("overlayFilters") is not None else None,
            "routable": obj.get("routable"),
            "routeDistinguisher": obj.get("routeDistinguisher"),
            "staticRoutes": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerCircuitsInnerStaticRoutesInner.from_dict(_item) for _item in obj["staticRoutes"]] if obj.get("staticRoutes") is not None else None,
            "syslogTargets": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerSyslogTargetsInner.from_dict(_item) for _item in obj["syslogTargets"]] if obj.get("syslogTargets") is not None else None,
            "trafficRuleset": obj.get("trafficRuleset")
        })
        return _obj


