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