def _get_url(self, payload, endpoint):
"""
Performs a GET request to the PD API endpoint with the payload.
If a 200 response is received the response data is returned.
:param payload: The GET payload to send to the PD API
:param endpoint: The PagerDuty endpoint, appended to api.pagerduty.com
:return: The response data from the PD endpoint
"""
url = 'https://api.pagerduty.com/%s' % endpoint
try:
r_data = self._s.get(url, params=payload)
if r_data.status_code != 200:
logging.error('PagerDuty API returned a status code of %s'
% r_data.status_code)
return r_data.json()
except Exception, e:
logging.error(e)
评论列表
文章目录