/ github / DeploymentStatus.py
DeploymentStatus.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2020 Colby Gallup <colbygallup@gmail.com>                          #
  4  # Copyright 2020 Pascal Hofmann <mail@pascalhofmann.de>                        #
  5  #                                                                              #
  6  # This file is part of PyGithub.                                               #
  7  # http://pygithub.readthedocs.io/                                              #
  8  #                                                                              #
  9  # PyGithub is free software: you can redistribute it and/or modify it under    #
 10  # the terms of the GNU Lesser General Public License as published by the Free  #
 11  # Software Foundation, either version 3 of the License, or (at your option)    #
 12  # any later version.                                                           #
 13  #                                                                              #
 14  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 15  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 16  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 17  # details.                                                                     #
 18  #                                                                              #
 19  # You should have received a copy of the GNU Lesser General Public License     #
 20  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 21  #                                                                              #
 22  ################################################################################
 23  from __future__ import annotations
 24  
 25  from datetime import datetime
 26  from typing import Any
 27  
 28  import github.NamedUser
 29  from github.GithubObject import Attribute, CompletableGithubObject, NotSet
 30  
 31  
 32  class DeploymentStatus(CompletableGithubObject):
 33      """
 34      This class represents Deployment Statuses. The reference can be found here https://docs.github.com/en/rest/reference/repos#deployments
 35      """
 36  
 37      def _initAttributes(self) -> None:
 38          self._created_at: Attribute[datetime] = NotSet
 39          self._creator: Attribute[github.NamedUser.NamedUser] = NotSet
 40          self._deployment_url: Attribute[str] = NotSet
 41          self._description: Attribute[str] = NotSet
 42          self._environment: Attribute[str] = NotSet
 43          self._environment_url: Attribute[str] = NotSet
 44          self._repository_url: Attribute[str] = NotSet
 45          self._state: Attribute[str] = NotSet
 46          self._target_url: Attribute[str] = NotSet
 47          self._updated_at: Attribute[datetime] = NotSet
 48          self._url: Attribute[str] = NotSet
 49          self._id: Attribute[int] = NotSet
 50          self._node_id: Attribute[str] = NotSet
 51  
 52      def __repr__(self) -> str:
 53          return self.get__repr__({"id": self._id.value, "url": self._url.value})
 54  
 55      @property
 56      def created_at(self) -> datetime:
 57          self._completeIfNotSet(self._created_at)
 58          return self._created_at.value
 59  
 60      @property
 61      def creator(self) -> github.NamedUser.NamedUser:
 62          self._completeIfNotSet(self._creator)
 63          return self._creator.value
 64  
 65      @property
 66      def deployment_url(self) -> str:
 67          self._completeIfNotSet(self._deployment_url)
 68          return self._deployment_url.value
 69  
 70      @property
 71      def description(self) -> str:
 72          self._completeIfNotSet(self._description)
 73          return self._description.value
 74  
 75      @property
 76      def environment(self) -> str:
 77          self._completeIfNotSet(self._environment)
 78          return self._environment.value
 79  
 80      @property
 81      def environment_url(self) -> str:
 82          self._completeIfNotSet(self._environment_url)
 83          return self._environment_url.value
 84  
 85      @property
 86      def repository_url(self) -> str:
 87          self._completeIfNotSet(self._repository_url)
 88          return self._repository_url.value
 89  
 90      @property
 91      def state(self) -> str:
 92          self._completeIfNotSet(self._state)
 93          return self._state.value
 94  
 95      @property
 96      def target_url(self) -> str:
 97          self._completeIfNotSet(self._target_url)
 98          return self._target_url.value
 99  
100      @property
101      def updated_at(self) -> datetime:
102          self._completeIfNotSet(self._updated_at)
103          return self._updated_at.value
104  
105      @property
106      def url(self) -> str:
107          self._completeIfNotSet(self._url)
108          return self._url.value
109  
110      @property
111      def id(self) -> int:
112          self._completeIfNotSet(self._id)
113          return self._id.value
114  
115      @property
116      def node_id(self) -> str:
117          self._completeIfNotSet(self._node_id)
118          return self._node_id.value
119  
120      def _useAttributes(self, attributes: dict[str, Any]) -> None:
121          if "environment_url" in attributes:  # pragma no branch
122              self._environment_url = self._makeStringAttribute(attributes["environment_url"])
123          if "url" in attributes:  # pragma no branch
124              self._url = self._makeStringAttribute(attributes["url"])
125          if "id" in attributes:  # pragma no branch
126              self._id = self._makeIntAttribute(attributes["id"])
127          if "node_id" in attributes:  # pragma no branch
128              self._node_id = self._makeStringAttribute(attributes["node_id"])
129          if "created_at" in attributes:  # pragma no branch
130              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
131          if "creator" in attributes:  # pragma no branch
132              self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"])
133          if "deployment_url" in attributes:  # pragma no branch
134              self._deployment_url = self._makeStringAttribute(attributes["deployment_url"])
135          if "description" in attributes:  # pragma no branch
136              self._description = self._makeStringAttribute(attributes["description"])
137          if "environment" in attributes:  # pragma no branch
138              self._environment = self._makeStringAttribute(attributes["environment"])
139          if "repository_url" in attributes:  # pragma no branch
140              self._repository_url = self._makeStringAttribute(attributes["repository_url"])
141          if "state" in attributes:  # pragma no branch
142              self._state = self._makeStringAttribute(attributes["state"])
143          if "target_url" in attributes:  # pragma no branch
144              self._target_url = self._makeStringAttribute(attributes["target_url"])
145          if "updated_at" in attributes:  # pragma no branch
146              self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])