# coding: utf-8

"""
    kameleo-local-api

    You can use the following API endpoints to communicate with the local running Kameleo programmatically.

    The version of the OpenAPI document: 4.3.0
    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
from kameleo.local_api_client.models.browser import Browser
from kameleo.local_api_client.models.device import Device
from kameleo.local_api_client.models.os import Os
from kameleo.local_api_client.models.webgl_meta import WebglMeta
from typing import Optional, Set
from typing_extensions import Self

class FingerprintPreview(BaseModel):
    """
    Provides a summarized view of a fingerprint, which encapsulates real-world browser fingerprint configurations used to  instantiate virtual browser profiles. This preview aids in selecting the appropriate fingerprint from hundreds of thousands available.
    """ # noqa: E501
    id: StrictStr = Field(description="The unique identifier of the fingerprint. You can use this as a reference to create a new profile from this fingerprint.")
    device: Device = Field(description="Information about the device of the fingerprint.")
    os: Os = Field(description="Information about the OS of the fingerprint.")
    browser: Browser = Field(description="Information about the browser of the fingerprint.")
    webgl_meta: WebglMeta = Field(description="The GPU details of the fingerprint extracted from WebGL parameters.", alias="webglMeta")
    user_agent: StrictStr = Field(description="The user agent of the fingerprint.", alias="userAgent")
    fonts_count: StrictInt = Field(description="The number of fonts in the fingerprint.", alias="fontsCount")
    __properties: ClassVar[List[str]] = ["id", "device", "os", "browser", "webglMeta", "userAgent", "fontsCount"]

    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 FingerprintPreview 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 device
        if self.device:
            _dict['device'] = self.device.to_dict()
        # override the default output from pydantic by calling `to_dict()` of os
        if self.os:
            _dict['os'] = self.os.to_dict()
        # override the default output from pydantic by calling `to_dict()` of browser
        if self.browser:
            _dict['browser'] = self.browser.to_dict()
        # override the default output from pydantic by calling `to_dict()` of webgl_meta
        if self.webgl_meta:
            _dict['webglMeta'] = self.webgl_meta.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of FingerprintPreview 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"),
            "device": Device.from_dict(obj["device"]) if obj.get("device") is not None else None,
            "os": Os.from_dict(obj["os"]) if obj.get("os") is not None else None,
            "browser": Browser.from_dict(obj["browser"]) if obj.get("browser") is not None else None,
            "webglMeta": WebglMeta.from_dict(obj["webglMeta"]) if obj.get("webglMeta") is not None else None,
            "userAgent": obj.get("userAgent"),
            "fontsCount": obj.get("fontsCount")
        })
        return _obj


