# 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_proxy_auth_type import EndpointProxyAuthType
from thousandeyes_sdk.endpoint_agents.models.endpoint_proxy_type import EndpointProxyType
from typing import Optional, Set
from typing_extensions import Self

class EndpointProxy(BaseModel):
    """
    EndpointProxy
    """ # noqa: E501
    proxy_id: Optional[StrictStr] = Field(default=None, description="Unique ID of the proxy setting.", alias="proxyId")
    name: Optional[StrictStr] = Field(default=None, description="Proxy setting name.")
    type: Optional[EndpointProxyType] = None
    host: Optional[StrictStr] = Field(default=None, description="Static proxy host name or IP address.")
    port: Optional[StrictInt] = Field(default=None, description="Static proxy port.")
    pac: Optional[StrictStr] = Field(default=None, description="PAC URL or PAC script location.")
    user_name: Optional[StrictStr] = Field(default=None, description="Proxy authentication user name.", alias="userName")
    bypass_list: Optional[StrictStr] = Field(default=None, description="Comma-separated proxy bypass list.", alias="bypassList")
    auth_type: Optional[EndpointProxyAuthType] = Field(default=None, alias="authType")
    agent_ids: Optional[List[StrictStr]] = Field(default=None, description="Endpoint Agent IDs assigned to the proxy setting.", alias="agentIds")
    test_ids: Optional[List[StrictStr]] = Field(default=None, description="Endpoint scheduled test IDs assigned to the proxy setting.", alias="testIds")
    __properties: ClassVar[List[str]] = ["proxyId", "name", "type", "host", "port", "pac", "userName", "bypassList", "authType", "agentIds", "testIds"]

    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 EndpointProxy 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([
            "proxy_id",
            "name",
            "host",
            "port",
            "pac",
            "user_name",
            "bypass_list",
        ])

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

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

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

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

        # set to None if bypass_list (nullable) is None
        # and model_fields_set contains the field
        if self.bypass_list is None and "bypass_list" in self.model_fields_set:
            _dict['bypassList'] = 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 test_ids (nullable) is None
        # and model_fields_set contains the field
        if self.test_ids is None and "test_ids" in self.model_fields_set:
            _dict['testIds'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "proxyId": obj.get("proxyId"),
            "name": obj.get("name"),
            "type": obj.get("type"),
            "host": obj.get("host"),
            "port": obj.get("port"),
            "pac": obj.get("pac"),
            "userName": obj.get("userName"),
            "bypassList": obj.get("bypassList"),
            "authType": obj.get("authType"),
            "agentIds": obj.get("agentIds"),
            "testIds": obj.get("testIds")
        })
        return _obj


