/ github / Event.py
Event.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 2013 martinqt <m.ki2@laposte.net>                                  #
  8  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
  9  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
 10  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 11  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 12  #                                                                              #
 13  # This file is part of PyGithub.                                               #
 14  # http://pygithub.readthedocs.io/                                              #
 15  #                                                                              #
 16  # PyGithub is free software: you can redistribute it and/or modify it under    #
 17  # the terms of the GNU Lesser General Public License as published by the Free  #
 18  # Software Foundation, either version 3 of the License, or (at your option)    #
 19  # any later version.                                                           #
 20  #                                                                              #
 21  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 22  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 23  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 24  # details.                                                                     #
 25  #                                                                              #
 26  # You should have received a copy of the GNU Lesser General Public License     #
 27  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 28  #                                                                              #
 29  ################################################################################
 30  from __future__ import annotations
 31  
 32  from datetime import datetime
 33  from typing import Any
 34  
 35  import github.GithubObject
 36  import github.NamedUser
 37  import github.Organization
 38  import github.Repository
 39  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
 40  
 41  
 42  class Event(NonCompletableGithubObject):
 43      """
 44      This class represents Events. The reference can be found here https://docs.github.com/en/rest/reference/activity#events
 45      """
 46  
 47      def _initAttributes(self) -> None:
 48          self._actor: Attribute[github.NamedUser.NamedUser] = NotSet
 49          self._created_at: Attribute[datetime] = NotSet
 50          self._id: Attribute[str] = NotSet
 51          self._org: Attribute[github.Organization.Organization] = NotSet
 52          self._payload: Attribute[dict[str, Any]] = NotSet
 53          self._public: Attribute[bool] = NotSet
 54          self._repo: Attribute[github.Repository.Repository] = NotSet
 55          self._type: Attribute[str] = NotSet
 56  
 57      def __repr__(self) -> str:
 58          return self.get__repr__({"id": self._id.value, "type": self._type.value})
 59  
 60      @property
 61      def actor(self) -> github.NamedUser.NamedUser:
 62          return self._actor.value
 63  
 64      @property
 65      def created_at(self) -> datetime:
 66          return self._created_at.value
 67  
 68      @property
 69      def id(self) -> str:
 70          return self._id.value
 71  
 72      @property
 73      def org(self) -> github.Organization.Organization:
 74          return self._org.value
 75  
 76      @property
 77      def payload(self) -> dict[str, Any]:
 78          return self._payload.value
 79  
 80      @property
 81      def public(self) -> bool:
 82          return self._public.value
 83  
 84      @property
 85      def repo(self) -> github.Repository.Repository:
 86          return self._repo.value
 87  
 88      @property
 89      def type(self) -> str:
 90          return self._type.value
 91  
 92      def _useAttributes(self, attributes: dict[str, Any]) -> None:
 93          if "actor" in attributes:  # pragma no branch
 94              self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"])
 95          if "created_at" in attributes:  # pragma no branch
 96              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
 97          if "id" in attributes:  # pragma no branch
 98              self._id = self._makeStringAttribute(attributes["id"])
 99          if "org" in attributes:  # pragma no branch
100              self._org = self._makeClassAttribute(github.Organization.Organization, attributes["org"])
101          if "payload" in attributes:  # pragma no branch
102              self._payload = self._makeDictAttribute(attributes["payload"])
103          if "public" in attributes:  # pragma no branch
104              self._public = self._makeBoolAttribute(attributes["public"])
105          if "repo" in attributes:  # pragma no branch
106              self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"])
107          if "type" in attributes:  # pragma no branch
108              self._type = self._makeStringAttribute(attributes["type"])