Skip to content

Commit 45f236a

Browse files
committed
add the ability to add annotations when creating dashboards
1 parent 187b452 commit 45f236a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

sdcclient/_client.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def filter_fn(panel):
603603
else:
604604
return [False, 'Not found']
605605

606-
def create_dashboard_from_template(self, newdashname, template, scope=[], shared=False):
606+
def create_dashboard_from_template(self, newdashname, template, scope=[], shared=False, annotations={}):
607607
if scope is None:
608608
scope = []
609609

@@ -686,9 +686,11 @@ def create_dashboard_from_template(self, newdashname, template, scope=[], shared
686686
chart['groupId'] = None
687687

688688
if 'annotations' in template:
689-
template['annotations']['createdByEngine'] = True
689+
template['annotations'].update(annotations)
690690
else:
691-
template['annotations'] = {'createdByEngine': True}
691+
template['annotations'] = annotations
692+
693+
template['annotations']['createdByEngine'] = True
692694

693695
ddboard = {'dashboard': template}
694696

@@ -701,7 +703,7 @@ def create_dashboard_from_template(self, newdashname, template, scope=[], shared
701703
else:
702704
return [True, res.json()]
703705

704-
def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False):
706+
def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False, annotations={}):
705707
#
706708
# Find our template view
707709
#
@@ -717,9 +719,9 @@ def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False
717719
#
718720
# Create the new dashboard
719721
#
720-
return self.create_dashboard_from_template(newdashname, view, filter, shared)
722+
return self.create_dashboard_from_template(newdashname, view, filter, shared, annotations)
721723

722-
def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False):
724+
def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False, annotations={}):
723725
#
724726
# Get the list of dashboards from the server
725727
#
@@ -746,9 +748,9 @@ def create_dashboard_from_dashboard(self, newdashname, templatename, filter, sha
746748
#
747749
# Create the dashboard
748750
#
749-
return self.create_dashboard_from_template(newdashname, dboard, filter, shared)
751+
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, annotations)
750752

751-
def create_dashboard_from_file(self, newdashname, filename, filter, shared=False):
753+
def create_dashboard_from_file(self, newdashname, filename, filter, shared=False, annotations={}):
752754
#
753755
# Load the Dashboard
754756
#
@@ -761,7 +763,7 @@ def create_dashboard_from_file(self, newdashname, filename, filter, shared=False
761763
#
762764
# Create the new dashboard
763765
#
764-
return self.create_dashboard_from_template(newdashname, dboard, filter, shared)
766+
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, annotations)
765767

766768
def delete_dashboard(self, dashboard):
767769
if 'id' not in dashboard:

0 commit comments

Comments
 (0)