# 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 typing_extensions import Annotated
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_community import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchCommunity
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_prefix_set import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchPrefixSet
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_protocol_route_type import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchProtocolRouteType
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_route_tag import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTag
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_source_interface import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_source_protocol import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceProtocol
from graphiant_sdk.models.v1_global_config_patch_request_routing_policies_value_policy_statements_value_statement_matches_value_match_stale import V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchStale
from typing import Optional, Set
from typing_extensions import Self

class V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatch(BaseModel):
    """
    V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatch
    """ # noqa: E501
    community: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchCommunity] = None
    prefix_set: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchPrefixSet] = Field(default=None, alias="prefixSet")
    protocol_route_type: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchProtocolRouteType] = Field(default=None, alias="protocolRouteType")
    route_tag: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTag] = Field(default=None, alias="routeTag")
    seq: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    source_interface: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface] = Field(default=None, alias="sourceInterface")
    source_protocol: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceProtocol] = Field(default=None, alias="sourceProtocol")
    stale: Optional[V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchStale] = None
    __properties: ClassVar[List[str]] = ["community", "prefixSet", "protocolRouteType", "routeTag", "seq", "sourceInterface", "sourceProtocol", "stale"]

    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 V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatch 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 community
        if self.community:
            _dict['community'] = self.community.to_dict()
        # override the default output from pydantic by calling `to_dict()` of prefix_set
        if self.prefix_set:
            _dict['prefixSet'] = self.prefix_set.to_dict()
        # override the default output from pydantic by calling `to_dict()` of protocol_route_type
        if self.protocol_route_type:
            _dict['protocolRouteType'] = self.protocol_route_type.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 source_interface
        if self.source_interface:
            _dict['sourceInterface'] = self.source_interface.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source_protocol
        if self.source_protocol:
            _dict['sourceProtocol'] = self.source_protocol.to_dict()
        # override the default output from pydantic by calling `to_dict()` of stale
        if self.stale:
            _dict['stale'] = self.stale.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "community": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchCommunity.from_dict(obj["community"]) if obj.get("community") is not None else None,
            "prefixSet": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchPrefixSet.from_dict(obj["prefixSet"]) if obj.get("prefixSet") is not None else None,
            "protocolRouteType": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchProtocolRouteType.from_dict(obj["protocolRouteType"]) if obj.get("protocolRouteType") is not None else None,
            "routeTag": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchRouteTag.from_dict(obj["routeTag"]) if obj.get("routeTag") is not None else None,
            "seq": obj.get("seq"),
            "sourceInterface": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceInterface.from_dict(obj["sourceInterface"]) if obj.get("sourceInterface") is not None else None,
            "sourceProtocol": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchSourceProtocol.from_dict(obj["sourceProtocol"]) if obj.get("sourceProtocol") is not None else None,
            "stale": V1GlobalConfigPatchRequestRoutingPoliciesValuePolicyStatementsValueStatementMatchesValueMatchStale.from_dict(obj["stale"]) if obj.get("stale") is not None else None
        })
        return _obj


