EnvironmentProtectionRule.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.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 typing import TYPE_CHECKING, Any 25 26 import github.EnvironmentProtectionRuleReviewer 27 from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet 28 29 if TYPE_CHECKING: 30 from github.EnvironmentProtectionRuleReviewer import EnvironmentProtectionRuleReviewer 31 32 33 class EnvironmentProtectionRule(NonCompletableGithubObject): 34 """ 35 This class represents a protection rule for an environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments 36 """ 37 38 def _initAttributes(self) -> None: 39 self._id: Attribute[int] = NotSet 40 self._node_id: Attribute[str] = NotSet 41 self._type: Attribute[str] = NotSet 42 self._reviewers: Attribute[list[EnvironmentProtectionRuleReviewer]] = NotSet 43 self._wait_timer: Attribute[int] = NotSet 44 45 def __repr__(self) -> str: 46 return self.get__repr__({"id": self._id.value}) 47 48 @property 49 def id(self) -> int: 50 return self._id.value 51 52 @property 53 def node_id(self) -> str: 54 return self._node_id.value 55 56 @property 57 def type(self) -> str: 58 return self._type.value 59 60 @property 61 def reviewers( 62 self, 63 ) -> list[EnvironmentProtectionRuleReviewer]: 64 return self._reviewers.value 65 66 @property 67 def wait_timer(self) -> int: 68 return self._wait_timer.value 69 70 def _useAttributes(self, attributes: dict[str, Any]) -> None: 71 if "id" in attributes: # pragma no branch 72 self._id = self._makeIntAttribute(attributes["id"]) 73 if "node_id" in attributes: # pragma no branch 74 self._node_id = self._makeStringAttribute(attributes["node_id"]) 75 if "type" in attributes: # pragma no branch 76 self._type = self._makeStringAttribute(attributes["type"]) 77 if "reviewers" in attributes: # pragma no branch 78 self._reviewers = self._makeListOfClassesAttribute( 79 github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer, 80 attributes["reviewers"], 81 ) 82 if "wait_timer" in attributes: # pragma no branch 83 self._wait_timer = self._makeIntAttribute(attributes["wait_timer"])