# coding: utf-8

"""
    Endpoint Agents API

    **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance.  Manage ThousandEyes Endpoint Agents using this API.   For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents).

    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 thousandeyes_sdk.endpoint_agents.models.address_profile import AddressProfile
from thousandeyes_sdk.endpoint_agents.models.endpoint_agent_ethernet_profile import EndpointAgentEthernetProfile
from thousandeyes_sdk.endpoint_agents.models.interface_hardware_type import InterfaceHardwareType
from thousandeyes_sdk.endpoint_agents.models.wireless_profile import WirelessProfile
from typing import Optional, Set
from typing_extensions import Self

class InterfaceProfile(BaseModel):
    """
    InterfaceProfile
    """ # noqa: E501
    interface_name: Optional[StrictStr] = Field(default=None, alias="interfaceName")
    address_profiles: Optional[List[AddressProfile]] = Field(default=None, alias="addressProfiles")
    hardware_type: Optional[InterfaceHardwareType] = Field(default=None, alias="hardwareType")
    ethernet_profile: Optional[EndpointAgentEthernetProfile] = Field(default=None, alias="ethernetProfile")
    wireless_profile: Optional[WirelessProfile] = Field(default=None, alias="wirelessProfile")
    __properties: ClassVar[List[str]] = ["interfaceName", "addressProfiles", "hardwareType", "ethernetProfile", "wirelessProfile"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
    )


    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 self.model_dump_json(by_alias=True, exclude_unset=True, exclude_none=True)

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of InterfaceProfile 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 address_profiles (list)
        _items = []
        if self.address_profiles:
            for _item in self.address_profiles:
                if _item:
                    _items.append(_item.to_dict())
            _dict['addressProfiles'] = _items
        # override the default output from pydantic by calling `to_dict()` of ethernet_profile
        if self.ethernet_profile:
            _dict['ethernetProfile'] = self.ethernet_profile.to_dict()
        # override the default output from pydantic by calling `to_dict()` of wireless_profile
        if self.wireless_profile:
            _dict['wirelessProfile'] = self.wireless_profile.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "interfaceName": obj.get("interfaceName"),
            "addressProfiles": [AddressProfile.from_dict(_item) for _item in obj["addressProfiles"]] if obj.get("addressProfiles") is not None else None,
            "hardwareType": obj.get("hardwareType"),
            "ethernetProfile": EndpointAgentEthernetProfile.from_dict(obj["ethernetProfile"]) if obj.get("ethernetProfile") is not None else None,
            "wirelessProfile": WirelessProfile.from_dict(obj["wirelessProfile"]) if obj.get("wirelessProfile") is not None else None
        })
        return _obj


