github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/state/imagestorage/interface.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package imagestorage
     5  
     6  import (
     7  	"io"
     8  	"time"
     9  )
    10  
    11  // Metadata describes an image blob.
    12  type Metadata struct {
    13  	ModelUUID string
    14  	Series    string
    15  	Arch      string
    16  	Kind      string
    17  	Size      int64
    18  	SHA256    string
    19  	Created   time.Time
    20  	SourceURL string
    21  }
    22  
    23  // ImageFilter is used to query image metadata.
    24  type ImageFilter struct {
    25  	Kind   string
    26  	Series string
    27  	Arch   string
    28  }
    29  
    30  // Storage provides methods for storing and retrieving images by kind, series, and arch.
    31  type Storage interface {
    32  	// AddImage adds the image blob and metadata into state,
    33  	// replacing existing metadata if any exists with the specified version.
    34  	AddImage(io.Reader, *Metadata) error
    35  
    36  	// DeleteImage deletes the image blob defined by metadata from state.
    37  	DeleteImage(*Metadata) error
    38  
    39  	// Image returns the Metadata and image blob contents
    40  	// for the specified kind, series, arch if it exists, else an error
    41  	// satisfying errors.IsNotFound.
    42  	Image(kind, series, arch string) (*Metadata, io.ReadCloser, error)
    43  
    44  	// ListImages returns the image metadata matching the specified filter.
    45  	ListImages(filter ImageFilter) ([]*Metadata, error)
    46  }