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

class DtProjectMetrics(BaseModel):
    """
    Project-level metrics from Dependency-Track
    """ # noqa: E501
    critical: Optional[StrictInt] = None
    findings_audited: Optional[StrictInt] = Field(default=None, alias="findingsAudited")
    findings_total: Optional[StrictInt] = Field(default=None, alias="findingsTotal")
    findings_unaudited: Optional[StrictInt] = Field(default=None, alias="findingsUnaudited")
    first_occurrence: Optional[StrictInt] = Field(default=None, alias="firstOccurrence")
    high: Optional[StrictInt] = None
    inherited_risk_score: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="inheritedRiskScore")
    last_occurrence: Optional[StrictInt] = Field(default=None, alias="lastOccurrence")
    low: Optional[StrictInt] = None
    medium: Optional[StrictInt] = None
    policy_violations_fail: Optional[StrictInt] = Field(default=None, alias="policyViolationsFail")
    policy_violations_info: Optional[StrictInt] = Field(default=None, alias="policyViolationsInfo")
    policy_violations_total: Optional[StrictInt] = Field(default=None, alias="policyViolationsTotal")
    policy_violations_warn: Optional[StrictInt] = Field(default=None, alias="policyViolationsWarn")
    suppressions: Optional[StrictInt] = None
    unassigned: Optional[StrictInt] = None
    vulnerabilities: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["critical", "findingsAudited", "findingsTotal", "findingsUnaudited", "firstOccurrence", "high", "inheritedRiskScore", "lastOccurrence", "low", "medium", "policyViolationsFail", "policyViolationsInfo", "policyViolationsTotal", "policyViolationsWarn", "suppressions", "unassigned", "vulnerabilities"]

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "critical": obj.get("critical"),
            "findingsAudited": obj.get("findingsAudited"),
            "findingsTotal": obj.get("findingsTotal"),
            "findingsUnaudited": obj.get("findingsUnaudited"),
            "firstOccurrence": obj.get("firstOccurrence"),
            "high": obj.get("high"),
            "inheritedRiskScore": obj.get("inheritedRiskScore"),
            "lastOccurrence": obj.get("lastOccurrence"),
            "low": obj.get("low"),
            "medium": obj.get("medium"),
            "policyViolationsFail": obj.get("policyViolationsFail"),
            "policyViolationsInfo": obj.get("policyViolationsInfo"),
            "policyViolationsTotal": obj.get("policyViolationsTotal"),
            "policyViolationsWarn": obj.get("policyViolationsWarn"),
            "suppressions": obj.get("suppressions"),
            "unassigned": obj.get("unassigned"),
            "vulnerabilities": obj.get("vulnerabilities")
        })
        return _obj


