mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Add is_alphanumeric attribute to Autolink and Repository.create_autolink (#2630)
This commit is contained in:
@@ -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"])
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -35,3 +35,4 @@ class Autolink(Framework.TestCase):
|
||||
self.assertEqual(self.link.id, 209614)
|
||||
self.assertEqual(self.link.key_prefix, "DUMMY-")
|
||||
self.assertEqual(self.link.url_template, "https://github.com/PyGithub/PyGithub/issues/<num>")
|
||||
self.assertEqual(self.link.is_alphanumeric, True)
|
||||
|
||||
@@ -29,5 +29,5 @@ None
|
||||
None
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Tue, 02 Nov 2021 13:15:54 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"535a973f8ad8495063caa679cdbf106f079769e4c6060713042dc3a9fc844b87"'), ('X-OAuth-Scopes', 'admin:repo_hook, repo'), ('X-Accepted-OAuth-Scopes', 'repo'), ('github-authentication-token-expiration', '2021-11-09 12:40:40 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4891'), ('X-RateLimit-Reset', '1635859633'), ('X-RateLimit-Used', '109'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'C17A:34FD:E2AD69:E8E4C0:61813A0A')]
|
||||
[{"id":209614,"key_prefix":"DUMMY-","url_template":"https://github.com/PyGithub/PyGithub/issues/<num>"}]
|
||||
[{"id":209614,"key_prefix":"DUMMY-","url_template":"https://github.com/PyGithub/PyGithub/issues/<num>","is_alphanumeric":true}]
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ None
|
||||
{"key_prefix": "DUMMY-", "url_template": "https://github.com/PyGithub/PyGithub/issues/<num>"}
|
||||
201
|
||||
[('Server', 'GitHub.com'), ('Date', 'Tue, 02 Nov 2021 12:57:55 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Content-Length', '102'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', '"f90a1a598b996d3d1967b96c218459edde984e62d452623ff4aba2530a256b85"'), ('X-OAuth-Scopes', 'admin:repo_hook, repo'), ('X-Accepted-OAuth-Scopes', 'repo'), ('github-authentication-token-expiration', '2021-11-09 12:40:40 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4947'), ('X-RateLimit-Reset', '1635859633'), ('X-RateLimit-Used', '53'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('X-GitHub-Request-Id', 'C6E6:34FE:190079B:197523C:618135D3')]
|
||||
{"id":209614,"key_prefix":"DUMMY-","url_template":"https://github.com/PyGithub/PyGithub/issues/<num>"}
|
||||
{"id":209614,"key_prefix":"DUMMY-","url_template":"https://github.com/PyGithub/PyGithub/issues/<num>","is_alphanumeric":true}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user