# 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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from cybee_sdk.api.models.global_restic_options import GlobalResticOptions
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python


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

    global_options: GlobalResticOptions
    exclude: Optional[List[StrictStr]] = None
    include: Optional[List[StrictStr]] = None
    iexclude: Optional[List[StrictStr]] = None
    iinclude: Optional[List[StrictStr]] = None
    host: Optional[StrictStr] = None
    path: Optional[StrictStr] = None
    tag: Optional[List[StrictStr]] = None
    sparse: Optional[StrictBool] = False
    target: StrictStr
    verify: Optional[StrictBool] = False
    snapshot_id: StrictStr
    __properties: ClassVar[List[str]] = [
        "global_options",
        "exclude",
        "include",
        "iexclude",
        "iinclude",
        "host",
        "path",
        "tag",
        "sparse",
        "target",
        "verify",
        "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 ResticRestore 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,
        )
        # override the default output from pydantic by calling `to_dict()` of global_options
        if self.global_options:
            _dict["global_options"] = self.global_options.to_dict()
        # set to None if host (nullable) is None
        # and model_fields_set contains the field
        if self.host is None and "host" in self.model_fields_set:
            _dict["host"] = None

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "global_options": GlobalResticOptions.from_dict(obj["global_options"])
                if obj.get("global_options") is not None
                else None,
                "exclude": obj.get("exclude"),
                "include": obj.get("include"),
                "iexclude": obj.get("iexclude"),
                "iinclude": obj.get("iinclude"),
                "host": obj.get("host"),
                "path": obj.get("path"),
                "tag": obj.get("tag"),
                "sparse": obj.get("sparse") if obj.get("sparse") is not None else False,
                "target": obj.get("target"),
                "verify": obj.get("verify") if obj.get("verify") is not None else False,
                "snapshot_id": obj.get("snapshot_id"),
            }
        )
        return _obj
