/ github / CommitCombinedStatus.py
CommitCombinedStatus.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
 4  # Copyright 2016 John Eskew <jeskew@edx.org>                                   #
 5  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 6  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 7  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 8  #                                                                              #
 9  # This file is part of PyGithub.                                               #
10  # http://pygithub.readthedocs.io/                                              #
11  #                                                                              #
12  # PyGithub is free software: you can redistribute it and/or modify it under    #
13  # the terms of the GNU Lesser General Public License as published by the Free  #
14  # Software Foundation, either version 3 of the License, or (at your option)    #
15  # any later version.                                                           #
16  #                                                                              #
17  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
18  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
19  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
20  # details.                                                                     #
21  #                                                                              #
22  # You should have received a copy of the GNU Lesser General Public License     #
23  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
24  #                                                                              #
25  ################################################################################
26  from __future__ import annotations
27  
28  from typing import Any
29  
30  import github.CommitStatus
31  import github.Repository
32  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
33  
34  
35  class CommitCombinedStatus(NonCompletableGithubObject):
36      """
37      This class represents CommitCombinedStatuses. The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses
38      """
39  
40      def _initAttributes(self) -> None:
41          self._state: Attribute[str] = NotSet
42          self._sha: Attribute[str] = NotSet
43          self._total_count: Attribute[int] = NotSet
44          self._commit_url: Attribute[str] = NotSet
45          self._url: Attribute[str] = NotSet
46          self._repository: Attribute[github.Repository.Repository] = NotSet
47          self._statuses: Attribute[list[github.CommitStatus.CommitStatus]] = NotSet
48  
49      def __repr__(self) -> str:
50          return self.get__repr__({"sha": self._sha.value, "state": self._state.value})
51  
52      @property
53      def state(self) -> str:
54          return self._state.value
55  
56      @property
57      def sha(self) -> str:
58          return self._sha.value
59  
60      @property
61      def total_count(self) -> int:
62          return self._total_count.value
63  
64      @property
65      def commit_url(self) -> str:
66          return self._commit_url.value
67  
68      @property
69      def url(self) -> str:
70          return self._url.value
71  
72      @property
73      def repository(self) -> github.Repository.Repository:
74          return self._repository.value
75  
76      @property
77      def statuses(self) -> list[github.CommitStatus.CommitStatus]:
78          return self._statuses.value
79  
80      def _useAttributes(self, attributes: dict[str, Any]) -> None:
81          if "state" in attributes:  # pragma no branch
82              self._state = self._makeStringAttribute(attributes["state"])
83          if "sha" in attributes:  # pragma no branch
84              self._sha = self._makeStringAttribute(attributes["sha"])
85          if "total_count" in attributes:  # pragma no branch
86              self._total_count = self._makeIntAttribute(attributes["total_count"])
87          if "commit_url" in attributes:  # pragma no branch
88              self._commit_url = self._makeStringAttribute(attributes["commit_url"])
89          if "url" in attributes:  # pragma no branch
90              self._url = self._makeStringAttribute(attributes["url"])
91          if "repository" in attributes:  # pragma no branch
92              self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"])
93          if "statuses" in attributes:  # pragma no branch
94              self._statuses = self._makeListOfClassesAttribute(github.CommitStatus.CommitStatus, attributes["statuses"])