diff --git a/endpoints/api/image_models_interface.py b/endpoints/api/image_models_interface.py new file mode 100644 index 000000000..7400abb6d --- /dev/null +++ b/endpoints/api/image_models_interface.py @@ -0,0 +1,44 @@ +from abc import ABCMeta, abstractmethod +from collections import namedtuple +from six import add_metaclass + +class Image(namedtuple('Image', ['docker_image_id', 'created', 'comment', 'command', 'size', + 'uploading', 'sort_index', 'ancestors'])): + """ + Image represents an image. + :type name: string + """ + +class ImageWithTags(namedtuple('ImageWithTags', ['image', 'tag_names'])): + """ + ImageWithTags represents an image, along with the tags that point to it. + :type image: Image + :type tag_names: list of string + """ + +class ImageWithHistory(namedtuple('ImageWithHistory', ['image', 'history'])): + """ + ImageWithHistory represents an image, along with its full history. + :type image: Image + :type history: list of Image + """ + + +@add_metaclass(ABCMeta) +class ImageInterface(object): + """ + Interface that represents all data store interactions required by the image API endpoint. + """ + + @abstractmethod + def get_repository_images(self, namespace_name, repo_name): + """ + Returns an iterator of all the ImageWithTag's defined in the matching repository. + """ + + @abstractmethod + def get_repository_image(self, namespace_name, repo_name, docker_image_id): + """ + Returns the matching ImageWithHistory under the matching repository, if any. If none, + returns None. + """ diff --git a/endpoints/api/image_models_pre_oci.py b/endpoints/api/image_models_pre_oci.py new file mode 100644 index 000000000..e69de29bb