from enum import Enum
from datetime import datetime
from uuid import UUID
from acelerai_pipelines.utils import toUpperFirst


class ProcessStatusType(str, Enum):
    Ok = "Ok"
    Warning = "Warning"
    Error = "Error"


class ProcessStatus:
    Id: UUID
    RunId: UUID
    ProcessName: str
    Status: ProcessStatusType
    Title: str
    Content: str | None
    CreatedAt: datetime

    def __init__(self, **kwargs):
        kwargs = {toUpperFirst(k): v for k, v in kwargs.items()}
        kwargs["Status"] = ProcessStatusType(kwargs["Status"])
        kwargs["Id"] = UUID(kwargs["Id"])
        kwargs["RunId"] = UUID(kwargs["RunId"])
        kwargs["CreatedAt"] = datetime.fromisoformat(kwargs["CreatedAt"])
        self.__dict__ = kwargs

    def get_dict(self):
        return {
            "id": self.Id,
            "runId": self.RunId,
            "processName": self.ProcessName,
            "status": self.Status,
            "createdAt": self.CreatedAt,
            "title": self.Title,
            "content": self.Content
        }
