# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class KernelResponse(BaseModel):
    """
    KernelResponse
    """ # noqa: E501
    id: StrictStr = Field(description="Unique identifier of the kernel.")
    platform: Annotated[str, Field(min_length=1, strict=True)] = Field(description="The operating system this kernel supports (e.g: win-x64, osx-arm64).")
    browser: Annotated[str, Field(min_length=1, strict=True)] = Field(description="The browser this kernel contains (e.g: chroma, junglefox).")
    version: StrictStr = Field(description="Version of the browser.")
    built_at: datetime = Field(description="Build timestamp of the kernel.", alias="builtAt")
    download_size: StrictInt = Field(description="Size of the download package in bytes.", alias="downloadSize")
    disk_size: Optional[StrictInt] = Field(default=None, description="Size of the extracted package on the local file system in bytes or null if the kernel is not installed.", alias="diskSize")
    is_installed: StrictBool = Field(description="Flag indicating if the kernel is locally available (true) or it has to be installed before usage (false).", alias="isInstalled")
    is_in_use: StrictBool = Field(description="Flag indicating if the kernel is currently in use.", alias="isInUse")
    is_marked_for_removal: StrictBool = Field(description="Flag indicating that the kernel will be removed from the local file system when it is not in use.", alias="isMarkedForRemoval")
    __properties: ClassVar[List[str]] = ["id", "platform", "browser", "version", "builtAt", "downloadSize", "diskSize", "isInstalled", "isInUse", "isMarkedForRemoval"]

    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 KernelResponse 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,
        )
        # set to None if disk_size (nullable) is None
        # and model_fields_set contains the field
        if self.disk_size is None and "disk_size" in self.model_fields_set:
            _dict['diskSize'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of KernelResponse 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"),
            "platform": obj.get("platform"),
            "browser": obj.get("browser"),
            "version": obj.get("version"),
            "builtAt": obj.get("builtAt"),
            "downloadSize": obj.get("downloadSize"),
            "diskSize": obj.get("diskSize"),
            "isInstalled": obj.get("isInstalled"),
            "isInUse": obj.get("isInUse"),
            "isMarkedForRemoval": obj.get("isMarkedForRemoval")
        })
        return _obj


