# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class RepoHealthResponse(BaseModel):
    """
    RepoHealthResponse
    """ # noqa: E501
    artifacts_evaluated: StrictInt
    artifacts_failing: StrictInt
    artifacts_passing: StrictInt
    avg_license_score: Optional[StrictInt] = None
    avg_metadata_score: Optional[StrictInt] = None
    avg_quality_score: Optional[StrictInt] = None
    avg_security_score: Optional[StrictInt] = None
    health_grade: StrictStr
    health_score: StrictInt
    last_evaluated_at: Optional[datetime] = None
    repository_id: StrictStr
    repository_key: StrictStr
    __properties: ClassVar[List[str]] = ["artifacts_evaluated", "artifacts_failing", "artifacts_passing", "avg_license_score", "avg_metadata_score", "avg_quality_score", "avg_security_score", "health_grade", "health_score", "last_evaluated_at", "repository_id", "repository_key"]

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "artifacts_evaluated": obj.get("artifacts_evaluated"),
            "artifacts_failing": obj.get("artifacts_failing"),
            "artifacts_passing": obj.get("artifacts_passing"),
            "avg_license_score": obj.get("avg_license_score"),
            "avg_metadata_score": obj.get("avg_metadata_score"),
            "avg_quality_score": obj.get("avg_quality_score"),
            "avg_security_score": obj.get("avg_security_score"),
            "health_grade": obj.get("health_grade"),
            "health_score": obj.get("health_score"),
            "last_evaluated_at": obj.get("last_evaluated_at"),
            "repository_id": obj.get("repository_id"),
            "repository_key": obj.get("repository_key")
        })
        return _obj


