# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class ConversionEventDeviceInfo(BaseModel):
    """
    Object containing information about the device where event occurred.
    """ # noqa: E501
    battery_level: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(default=None, description="Battery charge level percentage")
    brand: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Device brand")
    carrier: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="User device's mobile carrier.")
    cpu_cores: Optional[Annotated[int, Field(le=1152, strict=True, ge=0)]] = Field(default=None, description="Number of CPU cores")
    external_storage_free_space: Optional[Annotated[int, Field(le=1048576, strict=True, ge=0)]] = Field(default=None, description="External storage size in GB")
    external_storage_size: Optional[Annotated[int, Field(le=1048576, strict=True, ge=0)]] = Field(default=None, description="External storage size in GB")
    form_factor: Optional[StrictStr] = Field(default=None, description="Device form factor")
    kernel_version: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Kernel version. Examples: Linux: 6.15. Obtain by running: uname -r MacOS: 24.3.0. Obtain by running: sysctl kern.version Android: 6.6. Obtain from OS.uname().release")
    languages: Optional[Annotated[List[StrictStr], Field(min_length=0, max_length=100)]] = Field(default=None, description="List of user installed languages. ISO 639-1 format")
    locale: Optional[Annotated[str, Field(strict=True, max_length=35)]] = Field(default=None, description="Device locale BCP-47 format")
    model: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Device model name")
    network_type: Optional[StrictStr] = Field(default=None, description="Network type: 4G, 5G, ethernet, wifi In Android: NetworkCapabilities.getNetworkCapabilities()")
    os_family: Optional[StrictStr] = Field(default=None, description="OS Family")
    os_name: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Short name of the OS. This value if specific to os family. Examples: Windows: 10, 11; Android: 16; iOS: 18; MacOS: 15; Linux: Debian, Ubuntu, Arch")
    os_release_name: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Marketing name for the release version iOS: Dawn Android: Baklava MacOS: Sequoia Ubuntu Linux: Plucky Puffin")
    os_version: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Full name of the version. Examples: iOS: 18.3 Android: 16.1 MacOS: 15.5 Windows: 24H2 Ubuntu Linux: 25.04")
    screen_density: Optional[Annotated[int, Field(le=100000, strict=True, ge=0)]] = Field(default=None, description="Screen density, PPI")
    screen_height: Optional[Annotated[int, Field(le=30720, strict=True, ge=0)]] = Field(default=None, description="Screen height in pixels")
    screen_width: Optional[Annotated[int, Field(le=30720, strict=True, ge=0)]] = Field(default=None, description="Screen width in pixels")
    storage_free_space: Optional[Annotated[int, Field(le=1048576, strict=True, ge=0)]] = Field(default=None, description="Internal storage size in GB")
    storage_size: Optional[Annotated[int, Field(le=1048576, strict=True, ge=0)]] = Field(default=None, description="Internal storage size in GB")
    timezone: Optional[Annotated[str, Field(strict=True, max_length=40)]] = Field(default=None, description="Device timezone")
    timezone_abbr: Optional[Annotated[str, Field(strict=True, max_length=5)]] = Field(default=None, description="Timezone abbreviation")
    type: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Device type")
    __properties: ClassVar[List[str]] = ["battery_level", "brand", "carrier", "cpu_cores", "external_storage_free_space", "external_storage_size", "form_factor", "kernel_version", "languages", "locale", "model", "network_type", "os_family", "os_name", "os_release_name", "os_version", "screen_density", "screen_height", "screen_width", "storage_free_space", "storage_size", "timezone", "timezone_abbr", "type"]

    @field_validator('form_factor')
    def form_factor_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['desktop', 'laptop', 'cellphone', 'tablet', 'smartwatch', 'tv', 'vr', 'console', 'other']):
            raise ValueError("must be one of enum values ('desktop', 'laptop', 'cellphone', 'tablet', 'smartwatch', 'tv', 'vr', 'console', 'other')")
        return value

    @field_validator('network_type')
    def network_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['wifi', 'cellular_2g', 'cellular_3g', 'cellular_4g', 'cellular_5g', 'cellular_6g', 'ethernet', 'unknown']):
            raise ValueError("must be one of enum values ('wifi', 'cellular_2g', 'cellular_3g', 'cellular_4g', 'cellular_5g', 'cellular_6g', 'ethernet', 'unknown')")
        return value

    @field_validator('os_family')
    def os_family_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['ios', 'android', 'macos', 'windows', 'linux', 'bsd', 'other']):
            raise ValueError("must be one of enum values ('ios', 'android', 'macos', 'windows', 'linux', 'bsd', 'other')")
        return value

    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 ConversionEventDeviceInfo 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "battery_level": obj.get("battery_level"),
            "brand": obj.get("brand"),
            "carrier": obj.get("carrier"),
            "cpu_cores": obj.get("cpu_cores"),
            "external_storage_free_space": obj.get("external_storage_free_space"),
            "external_storage_size": obj.get("external_storage_size"),
            "form_factor": obj.get("form_factor"),
            "kernel_version": obj.get("kernel_version"),
            "languages": obj.get("languages"),
            "locale": obj.get("locale"),
            "model": obj.get("model"),
            "network_type": obj.get("network_type"),
            "os_family": obj.get("os_family"),
            "os_name": obj.get("os_name"),
            "os_release_name": obj.get("os_release_name"),
            "os_version": obj.get("os_version"),
            "screen_density": obj.get("screen_density"),
            "screen_height": obj.get("screen_height"),
            "screen_width": obj.get("screen_width"),
            "storage_free_space": obj.get("storage_free_space"),
            "storage_size": obj.get("storage_size"),
            "timezone": obj.get("timezone"),
            "timezone_abbr": obj.get("timezone_abbr"),
            "type": obj.get("type")
        })
        return _obj


