# coding: utf-8

"""
Cybee API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: 0.42.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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python


class Os(BaseModel):
    """
    Os
    """  # noqa: E501

    name: Optional[StrictStr] = None
    kernel_version: Optional[StrictStr] = None
    os_version: Optional[StrictStr] = None
    long_os_version: Optional[StrictStr] = None
    distribution_id: StrictStr
    host_name: Optional[StrictStr] = None
    license_info: Optional[StrictStr] = None
    domain_name: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = [
        "name",
        "kernel_version",
        "os_version",
        "long_os_version",
        "distribution_id",
        "host_name",
        "license_info",
        "domain_name",
    ]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Os 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 name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict["name"] = None

        # set to None if kernel_version (nullable) is None
        # and model_fields_set contains the field
        if self.kernel_version is None and "kernel_version" in self.model_fields_set:
            _dict["kernel_version"] = None

        # set to None if os_version (nullable) is None
        # and model_fields_set contains the field
        if self.os_version is None and "os_version" in self.model_fields_set:
            _dict["os_version"] = None

        # set to None if long_os_version (nullable) is None
        # and model_fields_set contains the field
        if self.long_os_version is None and "long_os_version" in self.model_fields_set:
            _dict["long_os_version"] = None

        # set to None if host_name (nullable) is None
        # and model_fields_set contains the field
        if self.host_name is None and "host_name" in self.model_fields_set:
            _dict["host_name"] = None

        # set to None if license_info (nullable) is None
        # and model_fields_set contains the field
        if self.license_info is None and "license_info" in self.model_fields_set:
            _dict["license_info"] = None

        # set to None if domain_name (nullable) is None
        # and model_fields_set contains the field
        if self.domain_name is None and "domain_name" in self.model_fields_set:
            _dict["domain_name"] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Os 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"),
                "kernel_version": obj.get("kernel_version"),
                "os_version": obj.get("os_version"),
                "long_os_version": obj.get("long_os_version"),
                "distribution_id": obj.get("distribution_id"),
                "host_name": obj.get("host_name"),
                "license_info": obj.get("license_info"),
                "domain_name": obj.get("domain_name"),
            }
        )
        return _obj
