Add is_alphanumeric attribute to Autolink and Repository.create_autolink (#2630)

This commit is contained in:
Oskar Jansson
2023-08-31 21:08:53 +02:00
committed by GitHub
parent b6ce0ba44b
commit b6a28a26f2
6 changed files with 24 additions and 4 deletions
+8 -1
View File
@@ -978,18 +978,25 @@ class Repository(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/compare/{base}...{head}")
return github.Comparison.Comparison(self._requester, headers, data, completed=True)
def create_autolink(self, key_prefix, url_template):
def create_autolink(self, key_prefix, url_template, is_alphanumeric=github.GithubObject.NotSet):
"""
:calls: `POST /repos/{owner}/{repo}/autolinks <http://docs.github.com/en/rest/reference/repos>`_
:param key_prefix: string
:param url_template: string
:param is_alphanumeric: bool
:rtype: :class:`github.Autolink.Autolink`
"""
assert isinstance(key_prefix, str), key_prefix
assert isinstance(url_template, str), url_template
assert is_alphanumeric is github.GithubObject.NotSet or isinstance(is_alphanumeric, bool), is_alphanumeric
post_parameters = {"key_prefix": key_prefix, "url_template": url_template}
if is_alphanumeric is not github.GithubObject.NotSet:
post_parameters["is_alphanumeric"] = is_alphanumeric
headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/autolinks", input=post_parameters)
return github.Autolink.Autolink(self._requester, headers, data, completed=True)
def create_git_blob(self, content, encoding):