CodeScanRule.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2022 Eric Nieuwland <eric.nieuwland@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.GithubObject import Attribute, NonCompletableGithubObject, NotSet 27 28 29 class CodeScanRule(NonCompletableGithubObject): 30 """ 31 This class represents Alerts from code scanning. 32 The reference can be found here https://docs.github.com/en/rest/reference/code-scanning. 33 """ 34 35 def _initAttributes(self) -> None: 36 self._id: Attribute[str] = NotSet 37 self._name: Attribute[str] = NotSet 38 self._severity: Attribute[str] = NotSet 39 self._security_severity_level: Attribute[str] = NotSet 40 self._description: Attribute[str] = NotSet 41 42 def __repr__(self) -> str: 43 return self.get__repr__({"id": self.id, "name": self.name}) 44 45 @property 46 def id(self) -> str: 47 return self._id.value 48 49 @property 50 def name(self) -> str: 51 return self._name.value 52 53 @property 54 def severity(self) -> str: 55 return self._severity.value 56 57 @property 58 def security_severity_level(self) -> str: 59 return self._security_severity_level.value 60 61 @property 62 def description(self) -> str: 63 return self._description.value 64 65 def _useAttributes(self, attributes: dict[str, Any]) -> None: 66 if "id" in attributes: # pragma no branch 67 self._id = self._makeStringAttribute(attributes["id"]) 68 if "name" in attributes: # pragma no branch 69 self._name = self._makeStringAttribute(attributes["name"]) 70 if "severity" in attributes: # pragma no branch 71 self._severity = self._makeStringAttribute(attributes["severity"]) 72 if "security_severity_level" in attributes: # pragma no branch 73 self._security_severity_level = self._makeStringAttribute(attributes["security_severity_level"]) 74 if "description" in attributes: # pragma no branch 75 self._description = self._makeStringAttribute(attributes["description"])