32 lines
905 B
Python
32 lines
905 B
Python
|
|
from typing import Literal
|
||
|
|
from pydantic import Field
|
||
|
|
from app.domain.timeline import Strict
|
||
|
|
|
||
|
|
|
||
|
|
class BatchWorkflow(Strict):
|
||
|
|
output_folder_id: str | None = None
|
||
|
|
kind: Literal["workflow"]
|
||
|
|
draft_id: str
|
||
|
|
draft_revision: int = Field(ge=1)
|
||
|
|
expected_version: int = Field(ge=1)
|
||
|
|
|
||
|
|
|
||
|
|
class BatchJob(Strict):
|
||
|
|
folder_id: str | None = None
|
||
|
|
output_folder_id: str | None = None
|
||
|
|
kind: Literal["job"]
|
||
|
|
task_type: str
|
||
|
|
input: dict = Field(default_factory=dict)
|
||
|
|
parameters: dict = Field(default_factory=dict)
|
||
|
|
count: int = Field(default=1, ge=1, le=4)
|
||
|
|
|
||
|
|
|
||
|
|
class BatchCreate(Strict):
|
||
|
|
name: str = Field(default="夜间批次", min_length=1, max_length=255)
|
||
|
|
items: list[BatchWorkflow | BatchJob] = Field(min_length=1, max_length=100)
|
||
|
|
|
||
|
|
|
||
|
|
class BatchControl(Strict):
|
||
|
|
desired_state: Literal["run", "pause", "cancel"]
|
||
|
|
expected_version: int | None = Field(default=None, ge=1)
|