# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from graphiant_sdk.models.v1_global_config_patch_request_traffic_policies_dpi_applications_value_application_destination_networks import V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationNetworks
from graphiant_sdk.models.v1_global_config_patch_request_traffic_policies_dpi_applications_value_application_destination_ports import V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationPorts
from typing import Optional, Set
from typing_extensions import Self

class V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplication(BaseModel):
    """
    V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplication
    """ # noqa: E501
    description: Optional[StrictStr] = None
    destination_network: Optional[StrictStr] = Field(default=None, alias="destinationNetwork")
    destination_network_list: Optional[StrictStr] = Field(default=None, alias="destinationNetworkList")
    destination_networks: Optional[V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationNetworks] = Field(default=None, alias="destinationNetworks")
    destination_port: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="destinationPort")
    destination_port_list: Optional[StrictStr] = Field(default=None, alias="destinationPortList")
    destination_ports: Optional[V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationPorts] = Field(default=None, alias="destinationPorts")
    icmp_type: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="icmpType")
    ip_protocol: Optional[StrictStr] = Field(default=None, alias="ipProtocol")
    name: Optional[StrictStr] = None
    source_network: Optional[StrictStr] = Field(default=None, alias="sourceNetwork")
    source_network_list: Optional[StrictStr] = Field(default=None, alias="sourceNetworkList")
    source_networks: Optional[V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationNetworks] = Field(default=None, alias="sourceNetworks")
    source_port: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="sourcePort")
    source_port_list: Optional[StrictStr] = Field(default=None, alias="sourcePortList")
    source_ports: Optional[V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationPorts] = Field(default=None, alias="sourcePorts")
    __properties: ClassVar[List[str]] = ["description", "destinationNetwork", "destinationNetworkList", "destinationNetworks", "destinationPort", "destinationPortList", "destinationPorts", "icmpType", "ipProtocol", "name", "sourceNetwork", "sourceNetworkList", "sourceNetworks", "sourcePort", "sourcePortList", "sourcePorts"]

    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 V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplication 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 destination_networks
        if self.destination_networks:
            _dict['destinationNetworks'] = self.destination_networks.to_dict()
        # override the default output from pydantic by calling `to_dict()` of destination_ports
        if self.destination_ports:
            _dict['destinationPorts'] = self.destination_ports.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source_networks
        if self.source_networks:
            _dict['sourceNetworks'] = self.source_networks.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source_ports
        if self.source_ports:
            _dict['sourcePorts'] = self.source_ports.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "description": obj.get("description"),
            "destinationNetwork": obj.get("destinationNetwork"),
            "destinationNetworkList": obj.get("destinationNetworkList"),
            "destinationNetworks": V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationNetworks.from_dict(obj["destinationNetworks"]) if obj.get("destinationNetworks") is not None else None,
            "destinationPort": obj.get("destinationPort"),
            "destinationPortList": obj.get("destinationPortList"),
            "destinationPorts": V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationPorts.from_dict(obj["destinationPorts"]) if obj.get("destinationPorts") is not None else None,
            "icmpType": obj.get("icmpType"),
            "ipProtocol": obj.get("ipProtocol"),
            "name": obj.get("name"),
            "sourceNetwork": obj.get("sourceNetwork"),
            "sourceNetworkList": obj.get("sourceNetworkList"),
            "sourceNetworks": V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationNetworks.from_dict(obj["sourceNetworks"]) if obj.get("sourceNetworks") is not None else None,
            "sourcePort": obj.get("sourcePort"),
            "sourcePortList": obj.get("sourcePortList"),
            "sourcePorts": V1GlobalConfigPatchRequestTrafficPoliciesDpiApplicationsValueApplicationDestinationPorts.from_dict(obj["sourcePorts"]) if obj.get("sourcePorts") is not None else None
        })
        return _obj


