From 5e72ba9869c9bc244b94b5d418d8ee1e9a3639c7 Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Mon, 9 Nov 2020 12:45:33 +0100 Subject: [PATCH] fix: Solve get_dashboards with light retrieval (#167) --- sdcclient/monitor/_dashboards_v3.py | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sdcclient/monitor/_dashboards_v3.py b/sdcclient/monitor/_dashboards_v3.py index d809ec3d..0425dc34 100644 --- a/sdcclient/monitor/_dashboards_v3.py +++ b/sdcclient/monitor/_dashboards_v3.py @@ -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()] @@ -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): @@ -56,11 +56,11 @@ def get_dashboards(self, light=True): `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): @@ -74,7 +74,7 @@ def update_dashboard(self, dashboard_data): `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): @@ -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): @@ -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 @@ -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) @@ -377,7 +377,7 @@ def get_dashboard(self, dashboard_id): `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): @@ -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] @@ -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"): @@ -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]