Skip to content

feat: get_dashboards now can retrieve full information #154

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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