# 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 graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_location import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerLocation
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_route_tag_entry import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTagEntry
from graphiant_sdk.models.v1_global_config_site_post_request_ipfix_exporter_ops_v2_value import V1GlobalConfigSitePostRequestIpfixExporterOpsV2Value
from typing import Optional, Set
from typing_extensions import Self

class V1SitesPostRequestSite(BaseModel):
    """
    V1SitesPostRequestSite
    """ # noqa: E501
    global_prefix_set_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="globalPrefixSetOps")
    ipfix_exporter_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="ipfixExporterOps")
    ipfix_exporter_ops_v2: Optional[Dict[str, V1GlobalConfigSitePostRequestIpfixExporterOpsV2Value]] = Field(default=None, alias="ipfixExporterOpsV2")
    location: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerLocation] = None
    name: Optional[StrictStr] = None
    notes: Optional[StrictStr] = None
    prefix_set_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="prefixSetOps")
    route_tag: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTagEntry] = Field(default=None, alias="routeTag")
    routing_policy_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="routingPolicyOps")
    snmp_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="snmpOps")
    syslog_server_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="syslogServerOps")
    syslog_server_ops_v2: Optional[Dict[str, V1GlobalConfigSitePostRequestIpfixExporterOpsV2Value]] = Field(default=None, alias="syslogServerOpsV2")
    traffic_policy_ops: Optional[Dict[str, StrictStr]] = Field(default=None, alias="trafficPolicyOps")
    __properties: ClassVar[List[str]] = ["globalPrefixSetOps", "ipfixExporterOps", "ipfixExporterOpsV2", "location", "name", "notes", "prefixSetOps", "routeTag", "routingPolicyOps", "snmpOps", "syslogServerOps", "syslogServerOpsV2", "trafficPolicyOps"]

    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 V1SitesPostRequestSite 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 ipfix_exporter_ops_v2 (dict)
        _field_dict = {}
        if self.ipfix_exporter_ops_v2:
            for _key_ipfix_exporter_ops_v2 in self.ipfix_exporter_ops_v2:
                if self.ipfix_exporter_ops_v2[_key_ipfix_exporter_ops_v2]:
                    _field_dict[_key_ipfix_exporter_ops_v2] = self.ipfix_exporter_ops_v2[_key_ipfix_exporter_ops_v2].to_dict()
            _dict['ipfixExporterOpsV2'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of location
        if self.location:
            _dict['location'] = self.location.to_dict()
        # override the default output from pydantic by calling `to_dict()` of route_tag
        if self.route_tag:
            _dict['routeTag'] = self.route_tag.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each value in syslog_server_ops_v2 (dict)
        _field_dict = {}
        if self.syslog_server_ops_v2:
            for _key_syslog_server_ops_v2 in self.syslog_server_ops_v2:
                if self.syslog_server_ops_v2[_key_syslog_server_ops_v2]:
                    _field_dict[_key_syslog_server_ops_v2] = self.syslog_server_ops_v2[_key_syslog_server_ops_v2].to_dict()
            _dict['syslogServerOpsV2'] = _field_dict
        return _dict

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

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

        _obj = cls.model_validate({
            "globalPrefixSetOps": obj.get("globalPrefixSetOps"),
            "ipfixExporterOps": obj.get("ipfixExporterOps"),
            "ipfixExporterOpsV2": dict(
                (_k, V1GlobalConfigSitePostRequestIpfixExporterOpsV2Value.from_dict(_v))
                for _k, _v in obj["ipfixExporterOpsV2"].items()
            )
            if obj.get("ipfixExporterOpsV2") is not None
            else None,
            "location": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerLocation.from_dict(obj["location"]) if obj.get("location") is not None else None,
            "name": obj.get("name"),
            "notes": obj.get("notes"),
            "prefixSetOps": obj.get("prefixSetOps"),
            "routeTag": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTagEntry.from_dict(obj["routeTag"]) if obj.get("routeTag") is not None else None,
            "routingPolicyOps": obj.get("routingPolicyOps"),
            "snmpOps": obj.get("snmpOps"),
            "syslogServerOps": obj.get("syslogServerOps"),
            "syslogServerOpsV2": dict(
                (_k, V1GlobalConfigSitePostRequestIpfixExporterOpsV2Value.from_dict(_v))
                for _k, _v in obj["syslogServerOpsV2"].items()
            )
            if obj.get("syslogServerOpsV2") is not None
            else None,
            "trafficPolicyOps": obj.get("trafficPolicyOps")
        })
        return _obj


