Gitlab Python API - attribute for date of shared project

Viewed 131

Do you know, whether in Gitlab there is an attribute that can be accessed via the Python API for the date when a project was shared with a group? It is not the attribute created_at, as the project exists way longer before it was shared. I am looking for this date:

Gitlab group GUI with shared project Thank you!

1 Answers

The date you've highlighted there is the project's last activity date. Not the date the project was shared. The last activity attribute is .last_activity_at. If you want to see the date access was granted in the UI, it's in the members page of the project.

If you want the date a project was shared with the group using the python-gitlab library, you can use the audit events API.

group = gl.groups.get(GROUP_ID)

for event in group.audit_events.list(as_list=False):
    if event.details.get('add') == 'project_access':
        print(
            f'Access granted for project "{event.details["target_details"]}" '
            f'to "{group.name}" group at {event.created_at} '
            f'by {e.details["author_name"]}.'
        )
Related