Get status of Github API (#188)

This commit is contained in:
Vincent Jacques
2013-09-06 11:01:33 +02:00
parent f2feb81dae
commit c819580ce8
9 changed files with 257 additions and 10 deletions
+44
View File
@@ -40,6 +40,8 @@ import github.GithubObject
import HookDescription
import GitignoreTemplate
import Notification
import Status
import StatusMessage
DEFAULT_BASE_URL = "https://api.github.com"
@@ -369,3 +371,45 @@ class Github(object):
:return: the unpickled object
"""
return self.create_from_raw_data(*pickle.load(f))
def get_api_status(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/status.json <https://status.github.com/api>`_
:rtype: :class:`github.Status.Status`
"""
headers, attributes = self.__requester.requestJsonAndCheck(
"GET",
"/api/status.json",
cnx="status"
)
return Status.Status(self.__requester, headers, attributes, completed=True)
def get_last_api_status_message(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/last-message.json <https://status.github.com/api>`_
:rtype: :class:`github.StatusMessage.StatusMessage`
"""
headers, attributes = self.__requester.requestJsonAndCheck(
"GET",
"/api/last-message.json",
cnx="status"
)
return StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True)
def get_api_status_messages(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.
:calls: `GET /api/messages.json <https://status.github.com/api>`_
:rtype: list of :class:`github.StatusMessage.StatusMessage`
"""
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/api/messages.json",
cnx="status"
)
return [StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True) for attributes in data]