mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Added support for Repository.get_workflow_runs parameters (#1682)
* Added support for `Repository.get_workflow_runs` parameters * Added anchor tag to docstring link * Tests
This commit is contained in:
+53
-13
@@ -3015,19 +3015,6 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
list_item="workflows",
|
||||
)
|
||||
|
||||
def get_workflow_runs(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/actions/runs <https://developer.github.com/v3/actions/workflow-runs>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowRun.WorkflowRun`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.WorkflowRun.WorkflowRun,
|
||||
self._requester,
|
||||
self.url + "/actions/runs",
|
||||
None,
|
||||
list_item="workflow_runs",
|
||||
)
|
||||
|
||||
def get_workflow(self, id_or_name):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/actions/workflows/:workflow_id <https://developer.github.com/v3/actions/workflows>`_
|
||||
@@ -3041,6 +3028,59 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Workflow.Workflow(self._requester, headers, data, completed=True)
|
||||
|
||||
def get_workflow_runs(
|
||||
self,
|
||||
actor=github.GithubObject.NotSet,
|
||||
branch=github.GithubObject.NotSet,
|
||||
event=github.GithubObject.NotSet,
|
||||
status=github.GithubObject.NotSet,
|
||||
):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/actions/runs <https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository>`_
|
||||
:param actor: :class:`github.NamedUser.NamedUser` or string
|
||||
:param branch: :class:`github.Branch.Branch` or string
|
||||
:param event: string
|
||||
:param status: string `queued`, `in_progress`, `completed`, `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required`
|
||||
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowRun.WorkflowRun`
|
||||
"""
|
||||
assert (
|
||||
actor is github.GithubObject.NotSet
|
||||
or isinstance(actor, github.NamedUser.NamedUser)
|
||||
or isinstance(actor, str)
|
||||
), actor
|
||||
assert (
|
||||
branch is github.GithubObject.NotSet
|
||||
or isinstance(branch, github.Branch.Branch)
|
||||
or isinstance(branch, str)
|
||||
), branch
|
||||
assert event is github.GithubObject.NotSet or isinstance(event, str), event
|
||||
assert status is github.GithubObject.NotSet or isinstance(status, str), status
|
||||
|
||||
url_parameters = dict()
|
||||
if actor is not github.GithubObject.NotSet:
|
||||
if isinstance(actor, github.NamedUser.NamedUser):
|
||||
url_parameters["actor"] = actor._identity
|
||||
else:
|
||||
url_parameters["actor"] = actor
|
||||
if branch is not github.GithubObject.NotSet:
|
||||
if isinstance(branch, github.Branch.Branch):
|
||||
url_parameters["branch"] = branch.name
|
||||
else:
|
||||
url_parameters["branch"] = branch
|
||||
if event is not github.GithubObject.NotSet:
|
||||
url_parameters["event"] = event
|
||||
if status is not github.GithubObject.NotSet:
|
||||
url_parameters["status"] = status
|
||||
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.WorkflowRun.WorkflowRun,
|
||||
self._requester,
|
||||
self.url + "/actions/runs",
|
||||
url_parameters,
|
||||
list_item="workflow_runs",
|
||||
)
|
||||
|
||||
def get_workflow_run(self, id_):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/actions/runs/:run_id <https://developer.github.com/v3/actions/workflow-runs>`_
|
||||
|
||||
Reference in New Issue
Block a user