✨ New /api/server endpoint incl. safe mode info

This commit is contained in:
Gina Häußge committed 2020-10-01 15:53:18 +02:00
1 parent 26151b3c42
commit 8a3a4ff653
4 files changed
+45 -6

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ REST API
general.rst
version.rst
server.rst
connection.rst
files.rst
job.rst
+34
View File
@@ -0,0 +1,34 @@
.. _sec-api-server:
******************
Server information
******************
.. http:get:: /api/server
Retrieve information regarding server status. Returns a JSON object with two keys, ``version`` containing
the server version and ``safe_mode`` containing one of ``settings``, ``incomplete_startup`` or ``flag``
to indicate the reason the server is running in safe mode, or the boolean value of ``false`` if it's not
running in safe mode.
**Example Request**
.. sourcecode:: http
GET /api/server HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
**Example Response**
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"server": "1.5.0",
"safe_mode": "incomplete_startup"
}
:statuscode 200: No error
+1 -1
View File
@@ -6,7 +6,7 @@ Version information
.. http:get:: /api/version
Retrieve information regarding server and API version. Returns a JSON object with two keys, ``api`` containing
Retrieve information regarding server and API version. Returns a JSON object with three keys, ``api`` containing
the API version, ``server`` containing the server version, ``text`` containing the server version including
the prefix ``OctoPrint `` (to determine that this is indeed a genuine OctoPrint instance).
+9 -5
View File
@@ -198,13 +198,17 @@ def apiPrinterState():
@api.route("/version", methods=["GET"])
@Permissions.STATUS.require(403)
def apiVersion():
return jsonify({
"server": octoprint.server.VERSION,
"api": VERSION,
"text": "OctoPrint {}".format(octoprint.server.DISPLAY_VERSION)
})
return jsonify(server=octoprint.server.VERSION,
api=VERSION,
text="OctoPrint {}".format(octoprint.server.DISPLAY_VERSION))
@api.route("/server", methods=["GET"])
@Permissions.STATUS.require(403)
def serverStatus():
return jsonify(version=octoprint.server.VERSION,
safemode=octoprint.server.safe_mode)
#~~ Login/user handling