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/api/image.py
2017-07-21 14:38:31 -04:00

41 lines
1.5 KiB
Python

""" List and lookup repository images. """
from endpoints.api import (resource, nickname, require_repo_read, RepositoryParamResource,
path_param, disallow_for_app_repositories)
from endpoints.api.image_models_pre_oci import pre_oci_model as model
from endpoints.exception import NotFound
@resource('/v1/repository/<apirepopath:repository>/image/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryImageList(RepositoryParamResource):
""" Resource for listing repository images. """
@require_repo_read
@nickname('listRepositoryImages')
@disallow_for_app_repositories
def get(self, namespace, repository):
""" List the images for the specified repository. """
images = model.get_repository_images(namespace, repository)
if images is None:
raise NotFound()
return {'images': [image.to_dict() for image in images]}
@resource('/v1/repository/<apirepopath:repository>/image/<image_id>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('image_id', 'The Docker image ID')
class RepositoryImage(RepositoryParamResource):
""" Resource for handling repository images. """
@require_repo_read
@nickname('getImage')
@disallow_for_app_repositories
def get(self, namespace, repository, image_id):
""" Get the information available for the specified image. """
image = model.get_repository_image(namespace, repository, image_id)
if image is None:
raise NotFound()
return image.to_dict()