This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/v2/catalog.py

31 lines
850 B
Python
Raw Normal View History

from flask import jsonify, url_for
from endpoints.v2 import v2_bp
2016-02-09 22:25:33 +00:00
from auth.registry_jwt_auth import process_registry_jwt_auth, get_granted_entity
from endpoints.decorators import anon_protect
from data import model
from endpoints.v2.v2util import add_pagination
@v2_bp.route('/_catalog', methods=['GET'])
2016-02-09 22:25:33 +00:00
@process_registry_jwt_auth
@anon_protect
def catalog_search():
url = url_for('v2.catalog_search')
2016-02-09 22:25:33 +00:00
username = None
entity = get_granted_entity()
if entity:
username = entity.user.username
query = model.repository.get_visible_repositories(username, include_public=(username is None))
link, query = add_pagination(query, url)
response = jsonify({
'repositories': ['%s/%s' % (repo.namespace_user.username, repo.name) for repo in query],
})
if link is not None:
response.headers['Link'] = link
return response