Add support for Workflows (#1496)

To start supporting GitHub Actions, add the first part of that,
Workflow, which encapsulates a workflow over the API, along with
two methods on Repository to query them.
This commit is contained in:
Steve Kowalik
2020-05-05 15:49:45 +10:00
committed by GitHub
parent ba9d59c209
commit a1ed7c0e2d
7 changed files with 296 additions and 0 deletions
+24
View File
@@ -135,6 +135,7 @@ import github.StatsPunchCard
import github.Tag
import github.Team
import github.View
import github.Workflow
from . import Consts
@@ -3000,6 +3001,29 @@ class Repository(github.GithubObject.CompletableGithubObject):
github.NamedUser.NamedUser, self._requester, self.url + "/watchers", None
)
def get_workflows(self):
"""
:calls: `GET /repos/:owner/:repo/actions/workflows <https://developer.github.com/v3/actions/workflows>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Workflow.Workflow`
"""
return github.PaginatedList.PaginatedList(
github.Workflow.Workflow,
self._requester,
self.url + "/actions/workflows",
None,
)
def get_workflow(self, id_or_name):
"""
:calls: `GET /repos/:owner/:repo/actions/workflows/:workflow_id <https://developer.github.com/v3/actions/workflows>`_
:rtype: :class:`github.Workflow.Workflow`
"""
assert isinstance(id_or_name, int) or isinstance(id_or_name, str), id_or_name
headers, data = self._requester.requestJsonAndCheck(
"GET", self.url + "/actions/workflows/" + id_or_name
)
return github.Workflow.Workflow(self._requester, headers, data, completed=True)
def has_in_assignees(self, assignee):
"""
:calls: `GET /repos/:owner/:repo/assignees/:assignee <http://developer.github.com/v3/issues/assignees>`_