1""" Archive related queries
3@contact: Debian FTPMaster <ftpmaster@debian.org>
4@copyright: 2014 Mark Hymers <mhy@debian.org>
5@license: GNU General Public License version 2 or later
6"""
8import bottle
9import json
11from daklib.dbconn import DBConn, Archive
12from dakweb.webregister import QueryRegister
15@bottle.route('/archives')
16def archives() -> str:
17 """
18 Give information about all known archives (sets of suites)
20 :return: list of dictionaries
21 """
23 s = DBConn().session()
24 q = s.query(Archive)
25 q = q.order_by(Archive.archive_name)
26 ret = []
27 for a in q:
28 ret.append({'name': a.archive_name,
29 'suites': [x.suite_name for x in a.suites]})
31 s.close()
33 bottle.response.content_type = 'application/json; charset=UTF-8'
34 return json.dumps(ret)
37QueryRegister().register_path('/archives', archives)