diff --git a/api_specification.md b/api_specification.md index fe095fef61dfd7649aa878153117d3e804b39cef..6f4410fbb8e7b54c34f5fa008aaa5fd371edaffe 100644 --- a/api_specification.md +++ b/api_specification.md @@ -1,4 +1,4 @@ -# Specification of the Web API for the Video-AG Website (v0.50). +# Specification of the Web API for the Video-AG Website (v0.51). ## Introduction @@ -66,12 +66,13 @@ This may be used even if the site is read-only or disabled. ###### Response: -| Field | Type | Notes | -|-----------------|----------------------------------------|---------------------------------------------------------| -| status | id_string | possible values: `available`, `readonly`, `unavailable` | -| is_debug | boolean | | -| git_commit_hash | ?string | | -| announcements | array of [announcement](#announcement) | | +| Field | Type | Notes | +|-----------------|-----------------------------------------|---------------------------------------------------------| +| status | id_string | possible values: `available`, `readonly`, `unavailable` | +| is_debug | boolean | | +| git_commit_hash | ?string | | +| server_name | string | Name of the server which is answering the request | +| announcements | array of [announcement](#announcement) | | <details> <summary>Example: <code>GET /announcement</code></summary> @@ -1519,6 +1520,10 @@ Possible `error_code`: ## Changelog +### v0.51 + +* Added `server_name` to `GET /status` + ### v0.50 * Removed `GET /announcements` diff --git a/config/api_example_config.py b/config/api_example_config.py index 0465506779ad3c1b4b70698a1a1f604814e2e844..32996cca9c500e5c7f13be36b28110e6f77bfb8e 100644 --- a/config/api_example_config.py +++ b/config/api_example_config.py @@ -1,6 +1,9 @@ # Defaults for development, do not use in production! DEBUG = True +# Name of this instance +SERVER_NAME = "dev" + # Prefix which is prepended to paths (which are saved in the database) before they are provided by the api # Must include the last / FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/" diff --git a/src/api/routes/site.py b/src/api/routes/site.py index 308190a147dfb59ecb16d60649e8f30739babf09..f9c420ddba787e04061784e3652b169cef231931 100644 --- a/src/api/routes/site.py +++ b/src/api/routes/site.py @@ -11,6 +11,8 @@ _GIT_COMMIT_HASH = os.environ.get("VIDEOAG_API_GIT_COMMIT_HASH", None) if _GIT_COMMIT_HASH is not None and len(_GIT_COMMIT_HASH) == 0: _GIT_COMMIT_HASH = None +_SERVER_NAME = api.config["SERVER_NAME"] + @api_route("/status", ["GET"], allow_while_readonly=True, allow_while_disabled=True) def api_route_status(): @@ -31,6 +33,7 @@ def api_route_status(): response = { "status": status, "is_debug": DEBUG_ENABLED, + "server_name": _SERVER_NAME, "announcements": announcements } if _GIT_COMMIT_HASH is not None: diff --git a/tests/routes/site.py b/tests/routes/site.py index 90b437eb51a540ac981bc37b1cae1c818f246306..705cbc8970d74489e88857f0c12eab9a6a90af9a 100644 --- a/tests/routes/site.py +++ b/tests/routes/site.py @@ -12,6 +12,7 @@ class SiteTest(ApiTest): None, { "status": "available", + "server_name": "dev", "announcements": [ TEST_DATA_ANNOUNCEMENT_1, TEST_DATA_ANNOUNCEMENT_2 @@ -26,6 +27,7 @@ class SiteTest(ApiTest): None, { "status": "available", + "server_name": "dev", "announcements": [ TEST_DATA_ANNOUNCEMENT_1_MOD, TEST_DATA_ANNOUNCEMENT_2_MOD,