2015-12-23 13:08:01 -05:00
|
|
|
""" List and lookup repository images. """
|
2015-05-14 16:47:38 -04:00
|
|
|
|
2014-03-17 13:10:12 -04:00
|
|
|
from endpoints.api import (resource, nickname, require_repo_read, RepositoryParamResource,
|
2017-07-21 14:38:31 -04:00
|
|
|
path_param, disallow_for_app_repositories)
|
|
|
|
from endpoints.api.image_models_pre_oci import pre_oci_model as model
|
2016-04-11 16:20:11 -04:00
|
|
|
from endpoints.exception import NotFound
|
2015-03-20 17:46:02 -04:00
|
|
|
|
2014-03-14 13:06:58 -04:00
|
|
|
|
2016-01-21 15:40:51 -05:00
|
|
|
@resource('/v1/repository/<apirepopath:repository>/image/')
|
2014-08-19 19:05:28 -04:00
|
|
|
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
|
2014-03-14 13:06:58 -04:00
|
|
|
class RepositoryImageList(RepositoryParamResource):
|
|
|
|
""" Resource for listing repository images. """
|
2017-07-10 09:46:02 -04:00
|
|
|
|
2014-03-14 13:06:58 -04:00
|
|
|
@require_repo_read
|
|
|
|
@nickname('listRepositoryImages')
|
2017-03-22 14:30:13 -04:00
|
|
|
@disallow_for_app_repositories
|
2014-03-14 13:06:58 -04:00
|
|
|
def get(self, namespace, repository):
|
|
|
|
""" List the images for the specified repository. """
|
2017-07-21 14:38:31 -04:00
|
|
|
images = model.get_repository_images(namespace, repository)
|
|
|
|
if images is None:
|
2015-07-31 16:31:29 -04:00
|
|
|
raise NotFound()
|
|
|
|
|
2017-07-21 14:38:31 -04:00
|
|
|
return {'images': [image.to_dict() for image in images]}
|
2014-03-14 13:06:58 -04:00
|
|
|
|
|
|
|
|
2016-01-21 15:40:51 -05:00
|
|
|
@resource('/v1/repository/<apirepopath:repository>/image/<image_id>')
|
2014-08-19 19:05:28 -04:00
|
|
|
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
|
|
|
|
@path_param('image_id', 'The Docker image ID')
|
2014-03-14 13:06:58 -04:00
|
|
|
class RepositoryImage(RepositoryParamResource):
|
|
|
|
""" Resource for handling repository images. """
|
2017-07-10 09:46:02 -04:00
|
|
|
|
2014-03-14 13:06:58 -04:00
|
|
|
@require_repo_read
|
|
|
|
@nickname('getImage')
|
2017-03-22 14:30:13 -04:00
|
|
|
@disallow_for_app_repositories
|
2014-03-14 13:06:58 -04:00
|
|
|
def get(self, namespace, repository, image_id):
|
2014-03-14 13:27:56 -04:00
|
|
|
""" Get the information available for the specified image. """
|
2017-07-21 14:38:31 -04:00
|
|
|
image = model.get_repository_image(namespace, repository, image_id)
|
|
|
|
if image is None:
|
2014-03-17 16:57:35 -04:00
|
|
|
raise NotFound()
|
2014-03-14 13:06:58 -04:00
|
|
|
|
2017-07-21 14:38:31 -04:00
|
|
|
return image.to_dict()
|