Jamie Hannaford | 9fdda58 | 2015-02-10 12:15:43 +0100 | [diff] [blame^] | 1 | package instances |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | type Flavor struct { |
| 9 | ID string |
| 10 | Links []gophercloud.Link |
| 11 | } |
| 12 | |
| 13 | type Volume struct { |
| 14 | Size int |
| 15 | } |
| 16 | |
| 17 | type Instance struct { |
| 18 | Created string //time.Time |
| 19 | Updated string //time.Time |
| 20 | Flavor Flavor |
| 21 | Hostname string |
| 22 | ID string |
| 23 | Links []gophercloud.Link |
| 24 | Name string |
| 25 | Status string |
| 26 | Volume Volume |
| 27 | } |
| 28 | |
| 29 | // CreateResult represents the result of a Create operation. |
| 30 | type CreateResult struct { |
| 31 | gophercloud.Result |
| 32 | } |
| 33 | |
| 34 | func (r CreateResult) Extract() (*Instance, error) { |
| 35 | if r.Err != nil { |
| 36 | return nil, r.Err |
| 37 | } |
| 38 | |
| 39 | var response struct { |
| 40 | Instance Instance `mapstructure:"instance"` |
| 41 | } |
| 42 | |
| 43 | err := mapstructure.Decode(r.Body, &response) |
| 44 | |
| 45 | return &response.Instance, err |
| 46 | } |