Skip to content

Commit 3bb074f

Browse files
nikodemasamotl
authored andcommitted
Add channels option
1 parent 09b0909 commit 3bb074f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

grafana_wtf/commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def run():
3939
grafana-wtf [options] log [<dashboard_uid>] [--number=<count>] [--head=<count>] [--tail=<count>] [--reverse] [--sql=<sql>]
4040
grafana-wtf [options] plugins list [--id=]
4141
grafana-wtf [options] plugins status [--id=]
42+
grafana-wtf [options] channels [--id=]
4243
grafana-wtf --version
4344
grafana-wtf (-h | --help)
4445
@@ -336,3 +337,10 @@ def run():
336337
else:
337338
raise DocoptExit('Subcommand "plugins" only provides "list" and "status"')
338339
output_results(output_format, response)
340+
341+
if options.channels:
342+
if options.id:
343+
response = engine.channels_list_by_id(options.id)
344+
else:
345+
response = engine.channels_list()
346+
output_results(output_format, response)

grafana_wtf/core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ def plugins_status_by_id(self, plugin_id):
539539
plugin = self.plugins_list_by_id(plugin_id)
540540
return self.get_plugin_status(plugin)
541541

542+
def channels_list(self):
543+
return self.grafana.notifications.lookup_channels()
544+
545+
def channels_list_by_id(self, channel_id):
546+
channel = self.grafana.notifications.get_channel_by_id(channel_id)
547+
return channel
548+
542549

543550
class Indexer:
544551
def __init__(self, engine: GrafanaWtf):

0 commit comments

Comments
 (0)