Using python Gitlab API, how to list merge requests filtered by some attributes ?
For instance, using curl I can use attributes in my request like ?author_username=MY_NAME&source_branch=MY_BRANCH
.
But I cannot find those attribute in the documentation (https://python-gitlab.readthedocs.io/en/stable/)
As the python-gitlab landing page you linked to states:
python-gitlab
enables you to [...] pass arbitrary parameters to the GitLab API. Simply follow GitLab’s docs on what parameters are available.
So you can just pass the GitLab APIs to the list call. Example:
import os
import gitlab
gl = gitlab.Gitlab(private_token=os.getenv("GITLAB_TOKEN"))
# Instance level
mrs = gl.mergerequests.list(
author_username=AUTHOR_USERNAME,
source_branch=SOURCE_BRANCH,
)
# Project level
project = gl.projects.get("your-group/your-project", lazy=True)
project_mrs = project.mergerequests.list(
author_username=AUTHOR_USERNAME,
source_branch=SOURCE_BRANCH,
)