github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/state/cloudimagemetadata/interface.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package cloudimagemetadata 5 6 import ( 7 jujutxn "github.com/juju/txn" 8 9 "github.com/juju/juju/mongo" 10 ) 11 12 // MetadataAttributes contains cloud image metadata attributes. 13 type MetadataAttributes struct { 14 // Stream contains reference to a particular stream, 15 // for e.g. "daily" or "released" 16 Stream string 17 18 // Region is the name of cloud region associated with the image. 19 Region string 20 21 // Series is Os version, for e.g. "quantal". 22 Series string 23 24 // Arch is the architecture for this cloud image, for e.g. "amd64" 25 Arch string 26 27 // VirtType contains virtualisation type of the cloud image, for e.g. "pv", "hvm". "kvm". 28 VirtType string 29 30 // RootStorageType contains type of root storage, for e.g. "ebs", "instance". 31 RootStorageType string 32 33 // RootStorageSize contains size of root storage in gigabytes (GB). 34 RootStorageSize *uint64 35 36 // Source describes where this image is coming from: is it public? custom? 37 Source SourceType 38 } 39 40 // Metadata describes a cloud image metadata. 41 type Metadata struct { 42 MetadataAttributes 43 44 // ImageId contains image identifier. 45 ImageId string 46 } 47 48 // Storage provides methods for storing and retrieving cloud image metadata. 49 type Storage interface { 50 // SaveMetadata adds cloud images metadata into state if it's new or 51 // updates metadata if it already exists, 52 SaveMetadata(Metadata) error 53 54 // FindMetadata returns all Metadata that match specified 55 // criteria or a "not found" error if none match. 56 // Empty criteria will return all cloud image metadata. 57 // Returned result is grouped by source type and ordered by date created. 58 FindMetadata(criteria MetadataFilter) (map[SourceType][]Metadata, error) 59 } 60 61 // DataStore exposes data store operations for use by the cloud image metadata package. 62 type DataStore interface { 63 64 // RunTransaction runs desired transactions against this data source.. 65 RunTransaction(jujutxn.TransactionSource) error 66 67 // GetCollection retrieves desired collection from this data source. 68 GetCollection(name string) (collection mongo.Collection, closer func()) 69 }