# coding: utf-8

"""
    Artifact Keeper API

    REST API for Artifact Keeper, an open-source universal artifact registry. Covers user management, repositories, artifacts, search, security scanning, SBOM, dependency tracking, SSO, analytics, monitoring, telemetry, lifecycle policies, plugins, edge nodes, migration, and administration. Format-specific protocol endpoints (npm, PyPI, Maven, Docker/OCI, etc.) are not included; those follow their respective upstream specifications.

    The version of the OpenAPI document: 1.0.0-a2
    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):
    """
    DtProjectMetrics
    """ # noqa: E501
    critical: StrictInt = Field(description="Number of critical severity vulnerabilities")
    high: StrictInt = Field(description="Number of high severity vulnerabilities")
    medium: StrictInt = Field(description="Number of medium severity vulnerabilities")
    low: StrictInt = Field(description="Number of low severity vulnerabilities")
    unassigned: StrictInt = Field(description="Number of unassigned severity vulnerabilities")
    vulnerabilities: Optional[StrictInt] = Field(default=None, description="Total number of unique vulnerabilities")
    findings_total: StrictInt = Field(description="Total number of findings")
    findings_audited: StrictInt = Field(description="Number of audited findings")
    findings_unaudited: StrictInt = Field(description="Number of unaudited findings")
    suppressions: StrictInt = Field(description="Number of suppressed findings")
    inherited_risk_score: Union[StrictFloat, StrictInt] = Field(description="Calculated inherited risk score")
    policy_violations_fail: StrictInt = Field(description="Number of policy violations with fail state")
    policy_violations_warn: StrictInt = Field(description="Number of policy violations with warn state")
    policy_violations_info: StrictInt = Field(description="Number of policy violations with info state")
    policy_violations_total: StrictInt = Field(description="Total number of policy violations")
    first_occurrence: Optional[StrictInt] = Field(default=None, description="Unix timestamp of the earliest metric occurrence")
    last_occurrence: Optional[StrictInt] = Field(default=None, description="Unix timestamp of the most recent metric occurrence")
    __properties: ClassVar[List[str]] = ["critical", "high", "medium", "low", "unassigned", "vulnerabilities", "findings_total", "findings_audited", "findings_unaudited", "suppressions", "inherited_risk_score", "policy_violations_fail", "policy_violations_warn", "policy_violations_info", "policy_violations_total", "first_occurrence", "last_occurrence"]

    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 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

        # 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['first_occurrence'] = 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['last_occurrence'] = 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"),
            "high": obj.get("high"),
            "medium": obj.get("medium"),
            "low": obj.get("low"),
            "unassigned": obj.get("unassigned"),
            "vulnerabilities": obj.get("vulnerabilities"),
            "findings_total": obj.get("findings_total"),
            "findings_audited": obj.get("findings_audited"),
            "findings_unaudited": obj.get("findings_unaudited"),
            "suppressions": obj.get("suppressions"),
            "inherited_risk_score": obj.get("inherited_risk_score"),
            "policy_violations_fail": obj.get("policy_violations_fail"),
            "policy_violations_warn": obj.get("policy_violations_warn"),
            "policy_violations_info": obj.get("policy_violations_info"),
            "policy_violations_total": obj.get("policy_violations_total"),
            "first_occurrence": obj.get("first_occurrence"),
            "last_occurrence": obj.get("last_occurrence")
        })
        return _obj


