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/tag.py

34 lines
1.1 KiB
Python
Raw Normal View History

from flask import jsonify, url_for
from auth.registry_jwt_auth import process_registry_jwt_auth
2016-03-09 21:20:28 +00:00
from endpoints.common import parse_repository_name
from endpoints.v2 import v2_bp, require_repo_read
from endpoints.v2.errors import NameUnknown
from endpoints.v2.v2util import add_pagination
from endpoints.decorators import anon_protect
from data import model
@v2_bp.route('/<repopath:repository>/tags/list', methods=['GET'])
@process_registry_jwt_auth
2016-03-09 21:20:28 +00:00
@parse_repository_name()
@require_repo_read
@anon_protect
2016-03-09 21:20:28 +00:00
def list_all_tags(namespace_name, repo_name):
repository = model.repository.get_repository(namespace_name, repo_name)
if repository is None:
raise NameUnknown()
2016-03-09 21:20:28 +00:00
query = model.tag.list_repository_tags(namespace_name, repo_name)
url = url_for('v2.list_all_tags', repository='%s/%s' % (namespace_name, repo_name))
link, query = add_pagination(query, url)
response = jsonify({
2016-03-09 21:20:28 +00:00
'name': '{0}/{1}'.format(namespace_name, repo_name),
'tags': [tag.name for tag in query],
})
if link is not None:
response.headers['Link'] = link
return response