-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathtrigger.py
More file actions
37 lines (34 loc) · 1.33 KB
/
trigger.py
File metadata and controls
37 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pydantic import Field
from beanie import Document
from typing import Optional
from pymongo import IndexModel
from ..trigger_models import TriggerTypeEnum, TriggerStatusEnum
from datetime import datetime
class DatabaseTriggers(Document):
type: TriggerTypeEnum = Field(..., description="Type of the trigger")
expression: Optional[str] = Field(default=None, description="Expression of the trigger")
timezone: Optional[str] = Field(default="UTC", description="Timezone for the trigger")
graph_name: str = Field(..., description="Name of the graph")
namespace: str = Field(..., description="Namespace of the graph")
trigger_time: datetime = Field(..., description="Trigger time of the trigger")
trigger_status: TriggerStatusEnum = Field(..., description="Status of the trigger")
class Settings:
indexes = [
IndexModel(
[
("trigger_time", -1),
],
name="idx_trigger_time"
),
IndexModel(
[
("type", 1),
("expression", 1),
("graph_name", 1),
("namespace", 1),
("trigger_time", 1),
],
name="uniq_graph_type_expr_time",
unique=True
)
]