Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync PublicKey class with API spec #3152

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updated class according to API spec
  • Loading branch information
EnricoMi committed Jan 8, 2025
commit a960ee47c6ca7085afa2704235da75a8c0abf745
32 changes: 32 additions & 0 deletions github/PublicKey.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,26 @@ class PublicKey(CompletableGithubObject):
"""

def _initAttributes(self) -> None:
self._created_at: Attribute[str] = NotSet
self._id: Attribute[int] = NotSet
self._key: Attribute[str] = NotSet
self._key_id: Attribute[str | int] = NotSet
self._title: Attribute[str] = NotSet
self._url: Attribute[str] = NotSet

def __repr__(self) -> str:
return self.get__repr__({"key_id": self._key_id.value, "key": self._key.value})

@property
def created_at(self) -> str:
self._completeIfNotSet(self._created_at)
return self._created_at.value

@property
def id(self) -> int:
self._completeIfNotSet(self._id)
return self._id.value

@property
def key(self) -> str:
self._completeIfNotSet(self._key)
Expand All @@ -90,14 +104,32 @@ def key_id(self) -> str | int:
self._completeIfNotSet(self._key_id)
return self._key_id.value

@property
def title(self) -> str:
self._completeIfNotSet(self._title)
return self._title.value

@property
def url(self) -> str:
self._completeIfNotSet(self._url)
return self._url.value

def encrypt(self, unencrypted_value: str) -> str:
return encrypt(self._key.value, unencrypted_value)

def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "created_at" in attributes: # pragma no branch
self._created_at = self._makeStringAttribute(attributes["created_at"])
if "id" in attributes: # pragma no branch
self._id = self._makeIntAttribute(attributes["id"])
if "key" in attributes: # pragma no branch
self._key = self._makeStringAttribute(attributes["key"])
if "key_id" in attributes: # pragma no branch
if isinstance(attributes["key_id"], str):
self._key_id = self._makeStringAttribute(attributes["key_id"])
else:
self._key_id = self._makeIntAttribute(attributes["key_id"])
if "title" in attributes: # pragma no branch
self._title = self._makeStringAttribute(attributes["title"])
if "url" in attributes: # pragma no branch
self._url = self._makeStringAttribute(attributes["url"])