| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 14b88a1 commit c01c034
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,23 @@ def __call__( | |||
| 45 | 45 | **kwargs, | |
| 46 | 46 | ) | |
| 47 | 47 | ||
| 48 | + @exc.on_http_error(exc.GitlabDeleteError) | ||
| 49 | + def delete(self, **kwargs: Any) -> None: | ||
| 50 | + """Delete the project's artifacts on the server. | ||
| 51 | + | ||
| 52 | + Args: | ||
| 53 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 54 | + | ||
| 55 | + Raises: | ||
| 56 | + GitlabAuthenticationError: If authentication is not correct | ||
| 57 | + GitlabDeleteError: If the server cannot perform the request | ||
| 58 | + """ | ||
| 59 | + path = self._compute_path("/projects/{project_id}/artifacts") | ||
| 60 | + | ||
| 61 | + if TYPE_CHECKING: | ||
| 62 | + assert path is not None | ||
| 63 | + self.gitlab.http_delete(path, **kwargs) | ||
| 64 | + | ||
| 48 | 65 | @cli.register_custom_action( | |
| 49 | 66 | "ProjectArtifactManager", ("ref_name", "job"), ("job_token",) | |
| 50 | 67 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,24 @@ def resp_artifacts_by_ref_name(binary_content): | |||
| 24 | 24 | yield rsps | |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | + @pytest.fixture | ||
| 28 | + def resp_project_artifacts_delete(no_content): | ||
| 29 | + with responses.RequestsMock() as rsps: | ||
| 30 | + rsps.add( | ||
| 31 | + method=responses.DELETE, | ||
| 32 | + url="http://localhost/api/v4/projects/1/artifacts", | ||
| 33 | + json=no_content, | ||
| 34 | + content_type="application/json", | ||
| 35 | + status=204, | ||
| 36 | + ) | ||
| 37 | + yield rsps | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + def test_project_artifacts_delete(gl, resp_project_artifacts_delete): | ||
| 41 | + project = gl.projects.get(1, lazy=True) | ||
| 42 | + project.artifacts.delete() | ||
| 43 | + | ||
| 44 | + | ||
| 27 | 45 | def test_project_artifacts_download_by_ref_name( | |
| 28 | 46 | gl, binary_content, resp_artifacts_by_ref_name | |
| 29 | 47 | ): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments