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

27 lines
999 B
Python
Raw Normal View History

import features
2016-07-26 22:41:51 +00:00
from flask import jsonify
from auth.auth_context import get_authenticated_user
from auth.registry_jwt_auth import process_registry_jwt_auth
from endpoints.decorators import anon_protect
2016-08-02 00:48:00 +00:00
from endpoints.v2 import v2_bp, paginate
from endpoints.v2.models_pre_oci import data_model as model
2017-06-26 22:16:15 +00:00
@v2_bp.route('/_catalog', methods=['GET'])
@process_registry_jwt_auth()
@anon_protect
2016-08-02 00:48:00 +00:00
@paginate()
2016-07-26 22:41:51 +00:00
def catalog_search(limit, offset, pagination_callback):
username = get_authenticated_user().username if get_authenticated_user() else None
include_public = bool(features.PUBLIC_CATALOG)
2017-06-26 22:16:15 +00:00
visible_repositories = model.get_visible_repositories(username, limit + 1, offset,
include_public=include_public)
response = jsonify({
2016-07-26 22:41:51 +00:00
'repositories': ['%s/%s' % (repo.namespace_name, repo.name)
2017-06-26 22:16:15 +00:00
for repo in visible_repositories][0:limit],})
2016-07-26 22:41:51 +00:00
pagination_callback(len(visible_repositories), response)
return response