1 Standard Structure for Message GET POST in the API
Zac Adam-MacEwen edited this page 2021-01-07 13:51:47 -04:00

Fundamentally, the bulk of what pyminder.monitor does as a service is to accept status messages, store them in a database, retrieve them upon request, and send the messages to the actual display application.

While the methods for posting and retrieving these messages will likely be unique, in both cases the format should be the same, except as noted below.

Property Type/Accepts Description and Usage
id UUID4 A unique identifier for referencing this exact message within the DB. Present only in message retrievals/GET; generated upon reciept/POST
name STR The name of the service or check that raises this alert. Ultimately up to the admin, and is arbitrary.
read Boolean A flag indicating whether or not the message has been acknowledged. Used by the monitor to determine if an LED needs to be lit or not
errorlevel STR One of info, minor, major, indicating the overall severity of the alert. Determines garbage handling and LED color for this message.
timestamp INT/Unix timestamp A unix timestamp giving the time the alert was raised. Used for garbage collection and as part of the alert display.
message str A string listing the message itself. Should be succinct and escaped in the usual way.
{
 "name": "Bitcoin Miner",
 "timestamp": 00000000000,
 "errorlevel": "major",
 "message": "It's not efficient to mine cryptocurrency on a raspberry pi!",
 "read": false,
}

API endpoints should also be exposed to DELETE and/or mark as read messages by ID alone; see API Definitions