# coding: utf-8

"""
    Endpoint Tests API

    Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. 

    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_tests.models.endpoint_monitoring_settings_type import EndpointMonitoringSettingsType
from typing import Optional, Set
from typing_extensions import Self

class EndpointMonitoringSettings(BaseModel):
    """
    EndpointMonitoringSettings
    """ # noqa: E501
    monitoring_settings_id: Optional[StrictStr] = Field(default=None, description="Unique ID of the monitoring settings.", alias="monitoringSettingsId")
    monitoring_settings_type: EndpointMonitoringSettingsType = Field(alias="monitoringSettingsType")
    agent_ids: Optional[List[StrictStr]] = Field(default=None, description="Endpoint Agent IDs selected by the monitoring settings.", alias="agentIds")
    tag_ids: Optional[List[StrictStr]] = Field(default=None, description="Endpoint Agent tag IDs selected by the monitoring settings.", alias="tagIds")
    label_ids: Optional[List[StrictStr]] = Field(default=None, description="Legacy Endpoint Agent label IDs selected by the monitoring settings.", alias="labelIds")
    __properties: ClassVar[List[str]] = ["monitoringSettingsId", "monitoringSettingsType", "agentIds", "tagIds", "labelIds"]

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

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if monitoring_settings_id (nullable) is None
        # and model_fields_set contains the field
        if self.monitoring_settings_id is None and "monitoring_settings_id" in self.model_fields_set:
            _dict['monitoringSettingsId'] = None

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "monitoringSettingsId": obj.get("monitoringSettingsId"),
            "monitoringSettingsType": obj.get("monitoringSettingsType"),
            "agentIds": obj.get("agentIds"),
            "tagIds": obj.get("tagIds"),
            "labelIds": obj.get("labelIds")
        })
        return _obj


