#29 [RFE] [API] return info about more than one packages at the same time
Closed: Fixed None Opened 10 years ago by ignatenkobrain.

Hi,

I have some idea for AppStream metadata generator - Adding FAS names to page which contains packages with failed data[0].

But doing ~2000 queries when generating seems not good idea, so I'd propose to enhance API for getting package information[1].
Would be good if we will can get info about multiple packages at the same time. for example:
https://admin.fedoraproject.org/pkgdb/api/package?pkgname=abduco&pkgname=mesa
should return info about abduco AND mesa. if we will add another pkgname it will add it.

[0]http://alt.fedoraproject.org/pub/alt/screenshots/f21/failed.html
[1]https://admin.fedoraproject.org/pkgdb/api/#package_information


Do you want the point of contact, or any person with commit good enough?

As in, if the later, then https://admin.fedoraproject.org/pkgdb/api/vcs should already do the trick

Replying to [comment:1 pingou]:

Do you want the point of contact, or any person with commit good enough?
we want to get all people who have commit acl for packages

Replying to [comment:2 pingou]:

As in, if the later, then https://admin.fedoraproject.org/pkgdb/api/vcs should already do the trick
there latest info about packages? i.e. if package will be retired what I will see there?

If a package is retired it won't appear on this page.

This is the page showing who is allowed to access which branch in git

For example: abby: https://admin.fedoraproject.org/pkgdb/package/abby/ is retired, it's not present in https://admin.fedoraproject.org/pkgdb/api/vcs

Furthermore: note that there is a format option allowing you to retrieve the info as json: https://admin.fedoraproject.org/pkgdb/api/#version_control_system_acls

Replying to [comment:5 pingou]:

If a package is retired it won't appear on this page.

This is the page showing who is allowed to access which branch in git

For example: abby: https://admin.fedoraproject.org/pkgdb/package/abby/ is retired, it's not present in https://admin.fedoraproject.org/pkgdb/api/vcs

Furthermore: note that there is a format option allowing you to retrieve the info as json: https://admin.fedoraproject.org/pkgdb/api/#version_control_system_acls
yes. that's all what I want.

I am currently adding a way to filter out ACLs from /api/package/<pkgname>.

That would speed things up to the point that performing a ~1000 queries is doable but it's not so interesting for you as then it only gives you access to the point of contact, not the list of all committers

For reference, this is what I was testing with:
{{{
import requests

def get_poc(pkg):
''' Return the POC of a given package in the devel branch. '''

# acls=0 -> no ACLs returned, branches=master -> restrict to rawhide
url = 'http://127.0.0.1:5000/api/package/%s?acls=0&branches=master' % pkg
req = requests.get(url)
if req.status_code != 200:
    #print 'Invalid package: ', pkg
    return

data = req.json()
return data['packages'][0]['point_of_contact']

req = requests.get('http://alt.fedoraproject.org/pub/alt/screenshots/f21/failed.html')
pkgs = []
for row in req.text.split('\n'):
if '<a name=' in row:
pkg = row.split('"')[1].split('"')[0]
if pkg:
print pkg, get_poc(pkg)
pkgs.append(pkg)

print '\n %s package retrieved' % len(pkgs)
}}}

Replying to [comment:7 pingou]:

I am currently adding a way to filter out ACLs from /api/package/<pkgname>.

That would speed things up to the point that performing a ~1000 queries is doable but it's not so interesting for you as then it only gives you access to the point of contact, not the list of all committers

For reference, this is what I was testing with:
{{{
import requests

def get_poc(pkg):
''' Return the POC of a given package in the devel branch. '''

# acls=0 -> no ACLs returned, branches=master -> restrict to rawhide
url = 'http://127.0.0.1:5000/api/package/%s?acls=0&branches=master' % pkg
req = requests.get(url)
if req.status_code != 200:
    #print 'Invalid package: ', pkg
    return

data = req.json()
return data['packages'][0]['point_of_contact']

req = requests.get('http://alt.fedoraproject.org/pub/alt/screenshots/f21/failed.html')
pkgs = []
for row in req.text.split('\n'):
if '<a name=' in row:
pkg = row.split('"')[1].split('"')[0]
if pkg:
print pkg, get_poc(pkg)
pkgs.append(pkg)

print '\n %s package retrieved' % len(pkgs)
}}}
how much time this will take?

1.16 has been deployed with this change to the API.

To run the script it takes me ~18 minutes it'll likely be faster from the US.

But the vcs endpoint will clearly be faster and provide you all the people with commit, instead of just the point of contact.

If the vcs endpoint works for you, then I would like to close this ticket, I am not a big fan of letting /api/package return info about multiple packages.

Log in to comment on this ticket.

Metadata