CommitStatus.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 2015 Matt Babineau <mbabineau@dataxu.com> # 9 # Copyright 2016 Jannis Gebauer <ja.geb@me.com> # 10 # Copyright 2016 Martijn Koster <mak-github@greenhills.co.uk> # 11 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 12 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 13 # Copyright 2018 sfdye <tsfdye@gmail.com> # 14 # # 15 # This file is part of PyGithub. # 16 # http://pygithub.readthedocs.io/ # 17 # # 18 # PyGithub is free software: you can redistribute it and/or modify it under # 19 # the terms of the GNU Lesser General Public License as published by the Free # 20 # Software Foundation, either version 3 of the License, or (at your option) # 21 # any later version. # 22 # # 23 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 24 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 25 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 26 # details. # 27 # # 28 # You should have received a copy of the GNU Lesser General Public License # 29 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 30 # # 31 ################################################################################ 32 from __future__ import annotations 33 34 from datetime import datetime 35 from typing import Any 36 37 import github.GithubObject 38 import github.NamedUser 39 from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet 40 41 42 class CommitStatus(NonCompletableGithubObject): 43 """ 44 This class represents CommitStatuses.The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses 45 """ 46 47 def _initAttributes(self) -> None: 48 self._created_at: Attribute[datetime] = NotSet 49 self._creator: Attribute[github.NamedUser.NamedUser] = NotSet 50 self._description: Attribute[str] = NotSet 51 self._id: Attribute[int] = NotSet 52 self._state: Attribute[str] = NotSet 53 self._context: Attribute[str] = NotSet 54 self._target_url: Attribute[str] = NotSet 55 self._updated_at: Attribute[datetime] = NotSet 56 self._url: Attribute[str] = NotSet 57 58 def __repr__(self) -> str: 59 return self.get__repr__( 60 { 61 "id": self._id.value, 62 "state": self._state.value, 63 "context": self._context.value, 64 } 65 ) 66 67 @property 68 def created_at(self) -> datetime: 69 return self._created_at.value 70 71 @property 72 def creator(self) -> github.NamedUser.NamedUser: 73 return self._creator.value 74 75 @property 76 def description(self) -> str: 77 return self._description.value 78 79 @property 80 def id(self) -> int: 81 return self._id.value 82 83 @property 84 def state(self) -> str: 85 return self._state.value 86 87 @property 88 def context(self) -> str: 89 return self._context.value 90 91 @property 92 def target_url(self) -> str: 93 return self._target_url.value 94 95 @property 96 def updated_at(self) -> datetime: 97 return self._updated_at.value 98 99 @property 100 def url(self) -> str: 101 return self._url.value 102 103 def _useAttributes(self, attributes: dict[str, Any]) -> None: 104 if "created_at" in attributes: # pragma no branch 105 self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) 106 if "creator" in attributes: # pragma no branch 107 self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) 108 if "description" in attributes: # pragma no branch 109 self._description = self._makeStringAttribute(attributes["description"]) 110 if "id" in attributes: # pragma no branch 111 self._id = self._makeIntAttribute(attributes["id"]) 112 if "state" in attributes: # pragma no branch 113 self._state = self._makeStringAttribute(attributes["state"]) 114 if "context" in attributes: # pragma no branch 115 self._context = self._makeStringAttribute(attributes["context"]) 116 if "target_url" in attributes: # pragma no branch 117 self._target_url = self._makeStringAttribute(attributes["target_url"]) 118 if "updated_at" in attributes: # pragma no branch 119 self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) 120 if "url" in attributes: # pragma no branch 121 self._url = self._makeStringAttribute(attributes["url"])