Skip to content

Commit

Permalink
feat: get_dashboards now can retrieve the full information of all the…
Browse files Browse the repository at this point in the history
… dashboards (#154)
  • Loading branch information
tembleking authored Oct 23, 2020
1 parent 1ec76b9 commit cbf1b96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions sdcclient/monitor/_dashboards_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_view(self, name):
verify=self.ssl_verify)
return self._request_result(res)

def get_dashboards(self):
def get_dashboards(self, light=True):
'''**Description**
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.
Expand All @@ -57,7 +57,11 @@ def get_dashboards(self):
**Example**
`examples/list_dashboards.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_dashboards.py>`_
'''
res = requests.get(self.url + self._dashboards_api_endpoint, params={"light": "true"}, headers=self.hdrs,
params = {
"light": light
}
res = requests.get(self.url + self._dashboards_api_endpoint, params=params,
headers=self.hdrs,
verify=self.ssl_verify)
return self._request_result(res)

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


# NOTE: Individual panels might override the dashboard scope, the override will NOT be reset
if 'widgets' in template and template['widgets'] is not None:
for chart in template['widgets']:
Expand Down
11 changes: 9 additions & 2 deletions specs/monitor/dashboards_v3_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import os
import tempfile

from expects import expect, have_key, have_keys, contain, equal, start_with
from expects.matchers.built_in import be_false, have_len, be_empty
from expects import expect, have_key, have_keys, contain, equal, start_with, be_false, have_len, be_empty, not_
from mamba import before, it, context, after, description

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

with it("is able to list all the dashboards with the full information"):
ok, res = self.client.get_dashboards(light=False)
expect((ok, res)).to(be_successful_api_call)
expect(res).to(have_key("dashboards", contain(have_keys("name", "id",
panels=not_(be_empty),
layout=not_(be_empty),
permissions=not_(be_empty)))))

with it("is able to retrieve the test dashboard by its id"):
ok, res = self.client.get_dashboard(dashboard_id=self.test_dashboard["id"])
expect((ok, res)).to(be_successful_api_call)
Expand Down

0 comments on commit cbf1b96

Please sign in to comment.