45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
|
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.
|
||
|
"""
|