| Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 1 | package images | 
 | 2 |  | 
| Ash Wilson | 9ccf9b6 | 2014-09-17 10:07:52 -0400 | [diff] [blame^] | 3 | import ( | 
 | 4 | 	"github.com/mitchellh/mapstructure" | 
 | 5 | 	"github.com/rackspace/gophercloud/pagination" | 
 | 6 | ) | 
| Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 7 |  | 
 | 8 | // Image is used for JSON (un)marshalling. | 
 | 9 | // It provides a description of an OS image. | 
| Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 10 | type Image struct { | 
| Ash Wilson | 9ccf9b6 | 2014-09-17 10:07:52 -0400 | [diff] [blame^] | 11 | 	// ID contains the image's unique identifier. | 
 | 12 | 	ID string | 
 | 13 |  | 
 | 14 | 	Created string | 
 | 15 |  | 
 | 16 | 	// MinDisk and MinRAM specify the minimum resources a server must provide to be able to install the image. | 
 | 17 | 	MinDisk int | 
 | 18 | 	MinRAM  int | 
 | 19 |  | 
 | 20 | 	// Name provides a human-readable moniker for the OS image. | 
 | 21 | 	Name string | 
 | 22 |  | 
 | 23 | 	// The Progress and Status fields indicate image-creation status. | 
 | 24 | 	// Any usable image will have 100% progress. | 
| Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 25 | 	Progress int | 
 | 26 | 	Status   string | 
| Ash Wilson | 9ccf9b6 | 2014-09-17 10:07:52 -0400 | [diff] [blame^] | 27 |  | 
 | 28 | 	Updated string | 
| Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 29 | } | 
 | 30 |  | 
| Ash Wilson | 9ccf9b6 | 2014-09-17 10:07:52 -0400 | [diff] [blame^] | 31 | // ExtractImages converts a page of List results into a slice of usable Image structs. | 
 | 32 | func ExtractImages(page pagination.Page) ([]Image, error) { | 
 | 33 | 	casted := page.(ListResults).Body | 
 | 34 | 	var results []Image | 
| Samuel A. Falvo II | 17ae565 | 2014-02-12 20:47:43 -0800 | [diff] [blame] | 35 |  | 
| Ash Wilson | 9ccf9b6 | 2014-09-17 10:07:52 -0400 | [diff] [blame^] | 36 | 	err := mapstructure.Decode(results, casted) | 
 | 37 | 	return results, err | 
| Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 38 | } |