Loading openflexure_microscope/api/app.py +3 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,9 @@ app.register_blueprint(task_blueprint, url_prefix=uri("/task", "v1")) ### V2 # Root routes v2_root_blueprint = v2.blueprints.root.construct_blueprint(api_microscope) app.register_blueprint(v2_root_blueprint, url_prefix=uri("/", "v2")) v2_stream_blueprint = v2.blueprints.stream.construct_blueprint(api_microscope) app.register_blueprint(v2_stream_blueprint, url_prefix=uri("/", "v2")) Loading openflexure_microscope/api/v2/blueprints/__init__.py +1 −1 Original line number Diff line number Diff line from . import captures, settings, status, tasks, stream, plugins, actions from . import root, captures, settings, status, tasks, stream, plugins, actions openflexure_microscope/api/v2/blueprints/actions/__init__.py +9 −4 Original line number Diff line number Diff line from flask import Blueprint, url_for, jsonify from sys import platform from openflexure_microscope.api.views import MicroscopeView from . import camera, stage, system _actions = { Loading Loading @@ -64,11 +66,14 @@ def actions_representation(): return actions class ActionsAPI(MicroscopeView): def get(self): return jsonify(actions_representation()) def construct_blueprint(microscope_obj): global _actions blueprint = Blueprint("actions_blueprint", __name__) blueprint = Blueprint("v2_actions_blueprint", __name__) # For each enabled action route defined in our dictionary above for name, action in enabled_actions().items(): Loading @@ -78,8 +83,8 @@ def construct_blueprint(microscope_obj): view_func=action["view_class"].as_view(name, microscope=microscope_obj), ) @blueprint.route("/") def representation(): return jsonify(actions_representation()) blueprint.add_url_rule( "/", view_func=ActionsAPI.as_view("actions", microscope=microscope_obj) ) return blueprint openflexure_microscope/api/v2/blueprints/captures.py +2 −2 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ class TagsAPI(MicroscopeView): def construct_blueprint(microscope_obj): blueprint = Blueprint("captures_blueprint", __name__) blueprint = Blueprint("v2_captures_blueprint", __name__) # Tag routes blueprint.add_url_rule( Loading @@ -405,6 +405,6 @@ def construct_blueprint(microscope_obj): ) blueprint.add_url_rule( "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj) "/", view_func=ListAPI.as_view("captures", microscope=microscope_obj) ) return blueprint openflexure_microscope/api/v2/blueprints/plugins.py +13 −3 Original line number Diff line number Diff line from openflexure_microscope.plugins import PluginLoader, MicroscopePlugin from openflexure_microscope.api.views import MicroscopeViewPlugin from flask import Blueprint, jsonify from flask import Blueprint, jsonify, url_for from openflexure_microscope.api.views import MicroscopeView import copy Loading @@ -27,6 +27,11 @@ def plugins_representation(plugin_loader_object: PluginLoader): "routes": plugin["routes"], "form": plugin["form"], } for route in d["routes"]: route_id = route["id"] uri = url_for(f"v2_plugins_blueprint.{route_id}") route["links"]["self"] = uri plugins.append(d) return plugins Loading @@ -51,7 +56,7 @@ class PluginFormAPI(MicroscopeView): def construct_blueprint(microscope_obj): blueprint = Blueprint("plugins_blueprint", __name__) blueprint = Blueprint("v2_plugins_blueprint", __name__) # Create a base route to return plugin API forms, if any exist blueprint.add_url_rule( Loading Loading @@ -110,7 +115,12 @@ def construct_blueprint(microscope_obj): ) # Add route to the plugin representation dictionary plugin_representation["routes"].append(full_view_route) route_representation = { "id": plugin_route_id, "route": full_view_route, "links": {}, } plugin_representation["routes"].append(route_representation) else: warnings.warn( Loading Loading
openflexure_microscope/api/app.py +3 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,9 @@ app.register_blueprint(task_blueprint, url_prefix=uri("/task", "v1")) ### V2 # Root routes v2_root_blueprint = v2.blueprints.root.construct_blueprint(api_microscope) app.register_blueprint(v2_root_blueprint, url_prefix=uri("/", "v2")) v2_stream_blueprint = v2.blueprints.stream.construct_blueprint(api_microscope) app.register_blueprint(v2_stream_blueprint, url_prefix=uri("/", "v2")) Loading
openflexure_microscope/api/v2/blueprints/__init__.py +1 −1 Original line number Diff line number Diff line from . import captures, settings, status, tasks, stream, plugins, actions from . import root, captures, settings, status, tasks, stream, plugins, actions
openflexure_microscope/api/v2/blueprints/actions/__init__.py +9 −4 Original line number Diff line number Diff line from flask import Blueprint, url_for, jsonify from sys import platform from openflexure_microscope.api.views import MicroscopeView from . import camera, stage, system _actions = { Loading Loading @@ -64,11 +66,14 @@ def actions_representation(): return actions class ActionsAPI(MicroscopeView): def get(self): return jsonify(actions_representation()) def construct_blueprint(microscope_obj): global _actions blueprint = Blueprint("actions_blueprint", __name__) blueprint = Blueprint("v2_actions_blueprint", __name__) # For each enabled action route defined in our dictionary above for name, action in enabled_actions().items(): Loading @@ -78,8 +83,8 @@ def construct_blueprint(microscope_obj): view_func=action["view_class"].as_view(name, microscope=microscope_obj), ) @blueprint.route("/") def representation(): return jsonify(actions_representation()) blueprint.add_url_rule( "/", view_func=ActionsAPI.as_view("actions", microscope=microscope_obj) ) return blueprint
openflexure_microscope/api/v2/blueprints/captures.py +2 −2 Original line number Diff line number Diff line Loading @@ -378,7 +378,7 @@ class TagsAPI(MicroscopeView): def construct_blueprint(microscope_obj): blueprint = Blueprint("captures_blueprint", __name__) blueprint = Blueprint("v2_captures_blueprint", __name__) # Tag routes blueprint.add_url_rule( Loading @@ -405,6 +405,6 @@ def construct_blueprint(microscope_obj): ) blueprint.add_url_rule( "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj) "/", view_func=ListAPI.as_view("captures", microscope=microscope_obj) ) return blueprint
openflexure_microscope/api/v2/blueprints/plugins.py +13 −3 Original line number Diff line number Diff line from openflexure_microscope.plugins import PluginLoader, MicroscopePlugin from openflexure_microscope.api.views import MicroscopeViewPlugin from flask import Blueprint, jsonify from flask import Blueprint, jsonify, url_for from openflexure_microscope.api.views import MicroscopeView import copy Loading @@ -27,6 +27,11 @@ def plugins_representation(plugin_loader_object: PluginLoader): "routes": plugin["routes"], "form": plugin["form"], } for route in d["routes"]: route_id = route["id"] uri = url_for(f"v2_plugins_blueprint.{route_id}") route["links"]["self"] = uri plugins.append(d) return plugins Loading @@ -51,7 +56,7 @@ class PluginFormAPI(MicroscopeView): def construct_blueprint(microscope_obj): blueprint = Blueprint("plugins_blueprint", __name__) blueprint = Blueprint("v2_plugins_blueprint", __name__) # Create a base route to return plugin API forms, if any exist blueprint.add_url_rule( Loading Loading @@ -110,7 +115,12 @@ def construct_blueprint(microscope_obj): ) # Add route to the plugin representation dictionary plugin_representation["routes"].append(full_view_route) route_representation = { "id": plugin_route_id, "route": full_view_route, "links": {}, } plugin_representation["routes"].append(route_representation) else: warnings.warn( Loading