blob: c3319e0bc0933b8c5b51098771787b4453bd384d [file] [log] [blame]
Jamie Hannaford9fdda582015-02-10 12:15:43 +01001package instances
2
3import (
4 "github.com/mitchellh/mapstructure"
5 "github.com/rackspace/gophercloud"
6)
7
8type Flavor struct {
9 ID string
10 Links []gophercloud.Link
11}
12
13type Volume struct {
14 Size int
15}
16
17type 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.
30type CreateResult struct {
31 gophercloud.Result
32}
33
34func (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}