From 9b22afd8fd7aa7432c0359d18a12f48a6c01bef7 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 21 Jul 2017 13:09:21 -0400 Subject: [PATCH] wip --- endpoints/api/image_models_interface.py | 44 +++++++++++++++++++++++++ endpoints/api/image_models_pre_oci.py | 0 2 files changed, 44 insertions(+) create mode 100644 endpoints/api/image_models_interface.py create mode 100644 endpoints/api/image_models_pre_oci.py 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