# coding: utf-8

"""
    Agent Service

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from asteroid_odyssey.models.agents_profile_cookie import AgentsProfileCookie
from asteroid_odyssey.models.agents_profile_country_code import AgentsProfileCountryCode
from asteroid_odyssey.models.agents_profile_credential import AgentsProfileCredential
from asteroid_odyssey.models.agents_profile_credential_update import AgentsProfileCredentialUpdate
from asteroid_odyssey.models.agents_profile_custom_proxy_config_input import AgentsProfileCustomProxyConfigInput
from asteroid_odyssey.models.agents_profile_operating_system import AgentsProfileOperatingSystem
from asteroid_odyssey.models.agents_profile_proxy_mode import AgentsProfileProxyMode
from asteroid_odyssey.models.agents_profile_proxy_type import AgentsProfileProxyType
from typing import Optional, Set
from typing_extensions import Self

class AgentsProfileUpdateAgentProfileRequest(BaseModel):
    """
    Request to update an existing agent profile
    """ # noqa: E501
    name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, description="New name for the profile")
    description: Optional[Annotated[str, Field(strict=True, max_length=1000)]] = Field(default=None, description="New description for the profile")
    proxy_mode: Optional[AgentsProfileProxyMode] = Field(default=None, description="Proxy configuration mode", alias="proxyMode")
    proxy_cc: Optional[AgentsProfileCountryCode] = Field(default=None, description="Country code for proxy location (for managed proxy mode)", alias="proxyCC")
    proxy_type: Optional[AgentsProfileProxyType] = Field(default=None, description="Type of managed proxy to use (for managed proxy mode)", alias="proxyType")
    custom_proxy: Optional[AgentsProfileCustomProxyConfigInput] = Field(default=None, description="Custom proxy configuration (for custom proxy mode)", alias="customProxy")
    tailscale_auth_key: Optional[StrictStr] = Field(default=None, description="Tailscale auth key for VPN access (for tailscale proxy mode)", alias="tailscaleAuthKey")
    captcha_solver_active: Optional[StrictBool] = Field(default=None, description="Whether the captcha solver should be active (managed proxy only)", alias="captchaSolverActive")
    operating_system: Optional[AgentsProfileOperatingSystem] = Field(default=None, description="Operating system to emulate", alias="operatingSystem")
    extra_stealth: Optional[StrictBool] = Field(default=None, description="Whether to enable extra stealth mode", alias="extraStealth")
    cache_persistence: Optional[StrictBool] = Field(default=None, description="Whether to persist browser cache between sessions", alias="cachePersistence")
    adblock_active: Optional[StrictBool] = Field(default=None, description="Whether to enable ad blocking", alias="adblockActive")
    popup_blocker_active: Optional[StrictBool] = Field(default=None, description="Whether to enable popup blocking (requires adblock to be active)", alias="popupBlockerActive")
    force_popups_as_tabs_active: Optional[StrictBool] = Field(default=None, description="Whether to force popups to open as tabs", alias="forcePopupsAsTabsActive")
    media_blocker_active: Optional[StrictBool] = Field(default=None, description="Whether to enable media blocking (images, videos, etc.)", alias="mediaBlockerActive")
    pdf_viewer_active: Optional[StrictBool] = Field(default=None, description="Whether to enable the built-in PDF viewer (if disabled, PDFs are downloaded)", alias="pdfViewerActive")
    tracing_enabled: Optional[StrictBool] = Field(default=None, description="Whether browser tracing is enabled (admin only)", alias="tracingEnabled")
    credentials_to_add: Optional[List[AgentsProfileCredential]] = Field(default=None, description="Credentials to add to the profile", alias="credentialsToAdd")
    credentials_to_update: Optional[List[AgentsProfileCredentialUpdate]] = Field(default=None, description="Credentials to update by name (matched case-insensitively)", alias="credentialsToUpdate")
    credentials_to_delete: Optional[List[StrictStr]] = Field(default=None, description="IDs of credentials to remove from the profile", alias="credentialsToDelete")
    cookies_to_add: Optional[List[AgentsProfileCookie]] = Field(default=None, description="Cookies to add to the profile", alias="cookiesToAdd")
    cookies_to_delete: Optional[List[StrictStr]] = Field(default=None, description="IDs of cookies to remove from the profile", alias="cookiesToDelete")
    __properties: ClassVar[List[str]] = ["name", "description", "proxyMode", "proxyCC", "proxyType", "customProxy", "tailscaleAuthKey", "captchaSolverActive", "operatingSystem", "extraStealth", "cachePersistence", "adblockActive", "popupBlockerActive", "forcePopupsAsTabsActive", "mediaBlockerActive", "pdfViewerActive", "tracingEnabled", "credentialsToAdd", "credentialsToUpdate", "credentialsToDelete", "cookiesToAdd", "cookiesToDelete"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    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 json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of AgentsProfileUpdateAgentProfileRequest 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 custom_proxy
        if self.custom_proxy:
            _dict['customProxy'] = self.custom_proxy.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in credentials_to_add (list)
        _items = []
        if self.credentials_to_add:
            for _item_credentials_to_add in self.credentials_to_add:
                if _item_credentials_to_add:
                    _items.append(_item_credentials_to_add.to_dict())
            _dict['credentialsToAdd'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in credentials_to_update (list)
        _items = []
        if self.credentials_to_update:
            for _item_credentials_to_update in self.credentials_to_update:
                if _item_credentials_to_update:
                    _items.append(_item_credentials_to_update.to_dict())
            _dict['credentialsToUpdate'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in cookies_to_add (list)
        _items = []
        if self.cookies_to_add:
            for _item_cookies_to_add in self.cookies_to_add:
                if _item_cookies_to_add:
                    _items.append(_item_cookies_to_add.to_dict())
            _dict['cookiesToAdd'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "description": obj.get("description"),
            "proxyMode": obj.get("proxyMode"),
            "proxyCC": obj.get("proxyCC"),
            "proxyType": obj.get("proxyType"),
            "customProxy": AgentsProfileCustomProxyConfigInput.from_dict(obj["customProxy"]) if obj.get("customProxy") is not None else None,
            "tailscaleAuthKey": obj.get("tailscaleAuthKey"),
            "captchaSolverActive": obj.get("captchaSolverActive"),
            "operatingSystem": obj.get("operatingSystem"),
            "extraStealth": obj.get("extraStealth"),
            "cachePersistence": obj.get("cachePersistence"),
            "adblockActive": obj.get("adblockActive"),
            "popupBlockerActive": obj.get("popupBlockerActive"),
            "forcePopupsAsTabsActive": obj.get("forcePopupsAsTabsActive"),
            "mediaBlockerActive": obj.get("mediaBlockerActive"),
            "pdfViewerActive": obj.get("pdfViewerActive"),
            "tracingEnabled": obj.get("tracingEnabled"),
            "credentialsToAdd": [AgentsProfileCredential.from_dict(_item) for _item in obj["credentialsToAdd"]] if obj.get("credentialsToAdd") is not None else None,
            "credentialsToUpdate": [AgentsProfileCredentialUpdate.from_dict(_item) for _item in obj["credentialsToUpdate"]] if obj.get("credentialsToUpdate") is not None else None,
            "credentialsToDelete": obj.get("credentialsToDelete"),
            "cookiesToAdd": [AgentsProfileCookie.from_dict(_item) for _item in obj["cookiesToAdd"]] if obj.get("cookiesToAdd") is not None else None,
            "cookiesToDelete": obj.get("cookiesToDelete")
        })
        return _obj


