WorkflowStep.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2021 Jeppe Fihl-Pearson <jeppe@tenzer.dk> # 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 datetime import datetime 23 from typing import Any, Dict 24 25 from github.GithubObject import Attribute, CompletableGithubObject, NotSet 26 27 28 class WorkflowStep(CompletableGithubObject): 29 """ 30 This class represents steps in a Workflow Job. The reference can be found here https://docs.github.com/en/rest/reference/actions#workflow-jobs 31 """ 32 33 def _initAttributes(self) -> None: 34 self._completed_at: Attribute[datetime] = NotSet 35 self._conclusion: Attribute[str] = NotSet 36 self._name: Attribute[str] = NotSet 37 self._number: Attribute[int] = NotSet 38 self._started_at: Attribute[datetime] = NotSet 39 self._status: Attribute[str] = NotSet 40 41 def __repr__(self) -> str: 42 return self.get__repr__({"number": self._number.value, "name": self._name.value}) 43 44 @property 45 def completed_at(self) -> datetime: 46 self._completeIfNotSet(self._completed_at) 47 return self._completed_at.value 48 49 @property 50 def conclusion(self) -> str: 51 self._completeIfNotSet(self._conclusion) 52 return self._conclusion.value 53 54 @property 55 def name(self) -> str: 56 self._completeIfNotSet(self._name) 57 return self._name.value 58 59 @property 60 def number(self) -> int: 61 self._completeIfNotSet(self._number) 62 return self._number.value 63 64 @property 65 def started_at(self) -> datetime: 66 self._completeIfNotSet(self._started_at) 67 return self._started_at.value 68 69 @property 70 def status(self) -> str: 71 self._completeIfNotSet(self._status) 72 return self._status.value 73 74 def _useAttributes(self, attributes: Dict[str, Any]) -> None: 75 if "completed_at" in attributes: # pragma no branch 76 self._completed_at = self._makeDatetimeAttribute(attributes["completed_at"]) 77 if "conclusion" in attributes: # pragma no branch 78 self._conclusion = self._makeStringAttribute(attributes["conclusion"]) 79 if "name" in attributes: # pragma no branch 80 self._name = self._makeStringAttribute(attributes["name"]) 81 if "number" in attributes: # pragma no branch 82 self._number = self._makeIntAttribute(attributes["number"]) 83 if "started_at" in attributes: # pragma no branch 84 self._started_at = self._makeDatetimeAttribute(attributes["started_at"]) 85 if "status" in attributes: # pragma no branch 86 self._status = self._makeStringAttribute(attributes["status"])