Bug 1130166 - RFE: API for listing all projects and/or all users
Summary: RFE: API for listing all projects and/or all users
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Copr
Classification: Community
Component: cli
Version: unspecified
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: ---
Assignee: Jakub Kadlčík
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-14 13:14 UTC by Petr Pisar
Modified: 2019-03-12 16:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-12 16:06:36 UTC
Embargoed:


Attachments (Terms of Use)

Description Petr Pisar 2014-08-14 13:14:31 UTC
Current API does allow to list all projects.

The /api/coprs/?search=<project> insists on at least 3 characters. (Why?)

The /api/coprs/?username=<username> needs an user name to list projects of the users. But there is no service to list all users.

I parsed all users from web interface, but it's too slow (over 3 minutes to retrieve 444 users scattered to 100 pages). Also the numbers (100 and 444) look suspicious. Is everything visible on the web?

Comment 1 Petr Šabata 2014-08-14 13:18:57 UTC
(In reply to Petr Pisar from comment #0)
> The /api/coprs/?search=<project> insists on at least 3 characters. (Why?)

Copr works with FAS accounts and FAS requires usernames to be at least 3 characters long.

Comment 2 Petr Pisar 2014-08-14 13:38:50 UTC
(In reply to Petr Šabata from comment #1)
> (In reply to Petr Pisar from comment #0)
> > The /api/coprs/?search=<project> insists on at least 3 characters. (Why?)
> 
> Copr works with FAS accounts and FAS requires usernames to be at least 3
> characters long.

However /api/coprs/?search=<project> searches for projects. Not for user names.

Comment 3 Jakub Kadlčík 2018-11-14 14:32:17 UTC
Hello Petr,
we apologize, that this took years to someone to look at this RFE. Meanwhile, both APIv1 (aka Legacy API) and APIv2 (aka REST-like API) are deprecated.

What was the actual goal? Getting all projects (from all users) in Copr?
This was implemented in 3861a97 (PR#458) and you don't need to go through a list of users anymore.

You can try this code sample


from copr.v3 import Client
from copr.v3.pagination import next_page

client = Client.create_from_config_file()

projects_page = client.project_proxy.get_list(pagination={"limit": 10})
while projects_page:
    for project in projects_page:
        print(project.full_name)
    projects_page = next_page(projects_page)


(The example uses pagination, which is not otherwise required. I just wouldn't recommend anyone to query all projects in Copr without it.)

Comment 4 Petr Pisar 2018-11-14 15:06:37 UTC
The actual goal was to enumerate all projects in Copr. I'm glad you implemented it. However the provided example does not work for me with current python3-copr-1.90-1.fc28:

$ python3 /tmp/test 
Traceback (most recent call last):
  File "/tmp/test", line 6, in <module>
    projects_page = client.project_proxy.get_list(pagination={"limit": 10})
TypeError: get_list() missing 1 required positional argument: 'ownername'

The ProjectProxy's get_list method still requires ownername as a second argument:

    def get_list(self, ownername, pagination=None):

Do I understand the MODIFIED state correctly that the new code is not yet available in any Fedora, but it will be in near future? If it is so, just close this bug when the code reaches Fedora.

Comment 5 Jakub Kadlčík 2018-11-14 15:09:51 UTC
> Do I understand the MODIFIED state correctly that the new code is not yet available in any Fedora, but it will be in near future?

Exactly. It is modified in the master, but not yet released.

Comment 6 Jakub Kadlčík 2019-03-12 16:06:36 UTC
This BZ was fixed during the latest Copr release.
Feel free to reopen, if you encounter any difficulties with the provided solution.


Note You need to log in before you can comment on or make changes to this bug.