# coding: utf-8

"""
    Artifact Keeper API

    Enterprise artifact registry supporting 45+ package formats.

    The version of the OpenAPI document: 1.0.0-rc.3
    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
from typing import Any, ClassVar, Dict, List, Optional
from artifact_keeper_client.models.check_status import CheckStatus
from typing import Optional, Set
from typing_extensions import Self

class HealthChecks(BaseModel):
    """
    HealthChecks
    """ # noqa: E501
    database: CheckStatus
    meilisearch: Optional[CheckStatus] = None
    security_scanner: Optional[CheckStatus] = None
    storage: CheckStatus
    __properties: ClassVar[List[str]] = ["database", "meilisearch", "security_scanner", "storage"]

    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 HealthChecks 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 database
        if self.database:
            _dict['database'] = self.database.to_dict()
        # override the default output from pydantic by calling `to_dict()` of meilisearch
        if self.meilisearch:
            _dict['meilisearch'] = self.meilisearch.to_dict()
        # override the default output from pydantic by calling `to_dict()` of security_scanner
        if self.security_scanner:
            _dict['security_scanner'] = self.security_scanner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of storage
        if self.storage:
            _dict['storage'] = self.storage.to_dict()
        # set to None if meilisearch (nullable) is None
        # and model_fields_set contains the field
        if self.meilisearch is None and "meilisearch" in self.model_fields_set:
            _dict['meilisearch'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "database": CheckStatus.from_dict(obj["database"]) if obj.get("database") is not None else None,
            "meilisearch": CheckStatus.from_dict(obj["meilisearch"]) if obj.get("meilisearch") is not None else None,
            "security_scanner": CheckStatus.from_dict(obj["security_scanner"]) if obj.get("security_scanner") is not None else None,
            "storage": CheckStatus.from_dict(obj["storage"]) if obj.get("storage") is not None else None
        })
        return _obj


