diff options
| author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-23 18:16:24 +0200 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2022-07-23 10:32:57 -0700 |
| commit | 4794ecc45d7aa08785c622918d08bb046e7359ae (patch) | |
| tree | 60878cab2e063f48e21161cdba81943e0c061006 /gitlab | |
| parent | 98336320a66d1859ba73e084a5e86edc3aa1643c (diff) | |
| download | gitlab-4794ecc45d7aa08785c622918d08bb046e7359ae.tar.gz | |
feat(projects): add support for project restore API
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/exceptions.py | 4 | ||||
| -rw-r--r-- | gitlab/v4/objects/projects.py | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py index 4a2f1dc..9ee64e3 100644 --- a/gitlab/exceptions.py +++ b/gitlab/exceptions.py @@ -286,6 +286,10 @@ class GitlabRepairError(GitlabOperationError): pass +class GitlabRestoreError(GitlabOperationError): + pass + + class GitlabRevertError(GitlabOperationError): pass diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 96d802b..a90bffb 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -477,6 +477,21 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO assert isinstance(data, dict) return {"alt": data["alt"], "url": data["url"], "markdown": data["markdown"]} + @cli.register_custom_action("Project") + @exc.on_http_error(exc.GitlabRestoreError) + def restore(self, **kwargs: Any) -> None: + """Restore a project marked for deletion. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabRestoreError: If the server failed to perform the request + """ + path = f"/projects/{self.encoded_id}/restore" + self.manager.gitlab.http_post(path, **kwargs) + @cli.register_custom_action("Project", optional=("wiki",)) @exc.on_http_error(exc.GitlabGetError) def snapshot( |
