# 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.endpoint_wifi_log_item_type import EndpointWifiLogItemType
from thousandeyes_sdk.endpoint_agents.models.endpoint_wireless_connection_failure import EndpointWirelessConnectionFailure
from typing import Optional, Set
from typing_extensions import Self

class EndpointWifiLogItem(BaseModel):
    """
    EndpointWifiLogItem
    """ # noqa: E501
    log_item_type: Optional[EndpointWifiLogItemType] = Field(default=None, alias="logItemType")
    ssid: Optional[StrictStr] = Field(default=None, description="Wireless network SSID.")
    bssid: Optional[StrictStr] = Field(default=None, description="Wireless access point BSSID.")
    bssid_from: Optional[StrictStr] = Field(default=None, description="Previous wireless access point BSSID.", alias="bssidFrom")
    channel: Optional[StrictStr] = Field(default=None, description="Wireless channel.")
    channel_from: Optional[StrictStr] = Field(default=None, description="Previous wireless channel.", alias="channelFrom")
    physical_mode: Optional[StrictStr] = Field(default=None, description="Wireless physical mode.", alias="physicalMode")
    physical_mode_from: Optional[StrictStr] = Field(default=None, description="Previous wireless physical mode.", alias="physicalModeFrom")
    failure: Optional[EndpointWirelessConnectionFailure] = None
    __properties: ClassVar[List[str]] = ["logItemType", "ssid", "bssid", "bssidFrom", "channel", "channelFrom", "physicalMode", "physicalModeFrom", "failure"]

    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 EndpointWifiLogItem 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "ssid",
            "bssid",
            "bssid_from",
            "channel",
            "channel_from",
            "physical_mode",
            "physical_mode_from",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of failure
        if self.failure:
            _dict['failure'] = self.failure.to_dict()
        # set to None if ssid (nullable) is None
        # and model_fields_set contains the field
        if self.ssid is None and "ssid" in self.model_fields_set:
            _dict['ssid'] = None

        # set to None if bssid (nullable) is None
        # and model_fields_set contains the field
        if self.bssid is None and "bssid" in self.model_fields_set:
            _dict['bssid'] = None

        # set to None if bssid_from (nullable) is None
        # and model_fields_set contains the field
        if self.bssid_from is None and "bssid_from" in self.model_fields_set:
            _dict['bssidFrom'] = None

        # set to None if channel (nullable) is None
        # and model_fields_set contains the field
        if self.channel is None and "channel" in self.model_fields_set:
            _dict['channel'] = None

        # set to None if channel_from (nullable) is None
        # and model_fields_set contains the field
        if self.channel_from is None and "channel_from" in self.model_fields_set:
            _dict['channelFrom'] = None

        # set to None if physical_mode (nullable) is None
        # and model_fields_set contains the field
        if self.physical_mode is None and "physical_mode" in self.model_fields_set:
            _dict['physicalMode'] = None

        # set to None if physical_mode_from (nullable) is None
        # and model_fields_set contains the field
        if self.physical_mode_from is None and "physical_mode_from" in self.model_fields_set:
            _dict['physicalModeFrom'] = None

        # set to None if failure (nullable) is None
        # and model_fields_set contains the field
        if self.failure is None and "failure" in self.model_fields_set:
            _dict['failure'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "logItemType": obj.get("logItemType"),
            "ssid": obj.get("ssid"),
            "bssid": obj.get("bssid"),
            "bssidFrom": obj.get("bssidFrom"),
            "channel": obj.get("channel"),
            "channelFrom": obj.get("channelFrom"),
            "physicalMode": obj.get("physicalMode"),
            "physicalModeFrom": obj.get("physicalModeFrom"),
            "failure": EndpointWirelessConnectionFailure.from_dict(obj["failure"]) if obj.get("failure") is not None else None
        })
        return _obj


