Skip to content

Commit 710181f

Browse files
committed
Merge pull request sigmavirus24#224 from sigmavirus24/pages-api
Pages API
2 parents 413bd5d + 8da403e commit 710181f

File tree

7 files changed

+130
-0
lines changed

7 files changed

+130
-0
lines changed

github3/repos/pages.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from github3.models import GitHubObject
2+
3+
4+
class PagesInfo(GitHubObject):
5+
def __init__(self, info):
6+
super(PagesInfo, self).__init__(info)
7+
self._api = info.get('url')
8+
9+
#: Status of the pages site, e.g., built
10+
self.status = info.get('status')
11+
12+
#: CName used for the pages site
13+
self.cname = info.get('cname')
14+
15+
#: Boolean indicating whether there is a custom 404 for the pages site
16+
self.custom_404 = info.get('custom_404')
17+
18+
19+
class PagesBuild(GitHubObject):
20+
def __init__(self, build):
21+
super(PagesBuild, self).__init__(build)
22+
self._api = build.get('url')
23+
24+
#: Status of the pages build, e.g., building
25+
self.status = build.get('status')
26+
27+
#: Error dictionary containing the error message
28+
self.error = build.get('error')
29+
30+
from github3.users import User
31+
#: :class:`User <github3.users.User>` representing who pushed the
32+
#: commit
33+
self.pusher = User(build.get('pusher'))
34+
35+
#: SHA of the commit that triggered the build
36+
self.commit = build.get('commit')
37+
38+
#: Time the build took to finish
39+
self.duration = build.get('duration')
40+
41+
#: Datetime the build was created
42+
self.created_at = self._strptime(build.get('created_at'))
43+
44+
#: Datetime the build was updated
45+
self.updated_at = self._strptime(build.get('updated_at'))

github3/repos/repo.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from github3.repos.contents import Contents, validate_commmitter
3030
from github3.repos.deployment import Deployment
3131
from github3.repos.hook import Hook
32+
from github3.repos.pages import PagesBuild, PagesInfo
3233
from github3.repos.status import Status
3334
from github3.repos.stats import ContributorStats
3435
from github3.repos.release import Release, Asset
@@ -1056,6 +1057,16 @@ def label(self, name):
10561057
json = self._json(self._get(url), 200)
10571058
return Label(json, self) if json else None
10581059

1060+
@requires_auth
1061+
def latest_pages_build(self):
1062+
"""Get the build information for the most recent Pages build.
1063+
1064+
:returns: :class:`PagesBuild <github3.repos.pages.PagesBuild>`
1065+
"""
1066+
url = self._build_url('pages', 'builds', 'latest', base_url=self._api)
1067+
json = self._json(self._get(url), 200)
1068+
return PagesBuild(json) if json else None
1069+
10591070
def iter_assignees(self, number=-1, etag=None):
10601071
"""Iterate over all available assignees to which an issue may be
10611072
assigned.
@@ -1466,6 +1477,16 @@ def iter_notifications(self, all=False, participating=False, since=None,
14661477
del params[k]
14671478
return self._iter(int(number), url, Thread, params, etag)
14681479

1480+
@requires_auth
1481+
def iter_pages_builds(self, number=-1, etag=None):
1482+
"""Iterate over pages builds of this repository.
1483+
1484+
:returns: generator of :class:`PagesBuild
1485+
<github3.repos.pages.PagesBuild>`
1486+
"""
1487+
url = self._build_url('pages', 'builds', base_url=self._api)
1488+
return self._iter(int(number), url, PagesBuild, etag=etag)
1489+
14691490
def iter_pulls(self, state=None, head=None, base=None, sort='created',
14701491
direction='desc', number=-1, etag=None):
14711492
"""List pull requests on repository.
@@ -1647,6 +1668,16 @@ def milestone(self, number):
16471668
json = self._json(self._get(url), 200)
16481669
return Milestone(json, self) if json else None
16491670

1671+
@requires_auth
1672+
def pages(self):
1673+
"""Get information about this repository's pages site.
1674+
1675+
:returns: :class:`PagesInfo <github3.repos.pages.PagesInfo>`
1676+
"""
1677+
url = self._build_url('pages', base_url=self._api)
1678+
json = self._json(self._get(url), 200)
1679+
return PagesInfo(json) if json else None
1680+
16501681
def pull_request(self, number):
16511682
"""Get the pull request indicated by ``number``.
16521683
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA62Yy5LqNhCGX4XyNgzCXAdvTrJKsjuLk002lGzLWDW25ZJkKMY1755flq+cBIZRNhQY9adfrW65W7XHYy9Y7/3l3vfnXkFz5gXeieu0CteL8urNvaTKsmP7h+KnnJ65rNRqQyajxKVg0gtqLxMnXoAxHgqKmWa1Wb6ul3OPnqmm8ljJDONSrUsVEGIfqoWlVorJSBSaFXoRiZxUxBp/A+okW4BhepG/eV1vd/HrITmstmx3WPn715AxPz6saZTsYXAzUcnbSSwZMylyozbVeXajz+pqTG4GJyLLxAWU2xU9moj0lsbNDYUXpy9SYFkToVMGx2JJH8ZRXOnnRTVWNXZX6SOPDUdhtySLnxbW2kGWCY6PmkhWigZYhSqSvNRcFM8LnFiDJuSJFvydfo0GawWIkfa8lMYK1uyMQH3e3JrVpJT8TKOrcY1kEeNnOPuLyBt7EPW1NDn9F4LCuJ5rdqRxbnI0oZliH3OvmV5jUPNgjpT8bPRPz4CY9buKCb9fdSqKWcZDSeV1lgg540homdAIsTq74IyZIVxnv3P9RxXOfvv+53kNgRj31iu5m7mN8yfJOJVjSA/25C4C6QkAJL2xqxPH2NcEn20+RUh1GgpJtXh0aNwXOAHVZPzTxJJmNHcS3gAASoVw82QDAIgrVbFPhfb9hTccRbr8Kao8tEfeZ7LmPtoSoJUqnPMFY04e7CE16U5lpEMRpW7YjlET+63ZbXpykmrsgQkzETpx8KIkDaQmKqX2PaSPruoM1TAmUMkSZ6mG0UO1dNzvRqaB9Ei8BDW23klnxyB169GMFqeKntyoPQS7bl7VJ/r+sIi5nzsDBUhTvkkeVu6H3MAxSm3tgHx3c+mAGaBNQXK/zHnggFFh07ggz/mjuuA+sUVMwv5/wJo4vUWb34/LmMdyDaMmw5lsD/2W7uLd9tTvdJJ6mKPtFZxComOQ+peS6tScXJiqpJK5iG4RpA4piq3FYlGnjDZldc6kYwZbAlBURimqRheddcdA1ZNT3VTriZEZo3rPBI2dfNtDALTb6KLVEsYxVqJJdRLYAMbEnGdMaVG4nbEDZcwuhOYJjz7TsdxPtwmo/qZ4EbE5zbI5olbziCOOUWubXUTBydw8ZAlYBu4IbKeSMYS0k9cls4ya2E4zkgyNSHykGg3EaumvXpbrF3/9wz8E29dgu/4bK6nKeDJm87LcvPi7H74fbHbB8mDGlJVKR5h/G4ITsA1BfMP9Az5x5/FTfz9qKcytAdhKpYPhr4NZ8B+XI61ZlCGWboL+83Oeb19Lj00hNRU5K1EmtNcs/SrX5XUBT8dov2IRqQV6YGJWxt8xdLdZbicFQSSqAvvh73Zz70I1ale8escPu0Kib/rM1FQdbZp6gZaV6SrxZDgGRg8v/I33HZ9t2lr6doNTkksp2suiAkmKfr9kRcseZNjGUXmBsRmNMLoH2e0qYpbQKtNHWzxDdoyqPxOliRwmc+g2FxPmNqvtlO0KTFR1qzHnhf2OBrpg+oJesVNjJIzLlM5X+49/ALYpvtVvEwAA", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"d3ccbef25c4850c0d561a3f11a05ac7e\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4969", "x-served-by": "62a1303ae95931e56e387e87d354bb24", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C9F6:1928:A71C3:534E6EC9", "access-control-allow-credentials": "true", "last-modified": "Wed, 16 Apr 2014 11:46:09 GMT", "date": "Wed, 16 Apr 2014 11:51:37 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1397651155"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2014-04-16T11:51:37"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/pages/builds/latest"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA52U3Y6rIBSF34XrThGsCt7MS5xzMzcNCloSFcKPk47pu8+WNidTTzKJvTPAt/ZisbcLim5ANbqEYH2NsbD62Otwic2xNSN2yhqPve5HMWsXPT3h+25+tFdsRa88bqIepMc5IQVjDB2QDyJED6LrToAF5ZxxqF7QqLwHBtVTHIbbAdnoLyrtDKbXEyA/SwGpJarpKWN5dkBiFkG488ZvWvQPz9Er15opqCkk+xHf4XeQ6t1DYNVELTmxvCgl4x2nhSo5JRVrlCKS56LtKgB+DWat9BwMEJcwDht/P7LcXK0zw2A+QWV7o+cX+L8Q/kdCyfu3nvoXVYBcsAnwCue10m0NSvuw31SiFugOH85arjrQBs4pudvYgwNbnxM4WlITJsHY+NZpG7SZ9ht8okHNuF5M+ku8pga0B5E0H7tvmCig1QyNuh+/Ywu2Ts+iva7RONUqPUPYL0pueFAMVwtziv5CU6zR66DOQo7rjHZi8AqGFwZs1AHO0EZydhKElnnHS1VxkomiEg1ngueStSwr4M+Qc9CR0aXAUU0IqUDDKRHAtkg6GcnfsuqNln9oVtOizooPYKKVv50pP9DtG95gkNLGBAAA", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"21be448cb6a20329feb5e91c4c8fa47b\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4968", "x-served-by": "6d7de9e645814cac34ea2a8d72ba3141", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C9F6:1928:A71DE:534E6EC9", "access-control-allow-credentials": "true", "last-modified": "Fri, 26 Jul 2013 20:25:06 GMT", "date": "Wed, 16 Apr 2014 11:51:37 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1397651155"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/pages/builds/latest"}, "recorded_at": "2014-04-16T11:51:37"}], "recorded_with": "betamax/{version}"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA62Yy5LqNhCGX4XyNgzC3GFzklWS3VmcbLKhZFvGqrEtlyRDMa559/yyfOUkXEbZUGDUn361uuVuVR6PvMNy68+3vj/1cpox7+CduE7KYDkrrt7Ui8s0PTZ/KH7K6JnLUi1WZDRKXHImvUPlpeLEczCG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mBPEN9w/4xJ3HT/39oKUwtwZgK5X0hr/2Zof/uBxpzMIUsXQT9M/Peb59LT02hdREZKxAmdBcs3SrXBbXGTwdof2KRKhm6IGJWRn/wNDNar4eFQShKHPsh7/ZTL0L1ahd8eodPmwLia7pM1NTdbRp6h20LE1XiSf9MTB4eOHvvOv4bNPW0NcrnJJcStFcFuVIUvT7Bcsbdi/DNo7KOxibwQiju5fdrCJiMS1TfbTFM2RHqPpTUZjIYTKDbnMxYW6zmk7ZrsBEVbsac17Y72igc6Yv6BVbNUbCsExpfbX9/AeFkaCKbxMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"e478f02b94af0bade6f085d1efd9ab6a\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4974", "x-served-by": "a1d8c69b807c8e21f06cad9da377d1b0", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C9F6:2126:C2770:534E6D4C", "access-control-allow-credentials": "true", "last-modified": "Wed, 16 Apr 2014 02:19:49 GMT", "date": "Wed, 16 Apr 2014 11:45:17 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1397651155"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2014-04-16T11:45:17"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.2", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/pages"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAAyWMQQoCMQwA/5KzNKI99TOSXWo3kG5Dkwgi/t2Cx5mB+UBMgQKHu1pBJOXU2I/Y0j46zqrD0Lh1evEMu2X813vSNyq1anABc/KwddmCxZfYT+oVyhkiC8J89Ee+ZihPEqvfH2LRabJ1AAAA", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-github-media-type": "github.v3; param=full; format=json", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"e478f02b94af0bade6f085d1efd9ab6a\"", "cache-control": "private, max-age=60, s-maxage=60", "status": "200 OK", "x-ratelimit-remaining": "4973", "x-served-by": "c436b2b44345c72ff906059f604991e7", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C9F6:2126:C27AC:534E6D4D", "access-control-allow-credentials": "true", "last-modified": "Wed, 16 Apr 2014 02:19:49 GMT", "date": "Wed, 16 Apr 2014 11:45:17 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1397651155"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/pages"}, "recorded_at": "2014-04-16T11:45:17"}], "recorded_with": "betamax/{version}"}

0 commit comments

Comments
 (0)