8000 Create lock() and unlock() for issues · pythonthings/github3.py@01f7225 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01f7225

Browse files
committed
Create lock() and unlock() for issues
1 parent fae7c8b commit 01f7225

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

github3/issues/issue.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ class Issue(GitHubCore):
3131
3232
"""
3333

34+
# The Accept header will likely be removable once the feature is out of
35+
# preview mode. See: https://git.io/vgXmB
36+
LOCKING_PREVIEW_HEADERS = {
37+
'Accept': 'application/vnd.github.the-key-preview+json'
38+
}
39+
3440
def _update_attributes(self, issue):
3541
self._api = issue.get('url', '')
3642
#: :class:`User <github3.users.User>` representing the user the issue
@@ -254,6 +260,17 @@ def labels(self, number=-1, etag=None):
254260
url = self._build_url('labels', base_url=self._api)
255261
return self._iter(int(number), url, Label, etag=etag)
256262

263+
@requires_auth
264+
def lock(self):
265+
"""Lock an issue.
266+
267+
:returns: bool
268+
"""
269+
headers = Issue.LOCKING_PREVIEW_HEADERS
270+
271+
url = self._build_url('lock', base_url=self._api)
272+
return self._boolean(self._put(url, headers=headers), 204, 404)
273+
257274
def pull_request(self):
258275
"""Retrieve the pull request associated with this issue.
259276
@@ -309,3 +326,14 @@ def reopen(self):
309326
labels = [str(l) for l in self.original_labels]
310327
return self.edit(self.title, self.body, assignee, 'open',
311328
number, labels)
329+
330+
@requires_auth
331+
def unlock(self):
332+
"""Unlock an issue.
333+
334+
:returns: bool
335+
"""
336+
headers = Issue.LOCKING_PREVIEW_HEADERS
337+
338+
url = self._build_url('lock', base_url=self._api)
339+
return self._boolean(self._delete(url, headers=headers), 204, 404)

0 commit comments

Comments
 (0)
0