parent
d9ce8fdf52
commit
f7f10f4a6d
2 changed files with 19 additions and 6 deletions
|
@ -16,12 +16,13 @@ from datetime import datetime
|
|||
@resource('/v1/repository/<repopath:repository>/tag/')
|
||||
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
|
||||
class ListRepositoryTags(RepositoryParamResource):
|
||||
""" Resource for listing repository tags. """
|
||||
""" Resource for listing full repository tag history, alive *and dead*. """
|
||||
|
||||
@require_repo_write
|
||||
@parse_args
|
||||
@query_param('specificTag', 'Filters the tags to the specific tag.', type=str, default='')
|
||||
@query_param('limit', 'Limit to the number of results to return. Max 100.', type=int, default=50)
|
||||
@query_param('limit', 'Limit to the number of results to return per page. Max 100.', type=int, default=50)
|
||||
@query_param('page', 'Page index for the results. Default 1.', type=int, default=1)
|
||||
@nickname('listRepoTags')
|
||||
def get(self, args, namespace, repository):
|
||||
repo = model.get_repository(namespace, repository)
|
||||
|
@ -44,9 +45,21 @@ class ListRepositoryTags(RepositoryParamResource):
|
|||
return tag_info
|
||||
|
||||
specific_tag = args.get('specificTag') or None
|
||||
|
||||
page = min(1, args.get('start', 1))
|
||||
limit = min(100, max(1, args.get('limit', 50)))
|
||||
tags = model.list_repository_tag_history(repo, limit=limit, specific_tag=specific_tag)
|
||||
return {'tags': [tag_view(tag) for tag in tags]}
|
||||
|
||||
# Note: We ask for limit+1 here, so we can check to see if there are
|
||||
# additional pages of results.
|
||||
tags = model.list_repository_tag_history(repo, page=page, size=limit+1,
|
||||
specific_tag=specific_tag)
|
||||
|
||||
tags = list(tags)
|
||||
return {
|
||||
'tags': [tag_view(tag) for tag in tags[0:limit]],
|
||||
'page': page,
|
||||
'has_additional': len(tags) >= limit
|
||||
}
|
||||
|
||||
|
||||
@resource('/v1/repository/<repopath:repository>/tag/<tag>')
|
||||
|
|
Reference in a new issue