Skip to content

introduce a way to get all user's projects - #404

Closed
akhmerov wants to merge 1 commit into
python-gitlab:masterfrom
akhmerov:user_projects
Closed

akhmerov wants to merge 1 commit into
python-gitlab:masterfrom
akhmerov:user_projects

Conversation

@akhmerov

Copy link
Copy Markdown

This is a proposal for accessing GET /users/:id/projects. Note that it isn't strictly backwards compatible because I renamed gitlab.user.projects into gitlab.user.project and used gitlab.user.projects for the new endpoint.

Closes #403

@gpocentek

Copy link
Copy Markdown
Contributor

Thanks for tackling this @akhmerov

I don't think this is the best way to implement this feature though. I believe that you could use the existing UserProject and UserProjectManager classes to support a create method. This would require to write a custom method instead of using the mixin, because of different URLs in the GitLab API.

Do you want to have a look at this?

@akhmerov

akhmerov commented Jan 5, 2018

Copy link
Copy Markdown
Author

I agree, my PR is mostly to illustrate what is missing, a custom class is a better solution.

Unfortunately after looking the codebase and not quite understanding what goes where, I believe it will take me too long time to implement a custom class adhering to the API, sorry. That is unless you have some specific pointers that I could straightforwardly adapt and adjust.

@gpocentek

Copy link
Copy Markdown
Contributor

@akhmerov thank you for your answer

No problem, I will take care of the implementation of the listing. I didn't want to take other this change before making sure it was OK with you.

Thanks again!

@gpocentek gpocentek closed this Jan 5, 2018
@llincolnatal

Copy link
Copy Markdown

Hi, has this feature ever been implemented? Thanks

@max-wittig

Copy link
Copy Markdown
Member

Yes this has been there since a few years. I guess, we're missing documentation:

gl.users.get(<id>).projects.list()

@max-wittig

Copy link
Copy Markdown
Member

I guess, we have some documentation in the projects api section about it. There is an example:

user_project = alice.projects.create({'name': 'project'})
user_projects = alice.projects.list()

@llincolnatal

Copy link
Copy Markdown

Thank you very much Max-wittig

@matusnovak

matusnovak commented Nov 4, 2021 •

Copy link
Copy Markdown

This is incorrect. Creating a project via alice.projects.create({}) always fails with 403 Forbidden. To correctly create a new project at user level you must use: POST /projects/user/%(user_id) (from official documentation) and not /users/%(user_id)s/projects (what is in this PR). See https://docs.gitlab.com/ee/api/projects.html#create-project-for-user

Edit: never mind, the API I have liked is only for administrators, please ignore this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for getting list of user projects

5 participants