# 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_operating_system import AgentsProfileOperatingSystem
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_cc: Optional[AgentsProfileCountryCode] = Field(default=None, description="Country code for proxy location", alias="proxyCC")
    proxy_type: Optional[AgentsProfileProxyType] = Field(default=None, description="Type of proxy to use (set to empty string to disable proxy)", alias="proxyType")
    captcha_solver_active: Optional[StrictBool] = Field(default=None, description="Whether the captcha solver should be active", 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")
    credentials_to_add: Optional[List[AgentsProfileCredential]] = Field(default=None, description="Credentials to add to the profile", alias="credentialsToAdd")
    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", "proxyCC", "proxyType", "captchaSolverActive", "operatingSystem", "extraStealth", "cachePersistence", "credentialsToAdd", "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 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 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"),
            "proxyCC": obj.get("proxyCC"),
            "proxyType": obj.get("proxyType"),
            "captchaSolverActive": obj.get("captchaSolverActive"),
            "operatingSystem": obj.get("operatingSystem"),
            "extraStealth": obj.get("extraStealth"),
            "cachePersistence": obj.get("cachePersistence"),
            "credentialsToAdd": [AgentsProfileCredential.from_dict(_item) for _item in obj["credentialsToAdd"]] if obj.get("credentialsToAdd") 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


