def _call_api(self, path):
"""
Call the REST API and convert the results into JSON.
:param path: str
"""
url = '{0}://{1}:{2}/api/{3}'.format(self.plugin_config('protocol'), self.plugin_config('host'), self.plugin_config('port'), path)
self.log.debug('Issuing RabbitMQ API call to get data on ' + str(url))
try:
requests_log = logging.getLogger("requests")
requests_log.addHandler(logging.NullHandler())
requests_log.propagate = False
r = requests.get(url, auth=(self.plugin_config('username'), self.plugin_config('password')))
data = r.text
return json.loads(data)
except requests.exceptions.RequestException as e:
self.log.error('RabbitMQ API call error: {0}'.format(e))
评论列表
文章目录