Merge "Handle API returning dict instead of list"
This commit is contained in:
commit
78de788e52
@ -57,7 +57,7 @@ class AlarmDefinitionsManager(monasca_manager.MonascaManager):
|
|||||||
# print url_str
|
# print url_str
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', url_str, headers=newheaders)
|
'GET', url_str, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def delete(self, **kwargs):
|
def delete(self, **kwargs):
|
||||||
"""Delete a specific alarm definition."""
|
"""Delete a specific alarm definition."""
|
||||||
|
@ -49,7 +49,7 @@ class AlarmsManager(monasca_manager.MonascaManager):
|
|||||||
# print url_str
|
# print url_str
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', url_str, headers=newheaders)
|
'GET', url_str, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def delete(self, **kwargs):
|
def delete(self, **kwargs):
|
||||||
"""Delete a specific alarm."""
|
"""Delete a specific alarm."""
|
||||||
@ -86,7 +86,7 @@ class AlarmsManager(monasca_manager.MonascaManager):
|
|||||||
del kwargs['alarm_id']
|
del kwargs['alarm_id']
|
||||||
resp, body = self.client.json_request('GET', url_str,
|
resp, body = self.client.json_request('GET', url_str,
|
||||||
headers=newheaders)
|
headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def history_list(self, **kwargs):
|
def history_list(self, **kwargs):
|
||||||
"""History list of alarm state."""
|
"""History list of alarm state."""
|
||||||
@ -99,4 +99,4 @@ class AlarmsManager(monasca_manager.MonascaManager):
|
|||||||
url_str = url_str + '?%s' % urlutils.urlencode(kwargs, True)
|
url_str = url_str + '?%s' % urlutils.urlencode(kwargs, True)
|
||||||
resp, body = self.client.json_request('GET', url_str,
|
resp, body = self.client.json_request('GET', url_str,
|
||||||
headers=newheaders)
|
headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
@ -58,7 +58,7 @@ class MetricsManager(monasca_manager.MonascaManager):
|
|||||||
# print url_str
|
# print url_str
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', url_str, headers=newheaders)
|
'GET', url_str, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def list_measurements(self, **kwargs):
|
def list_measurements(self, **kwargs):
|
||||||
"""Get a list of measurements based on metric definition filters."""
|
"""Get a list of measurements based on metric definition filters."""
|
||||||
@ -73,7 +73,7 @@ class MetricsManager(monasca_manager.MonascaManager):
|
|||||||
# print url_str
|
# print url_str
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', url_str, headers=newheaders)
|
'GET', url_str, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def list_statistics(self, **kwargs):
|
def list_statistics(self, **kwargs):
|
||||||
"""Get a list of measurement statistics based on metric def filters."""
|
"""Get a list of measurement statistics based on metric def filters."""
|
||||||
@ -88,4 +88,4 @@ class MetricsManager(monasca_manager.MonascaManager):
|
|||||||
# print url_str
|
# print url_str
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', url_str, headers=newheaders)
|
'GET', url_str, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
@ -48,7 +48,7 @@ class NotificationsManager(monasca_manager.MonascaManager):
|
|||||||
newheaders = self.get_headers()
|
newheaders = self.get_headers()
|
||||||
resp, body = self.client.json_request(
|
resp, body = self.client.json_request(
|
||||||
'GET', self.base_url, headers=newheaders)
|
'GET', self.base_url, headers=newheaders)
|
||||||
return body
|
return body['elements'] if type(body) is dict else body
|
||||||
|
|
||||||
def delete(self, **kwargs):
|
def delete(self, **kwargs):
|
||||||
"""Delete a notification."""
|
"""Delete a notification."""
|
||||||
|
Loading…
Reference in New Issue
Block a user