Add class Artifact (#2313) (#2319)

Co-authored-by: Aleksei Fedotov <aleksei@fedotov.email>
This commit is contained in:
Aleksei Fedotov
2022-10-25 11:02:33 +08:00
committed by GitHub
co-authored by Aleksei Fedotov
parent 17b44d8857
commit 437ff8452a
12 changed files with 432 additions and 0 deletions
+29
View File
@@ -65,6 +65,7 @@
# Copyright 2018 Yves Zumbach <yzumbach@andrew.cmu.edu> #
# Copyright 2018 Leying Chen <leyingc@andrew.cmu.edu> #
# Copyright 2020 Pascal Hofmann <mail@pascalhofmann.de> #
# Copyright 2022 Aleksei Fedotov <aleksei@fedotov.email> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
@@ -91,6 +92,7 @@ from base64 import b64encode
from deprecated import deprecated
import github.Artifact
import github.Branch
import github.CheckRun
import github.CheckSuite
@@ -3703,6 +3705,33 @@ class Repository(github.GithubObject.CompletableGithubObject):
)
return github.CheckRun.CheckRun(self._requester, headers, data, completed=True)
def get_artifacts(self):
"""
:calls: `GET /repos/{owner}/{repo}/actions/artifacts <https://docs.github.com/en/rest/actions/artifacts#list-artifacts-for-a-repository>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Artifact.Artifact`
"""
return github.PaginatedList.PaginatedList(
github.Artifact.Artifact,
self._requester,
f"{self.url}/actions/artifacts",
None,
list_item="artifacts",
)
def get_artifact(self, artifact_id):
"""
:calls: `GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id} <https://docs.github.com/en/rest/actions/artifacts#get-an-artifact>`_
:param artifact_id: int
:rtype: :class:`github.Artifact.Artifact`
"""
assert isinstance(artifact_id, int), artifact_id
headers, data = self._requester.requestJsonAndCheck(
"GET", f"{self.url}/actions/artifacts/{artifact_id}"
)
return github.Artifact.Artifact(self._requester, headers, data, completed=True)
def _initAttributes(self):
self._allow_merge_commit = github.GithubObject.NotSet
self._allow_rebase_merge = github.GithubObject.NotSet