about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-09-01 11:59:47 -0500
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-09-01 11:59:47 -0500
commit5cef7f717b81f46e620280ee1ae9dfc44af01bd2 (patch)
treece256c068de2404efceeb1e483d7a1890b70526c
parentde676ab08ecf8502ffd45fb0ada68803e5e62124 (diff)
downloadgenenetwork3-5cef7f717b81f46e620280ee1ae9dfc44af01bd2.tar.gz
Add the root endpoint and documentation to help use the API.
Add a root endpoint for the GN3 system. Use the HATEOAS paradigm (or
adjacent) to help with discovery of the API.
-rw-r--r--gn3/api/general.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/gn3/api/general.py b/gn3/api/general.py
index 8b57f23..7ec047f 100644
--- a/gn3/api/general.py
+++ b/gn3/api/general.py
@@ -1,22 +1,41 @@
 """General API endpoints.  Put endpoints that can't be grouped together nicely
 here."""
 import os
-from flask import Blueprint
-from flask import current_app
-from flask import jsonify
-from flask import request
+from flask import (url_for,
+                   request,
+                   jsonify,
+                   Blueprint,
+                   current_app,
+                   make_response)
 
 from gn3.fs_helpers import extract_uploaded_file
 from gn3.commands import run_cmd
 
 
 general = Blueprint("general", __name__)
+_WELCOME_MESSAGE = """Welcome to the GeneNetwork API service.
+
+The 'v1' endpoints provide a hierarchical view into the data present in the
+GeneNetwork system. Follow the v1 link for available resources."""
+
+
+@general.route("/")
+def index():
+    """Entry-point to the API. Give basic information on available routes."""
+    return make_response(jsonify({
+        "message": _WELCOME_MESSAGE,
+        "links": {
+            "self": url_for("general.index"),
+            "v1": url_for("v1.index")
+        }}), 200)
+
 
 @general.route("/version")
 def version():
     """Get API version."""
     return jsonify("1.0")
 
+
 @general.route("/metadata/upload/", methods=["POST"],
                strict_slashes=False)
 def upload_metadata_with_no_token():