parent
dfe564fe24
commit
f44ca79391
4 changed files with 56 additions and 16 deletions
32
endpoints/v2/catalog.py
Normal file
32
endpoints/v2/catalog.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# XXX This code is not yet ready to be run in production, and should remain disabled until such
|
||||
# XXX time as this notice is removed.
|
||||
|
||||
from flask import jsonify, url_for
|
||||
|
||||
from endpoints.v2 import v2_bp
|
||||
from auth.auth import process_auth
|
||||
from endpoints.decorators import anon_protect
|
||||
from data import model
|
||||
from endpoints.v2.v2util import add_pagination
|
||||
from auth.auth_context import get_authenticated_user
|
||||
|
||||
@v2_bp.route('/_catalog', methods=['GET'])
|
||||
@process_auth
|
||||
@anon_protect
|
||||
def catalog_search():
|
||||
url = url_for('v2.catalog_search')
|
||||
|
||||
username = get_authenticated_user().username if get_authenticated_user() else None
|
||||
query = model.repository.get_visible_repositories(username, include_public=(username is None),
|
||||
limit=50)
|
||||
|
||||
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
|
Reference in a new issue