diff options
author | Jonathon Reinhart <Jonathon.Reinhart@gmail.com> | 2016-10-02 10:30:39 -0400 |
---|---|---|
committer | Jonathon Reinhart <Jonathon.Reinhart@gmail.com> | 2016-10-02 10:30:39 -0400 |
commit | c2f45e90a52cb418665c65258628d382e0725401 (patch) | |
tree | 06dbdfff382d6b631561c3c03d0f351d61f26f02 | |
parent | 7d424ae5a4dad41533af7add24d728c315563022 (diff) | |
download | gitlab-c2f45e90a52cb418665c65258628d382e0725401.tar.gz |
Add ProjectBuild.erase()
We can't use the existing delete() functionality, because GitLab uses
`POST /projects/:id/builds/:build_id/erase` to erase a build. Instead of
overriding delete(), we add a separate erase() method to keep the naming
consistent, and allow potentially more fine-grained operations in the
future.
- https://docs.gitlab.com/ce/api/builds.html#erase-a-build
-rw-r--r-- | gitlab/exceptions.py | 4 | ||||
-rw-r--r-- | gitlab/objects.py | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py index 7b0f7f0..0fc8617 100644 --- a/gitlab/exceptions.py +++ b/gitlab/exceptions.py @@ -95,6 +95,10 @@ class GitlabBuildRetryError(GitlabRetryError): pass +class GitlabBuildEraseError(GitlabRetryError): + pass + + class GitlabPipelineRetryError(GitlabRetryError): pass diff --git a/gitlab/objects.py b/gitlab/objects.py index 8821633..2609e1b 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -961,6 +961,12 @@ class ProjectBuild(GitlabObject): r = self.gitlab._raw_post(url) raise_error_from_response(r, GitlabBuildRetryError, 201) + def erase(self, **kwargs): + """Erase the build (remove build artifacts and trace).""" + url = '/projects/%s/builds/%s/erase' % (self.project_id, self.id) + r = self.gitlab._raw_post(url) + raise_error_from_response(r, GitlabBuildEraseError, 201) + def keep_artifacts(self, **kwargs): """Prevent artifacts from being delete when expiration is set. |