- Notifications
You must be signed in to change notification settings - Fork673
Closed
Description
Discussed in#2252
Originally posted byjbotello7381 August 23, 2022
I was playing with deployment and gitlab python library, and notice there's no method to approve or reject a deployment? i was able to do it via REST API from my python code, but not via the python wrapper. I'm using 3.8.1 of the gitlab python library.
So it looks like it is this API:
https://docs.gitlab.com/ee/api/deployments.html#approve-or-reject-a-blocked-deployment
And it doesn't look like there is any support for that yet in:
https://github.com/python-gitlab/python-gitlab/blob/main/gitlab/v4/objects/deployments.py
Implementing it will look similar to how the "approve" method is done for a merge request.
python-gitlab/gitlab/v4/objects/merge_requests.py
Lines 263 to 290 inf67514e
@cli.register_custom_action("ProjectMergeRequest", (), ("sha",)) | |
@exc.on_http_error(exc.GitlabMRApprovalError) | |
defapprove(self,sha:Optional[str]=None,**kwargs:Any)->Dict[str,Any]: | |
"""Approve the merge request. | |
Args: | |
sha: Head SHA of MR | |
**kwargs: Extra options to send to the server (e.g. sudo) | |
Raises: | |
GitlabAuthenticationError: If authentication is not correct | |
GitlabMRApprovalError: If the approval failed | |
Returns: | |
A dict containing the result. | |
https://docs.gitlab.com/ee/api/merge_request_approvals.html#approve-merge-request | |
""" | |
path=f"{self.manager.path}/{self.encoded_id}/approve" | |
data= {} | |
ifsha: | |
data["sha"]=sha | |
server_data=self.manager.gitlab.http_post(path,post_data=data,**kwargs) | |
ifTYPE_CHECKING: | |
assertisinstance(server_data,dict) | |
self._update_attrs(server_data) | |
returnserver_data |
Metadata
Metadata
Assignees
Labels
No labels