diff --git a/docs/api/index.rst b/docs/api/index.rst index 9d49f2428..f6e953b38 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -9,6 +9,7 @@ REST API general.rst version.rst + server.rst connection.rst files.rst job.rst diff --git a/docs/api/server.rst b/docs/api/server.rst new file mode 100644 index 000000000..b88292256 --- /dev/null +++ b/docs/api/server.rst @@ -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 diff --git a/docs/api/version.rst b/docs/api/version.rst index 9716139c4..61154cced 100644 --- a/docs/api/version.rst +++ b/docs/api/version.rst @@ -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). diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py index cbab8d7fd..14e42b069 100644 --- a/src/octoprint/server/api/__init__.py +++ b/src/octoprint/server/api/__init__.py @@ -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