""" 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//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//image/') @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()