Alerts
- class pytm4srv.models.PersistentAlert
Represents a system alert.
- actions: Mapped[Dict[str, str]]
Alert-specific buttons to display.
The map keys are translated strings to label the buttons. The value of each key is an action string, which will be in on of the following forms:
Server action (indicated by two preceding underscores like
__server_action
)Client action (indicated by one preceding underscore like
_client_action
)URL to open (with no preceding underscores)
When the user clicks an alert action button, use an algorithm like the following to handle it:
if action.startswith("__"): http.post(f"/api/alerts/{alert_id}/action/{action}") else if action.startswith("_"): # Handle action in client using the table below else: browser.open_url(action)
The client should be able to handle the following actions:
Action
Description
_edit_downtime
Open the downtime block editor for the downtime block ID stored in the alert’s
downtime_id
data property._edit_machine_state_defs
Open the machine state definition editor interface. Optionally, highlight the state definitions whose IDs are present in the alert’s
state_def_ids
data property._edit_process
Open the process editor for the process ID stored in the alert’s
process_id
data property._edit_tool
Open the tool editor for the tool ID stored in the alert’s
tool_id
data property._edit_tool_replacement_ notify_rule
Open the tool replacement notification rule editor for the rule ID stored in the alert’s
rule_id
data property._create_maintenance_entry
Ask the user to enter a maintenance record for the maintenance item ID stored in the alert’s
item_id
data property._replace_tool
Open the tool replacement flow for the tool ID stored in the alert’s
tool_id
data property._submit_shift_notes
Open the shift notes submission form for the machine ID stored in the alert’s
machine_id
data property and the shift ID stored in the alert’sshift_id
data property for the current day._process_changeover
Guide the user through choosing which tools to keep in the newly loaded process. The previous process’s ID is stored in the alert’s
from_process_id
data property, and the newly loaded process’s ID is stored in the alert’sto_process_id
data property.
- data: Mapped[Dict[str, Any]]
Alert-specific metadata to be read by client or server actions.
- details: Mapped[str]
Longer HTML detail text about the alert.
- id: Mapped[int]
Unique, numeric ID for this alert.
- key: Mapped[str]
The type of alert and some identifying data about it.
Used to prevent duplicate alerts.
- last_seen: Mapped[datetime]
The date and time the alert was last fired.
- machine_id: Mapped[int | None]
The ID of the machine that produced this alert, if any.
- message: Mapped[str]
Short title of the alert.
- severity: Mapped[str]
The class of alert: INFO (default), REPORT, WARNING, or PROBLEM
- times_seen: Mapped[int]
The number of times this alert has been fired without being dismissed.
- timestamp: Mapped[datetime]
The date and time the alert was created.
- ttl: Mapped[timedelta | None]
How long (in seconds) after the timestamp the alert will expire.
NULL means it never expires.