mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Merge Migration type stub back to source (#2673)
This commit is contained in:
+32
-67
@@ -29,109 +29,89 @@
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import github.GithubObject
|
||||
import github.NamedUser
|
||||
import github.PaginatedList
|
||||
|
||||
from . import Consts
|
||||
import github.Repository
|
||||
from github import Consts
|
||||
from github.GithubObject import Attribute, CompletableGithubObject, NotSet
|
||||
|
||||
|
||||
class Migration(github.GithubObject.CompletableGithubObject):
|
||||
class Migration(CompletableGithubObject):
|
||||
"""
|
||||
This class represents Migrations. The reference can be found here https://docs.github.com/en/rest/reference/migrations
|
||||
"""
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._id: Attribute[int] = NotSet
|
||||
self._owner: Attribute[github.NamedUser.NamedUser] = NotSet
|
||||
self._guid: Attribute[str] = NotSet
|
||||
self._state: Attribute[str] = NotSet
|
||||
self._lock_repositories: Attribute[bool] = NotSet
|
||||
self._exclude_attachments: Attribute[bool] = NotSet
|
||||
self._repositories: Attribute[list[github.Repository.Repository]] = NotSet
|
||||
self._url: Attribute[str] = NotSet
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.get__repr__({"state": self._state.value, "url": self._url.value})
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
:type: int
|
||||
"""
|
||||
def id(self) -> int:
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
"""
|
||||
:type: :class:`github.NamedUser.NamedUser`
|
||||
"""
|
||||
def owner(self) -> github.NamedUser.NamedUser:
|
||||
self._completeIfNotSet(self._owner)
|
||||
return self._owner.value
|
||||
|
||||
@property
|
||||
def guid(self):
|
||||
"""
|
||||
:type: str
|
||||
"""
|
||||
def guid(self) -> str:
|
||||
self._completeIfNotSet(self._guid)
|
||||
return self._guid.value
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""
|
||||
:type: str
|
||||
"""
|
||||
def state(self) -> str:
|
||||
self._completeIfNotSet(self._guid)
|
||||
return self._state.value
|
||||
|
||||
@property
|
||||
def lock_repositories(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
def lock_repositories(self) -> bool:
|
||||
self._completeIfNotSet(self._repositories)
|
||||
return self._lock_repositories.value
|
||||
|
||||
@property
|
||||
def exclude_attachments(self):
|
||||
"""
|
||||
:type: bool
|
||||
"""
|
||||
def exclude_attachments(self) -> bool:
|
||||
self._completeIfNotSet(self._exclude_attachments)
|
||||
return self._exclude_attachments.value
|
||||
|
||||
@property
|
||||
def repositories(self):
|
||||
"""
|
||||
:type: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
|
||||
"""
|
||||
def repositories(self) -> list[github.Repository.Repository]:
|
||||
self._completeIfNotSet(self._repositories)
|
||||
return self._repositories.value
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""
|
||||
:type: str
|
||||
"""
|
||||
def url(self) -> str:
|
||||
self._completeIfNotSet(self._url)
|
||||
return self._url.value
|
||||
|
||||
@property
|
||||
def created_at(self):
|
||||
"""
|
||||
:type: datetime.datetime
|
||||
:rtype: None
|
||||
"""
|
||||
def created_at(self) -> datetime:
|
||||
self._completeIfNotSet(self._created_at)
|
||||
return self._created_at.value
|
||||
|
||||
@property
|
||||
def updated_at(self):
|
||||
"""
|
||||
:type: datetime.datetime
|
||||
:rtype: None
|
||||
"""
|
||||
def updated_at(self) -> datetime:
|
||||
self._completeIfNotSet(self._updated_at)
|
||||
return self._updated_at.value
|
||||
|
||||
def get_status(self):
|
||||
def get_status(self) -> str:
|
||||
"""
|
||||
:calls: `GET /user/migrations/{migration_id} <https://docs.github.com/en/rest/reference/migrations>`_
|
||||
:rtype: str
|
||||
"""
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url, headers={"Accept": Consts.mediaTypeMigrationPreview}
|
||||
@@ -139,10 +119,9 @@ class Migration(github.GithubObject.CompletableGithubObject):
|
||||
self._useAttributes(data)
|
||||
return self.state
|
||||
|
||||
def get_archive_url(self):
|
||||
def get_archive_url(self) -> str:
|
||||
"""
|
||||
:calls: `GET /user/migrations/{migration_id}/archive <https://docs.github.com/en/rest/reference/migrations>`_
|
||||
:rtype: str
|
||||
"""
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
@@ -151,7 +130,7 @@ class Migration(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return data["data"]
|
||||
|
||||
def delete(self):
|
||||
def delete(self) -> None:
|
||||
"""
|
||||
:calls: `DELETE /user/migrations/{migration_id}/archive <https://docs.github.com/en/rest/reference/migrations>`_
|
||||
"""
|
||||
@@ -161,11 +140,9 @@ class Migration(github.GithubObject.CompletableGithubObject):
|
||||
headers={"Accept": Consts.mediaTypeMigrationPreview},
|
||||
)
|
||||
|
||||
def unlock_repo(self, repo_name):
|
||||
def unlock_repo(self, repo_name: str) -> None:
|
||||
"""
|
||||
:calls: `DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock <https://docs.github.com/en/rest/reference/migrations>`_
|
||||
:param repo_name: str
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(repo_name, str), repo_name
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
@@ -174,19 +151,7 @@ class Migration(github.GithubObject.CompletableGithubObject):
|
||||
headers={"Accept": Consts.mediaTypeMigrationPreview},
|
||||
)
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._owner = github.GithubObject.NotSet
|
||||
self._guid = github.GithubObject.NotSet
|
||||
self._state = github.GithubObject.NotSet
|
||||
self._lock_repositories = github.GithubObject.NotSet
|
||||
self._exclude_attachments = github.GithubObject.NotSet
|
||||
self._repositories = github.GithubObject.NotSet
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._created_at = github.GithubObject.NotSet
|
||||
self._updated_at = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
|
||||
def _useAttributes(self, attributes: dict[str, Any]) -> None:
|
||||
if "id" in attributes:
|
||||
self._id = self._makeIntAttribute(attributes["id"])
|
||||
if "owner" in attributes:
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from github.GithubObject import CompletableGithubObject
|
||||
from github.NamedUser import NamedUser
|
||||
from github.Repository import Repository
|
||||
|
||||
class Migration(CompletableGithubObject):
|
||||
def __repr__(self) -> str: ...
|
||||
def _initAttributes(self) -> None: ...
|
||||
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
|
||||
@property
|
||||
def created_at(self) -> datetime: ...
|
||||
def delete(self) -> None: ...
|
||||
@property
|
||||
def exclude_attachments(self) -> bool: ...
|
||||
def get_archive_url(self) -> str: ...
|
||||
def get_status(self) -> str: ...
|
||||
@property
|
||||
def guid(self) -> str: ...
|
||||
@property
|
||||
def id(self) -> int: ...
|
||||
@property
|
||||
def lock_repositories(self) -> bool: ...
|
||||
@property
|
||||
def owner(self) -> NamedUser: ...
|
||||
@property
|
||||
def repositories(self) -> List[Repository]: ...
|
||||
@property
|
||||
def state(self) -> str: ...
|
||||
def unlock_repo(self, repo_name: str) -> None: ...
|
||||
@property
|
||||
def updated_at(self) -> datetime: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
Reference in New Issue
Block a user