/ github / TeamDiscussion.py
TeamDiscussion.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2019 Adam Baratz <adam.baratz@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 datetime import datetime
 25  from typing import Any
 26  
 27  import github.GithubObject
 28  import github.NamedUser
 29  from github.GithubObject import Attribute, CompletableGithubObject, NotSet
 30  
 31  
 32  class TeamDiscussion(CompletableGithubObject):
 33      """
 34      This class represents TeamDiscussions. The reference can be found here https://docs.github.com/en/rest/reference/teams#discussions
 35      """
 36  
 37      def _initAttributes(self) -> None:
 38          self._author: Attribute[github.NamedUser.NamedUser] = NotSet
 39          self._body: Attribute[str] = NotSet
 40          self._body_html: Attribute[str] = NotSet
 41          self._body_version: Attribute[str] = NotSet
 42          self._comments_count: Attribute[int] = NotSet
 43          self._comments_url: Attribute[str] = NotSet
 44          self._created_at: Attribute[datetime] = NotSet
 45          self._html_url: Attribute[str] = NotSet
 46          self._last_edited_at: Attribute[datetime] = NotSet
 47          self._node_id: Attribute[str] = NotSet
 48          self._number: Attribute[int] = NotSet
 49          self._pinned: Attribute[bool] = NotSet
 50          self._private: Attribute[bool] = NotSet
 51          self._team_url: Attribute[str] = NotSet
 52          self._title: Attribute[str] = NotSet
 53          self._updated_at: Attribute[datetime] = NotSet
 54          self._url: Attribute[str] = NotSet
 55  
 56      def __repr__(self) -> str:
 57          return self.get__repr__({"number": self._number.value, "title": self._title.value})
 58  
 59      @property
 60      def author(self) -> github.NamedUser.NamedUser:
 61          self._completeIfNotSet(self._author)
 62          return self._author.value
 63  
 64      @property
 65      def body(self) -> str:
 66          self._completeIfNotSet(self._body)
 67          return self._body.value
 68  
 69      @property
 70      def body_html(self) -> str:
 71          self._completeIfNotSet(self._body_html)
 72          return self._body_html.value
 73  
 74      @property
 75      def body_version(self) -> str:
 76          self._completeIfNotSet(self._body_version)
 77          return self._body_version.value
 78  
 79      @property
 80      def comments_count(self) -> int:
 81          self._completeIfNotSet(self._comments_count)
 82          return self._comments_count.value
 83  
 84      @property
 85      def comments_url(self) -> str:
 86          self._completeIfNotSet(self._comments_url)
 87          return self._comments_url.value
 88  
 89      @property
 90      def created_at(self) -> datetime:
 91          self._completeIfNotSet(self._created_at)
 92          return self._created_at.value
 93  
 94      @property
 95      def html_url(self) -> str:
 96          self._completeIfNotSet(self._html_url)
 97          return self._html_url.value
 98  
 99      @property
100      def last_edited_at(self) -> datetime:
101          self._completeIfNotSet(self._last_edited_at)
102          return self._last_edited_at.value
103  
104      @property
105      def node_id(self) -> str:
106          self._completeIfNotSet(self._node_id)
107          return self._node_id.value
108  
109      @property
110      def number(self) -> int:
111          self._completeIfNotSet(self._number)
112          return self._number.value
113  
114      @property
115      def pinned(self) -> bool:
116          self._completeIfNotSet(self._pinned)
117          return self._pinned.value
118  
119      @property
120      def private(self) -> bool:
121          self._completeIfNotSet(self._private)
122          return self._private.value
123  
124      @property
125      def team_url(self) -> str:
126          self._completeIfNotSet(self._team_url)
127          return self._team_url.value
128  
129      @property
130      def title(self) -> str:
131          self._completeIfNotSet(self._title)
132          return self._title.value
133  
134      @property
135      def updated_at(self) -> datetime:
136          self._completeIfNotSet(self._updated_at)
137          return self._updated_at.value
138  
139      @property
140      def url(self) -> str:
141          self._completeIfNotSet(self._url)
142          return self._url.value
143  
144      def _useAttributes(self, attributes: dict[str, Any]) -> None:
145          if "author" in attributes:  # pragma no branch
146              self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"])
147          if "body" in attributes:  # pragma no branch
148              self._body = self._makeStringAttribute(attributes["body"])
149          if "body_html" in attributes:  # pragma no branch
150              self._body_html = self._makeStringAttribute(attributes["body_html"])
151          if "body_version" in attributes:  # pragma no branch
152              self._body_version = self._makeStringAttribute(attributes["body_version"])
153          if "comments_count" in attributes:  # pragma no branch
154              self._comments_count = self._makeIntAttribute(attributes["comments_count"])
155          if "comments_url" in attributes:  # pragma no branch
156              self._comments_url = self._makeStringAttribute(attributes["comments_url"])
157          if "created_at" in attributes:  # pragma no branch
158              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
159          if "html_url" in attributes:  # pragma no branch
160              self._html_url = self._makeStringAttribute(attributes["html_url"])
161          if "last_edited_at" in attributes:  # pragma no branch
162              self._last_edited_at = self._makeDatetimeAttribute(attributes["last_edited_at"])
163          if "node_id" in attributes:  # pragma no branch
164              self._node_id = self._makeStringAttribute(attributes["node_id"])
165          if "number" in attributes:  # pragma no branch
166              self._number = self._makeIntAttribute(attributes["number"])
167          if "pinned" in attributes:  # pragma no branch
168              self._pinned = self._makeBoolAttribute(attributes["pinned"])
169          if "private" in attributes:  # pragma no branch
170              self._private = self._makeBoolAttribute(attributes["private"])
171          if "team_url" in attributes:  # pragma no branch
172              self._team_url = self._makeStringAttribute(attributes["team_url"])
173          if "title" in attributes:
174              self._title = self._makeStringAttribute(attributes["title"])
175          if "updated_at" in attributes:  # pragma no branch
176              self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
177          if "url" in attributes:  # pragma no branch
178              self._url = self._makeStringAttribute(attributes["url"])