# 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
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_dpi_applications_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyDpiApplicationsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_network_lists_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyNetworkListsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_port_lists_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyPortListsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_security_rulesets_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicySecurityRulesetsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_traffic_rulesets_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyTrafficRulesetsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_zone_firewalls_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZoneFirewallsInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_traffic_policy_zone_pairs_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZonePairsInner
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicy(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicy
    """ # noqa: E501
    dpi_applications: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyDpiApplicationsInner]] = Field(default=None, alias="dpiApplications")
    network_lists: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyNetworkListsInner]] = Field(default=None, alias="networkLists")
    port_lists: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyPortListsInner]] = Field(default=None, alias="portLists")
    security_rulesets: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicySecurityRulesetsInner]] = Field(default=None, alias="securityRulesets")
    traffic_rulesets: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyTrafficRulesetsInner]] = Field(default=None, alias="trafficRulesets")
    zone_firewalls: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZoneFirewallsInner]] = Field(default=None, alias="zoneFirewalls")
    zone_pairs: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZonePairsInner]] = Field(default=None, alias="zonePairs")
    __properties: ClassVar[List[str]] = ["dpiApplications", "networkLists", "portLists", "securityRulesets", "trafficRulesets", "zoneFirewalls", "zonePairs"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicy 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 dpi_applications (list)
        _items = []
        if self.dpi_applications:
            for _item_dpi_applications in self.dpi_applications:
                if _item_dpi_applications:
                    _items.append(_item_dpi_applications.to_dict())
            _dict['dpiApplications'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in network_lists (list)
        _items = []
        if self.network_lists:
            for _item_network_lists in self.network_lists:
                if _item_network_lists:
                    _items.append(_item_network_lists.to_dict())
            _dict['networkLists'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in port_lists (list)
        _items = []
        if self.port_lists:
            for _item_port_lists in self.port_lists:
                if _item_port_lists:
                    _items.append(_item_port_lists.to_dict())
            _dict['portLists'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in security_rulesets (list)
        _items = []
        if self.security_rulesets:
            for _item_security_rulesets in self.security_rulesets:
                if _item_security_rulesets:
                    _items.append(_item_security_rulesets.to_dict())
            _dict['securityRulesets'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in traffic_rulesets (list)
        _items = []
        if self.traffic_rulesets:
            for _item_traffic_rulesets in self.traffic_rulesets:
                if _item_traffic_rulesets:
                    _items.append(_item_traffic_rulesets.to_dict())
            _dict['trafficRulesets'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in zone_firewalls (list)
        _items = []
        if self.zone_firewalls:
            for _item_zone_firewalls in self.zone_firewalls:
                if _item_zone_firewalls:
                    _items.append(_item_zone_firewalls.to_dict())
            _dict['zoneFirewalls'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in zone_pairs (list)
        _items = []
        if self.zone_pairs:
            for _item_zone_pairs in self.zone_pairs:
                if _item_zone_pairs:
                    _items.append(_item_zone_pairs.to_dict())
            _dict['zonePairs'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "dpiApplications": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyDpiApplicationsInner.from_dict(_item) for _item in obj["dpiApplications"]] if obj.get("dpiApplications") is not None else None,
            "networkLists": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyNetworkListsInner.from_dict(_item) for _item in obj["networkLists"]] if obj.get("networkLists") is not None else None,
            "portLists": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyPortListsInner.from_dict(_item) for _item in obj["portLists"]] if obj.get("portLists") is not None else None,
            "securityRulesets": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicySecurityRulesetsInner.from_dict(_item) for _item in obj["securityRulesets"]] if obj.get("securityRulesets") is not None else None,
            "trafficRulesets": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyTrafficRulesetsInner.from_dict(_item) for _item in obj["trafficRulesets"]] if obj.get("trafficRulesets") is not None else None,
            "zoneFirewalls": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZoneFirewallsInner.from_dict(_item) for _item in obj["zoneFirewalls"]] if obj.get("zoneFirewalls") is not None else None,
            "zonePairs": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerTrafficPolicyZonePairsInner.from_dict(_item) for _item in obj["zonePairs"]] if obj.get("zonePairs") is not None else None
        })
        return _obj


