Last active
September 8, 2016 21:56
-
-
Save flyingclimber/1cc8993d9df321040a886e051db0b909 to your computer and use it in GitHub Desktop.
Report on outage lengths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
from dateutil import parser | |
OUATH_KEY = 'X' | |
PAGE_ID = 'X' | |
def send_request(): | |
try: | |
response = requests.get( | |
url="https://api.statuspage.io/v1/pages/{}/incidents.json".format(PAGE_ID), | |
headers={ | |
"Authorization": "OAuth {}".format(OUATH_KEY), | |
}, | |
) | |
return response.content | |
except requests.exceptions.RequestException: | |
print 'HTTP Request failed' | |
if __name__ == "__main__": | |
res = send_request() | |
parsed = json.loads(res) | |
for item in parsed: | |
begin = parser.parse(item['created_at']) | |
end = parser.parse(item['resolved_at']) | |
print '{} | {} - {} | {} | {} '.format( | |
end - begin, | |
begin.strftime('%m-%d-%Y %H:%M'), | |
end.strftime('%m-%d-%Y %H:%M'), | |
item['name'], | |
item['status'] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment