# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_interfaces_inner_ipv4_vrrp_group_group_members_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupGroupMembersInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_interfaces_inner_ipv4_vrrp_group_tracked_interfaces_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupTrackedInterfacesInner
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroup(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroup
    """ # noqa: E501
    accept_mode: Optional[StrictBool] = Field(default=None, alias="acceptMode")
    allow_inter_operability: Optional[StrictBool] = Field(default=None, alias="allowInterOperability")
    description: Optional[StrictStr] = None
    effective_priority: Optional[StrictInt] = Field(default=None, alias="effectivePriority")
    enabled: Optional[StrictBool] = None
    group_members: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupGroupMembersInner]] = Field(default=None, alias="groupMembers")
    id: Optional[StrictInt] = None
    name: Optional[StrictStr] = None
    preempt: Optional[StrictBool] = None
    priority: Optional[StrictInt] = None
    state: Optional[StrictStr] = None
    tracked_interfaces: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupTrackedInterfacesInner]] = Field(default=None, alias="trackedInterfaces")
    virtual_ip_address: Optional[StrictStr] = Field(default=None, alias="virtualIpAddress")
    virtual_mac_address: Optional[StrictStr] = Field(default=None, alias="virtualMacAddress")
    __properties: ClassVar[List[str]] = ["acceptMode", "allowInterOperability", "description", "effectivePriority", "enabled", "groupMembers", "id", "name", "preempt", "priority", "state", "trackedInterfaces", "virtualIpAddress", "virtualMacAddress"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroup 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 group_members (list)
        _items = []
        if self.group_members:
            for _item_group_members in self.group_members:
                if _item_group_members:
                    _items.append(_item_group_members.to_dict())
            _dict['groupMembers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in tracked_interfaces (list)
        _items = []
        if self.tracked_interfaces:
            for _item_tracked_interfaces in self.tracked_interfaces:
                if _item_tracked_interfaces:
                    _items.append(_item_tracked_interfaces.to_dict())
            _dict['trackedInterfaces'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "acceptMode": obj.get("acceptMode"),
            "allowInterOperability": obj.get("allowInterOperability"),
            "description": obj.get("description"),
            "effectivePriority": obj.get("effectivePriority"),
            "enabled": obj.get("enabled"),
            "groupMembers": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupGroupMembersInner.from_dict(_item) for _item in obj["groupMembers"]] if obj.get("groupMembers") is not None else None,
            "id": obj.get("id"),
            "name": obj.get("name"),
            "preempt": obj.get("preempt"),
            "priority": obj.get("priority"),
            "state": obj.get("state"),
            "trackedInterfaces": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerInterfacesInnerIpv4VrrpGroupTrackedInterfacesInner.from_dict(_item) for _item in obj["trackedInterfaces"]] if obj.get("trackedInterfaces") is not None else None,
            "virtualIpAddress": obj.get("virtualIpAddress"),
            "virtualMacAddress": obj.get("virtualMacAddress")
        })
        return _obj


