from dataclasses import dataclass
from enum import Enum
from typing import List


class HealthStatus(Enum):
    OK = "ok"
    WARNING = "warning"
    CRITICAL = "critical"


@dataclass
class HealthCheck:
    name: str
    status: HealthStatus
    message: str
    details: dict


@dataclass
class HealthReport:
    checks: List[HealthCheck]

    @property
    def status(self) -> HealthStatus:
        if any(c.status == HealthStatus.CRITICAL for c in self.checks):
            return HealthStatus.CRITICAL
        if any(c.status == HealthStatus.WARNING for c in self.checks):
            return HealthStatus.WARNING
        return HealthStatus.OK

    @property
    def exit_code(self) -> int:
        if self.status == HealthStatus.CRITICAL:
            return 2
        if self.status == HealthStatus.WARNING:
            return 1
        return 0


def run_checks(checks: List[HealthCheck]) -> HealthReport:
    return HealthReport(checks=checks)
