Skip to content

Commit a8df369

Browse files
author
Davide Schiera
authored
Add parameter to control public sharing option (#75)
1 parent 8ff2603 commit a8df369

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sdcclient/_client.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ def filter_fn(panel):
15781578
else:
15791579
return [False, 'Not found']
15801580

1581-
def create_dashboard_from_template(self, dashboard_name, template, scope, shared=False, annotations={}):
1581+
def create_dashboard_from_template(self, dashboard_name, template, scope, shared=False, public=False, annotations={}):
15821582
if scope is not None:
15831583
if isinstance(scope, basestring) == False:
15841584
return [False, 'Invalid scope format: Expected a string']
@@ -1590,8 +1590,8 @@ def create_dashboard_from_template(self, dashboard_name, template, scope, shared
15901590
template['version'] = None
15911591
template['schema'] = 1
15921592
template['name'] = dashboard_name
1593-
template['isShared'] = shared # make sure the dashboard is not shared
1594-
template['isPublic'] = False # reset public sharing
1593+
template['isShared'] = shared
1594+
template['isPublic'] = public
15951595
template['publicToken'] = None
15961596

15971597
#
@@ -1622,7 +1622,7 @@ def create_dashboard_from_template(self, dashboard_name, template, scope, shared
16221622
else:
16231623
return [True, res.json()]
16241624

1625-
def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False, annotations={}):
1625+
def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False, public=False, annotations={}):
16261626
'''**Description**
16271627
Create a new dasboard using one of the Sysdig Monitor views as a template. You will be able to define the scope of the new dashboard.
16281628
@@ -1631,6 +1631,7 @@ def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False
16311631
- **viewname**: the name of the view to use as the template for the new dashboard. This corresponds to the name that the view has in the Explore page.
16321632
- **filter**: a boolean expression combining Sysdig Monitor segmentation criteria that defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
16331633
- **shared**: if set to True, the new dashboard will be a shared one.
1634+
- **public**: if set to True, the new dashboard will be shared with public token.
16341635
- **annotations**: an optional dictionary of custom properties that you can associate to this dashboard for automation or management reasons
16351636
16361637
**Success Return Value**
@@ -1654,9 +1655,9 @@ def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False
16541655
#
16551656
# Create the new dashboard
16561657
#
1657-
return self.create_dashboard_from_template(newdashname, view, filter, shared, annotations)
1658+
return self.create_dashboard_from_template(newdashname, view, filter, shared, public, annotations)
16581659

1659-
def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False, annotations={}):
1660+
def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False, public=False, annotations={}):
16601661
'''**Description**
16611662
Create a new dasboard using one of the existing dashboards as a template. You will be able to define the scope of the new dasboard.
16621663
@@ -1665,6 +1666,7 @@ def create_dashboard_from_dashboard(self, newdashname, templatename, filter, sha
16651666
- **viewname**: the name of the dasboard to use as the template, as it appears in the Sysdig Monitor dashboard page.
16661667
- **filter**: a boolean expression combining Sysdig Monitor segmentation criteria defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
16671668
- **shared**: if set to True, the new dashboard will be a shared one.
1669+
- **public**: if set to True, the new dashboard will be shared with public token.
16681670
- **annotations**: an optional dictionary of custom properties that you can associate to this dashboard for automation or management reasons
16691671
16701672
**Success Return Value**
@@ -1699,9 +1701,9 @@ def create_dashboard_from_dashboard(self, newdashname, templatename, filter, sha
16991701
#
17001702
# Create the dashboard
17011703
#
1702-
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, annotations)
1704+
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, public, annotations)
17031705

1704-
def create_dashboard_from_file(self, newdashname, filename, filter, shared=False, annotations={}):
1706+
def create_dashboard_from_file(self, newdashname, filename, filter, shared=False, public=False, annotations={}):
17051707
'''
17061708
**Description**
17071709
Create a new dasboard using a dashboard template saved to disk.
@@ -1711,6 +1713,7 @@ def create_dashboard_from_file(self, newdashname, filename, filter, shared=False
17111713
- **filename**: name of a file containing a JSON object for a dashboard in the format of an array element returned by :func:`~SdcClient.get_dashboards`
17121714
- **filter**: a boolean expression combining Sysdig Monitor segmentation criteria defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
17131715
- **shared**: if set to True, the new dashboard will be a shared one.
1716+
- **public**: if set to True, the new dashboard will be shared with public token.
17141717
- **annotations**: an optional dictionary of custom properties that you can associate to this dashboard for automation or management reasons
17151718
17161719
**Success Return Value**
@@ -1731,7 +1734,7 @@ def create_dashboard_from_file(self, newdashname, filename, filter, shared=False
17311734
#
17321735
# Create the new dashboard
17331736
#
1734-
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, annotations)
1737+
return self.create_dashboard_from_template(newdashname, dboard, filter, shared, public, annotations)
17351738

17361739
def delete_dashboard(self, dashboard):
17371740
'''**Description**

0 commit comments

Comments
 (0)