0

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/)

1 Answer 1

1

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,
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.