Skip to content

Commit cbf1b96

Browse files
authored
feat: get_dashboards now can retrieve the full information of all the dashboards (#154)
1 parent 1ec76b9 commit cbf1b96

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

sdcclient/monitor/_dashboards_v3.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_view(self, name):
4747
verify=self.ssl_verify)
4848
return self._request_result(res)
4949

50-
def get_dashboards(self):
50+
def get_dashboards(self, light=True):
5151
'''**Description**
5252
Return the list of dashboards available under the given user account. This includes the dashboards created by the user and the ones shared with her by other users.
5353
@@ -57,7 +57,11 @@ def get_dashboards(self):
5757
**Example**
5858
`examples/list_dashboards.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_dashboards.py>`_
5959
'''
60-
res = requests.get(self.url + self._dashboards_api_endpoint, params={"light": "true"}, headers=self.hdrs,
60+
params = {
61+
"light": light
62+
}
63+
res = requests.get(self.url + self._dashboards_api_endpoint, params=params,
64+
headers=self.hdrs,
6165
verify=self.ssl_verify)
6266
return self._request_result(res)
6367

@@ -281,7 +285,6 @@ def create_dashboard_from_template(self, dashboard_name, template, scope=None, s
281285
return ok, converted_scope
282286
template['scopeExpressionList'] = converted_scope
283287

284-
285288
# NOTE: Individual panels might override the dashboard scope, the override will NOT be reset
286289
if 'widgets' in template and template['widgets'] is not None:
287290
for chart in template['widgets']:

specs/monitor/dashboards_v3_spec.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import os
33
import tempfile
44

5-
from expects import expect, have_key, have_keys, contain, equal, start_with
6-
from expects.matchers.built_in import be_false, have_len, be_empty
5+
from expects import expect, have_key, have_keys, contain, equal, start_with, be_false, have_len, be_empty, not_
76
from mamba import before, it, context, after, description
87

98
from sdcclient import SdMonitorClient
@@ -76,6 +75,14 @@ def create_test_dashboard(self):
7675
expect((ok, res)).to(be_successful_api_call)
7776
expect(res).to(have_key("dashboards", contain(have_keys("name", "id"))))
7877

78+
with it("is able to list all the dashboards with the full information"):
79+
ok, res = self.client.get_dashboards(light=False)
80+
expect((ok, res)).to(be_successful_api_call)
81+
expect(res).to(have_key("dashboards", contain(have_keys("name", "id",
82+
panels=not_(be_empty),
83+
layout=not_(be_empty),
84+
permissions=not_(be_empty)))))
85+
7986
with it("is able to retrieve the test dashboard by its id"):
8087
ok, res = self.client.get_dashboard(dashboard_id=self.test_dashboard["id"])
8188
expect((ok, res)).to(be_successful_api_call)

0 commit comments

Comments
 (0)