# 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_dns_cloudflare_servers_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_dns_dynamic_servers_v2 import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsDynamicServersV2
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_dns_static_servers_v2 import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsStaticServersV2
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDns(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDns
    """ # noqa: E501
    cloudflare_servers: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner]] = Field(default=None, alias="cloudflareServers")
    dynamic_servers: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner]] = Field(default=None, alias="dynamicServers")
    dynamic_servers_v2: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsDynamicServersV2] = Field(default=None, alias="dynamicServersV2")
    mode: Optional[StrictStr] = None
    static_servers: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner]] = Field(default=None, alias="staticServers")
    static_servers_v2: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsStaticServersV2] = Field(default=None, alias="staticServersV2")
    __properties: ClassVar[List[str]] = ["cloudflareServers", "dynamicServers", "dynamicServersV2", "mode", "staticServers", "staticServersV2"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDns 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 cloudflare_servers (list)
        _items = []
        if self.cloudflare_servers:
            for _item_cloudflare_servers in self.cloudflare_servers:
                if _item_cloudflare_servers:
                    _items.append(_item_cloudflare_servers.to_dict())
            _dict['cloudflareServers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in dynamic_servers (list)
        _items = []
        if self.dynamic_servers:
            for _item_dynamic_servers in self.dynamic_servers:
                if _item_dynamic_servers:
                    _items.append(_item_dynamic_servers.to_dict())
            _dict['dynamicServers'] = _items
        # override the default output from pydantic by calling `to_dict()` of dynamic_servers_v2
        if self.dynamic_servers_v2:
            _dict['dynamicServersV2'] = self.dynamic_servers_v2.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in static_servers (list)
        _items = []
        if self.static_servers:
            for _item_static_servers in self.static_servers:
                if _item_static_servers:
                    _items.append(_item_static_servers.to_dict())
            _dict['staticServers'] = _items
        # override the default output from pydantic by calling `to_dict()` of static_servers_v2
        if self.static_servers_v2:
            _dict['staticServersV2'] = self.static_servers_v2.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "cloudflareServers": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner.from_dict(_item) for _item in obj["cloudflareServers"]] if obj.get("cloudflareServers") is not None else None,
            "dynamicServers": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner.from_dict(_item) for _item in obj["dynamicServers"]] if obj.get("dynamicServers") is not None else None,
            "dynamicServersV2": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsDynamicServersV2.from_dict(obj["dynamicServersV2"]) if obj.get("dynamicServersV2") is not None else None,
            "mode": obj.get("mode"),
            "staticServers": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsCloudflareServersInner.from_dict(_item) for _item in obj["staticServers"]] if obj.get("staticServers") is not None else None,
            "staticServersV2": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerDnsStaticServersV2.from_dict(obj["staticServersV2"]) if obj.get("staticServersV2") is not None else None
        })
        return _obj


