summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorLucas Zampieri <lzampier@redhat.com>2022-09-22 16:09:47 -0300
committerNejc Habjan <hab.nejc@gmail.com>2022-09-26 21:19:14 +0200
commit88693ff2d6f4eecf3c79d017df52738886e2d636 (patch)
treee1c65e4c58ab52df5dac135b673f6a19d64cc3bc /gitlab
parent1714d0a980afdb648d203751dedf95ee95ac326e (diff)
downloadgitlab-88693ff2d6f4eecf3c79d017df52738886e2d636.tar.gz
feat: Add reset_approvals api
Added the newly added reset_approvals merge request api. Signed-off-by: Lucas Zampieri <lzampier@redhat.com>
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/exceptions.py4
-rw-r--r--gitlab/v4/objects/merge_requests.py18
2 files changed, 22 insertions, 0 deletions
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py
index 633de5b..613e9a0 100644
--- a/gitlab/exceptions.py
+++ b/gitlab/exceptions.py
@@ -205,6 +205,10 @@ class GitlabMRRebaseError(GitlabOperationError):
pass
+class GitlabMRResetApprovalError(GitlabOperationError):
+ pass
+
+
class GitlabMRClosedError(GitlabOperationError):
pass
diff --git a/gitlab/v4/objects/merge_requests.py b/gitlab/v4/objects/merge_requests.py
index 6a47b7b..2e1ab09 100644
--- a/gitlab/v4/objects/merge_requests.py
+++ b/gitlab/v4/objects/merge_requests.py
@@ -328,6 +328,24 @@ class ProjectMergeRequest(
return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
@cli.register_custom_action("ProjectMergeRequest")
+ @exc.on_http_error(exc.GitlabMRResetApprovalError)
+ def reset_approvals(
+ self, **kwargs: Any
+ ) -> Union[Dict[str, Any], requests.Response]:
+ """Clear all approvals of the merge request.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabMRResetApprovalError: If reset approval failed
+ """
+ path = f"{self.manager.path}/{self.encoded_id}/reset_approvals"
+ data: Dict[str, Any] = {}
+ return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
+
+ @cli.register_custom_action("ProjectMergeRequest")
@exc.on_http_error(exc.GitlabGetError)
def merge_ref(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
"""Attempt to merge changes between source and target branches into