/ github / CodeScanTool.py
CodeScanTool.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  
23  from typing import Any, Dict
24  
25  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
26  
27  
28  class CodeScanTool(NonCompletableGithubObject):
29      """
30      This class represents code scanning tools.
31      The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.
32      """
33  
34      def _initAttributes(self) -> None:
35          self._name: Attribute[str] = NotSet
36          self._version: Attribute[str] = NotSet
37          self._guid: Attribute[str] = NotSet
38  
39      def __repr__(self) -> str:
40          return self.get__repr__(
41              {
42                  "guid": self.guid,
43                  "name": self.name,
44                  "version": self.version,
45              }
46          )
47  
48      @property
49      def name(self) -> str:
50          return self._name.value
51  
52      @property
53      def version(self) -> str:
54          return self._version.value
55  
56      @property
57      def guid(self) -> str:
58          return self._guid.value
59  
60      def _useAttributes(self, attributes: Dict[str, Any]) -> None:
61          if "name" in attributes:  # pragma no branch
62              self._name = self._makeStringAttribute(attributes["name"])
63          if "version" in attributes:  # pragma no branch
64              self._version = self._makeStringAttribute(attributes["version"])
65          if "guid" in attributes:  # pragma no branch
66              self._guid = self._makeStringAttribute(attributes["guid"])