SourceImport.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2018 Hayden Fuss <wifu1234@gmail.com> # 4 # # 5 # This file is part of PyGithub. # 6 # http://pygithub.readthedocs.io/ # 7 # # 8 # PyGithub is free software: you can redistribute it and/or modify it under # 9 # the terms of the GNU Lesser General Public License as published by the Free # 10 # Software Foundation, either version 3 of the License, or (at your option) # 11 # any later version. # 12 # # 13 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 15 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 16 # details. # 17 # # 18 # You should have received a copy of the GNU Lesser General Public License # 19 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 20 # # 21 ################################################################################ 22 from __future__ import annotations 23 24 from typing import Any 25 26 from github import Consts 27 from github.GithubObject import Attribute, CompletableGithubObject, NotSet 28 29 30 class SourceImport(CompletableGithubObject): 31 """ 32 This class represents SourceImports. The reference can be found here https://docs.github.com/en/rest/reference/migrations#source-imports 33 """ 34 35 def _initAttributes(self) -> None: 36 self._authors_count: Attribute[int] = NotSet 37 self._authors_url: Attribute[str] = NotSet 38 self._has_large_files: Attribute[bool] = NotSet 39 self._html_url: Attribute[str] = NotSet 40 self._large_files_count: Attribute[int] = NotSet 41 self._large_files_size: Attribute[int] = NotSet 42 self._repository_url: Attribute[str] = NotSet 43 self._status: Attribute[str] = NotSet 44 self._status_text: Attribute[str] = NotSet 45 self._url: Attribute[str] = NotSet 46 self._use_lfs: Attribute[str] = NotSet 47 self._vcs: Attribute[str] = NotSet 48 self._vcs_url: Attribute[str] = NotSet 49 50 def __repr__(self) -> str: 51 return self.get__repr__( 52 { 53 "vcs_url": self._vcs_url.value, 54 "repository_url": self._repository_url.value, 55 "status": self._status.value, 56 "url": self._url.value, 57 } 58 ) 59 60 @property 61 def authors_count(self) -> int: 62 self._completeIfNotSet(self._authors_count) 63 return self._authors_count.value 64 65 @property 66 def authors_url(self) -> str: 67 self._completeIfNotSet(self._authors_url) 68 return self._authors_url.value 69 70 @property 71 def has_large_files(self) -> bool: 72 self._completeIfNotSet(self._has_large_files) 73 return self._has_large_files.value 74 75 @property 76 def html_url(self) -> str: 77 self._completeIfNotSet(self._html_url) 78 return self._html_url.value 79 80 @property 81 def large_files_count(self) -> int: 82 self._completeIfNotSet(self._large_files_count) 83 return self._large_files_count.value 84 85 @property 86 def large_files_size(self) -> int: 87 self._completeIfNotSet(self._large_files_size) 88 return self._large_files_size.value 89 90 @property 91 def repository_url(self) -> str: 92 self._completeIfNotSet(self._repository_url) 93 return self._repository_url.value 94 95 @property 96 def status(self) -> str: 97 self._completeIfNotSet(self._status) 98 return self._status.value 99 100 @property 101 def status_text(self) -> str: 102 self._completeIfNotSet(self._status_text) 103 return self._status_text.value 104 105 @property 106 def url(self) -> str: 107 self._completeIfNotSet(self._url) 108 return self._url.value 109 110 @property 111 def use_lfs(self) -> str: 112 self._completeIfNotSet(self._use_lfs) 113 return self._use_lfs.value 114 115 @property 116 def vcs(self) -> str: 117 self._completeIfNotSet(self._vcs) 118 return self._vcs.value 119 120 @property 121 def vcs_url(self) -> str: 122 self._completeIfNotSet(self._vcs_url) 123 return self._vcs_url.value 124 125 def update(self, additional_headers: None | dict[str, Any] = None) -> bool: 126 import_header = {"Accept": Consts.mediaTypeImportPreview} 127 return super().update(additional_headers=import_header) 128 129 def _useAttributes(self, attributes: dict[str, Any]) -> None: 130 if "authors_count" in attributes: # pragma no branch 131 self._authors_count = self._makeIntAttribute(attributes["authors_count"]) 132 if "authors_url" in attributes: # pragma no branch 133 self._authors_url = self._makeStringAttribute(attributes["authors_url"]) 134 if "has_large_files" in attributes: # pragma no branch 135 self._has_large_files = self._makeBoolAttribute(attributes["has_large_files"]) 136 if "html_url" in attributes: # pragma no branch 137 self._html_url = self._makeStringAttribute(attributes["html_url"]) 138 if "large_files_count" in attributes: # pragma no branch 139 self._large_files_count = self._makeIntAttribute(attributes["large_files_count"]) 140 if "large_files_size" in attributes: # pragma no branch 141 self._large_files_size = self._makeIntAttribute(attributes["large_files_size"]) 142 if "repository_url" in attributes: # pragma no branch 143 self._repository_url = self._makeStringAttribute(attributes["repository_url"]) 144 if "status" in attributes: # pragma no branch 145 self._status = self._makeStringAttribute(attributes["status"]) 146 if "status_text" in attributes: # pragma no branch 147 self._status_text = self._makeStringAttribute(attributes["status_text"]) 148 if "url" in attributes: # pragma no branch 149 self._url = self._makeStringAttribute(attributes["url"]) 150 if "use_lfs" in attributes: # pragma no branch 151 self._use_lfs = self._makeStringAttribute(attributes["use_lfs"]) 152 if "vcs" in attributes: # pragma no branch 153 self._vcs = self._makeStringAttribute(attributes["vcs"]) 154 if "vcs_url" in attributes: # pragma no branch 155 self._vcs_url = self._makeStringAttribute(attributes["vcs_url"])