Add system actions list
This commit is contained in:
parent
38f92c6261
commit
fc1ba3d834
1 changed files with 35 additions and 0 deletions
|
|
@ -4,6 +4,11 @@ Top-level representation of enabled actions
|
||||||
|
|
||||||
from . import camera, stage, system
|
from . import camera, stage, system
|
||||||
|
|
||||||
|
from openflexure_microscope.common.flask_labthings.view import View
|
||||||
|
from openflexure_microscope.common.flask_labthings.find import current_labthing
|
||||||
|
from openflexure_microscope.common.flask_labthings.utilities import description_from_view
|
||||||
|
from openflexure_microscope.common.flask_labthings.decorators import Tag
|
||||||
|
|
||||||
_actions = {
|
_actions = {
|
||||||
"capture": {
|
"capture": {
|
||||||
"rule": "/camera/capture/",
|
"rule": "/camera/capture/",
|
||||||
|
|
@ -46,3 +51,33 @@ _actions = {
|
||||||
def enabled_root_actions():
|
def enabled_root_actions():
|
||||||
global _actions
|
global _actions
|
||||||
return {k: v for k, v in _actions.items() if v["conditions"]}
|
return {k: v for k, v in _actions.items() if v["conditions"]}
|
||||||
|
|
||||||
|
|
||||||
|
@Tag("actions")
|
||||||
|
class ActionsView(View):
|
||||||
|
def get(self):
|
||||||
|
"""
|
||||||
|
List of enabled default API actions.
|
||||||
|
|
||||||
|
This list does not include any actions added by LabThings extensions, only
|
||||||
|
those part of the default OpenFlexure Microscope API.
|
||||||
|
"""
|
||||||
|
global _actions
|
||||||
|
|
||||||
|
actions = {}
|
||||||
|
for name, action in enabled_root_actions().items():
|
||||||
|
d = {
|
||||||
|
"links": {
|
||||||
|
"self": {
|
||||||
|
"href": current_labthing().url_for(action["view_class"]),
|
||||||
|
"mimetype": "application/json",
|
||||||
|
**description_from_view(action["view_class"])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rule": action["rule"],
|
||||||
|
"view_class": str(action["view_class"]),
|
||||||
|
}
|
||||||
|
|
||||||
|
actions[name] = d
|
||||||
|
|
||||||
|
return actions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue