from typing import List
from datetime import datetime
from pydantic import BaseModel

from sator_core.models.product import Product


class VulnerabilityMetadata(BaseModel):
    id: str
    assigner: str
    reported_date: datetime
    published_date: datetime
    affected_products: List[Product]

    def __hash__(self):
        return hash(self.id)

    def __str__(self):
        _str = f"Vulnerability ID - {self.id} | Assigner - {self.assigner} | Reported Date - {self.reported_date}"
        _str += f" | Published Date - {self.published_date}"
        _str += f" | Affected Products - {len(self.affected_products)}"

        return _str
