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
+7
View File
@@ -35,6 +35,7 @@ class Autolink(NonCompletableGithubObject):
self._id: Attribute[int] = NotSet
self._key_prefix: Attribute[str] = NotSet
self._url_template: Attribute[str] = NotSet
self._is_alphanumeric: Attribute[bool] = NotSet
def __repr__(self) -> str:
return self.get__repr__({"id": self._id.value})
@@ -51,6 +52,10 @@ class Autolink(NonCompletableGithubObject):
def url_template(self) -> str:
return self._url_template.value
@property
def is_alphanumeric(self) -> bool:
return self._is_alphanumeric.value
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
if "id" in attributes: # pragma no branch
self._id = self._makeIntAttribute(attributes["id"])
@@ -58,3 +63,5 @@ class Autolink(NonCompletableGithubObject):
self._key_prefix = self._makeStringAttribute(attributes["key_prefix"])
if "url_template" in attributes: # pragma no branch
self._url_template = self._makeStringAttribute(attributes["url_template"])
if "is_alphanumeric" in attributes: # pragma no branch
self._is_alphanumeric = self._makeBoolAttribute(attributes["is_alphanumeric"])
+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):
+6 -1
View File
@@ -123,7 +123,12 @@ class Repository(CompletableGithubObject):
def contents_url(self) -> str: ...
@property
def contributors_url(self) -> str: ...
def create_autolink(self, key_prefix: str, url_template: str) -> Autolink: ...
def create_autolink(
self,
key_prefix: str,
url_template: str,
is_alphanumeric: Union[bool, _NotSetType] = ...,
) -> Autolink: ...
def create_check_run(
self,
name: str,