Scinana
Scinana

Reputation: 402

How to return and see all a Gitlab's Project Issue info using python-gitlab?

I am using python-gitlab to access my Gitlab repo's data and get a list of all my repo's issues by running the following:

project = gl.projects.get(#my_project_id)
issues = project.issues.list()

I can then print this list to see which issues are in the list.

issues
[<ProjectIssue iid:1>,<ProjectIssue iid:2>...]

I have also tried to get the info for a specific issue by running:

issue = project.issues.get(1)     #example for issue 1

However, I don't know how to access all the info within that particular issue

When trying to run the "issue" line, I get the following, but I cannot see all the attributes and information of that issue. I'm looking for all the information that should be sent in the API response as defined here (eg. state, author, description, etc). How can I see this information?

issue
<ProjectIssue iid:1>

I know that python-gitlab has defined some methods like the .time_stats() to list the time stats for my issue, but I can't find which method to use to find ALL the information for that issue

[In] issue.time_stats()
[Out] {'time_estimate': 0, 'total_time_spent': 0, 'human_time_estimate': None, 'human_total_time_spent': None}

Upvotes: 0

Views: 2159

Answers (1)

Adam Marshall
Adam Marshall

Reputation: 7649

When you run project.issues.get(1) it's returning the GitLab Issue as an object (the ProjectIssue class), not as json or an array. I'm not familiar with python-gitlab (and haven't used python in years) but the issue data is likely accessible as an attribute:

issue = project.issues.get(1)
description = issue.description
labels = issue.labels

Note that some of the attributes of the ProjectIssue class might be another object.

To get all attributes on the ProjectIssue class, you can do

issue = project.issues.get(1)
getmembers(issue)

See this answer for more details.

Upvotes: 1

Related Questions