Added proper root representation
This commit is contained in:
parent
dac50f1f3a
commit
edecc01ca1
7 changed files with 122 additions and 13 deletions
44
openflexure_microscope/api/v2/blueprints/root.py
Normal file
44
openflexure_microscope/api/v2/blueprints/root.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from flask import Blueprint, jsonify, url_for
|
||||
from openflexure_microscope import Microscope
|
||||
from openflexure_microscope.api.views import MicroscopeView
|
||||
|
||||
def root_representation(microscope_obj: Microscope):
|
||||
d = {
|
||||
"settings": {
|
||||
"description": "Writeable settings for the microscope, and attached hardware",
|
||||
"links": {"self": url_for("v2_settings_blueprint.settings")}
|
||||
},
|
||||
"status": {
|
||||
"description": "Read-only status of the microscope, and attached hardware info",
|
||||
"links": {"self": url_for("v2_status_blueprint.status")}
|
||||
},
|
||||
"plugins": {
|
||||
"description": "Top-level representation of attached and enabled plugins",
|
||||
"links": {"self": url_for("v2_plugins_blueprint.plugins")}
|
||||
},
|
||||
"captures": {
|
||||
"description": "Top-level representation of all acquired captures",
|
||||
"links": {"self": url_for("v2_captures_blueprint.captures")}
|
||||
},
|
||||
"actions": {
|
||||
"description": "Top-level representation of enabled actions",
|
||||
"links": {"self": url_for("v2_actions_blueprint.actions")}
|
||||
},
|
||||
}
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class RootAPI(MicroscopeView):
|
||||
def get(self):
|
||||
|
||||
return jsonify(root_representation(self.microscope))
|
||||
|
||||
|
||||
def construct_blueprint(microscope_obj):
|
||||
blueprint = Blueprint("root_blueprint", __name__)
|
||||
|
||||
blueprint.add_url_rule(
|
||||
"/", view_func=RootAPI.as_view("root_repr", microscope=microscope_obj)
|
||||
)
|
||||
return blueprint
|
||||
Loading…
Add table
Add a link
Reference in a new issue