# coding: utf-8

"""
Immich

Immich API

The version of the OpenAPI document: 2.4.1
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
from typing import Any, ClassVar, Dict, List
from immich.client.models.job_settings_dto import JobSettingsDto
from typing import Optional, Set
from typing_extensions import Self


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

    background_task: JobSettingsDto = Field(alias="backgroundTask")
    face_detection: JobSettingsDto = Field(alias="faceDetection")
    library: JobSettingsDto
    metadata_extraction: JobSettingsDto = Field(alias="metadataExtraction")
    migration: JobSettingsDto
    notifications: JobSettingsDto
    ocr: JobSettingsDto
    search: JobSettingsDto
    sidecar: JobSettingsDto
    smart_search: JobSettingsDto = Field(alias="smartSearch")
    thumbnail_generation: JobSettingsDto = Field(alias="thumbnailGeneration")
    video_conversion: JobSettingsDto = Field(alias="videoConversion")
    workflow: JobSettingsDto
    __properties: ClassVar[List[str]] = [
        "backgroundTask",
        "faceDetection",
        "library",
        "metadataExtraction",
        "migration",
        "notifications",
        "ocr",
        "search",
        "sidecar",
        "smartSearch",
        "thumbnailGeneration",
        "videoConversion",
        "workflow",
    ]

    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 SystemConfigJobDto 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 background_task
        if self.background_task:
            _dict["backgroundTask"] = self.background_task.to_dict()
        # override the default output from pydantic by calling `to_dict()` of face_detection
        if self.face_detection:
            _dict["faceDetection"] = self.face_detection.to_dict()
        # override the default output from pydantic by calling `to_dict()` of library
        if self.library:
            _dict["library"] = self.library.to_dict()
        # override the default output from pydantic by calling `to_dict()` of metadata_extraction
        if self.metadata_extraction:
            _dict["metadataExtraction"] = self.metadata_extraction.to_dict()
        # override the default output from pydantic by calling `to_dict()` of migration
        if self.migration:
            _dict["migration"] = self.migration.to_dict()
        # override the default output from pydantic by calling `to_dict()` of notifications
        if self.notifications:
            _dict["notifications"] = self.notifications.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ocr
        if self.ocr:
            _dict["ocr"] = self.ocr.to_dict()
        # override the default output from pydantic by calling `to_dict()` of search
        if self.search:
            _dict["search"] = self.search.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sidecar
        if self.sidecar:
            _dict["sidecar"] = self.sidecar.to_dict()
        # override the default output from pydantic by calling `to_dict()` of smart_search
        if self.smart_search:
            _dict["smartSearch"] = self.smart_search.to_dict()
        # override the default output from pydantic by calling `to_dict()` of thumbnail_generation
        if self.thumbnail_generation:
            _dict["thumbnailGeneration"] = self.thumbnail_generation.to_dict()
        # override the default output from pydantic by calling `to_dict()` of video_conversion
        if self.video_conversion:
            _dict["videoConversion"] = self.video_conversion.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workflow
        if self.workflow:
            _dict["workflow"] = self.workflow.to_dict()
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "backgroundTask": JobSettingsDto.from_dict(obj["backgroundTask"])
                if obj.get("backgroundTask") is not None
                else None,
                "faceDetection": JobSettingsDto.from_dict(obj["faceDetection"])
                if obj.get("faceDetection") is not None
                else None,
                "library": JobSettingsDto.from_dict(obj["library"])
                if obj.get("library") is not None
                else None,
                "metadataExtraction": JobSettingsDto.from_dict(
                    obj["metadataExtraction"]
                )
                if obj.get("metadataExtraction") is not None
                else None,
                "migration": JobSettingsDto.from_dict(obj["migration"])
                if obj.get("migration") is not None
                else None,
                "notifications": JobSettingsDto.from_dict(obj["notifications"])
                if obj.get("notifications") is not None
                else None,
                "ocr": JobSettingsDto.from_dict(obj["ocr"])
                if obj.get("ocr") is not None
                else None,
                "search": JobSettingsDto.from_dict(obj["search"])
                if obj.get("search") is not None
                else None,
                "sidecar": JobSettingsDto.from_dict(obj["sidecar"])
                if obj.get("sidecar") is not None
                else None,
                "smartSearch": JobSettingsDto.from_dict(obj["smartSearch"])
                if obj.get("smartSearch") is not None
                else None,
                "thumbnailGeneration": JobSettingsDto.from_dict(
                    obj["thumbnailGeneration"]
                )
                if obj.get("thumbnailGeneration") is not None
                else None,
                "videoConversion": JobSettingsDto.from_dict(obj["videoConversion"])
                if obj.get("videoConversion") is not None
                else None,
                "workflow": JobSettingsDto.from_dict(obj["workflow"])
                if obj.get("workflow") is not None
                else None,
            }
        )
        return _obj
