mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Labels API: support description (#738)
The description attribute handling requirement is
a custom media type in the Accept header:
application/vnd.github.symmetra-preview+json
Limitation: Repository.get_labels does not report description,
possibly something has changed in the preview API.
This commit is contained in:
committed by
Wan Liuyang
parent
6bf2acc74d
commit
42e7593871
@@ -999,23 +999,28 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True, repoUrl=self.url)
|
||||
|
||||
def create_label(self, name, color):
|
||||
def create_label(self, name, color, description=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/labels <http://developer.github.com/v3/issues/labels>`_
|
||||
:param name: string
|
||||
:param color: string
|
||||
:param description: string
|
||||
:rtype: :class:`github.Label.Label`
|
||||
"""
|
||||
assert isinstance(name, (str, unicode)), name
|
||||
assert isinstance(color, (str, unicode)), color
|
||||
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description
|
||||
post_parameters = {
|
||||
"name": name,
|
||||
"color": color,
|
||||
}
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/labels",
|
||||
input=post_parameters
|
||||
input=post_parameters,
|
||||
headers={'Accept': 'application/vnd.github.symmetra-preview+json'}
|
||||
)
|
||||
return github.Label.Label(self._requester, headers, data, completed=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user