mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
refactor(automations): move schedule trigger into builtin package
This commit is contained in:
parent
acd673023a
commit
f293aa6bdf
13 changed files with 14 additions and 263 deletions
|
|
@ -0,0 +1,24 @@
|
|||
"""``ScheduleTriggerParams`` — params for the ``schedule`` trigger type."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from .cron import InvalidCronError, validate_cron
|
||||
|
||||
|
||||
class ScheduleTriggerParams(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
cron: str = Field(
|
||||
..., description="Five-field cron expression.", examples=["0 9 * * 1-5"]
|
||||
)
|
||||
timezone: str = Field(..., description="IANA timezone.", examples=["Africa/Kigali"])
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _validate(self) -> ScheduleTriggerParams:
|
||||
try:
|
||||
validate_cron(self.cron, self.timezone)
|
||||
except InvalidCronError as exc:
|
||||
raise ValueError(str(exc)) from exc
|
||||
return self
|
||||
Loading…
Add table
Add a link
Reference in a new issue