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


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

    files_new: Annotated[int, Field(strict=True, ge=0)]
    files_changed: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    files_unmodified: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    dirs_new: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    dirs_changed: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    dirs_unmodified: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    data_blobs: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    tree_blobs: Annotated[int, Field(strict=True, ge=0)]
    data_added: Annotated[int, Field(strict=True, ge=0)]
    data_added_packed: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    total_files_processed: Annotated[int, Field(strict=True, ge=0)]
    total_bytes_processed: Annotated[int, Field(strict=True, ge=0)]
    total_duration: Union[StrictFloat, StrictInt]
    snapshot_id: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = [
        "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",
    ]

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

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

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

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

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

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

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

        # 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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "files_new": obj.get("files_new"),
                "files_changed": obj.get("files_changed"),
                "files_unmodified": obj.get("files_unmodified"),
                "dirs_new": obj.get("dirs_new"),
                "dirs_changed": obj.get("dirs_changed"),
                "dirs_unmodified": obj.get("dirs_unmodified"),
                "data_blobs": obj.get("data_blobs"),
                "tree_blobs": obj.get("tree_blobs"),
                "data_added": obj.get("data_added"),
                "data_added_packed": obj.get("data_added_packed"),
                "total_files_processed": obj.get("total_files_processed"),
                "total_bytes_processed": obj.get("total_bytes_processed"),
                "total_duration": obj.get("total_duration"),
                "snapshot_id": obj.get("snapshot_id"),
            }
        )
        return _obj
