/ github / IssueEvent.py
IssueEvent.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
  4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
  5  # Copyright 2013 AKFish <akfish@gmail.com>                                     #
  6  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
  7  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
  8  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
  9  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 10  # Copyright 2017 Simon <spam@esemi.ru>                                         #
 11  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 12  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 13  #                                                                              #
 14  # This file is part of PyGithub.                                               #
 15  # http://pygithub.readthedocs.io/                                              #
 16  #                                                                              #
 17  # PyGithub is free software: you can redistribute it and/or modify it under    #
 18  # the terms of the GNU Lesser General Public License as published by the Free  #
 19  # Software Foundation, either version 3 of the License, or (at your option)    #
 20  # any later version.                                                           #
 21  #                                                                              #
 22  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 23  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 24  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 25  # details.                                                                     #
 26  #                                                                              #
 27  # You should have received a copy of the GNU Lesser General Public License     #
 28  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 29  #                                                                              #
 30  ################################################################################
 31  from __future__ import annotations
 32  
 33  from datetime import datetime
 34  from typing import Any
 35  
 36  import github.GithubObject
 37  import github.Issue
 38  import github.Label
 39  import github.Milestone
 40  import github.NamedUser
 41  from github.GithubObject import Attribute, CompletableGithubObject, NotSet
 42  
 43  
 44  class IssueEvent(CompletableGithubObject):
 45      """
 46      This class represents IssueEvents. The reference can be found here https://docs.github.com/en/rest/reference/issues#events
 47      """
 48  
 49      def _initAttributes(self) -> None:
 50          self._actor: Attribute[github.NamedUser.NamedUser] = NotSet
 51          self._commit_id: Attribute[str] = NotSet
 52          self._created_at: Attribute[datetime] = NotSet
 53          self._event: Attribute[str] = NotSet
 54          self._id: Attribute[int] = NotSet
 55          self._issue: Attribute[github.Issue.Issue] = NotSet
 56          self._url: Attribute[str] = NotSet
 57          self._node_id: Attribute[str] = NotSet
 58          self._commit_url: Attribute[str] = NotSet
 59          self._label: Attribute[github.Label.Label] = NotSet
 60          self._assignee: Attribute[github.NamedUser.NamedUser] = NotSet
 61          self._assigner: Attribute[github.NamedUser.NamedUser] = NotSet
 62          self._review_requester: Attribute[github.NamedUser.NamedUser] = NotSet
 63          self._requested_reviewer: Attribute[github.NamedUser.NamedUser] = NotSet
 64          self._milestone: Attribute[github.Milestone.Milestone] = NotSet
 65          self._rename: Attribute[dict] = NotSet
 66          self._dismissed_review: Attribute[dict] = NotSet
 67          self._lock_reason: Attribute[str] = NotSet
 68  
 69      def __repr__(self) -> str:
 70          return self.get__repr__({"id": self._id.value})
 71  
 72      @property
 73      def actor(self) -> github.NamedUser.NamedUser:
 74          self._completeIfNotSet(self._actor)
 75          return self._actor.value
 76  
 77      @property
 78      def commit_id(self) -> str:
 79          self._completeIfNotSet(self._commit_id)
 80          return self._commit_id.value
 81  
 82      @property
 83      def created_at(self) -> datetime:
 84          self._completeIfNotSet(self._created_at)
 85          return self._created_at.value
 86  
 87      @property
 88      def event(self) -> str:
 89          self._completeIfNotSet(self._event)
 90          return self._event.value
 91  
 92      @property
 93      def id(self) -> int:
 94          self._completeIfNotSet(self._id)
 95          return self._id.value
 96  
 97      @property
 98      def issue(self) -> github.Issue.Issue:
 99          self._completeIfNotSet(self._issue)
100          return self._issue.value
101  
102      @property
103      def url(self) -> str:
104          self._completeIfNotSet(self._url)
105          return self._url.value
106  
107      @property
108      def node_id(self) -> str:
109          self._completeIfNotSet(self._node_id)
110          return self._node_id.value
111  
112      @property
113      def commit_url(self) -> str:
114          self._completeIfNotSet(self._commit_url)
115          return self._commit_url.value
116  
117      @property
118      def label(self) -> github.Label.Label:
119          self._completeIfNotSet(self._label)
120          return self._label.value
121  
122      @property
123      def assignee(self) -> github.NamedUser.NamedUser:
124          self._completeIfNotSet(self._assignee)
125          return self._assignee.value
126  
127      @property
128      def assigner(self) -> github.NamedUser.NamedUser:
129          self._completeIfNotSet(self._assigner)
130          return self._assigner.value
131  
132      @property
133      def review_requester(self) -> github.NamedUser.NamedUser:
134          self._completeIfNotSet(self._review_requester)
135          return self._review_requester.value
136  
137      @property
138      def requested_reviewer(self) -> github.NamedUser.NamedUser:
139          self._completeIfNotSet(self._requested_reviewer)
140          return self._requested_reviewer.value
141  
142      @property
143      def milestone(self) -> github.Milestone.Milestone:
144          self._completeIfNotSet(self._milestone)
145          return self._milestone.value
146  
147      @property
148      def rename(self) -> dict:
149          self._completeIfNotSet(self._rename)
150          return self._rename.value
151  
152      @property
153      def dismissed_review(self) -> dict:
154          self._completeIfNotSet(self._dismissed_review)
155          return self._dismissed_review.value
156  
157      @property
158      def lock_reason(self) -> str:
159          self._completeIfNotSet(self._lock_reason)
160          return self._lock_reason.value
161  
162      def _useAttributes(self, attributes: dict[str, Any]) -> None:
163          if "actor" in attributes:  # pragma no branch
164              self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"])
165          if "commit_id" in attributes:  # pragma no branch
166              self._commit_id = self._makeStringAttribute(attributes["commit_id"])
167          if "created_at" in attributes:  # pragma no branch
168              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
169          if "event" in attributes:  # pragma no branch
170              self._event = self._makeStringAttribute(attributes["event"])
171          if "id" in attributes:  # pragma no branch
172              self._id = self._makeIntAttribute(attributes["id"])
173          if "issue" in attributes:  # pragma no branch
174              self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"])
175          if "url" in attributes:  # pragma no branch
176              self._url = self._makeStringAttribute(attributes["url"])
177          if "node_id" in attributes:  # pragma no branch
178              self._node_id = self._makeStringAttribute(attributes["node_id"])
179          if "commit_url" in attributes:  # pragma no branch
180              self._commit_url = self._makeStringAttribute(attributes["commit_url"])
181          if "label" in attributes:  # pragma no branch
182              self._label = self._makeClassAttribute(github.Label.Label, attributes["label"])
183          if "assignee" in attributes:  # pragma no branch
184              self._assignee = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assignee"])
185          if "assigner" in attributes:  # pragma no branch
186              self._assigner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["assigner"])
187          if "review_requester" in attributes:  # pragma no branch
188              self._review_requester = self._makeClassAttribute(
189                  github.NamedUser.NamedUser, attributes["review_requester"]
190              )
191          if "requested_reviewer" in attributes:  # pragma no branch
192              self._requested_reviewer = self._makeClassAttribute(
193                  github.NamedUser.NamedUser, attributes["requested_reviewer"]
194              )
195          if "milestone" in attributes:  # pragma no branch
196              self._milestone = self._makeClassAttribute(github.Milestone.Milestone, attributes["milestone"])
197          if "rename" in attributes:  # pragma no branch
198              self._rename = self._makeDictAttribute(attributes["rename"])
199          if "dismissed_review" in attributes:  # pragma no branch
200              self._dismissed_review = self._makeDictAttribute(attributes["dismissed_review"])
201          if "lock_reason" in attributes:  # pragma no branch
202              self._lock_reason = self._makeStringAttribute(attributes["lock_reason"])