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:
Mateusz Loskot
2018-03-29 18:16:20 +08:00
committed by Wan Liuyang
parent 6bf2acc74d
commit 42e7593871
7 changed files with 37 additions and 13 deletions
+7 -2
View File
@@ -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)