/ github / SelfHostedActionsRunner.py
SelfHostedActionsRunner.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2020 Victor Zeng <zacker150@hotmail.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 __future__ import annotations
24  
25  from typing import Any
26  
27  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
28  
29  
30  class SelfHostedActionsRunner(NonCompletableGithubObject):
31      """
32      This class represents Self-hosted GitHub Actions Runners. The reference can be found at
33      https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners
34      """
35  
36      def _initAttributes(self) -> None:
37          self._id: Attribute[int] = NotSet
38          self._name: Attribute[str] = NotSet
39          self._os: Attribute[str] = NotSet
40          self._status: Attribute[str] = NotSet
41          self._busy: Attribute[bool] = NotSet
42          self._labels: Attribute[list[dict[str, int | str]]] = NotSet
43  
44      def __repr__(self) -> str:
45          return self.get__repr__({"name": self._name.value})
46  
47      @property
48      def id(self) -> int:
49          return self._id.value
50  
51      @property
52      def name(self) -> str:
53          return self._name.value
54  
55      @property
56      def os(self) -> str:
57          return self._os.value
58  
59      @property
60      def status(self) -> str:
61          return self._status.value
62  
63      @property
64      def busy(self) -> bool:
65          return self._busy.value
66  
67      def labels(self) -> list[dict[str, int | str]]:
68          return self._labels.value
69  
70      def _useAttributes(self, attributes: dict[str, Any]) -> None:
71          if "id" in attributes:  # pragma no branch
72              self._id = self._makeIntAttribute(attributes["id"])
73          if "name" in attributes:  # pragma no branch
74              self._name = self._makeStringAttribute(attributes["name"])
75          if "os" in attributes:  # pragma no branch
76              self._os = self._makeStringAttribute(attributes["os"])
77          if "status" in attributes:  # pragma no branch
78              self._status = self._makeStringAttribute(attributes["status"])
79          if "busy" in attributes:
80              self._busy = self._makeBoolAttribute(attributes["busy"])
81          if "labels" in attributes:
82              self._labels = self._makeListOfDictsAttribute(attributes["labels"])