CodeScanAlertInstance.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 TYPE_CHECKING, Any 25 26 import github.CodeScanAlertInstanceLocation 27 from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet 28 29 if TYPE_CHECKING: 30 from github.CodeScanAlertInstanceLocation import CodeScanAlertInstanceLocation 31 32 33 class CodeScanAlertInstance(NonCompletableGithubObject): 34 """ 35 This class represents code scanning alert instances. 36 The reference can be found here https://docs.github.com/en/rest/reference/code-scanning. 37 """ 38 39 def _initAttributes(self) -> None: 40 self._ref: Attribute[str] = NotSet 41 self._analysis_key: Attribute[str] = NotSet 42 self._environment: Attribute[str] = NotSet 43 self._state: Attribute[str] = NotSet 44 self._commit_sha: Attribute[str] = NotSet 45 self._message: Attribute[dict[str, Any]] = NotSet 46 self._location: Attribute[CodeScanAlertInstanceLocation] = NotSet 47 self._classifications: Attribute[list[str]] = NotSet 48 49 def __repr__(self) -> str: 50 return self.get__repr__({"ref": self.ref, "analysis_key": self.analysis_key}) 51 52 @property 53 def ref(self) -> str: 54 return self._ref.value 55 56 @property 57 def analysis_key(self) -> str: 58 return self._analysis_key.value 59 60 @property 61 def environment(self) -> str: 62 return self._environment.value 63 64 @property 65 def state(self) -> str: 66 return self._state.value 67 68 @property 69 def commit_sha(self) -> str: 70 return self._commit_sha.value 71 72 @property 73 def message(self) -> dict[str, Any]: 74 return self._message.value 75 76 @property 77 def location(self) -> CodeScanAlertInstanceLocation: 78 return self._location.value 79 80 @property 81 def classifications(self) -> list[str]: 82 return self._classifications.value 83 84 def _useAttributes(self, attributes: dict[str, Any]) -> None: 85 if "ref" in attributes: # pragma no branch 86 self._ref = self._makeStringAttribute(attributes["ref"]) 87 if "analysis_key" in attributes: # pragma no branch 88 self._analysis_key = self._makeStringAttribute(attributes["analysis_key"]) 89 if "environment" in attributes: # pragma no branch 90 self._environment = self._makeStringAttribute(attributes["environment"]) 91 if "state" in attributes: # pragma no branch 92 self._state = self._makeStringAttribute(attributes["state"]) 93 if "environment" in attributes: # pragma no branch 94 self._environment = self._makeStringAttribute(attributes["environment"]) 95 if "commit_sha" in attributes: # pragma no branch 96 self._commit_sha = self._makeStringAttribute(attributes["commit_sha"]) 97 if "message" in attributes: # pragma no branch 98 self._message = self._makeDictAttribute(attributes["message"]) 99 if "location" in attributes: # pragma no branch 100 self._location = self._makeClassAttribute( 101 github.CodeScanAlertInstanceLocation.CodeScanAlertInstanceLocation, 102 attributes["location"], 103 ) 104 if "classifications" in attributes: # pragma no branch 105 self._classifications = self._makeListOfStringsAttribute(attributes["classifications"])