platypush/platypush/plugins/config/__init__.py

64 lines
1.3 KiB
Python
Raw Normal View History

2020-11-30 20:57:00 +01:00
import json
2020-11-21 01:12:08 +01:00
from platypush import Config
2020-11-30 20:57:00 +01:00
from platypush.message import Message
2020-11-21 01:12:08 +01:00
from platypush.plugins import Plugin, action
class ConfigPlugin(Plugin):
"""
This plugin can be used to programmatically access the application configuration.
"""
2020-11-21 01:12:08 +01:00
@action
def get(self) -> dict:
2021-11-17 23:59:17 +01:00
"""
Get the current configuration.
"""
2020-11-21 01:12:08 +01:00
return Config.get()
2020-11-30 20:57:00 +01:00
@action
def get_plugins(self) -> dict:
2021-11-17 23:59:17 +01:00
"""
Get the configured plugins.
"""
2020-11-30 20:57:00 +01:00
return Config.get_plugins()
@action
def get_backends(self) -> dict:
2021-11-17 23:59:17 +01:00
"""
Get the configured backends.
"""
2020-11-30 20:57:00 +01:00
return Config.get_backends()
@action
def get_procedures(self) -> dict:
2021-11-17 23:59:17 +01:00
"""
Get the configured procedures.
"""
2020-11-30 20:57:00 +01:00
return json.loads(json.dumps(Config.get_procedures(), cls=Message.Encoder))
2020-11-21 01:12:08 +01:00
@action
def dashboards(self) -> dict:
2021-11-17 23:59:17 +01:00
"""
Get the configured dashboards.
"""
2020-11-21 01:12:08 +01:00
return Config.get_dashboards()
@action
def get_dashboard(self, name: str) -> str:
2021-11-17 23:59:17 +01:00
"""
Get a dashboard configuration by name.
"""
2020-11-21 01:12:08 +01:00
return Config.get_dashboard(name)
2020-11-30 20:57:00 +01:00
@action
def get_device_id(self) -> str:
2021-11-17 23:59:17 +01:00
"""
Get the configured ``device_id``.
"""
2020-11-30 20:57:00 +01:00
return Config.get('device_id')
2020-11-21 01:12:08 +01:00
# vim:sw=4:ts=4:et: