Merge RepositoryKey type stub back to source (#2656)

This commit is contained in:
Trim21
2023-08-18 08:36:00 +02:00
committed by GitHub
parent d7b02f9d02
commit 05c48c72c1
2 changed files with 20 additions and 66 deletions
+20 -42
View File
@@ -32,92 +32,70 @@
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
from datetime import datetime
from typing import Any, Dict
import github.GithubObject
from github.GithubObject import Attribute, CompletableGithubObject, NotSet
class RepositoryKey(github.GithubObject.CompletableGithubObject):
class RepositoryKey(CompletableGithubObject):
"""
This class represents RepositoryKeys. The reference can be found here https://docs.github.com/en/rest/reference/repos#deploy-keys
"""
def _initAttributes(self) -> None:
self._created_at: Attribute[datetime] = NotSet
self._id: Attribute[int] = NotSet
self._key: Attribute[str] = NotSet
self._title: Attribute[str] = NotSet
self._url: Attribute[str] = NotSet
self._verified: Attribute[bool] = NotSet
self._read_only: Attribute[bool] = NotSet
def __repr__(self) -> str:
return self.get__repr__({"id": self._id.value, "title": self._title.value})
@property
def created_at(self):
"""
:type: datetime.datetime
"""
def created_at(self) -> datetime:
self._completeIfNotSet(self._created_at)
return self._created_at.value
@property
def id(self):
"""
:type: integer
"""
def id(self) -> int:
self._completeIfNotSet(self._id)
return self._id.value
@property
def key(self):
"""
:type: string
"""
def key(self) -> str:
self._completeIfNotSet(self._key)
return self._key.value
@property
def title(self):
"""
:type: string
"""
def title(self) -> str:
self._completeIfNotSet(self._title)
return self._title.value
@property
def url(self):
"""
:type: string
"""
def url(self) -> str:
self._completeIfNotSet(self._url)
return self._url.value
@property
def verified(self):
"""
:type: bool
"""
def verified(self) -> bool:
self._completeIfNotSet(self._verified)
return self._verified.value
@property
def read_only(self):
"""
:type: bool
"""
def read_only(self) -> bool:
self._completeIfNotSet(self._read_only)
return self._read_only.value
def delete(self):
def delete(self) -> None:
"""
:calls: `DELETE /repos/{owner}/{repo}/keys/{id} <https://docs.github.com/en/rest/reference/repos#deploy-keys>`_
:rtype: None
"""
headers, data = self._requester.requestJsonAndCheck("DELETE", self.url)
def _initAttributes(self) -> None:
self._created_at = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._key = github.GithubObject.NotSet
self._title = github.GithubObject.NotSet
self._url = github.GithubObject.NotSet
self._verified = github.GithubObject.NotSet
self._read_only = github.GithubObject.NotSet
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
if "created_at" in attributes: # pragma no branch
self._created_at = self._makeDatetimeAttribute(attributes["created_at"])