# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
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_custom_proxy_config_output import AgentsProfileCustomProxyConfigOutput
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 AgentsProfileAgentProfile(BaseModel):
    """
    An agent profile containing browser configuration and credentials
    """ # noqa: E501
    id: StrictStr = Field(description="Unique identifier for the agent profile")
    name: StrictStr = Field(description="Name of the agent profile (unique within organization)")
    description: StrictStr = Field(description="Description of the agent profile")
    organization_id: StrictStr = Field(description="The ID of the organization that owns this profile", alias="organizationId")
    proxy_mode: AgentsProfileProxyMode = Field(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[AgentsProfileCustomProxyConfigOutput] = Field(default=None, description="Custom proxy configuration (for custom proxy mode, password excluded)", alias="customProxy")
    captcha_solver_active: StrictBool = Field(description="Whether the captcha solver is active for this profile (managed proxy only)", alias="captchaSolverActive")
    sticky_ip: StrictBool = Field(description="Whether to use the same IP address for all executions (managed proxy only)", alias="stickyIP")
    operating_system: Optional[AgentsProfileOperatingSystem] = Field(default=None, description="Operating system to emulate", alias="operatingSystem")
    extra_stealth: StrictBool = Field(description="Whether extra stealth mode is enabled", alias="extraStealth")
    cache_persistence: StrictBool = Field(description="Whether to persist browser cache between sessions", alias="cachePersistence")
    adblock_active: StrictBool = Field(description="Whether to enable ad blocking", alias="adblockActive")
    popup_blocker_active: StrictBool = Field(description="Whether to enable popup blocking (requires adblock to be active)", alias="popupBlockerActive")
    force_popups_as_tabs_active: StrictBool = Field(description="Whether to force popups to open as tabs", alias="forcePopupsAsTabsActive")
    media_blocker_active: StrictBool = Field(description="Whether to enable media blocking (images, videos, etc.)", alias="mediaBlockerActive")
    pdf_viewer_active: StrictBool = Field(description="Whether to enable the built-in PDF viewer (if disabled, PDFs are downloaded)", alias="pdfViewerActive")
    credentials: List[AgentsProfileCredential] = Field(description="List of credentials associated with this profile")
    cookies: List[AgentsProfileCookie] = Field(description="List of cookies associated with this profile")
    created_at: datetime = Field(description="When the profile was created", alias="createdAt")
    updated_at: datetime = Field(description="When the profile was last updated", alias="updatedAt")
    __properties: ClassVar[List[str]] = ["id", "name", "description", "organizationId", "proxyMode", "proxyCC", "proxyType", "customProxy", "captchaSolverActive", "stickyIP", "operatingSystem", "extraStealth", "cachePersistence", "adblockActive", "popupBlockerActive", "forcePopupsAsTabsActive", "mediaBlockerActive", "pdfViewerActive", "credentials", "cookies", "createdAt", "updatedAt"]

    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 AgentsProfileAgentProfile 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 (list)
        _items = []
        if self.credentials:
            for _item_credentials in self.credentials:
                if _item_credentials:
                    _items.append(_item_credentials.to_dict())
            _dict['credentials'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in cookies (list)
        _items = []
        if self.cookies:
            for _item_cookies in self.cookies:
                if _item_cookies:
                    _items.append(_item_cookies.to_dict())
            _dict['cookies'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AgentsProfileAgentProfile 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"),
            "name": obj.get("name"),
            "description": obj.get("description"),
            "organizationId": obj.get("organizationId"),
            "proxyMode": obj.get("proxyMode"),
            "proxyCC": obj.get("proxyCC"),
            "proxyType": obj.get("proxyType"),
            "customProxy": AgentsProfileCustomProxyConfigOutput.from_dict(obj["customProxy"]) if obj.get("customProxy") is not None else None,
            "captchaSolverActive": obj.get("captchaSolverActive"),
            "stickyIP": obj.get("stickyIP"),
            "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"),
            "credentials": [AgentsProfileCredential.from_dict(_item) for _item in obj["credentials"]] if obj.get("credentials") is not None else None,
            "cookies": [AgentsProfileCookie.from_dict(_item) for _item in obj["cookies"]] if obj.get("cookies") is not None else None,
            "createdAt": obj.get("createdAt"),
            "updatedAt": obj.get("updatedAt")
        })
        return _obj


