# 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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from thousandeyes_sdk.endpoint_agents.models.endpoint_agent_log_item_type import EndpointAgentLogItemType
from thousandeyes_sdk.endpoint_agents.models.endpoint_online_offline_log_item import EndpointOnlineOfflineLogItem
from thousandeyes_sdk.endpoint_agents.models.endpoint_state_changes_log_item import EndpointStateChangesLogItem
from thousandeyes_sdk.endpoint_agents.models.endpoint_vpn_log_item import EndpointVpnLogItem
from thousandeyes_sdk.endpoint_agents.models.endpoint_wifi_log_item import EndpointWifiLogItem
from typing import Optional, Set
from typing_extensions import Self

class EndpointAgentLogItem(BaseModel):
    """
    EndpointAgentLogItem
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Unique ID of the log item.")
    agent_log_item_type: Optional[EndpointAgentLogItemType] = Field(default=None, alias="agentLogItemType")
    timestamp_ms: Optional[StrictInt] = Field(default=None, description="Time when the log item was recorded, in milliseconds since the Unix epoch.", alias="timestampMs")
    wifi_log_item: Optional[EndpointWifiLogItem] = Field(default=None, alias="wifiLogItem")
    vpn_log_item: Optional[EndpointVpnLogItem] = Field(default=None, alias="vpnLogItem")
    online_offline_log_item: Optional[EndpointOnlineOfflineLogItem] = Field(default=None, alias="onlineOfflineLogItem")
    state_changes_log_item: Optional[EndpointStateChangesLogItem] = Field(default=None, alias="stateChangesLogItem")
    __properties: ClassVar[List[str]] = ["id", "agentLogItemType", "timestampMs", "wifiLogItem", "vpnLogItem", "onlineOfflineLogItem", "stateChangesLogItem"]

    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 EndpointAgentLogItem 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.
        """
        excluded_fields: Set[str] = set([
            "id",
            "timestamp_ms",
        ])

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "agentLogItemType": obj.get("agentLogItemType"),
            "timestampMs": obj.get("timestampMs"),
            "wifiLogItem": EndpointWifiLogItem.from_dict(obj["wifiLogItem"]) if obj.get("wifiLogItem") is not None else None,
            "vpnLogItem": EndpointVpnLogItem.from_dict(obj["vpnLogItem"]) if obj.get("vpnLogItem") is not None else None,
            "onlineOfflineLogItem": EndpointOnlineOfflineLogItem.from_dict(obj["onlineOfflineLogItem"]) if obj.get("onlineOfflineLogItem") is not None else None,
            "stateChangesLogItem": EndpointStateChangesLogItem.from_dict(obj["stateChangesLogItem"]) if obj.get("stateChangesLogItem") is not None else None
        })
        return _obj


