2023-03-19 23:21:32 +08:00
|
|
|
from typing import Any, Optional
|
2022-11-06 20:09:44 +08:00
|
|
|
|
2023-04-10 20:23:31 +08:00
|
|
|
from core.uid_gen import FelicityIDType
|
2021-01-06 19:52:14 +08:00
|
|
|
from pydantic import BaseModel
|
2021-02-27 19:24:39 +08:00
|
|
|
|
2022-01-10 00:00:14 +08:00
|
|
|
from .conf import categories, priorities, states
|
2021-01-06 19:52:14 +08:00
|
|
|
|
|
|
|
|
2022-01-10 00:00:14 +08:00
|
|
|
#
|
2021-01-06 19:52:14 +08:00
|
|
|
# Job Schemas
|
2022-01-10 00:00:14 +08:00
|
|
|
#
|
2021-02-27 19:24:39 +08:00
|
|
|
class JobBase(BaseModel):
|
2023-04-25 22:42:39 +08:00
|
|
|
action: str | None = None
|
|
|
|
category: str | None = categories.WORKSHEET
|
|
|
|
priority: int | None = priorities.NORMAL
|
2023-02-26 22:14:43 +08:00
|
|
|
data: Optional[Any] = None
|
2023-04-25 22:42:39 +08:00
|
|
|
job_id: FelicityIDType| None = None
|
|
|
|
status: str | None = states.PENDING
|
|
|
|
reason: str | None = None
|
|
|
|
creator_uid: FelicityIDType| None = None
|
2021-02-27 19:24:39 +08:00
|
|
|
|
|
|
|
|
2021-01-06 19:52:14 +08:00
|
|
|
class Job(JobBase):
|
2023-04-25 22:42:39 +08:00
|
|
|
uid: FelicityIDType| None = None
|
2021-01-06 19:52:14 +08:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
2021-02-27 19:24:39 +08:00
|
|
|
|
2021-01-06 19:52:14 +08:00
|
|
|
class JobCreate(JobBase):
|
|
|
|
pass
|
|
|
|
|
2021-02-27 19:24:39 +08:00
|
|
|
|
2021-01-06 19:52:14 +08:00
|
|
|
class JobUpdate(JobBase):
|
2021-02-27 19:24:39 +08:00
|
|
|
pass
|