Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deployment approve/reject via python api supported?#2252

jbotello7381 started this conversation inGeneral
Discussion options

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.

You must be logged in to vote

Replies: 4 comments 3 replies

Comment options

Would be useful to have a link to the upstream GitLab API docs for what is missing. Thanks.

You must be logged in to vote
0 replies
Comment options

Sorry, this is the endpoint
https://docs.gitlab.com/ee/ci/environments/deployment_approvals.html#approve-or-reject-a-deployment-using-the-api

You must be logged in to vote
0 replies
Comment options

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.

@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

You must be logged in to vote
2 replies
@JohnVillalovos
Comment options

I opened#2253 as a RFE (Request For Enhancement)

@JohnVillalovos
Comment options

Created a PR:#2254

Comment options

I tested on my local environment with your PR and it works. Thanks for the quick PR.

You must be logged in to vote
1 reply
@JohnVillalovos
Comment options

I tested on my local environment with your PR and it works. Thanks for the quick PR.

Thanks for the test! Glad to know it works.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@jbotello7381@JohnVillalovos

[8]ページ先頭

©2009-2025 Movatter.jp