# 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, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python


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

    id: UUID
    files_new: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    files_changed: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    files_unmodified: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    dirs_new: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    dirs_changed: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    dirs_unmodified: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    data_blobs: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    tree_blobs: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    data_added: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    data_added_packed: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    total_files_processed: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    total_bytes_processed: Optional[Annotated[int, Field(strict=True, ge=0)]] = 0
    total_duration: Optional[
        Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]
    ] = 0
    snapshot_id: Optional[StrictStr] = None
    backup_paths: Optional[List[StrictStr]] = None
    __properties: ClassVar[List[str]] = [
        "id",
        "files_new",
        "files_changed",
        "files_unmodified",
        "dirs_new",
        "dirs_changed",
        "dirs_unmodified",
        "data_blobs",
        "tree_blobs",
        "data_added",
        "data_added_packed",
        "total_files_processed",
        "total_bytes_processed",
        "total_duration",
        "snapshot_id",
        "backup_paths",
    ]

    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 Snapshot 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 snapshot_id (nullable) is None
        # and model_fields_set contains the field
        if self.snapshot_id is None and "snapshot_id" in self.model_fields_set:
            _dict["snapshot_id"] = None

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Snapshot 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"),
                "files_new": obj.get("files_new") if obj.get("files_new") is not None else 0,
                "files_changed": obj.get("files_changed") if obj.get("files_changed") is not None else 0,
                "files_unmodified": obj.get("files_unmodified") if obj.get("files_unmodified") is not None else 0,
                "dirs_new": obj.get("dirs_new") if obj.get("dirs_new") is not None else 0,
                "dirs_changed": obj.get("dirs_changed") if obj.get("dirs_changed") is not None else 0,
                "dirs_unmodified": obj.get("dirs_unmodified") if obj.get("dirs_unmodified") is not None else 0,
                "data_blobs": obj.get("data_blobs") if obj.get("data_blobs") is not None else 0,
                "tree_blobs": obj.get("tree_blobs") if obj.get("tree_blobs") is not None else 0,
                "data_added": obj.get("data_added") if obj.get("data_added") is not None else 0,
                "data_added_packed": obj.get("data_added_packed") if obj.get("data_added_packed") is not None else 0,
                "total_files_processed": obj.get("total_files_processed")
                if obj.get("total_files_processed") is not None
                else 0,
                "total_bytes_processed": obj.get("total_bytes_processed")
                if obj.get("total_bytes_processed") is not None
                else 0,
                "total_duration": obj.get("total_duration") if obj.get("total_duration") is not None else 0,
                "snapshot_id": obj.get("snapshot_id"),
                "backup_paths": obj.get("backup_paths"),
            }
        )
        return _obj
