RPyMostat Engine HTTP API¶
-
GET
/
¶ Simple informational page that returns HTML describing the program and version, where to find the source code, and links to the documentation and status page.
Served by
handle_root()
.Example request:
GET / HTTP/1.1 Host: example.com
Status Codes: - 200 OK – no error
-
GET
/v1/sensors
¶ Return application status information. Currently just returns the text string “Status: Running”.
Served by
list()
.Example request:
GET /v1/sensors HTTP/1.1 Host: example.com
Example Response:
HTTP/1.1 200 OK Content-Type: application/json {}
Status Codes: - 200 OK – no errors
-
PUT
/v1/sensors/update
¶ Update current data/readings for sensors from a remote RPyMostat-sensor device.
Served by
update()
.Example request:
PUT /v1/sensors/update HTTP/1.1 Host: example.com { 'host_id': 'myhostid', 'sensors': { '1058F50F01080047': { 'type': 'DS18S20', 'value': 24.3125, 'alias': 'some_alias', 'extra': 'arbitrary string' }, ... } }
Sensor Data Objects:
The
sensors
request attribute is itself an object (dict/hash). Keys are globally-unique sensor IDs. The value is an object with the following fields/attributes/keys:- type: (string) descriptive type, such as the sensor model
- value: (float/decimal or null) decimal current temperature reading in degrees Celsius, or null if the current reading cannot be determined.
- alias: (optional; string) a human-readable alias or name for this sensor, if the system it runs on contains this information. This is not to be confused with the name that RPyMostat maintains for the sensor.
- extra: (optional; string) arbitrary further information about this sensor, to be included in details about it.
Example Response:
HTTP/1.1 202 OK Content-Type: application/json {"status": "ok", "ids": [ "id_1", "id_2" ]}
Example Response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json {"status": "error", "error": "host_id field is missing"}
Request JSON Object: - host_id – (string) the unique identifier of the sending host
- sensors – (object) array of sensor data objects, conforming to the description above.
Response JSON Object: - status – (string) the status of the update;
accepted
ordone
- id – (int) unique identifier for the update
Status Codes: - 201 Created – update has been made in the database
-
GET
/v1/status
¶ Return application status information (mainly dependent services).
Served by
status()
.Example request:
GET /v1/status HTTP/1.1 Host: example.com
Example Response:
HTTP/1.1 200 OK Content-Type: application/json { "status": true, "dependencies": { "mongodb": true } }
Status Codes: - 200 OK – operational
- 503 Service Unavailable – non-operational