Skip to content

fix: Solve get_dashboards with light retrieval #167

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 1 commit into from
Nov 9, 2020
Merged
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
30 changes: 15 additions & 15 deletions sdcclient/monitor/_dashboards_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=T

def get_views_list(self):
res = self.http.get(self.url + self._default_dashboards_api_endpoint, headers=self.hdrs,
verify=self.ssl_verify)
verify=self.ssl_verify)
if not self._checkResponse(res):
return [False, self.lasterr]
return [True, res.json()]
Expand All @@ -42,7 +42,7 @@ def get_view(self, name):
return [False, 'view ' + name + ' not found']

res = self.http.get(self.url + self._default_dashboards_api_endpoint + '/' + id, headers=self.hdrs,
verify=self.ssl_verify)
verify=self.ssl_verify)
return self._request_result(res)

def get_dashboards(self, light=True):
Expand All @@ -56,11 +56,11 @@ def get_dashboards(self, light=True):
`examples/list_dashboards.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_dashboards.py>`_
'''
params = {
"light": light
"light": "true" if light else "false"
}
res = self.http.get(self.url + self._dashboards_api_endpoint, params=params,
headers=self.hdrs,
verify=self.ssl_verify)
headers=self.hdrs,
verify=self.ssl_verify)
return self._request_result(res)

def update_dashboard(self, dashboard_data):
Expand All @@ -74,7 +74,7 @@ def update_dashboard(self, dashboard_data):
`examples/dashboard_basic_crud.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard_basic_crud.py>`_
'''
res = self.http.put(self.url + self._dashboards_api_endpoint + "/" + str(dashboard_data['id']),
headers=self.hdrs, verify=self.ssl_verify, data=json.dumps({'dashboard': dashboard_data}))
headers=self.hdrs, verify=self.ssl_verify, data=json.dumps({'dashboard': dashboard_data}))
return self._request_result(res)

def find_dashboard_by(self, name=None):
Expand Down Expand Up @@ -112,8 +112,8 @@ def create_dashboard_with_configuration(self, configuration):
del configuration_clone['version']

res = self.http.post(self.url + self._dashboards_api_endpoint, headers=self.hdrs,
data=json.dumps({'dashboard': configuration_clone}),
verify=self.ssl_verify)
data=json.dumps({'dashboard': configuration_clone}),
verify=self.ssl_verify)
return self._request_result(res)

def create_dashboard(self, name):
Expand Down Expand Up @@ -145,8 +145,8 @@ def create_dashboard(self, name):
# Create the new dashboard
#
res = self.http.post(self.url + self._dashboards_api_endpoint, headers=self.hdrs,
data=json.dumps({'dashboard': dashboard_configuration}),
verify=self.ssl_verify)
data=json.dumps({'dashboard': dashboard_configuration}),
verify=self.ssl_verify)
return self._request_result(res)

# TODO COVER
Expand Down Expand Up @@ -305,7 +305,7 @@ def create_dashboard_from_template(self, dashboard_name, template, scope=None, s
# Create the new dashboard
#
res = self.http.post(self.url + self._dashboards_api_endpoint, headers=self.hdrs,
data=json.dumps({'dashboard': template}), verify=self.ssl_verify)
data=json.dumps({'dashboard': template}), verify=self.ssl_verify)

return self._request_result(res)

Expand Down Expand Up @@ -377,7 +377,7 @@ def get_dashboard(self, dashboard_id):
`examples/dashboard_basic_crud.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard_basic_crud.py>`_
'''
res = self.http.get(self.url + self._dashboards_api_endpoint + "/" + str(dashboard_id), headers=self.hdrs,
verify=self.ssl_verify)
verify=self.ssl_verify)
return self._request_result(res)

def create_dashboard_from_dashboard(self, newdashname, templatename, filter=None, shared=False, public=False):
Expand All @@ -401,7 +401,7 @@ def create_dashboard_from_dashboard(self, newdashname, templatename, filter=None
# Get the list of dashboards from the server
#
dashboard = self.http.get(self.url + self._dashboards_api_endpoint, params={"light": "true"}, headers=self.hdrs,
verify=self.ssl_verify)
verify=self.ssl_verify)
if not self._checkResponse(dashboard):
return [False, self.lasterr]

Expand Down Expand Up @@ -432,7 +432,7 @@ def create_dashboard_from_dashboard(self, newdashname, templatename, filter=None
def favorite_dashboard(self, dashboard_id, favorite):
data = {"dashboard": {"favorite": favorite}}
res = self.http.patch(self.url + self._dashboards_api_endpoint + "/" + str(dashboard_id), json=data,
headers=self.hdrs, verify=self.ssl_verify)
headers=self.hdrs, verify=self.ssl_verify)
return self._request_result(res)

def share_dashboard_with_all_teams(self, dashboard, mode="r"):
Expand Down Expand Up @@ -548,7 +548,7 @@ def delete_dashboard(self, dashboard):
return [False, "Invalid dashboard format"]

res = self.http.delete(self.url + self._dashboards_api_endpoint + '/' + str(dashboard['id']), headers=self.hdrs,
verify=self.ssl_verify)
verify=self.ssl_verify)
if not self._checkResponse(res):
return [False, self.lasterr]

Expand Down