This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/api/image_models_interface.py

45 lines
1.3 KiB
Python
Raw Normal View History

2017-07-21 17:09:21 +00:00
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.
"""