42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class ScriptBase(BaseModel):
|
|
code: str = Field(min_length=1, max_length=64)
|
|
name: str = Field(min_length=1, max_length=128)
|
|
language: str = Field(default="python", pattern=r"^(python|node|shell)$")
|
|
description: str | None = None
|
|
content: str = ""
|
|
timeout_seconds: int = Field(default=60, ge=1, le=3600)
|
|
status: str = Field(default="ACTIVE", pattern=r"^(ACTIVE|DISABLED)$")
|
|
|
|
|
|
class ScriptCreate(ScriptBase):
|
|
pass
|
|
|
|
|
|
class ScriptUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=128)
|
|
language: str | None = Field(default=None, pattern=r"^(python|node|shell)$")
|
|
description: str | None = None
|
|
content: str | None = None
|
|
timeout_seconds: int | None = Field(default=None, ge=1, le=3600)
|
|
status: str | None = Field(default=None, pattern=r"^(ACTIVE|DISABLED)$")
|
|
|
|
|
|
class ScriptRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
code: str
|
|
name: str
|
|
language: str
|
|
description: str | None = None
|
|
content: str
|
|
version: int
|
|
timeout_seconds: int
|
|
status: str
|
|
owner_id: int | None = None
|