diff --git a/platypush/plugins/inspect.py b/platypush/plugins/inspect.py index 2805feb95..d41d622e1 100644 --- a/platypush/plugins/inspect.py +++ b/platypush/plugins/inspect.py @@ -11,6 +11,7 @@ import platypush.message.event import platypush.message.response from platypush.backend import Backend +from platypush.config import Config from platypush.plugins import Plugin, action from platypush.message.event import Event from platypush.message.response import Response @@ -36,6 +37,16 @@ class Model: return docutils.core.publish_parts(doc, writer_name='html')['html_body'] +class ProcedureEncoder(json.JSONEncoder): + def default(self, o): + if callable(o): + return { + 'type': 'native_function', + } + + return super().default(o) + + class BackendModel(Model): def __init__(self, backend, prefix='', html_doc: bool = False): self.name = backend.__module__[len(prefix):] @@ -321,5 +332,12 @@ class InspectPlugin(Plugin): for package, events in self._responses.items() }) + @action + def get_procedures(self) -> dict: + """ + Get the list of procedures installed on the device. + """ + return json.loads(json.dumps(Config.get_procedures(), cls=ProcedureEncoder)) + # vim:sw=4:ts=4:et: