Get list of maintainer-groups for a project

I am an admin for a self-hosted GitLab-instance. In this instance we add groups/teams as maintainers to projects. I am currently trying to write a python script to fetch the maintainer-group for each project to create a label/tag with project ownership for each repo to improve metadata for logging-purposes.

Unfortunately the project/:id-endpoint of the api did not return any list of maintainers.
Then I attempted to go through each group and fetch all projects where the group are maintainers with the following api-call:
> /api/v4/groups/{groupid}/projects?min_access_level=40

The problem with this is that the min_access_level-parameter queries with my personal access token as an admin, which will retrieve more projects than it should, since I am owner/maintainer of pretty much all projects, so the response is not accurate by any means.

My next and final solution would then need to be:

  • Fetch a single user from each group,
  • Create an impersonation-token for that user,
  • Use that token to fetch projects for each group where the group are maintainers (which might not be accurate since this user might have membership to several groups or have set up private projects),
  • Revoke the impersonation token and validate the revoking
  • Create the labels

This, to me, seems like a way too roundabout process of getting data that I think should be pretty easy to get. Am I missing something that would make getting maintainer-groups of a specific project easier?

Thanks in advance

1 Like