blob: df13aede24f6ad48b30fe1210be7bb211e42e8d3 [file] [log] [blame]
Jamie Hannaford2a4beaa2015-02-09 17:27:18 +01001package instances
2
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +01003import (
4 "github.com/mitchellh/mapstructure"
5 "github.com/rackspace/gophercloud"
Jamie Hannaford9fdda582015-02-10 12:15:43 +01006 os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +01007)
8
9type Datastore struct {
10 Type string
11 Version string
12}
13
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +010014type Instance struct {
15 Created string //time.Time
16 Updated string //time.Time
17 Datastore Datastore
Jamie Hannaford9fdda582015-02-10 12:15:43 +010018 Flavor os.Flavor
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +010019 Hostname string
20 ID string
21 Links []gophercloud.Link
22 Name string
23 Status string
Jamie Hannaford9fdda582015-02-10 12:15:43 +010024 Volume os.Volume
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +010025}
Jamie Hannaford2a4beaa2015-02-09 17:27:18 +010026
27// CreateResult represents the result of a Create operation.
28type CreateResult struct {
Jamie Hannaford9fdda582015-02-10 12:15:43 +010029 os.CreateResult
Jamie Hannaford2a4beaa2015-02-09 17:27:18 +010030}
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +010031
Jamie Hannaford3dbfb2d2015-02-10 11:06:47 +010032func (r CreateResult) Extract() (*Instance, error) {
33 if r.Err != nil {
34 return nil, r.Err
35 }
36
37 var response struct {
38 Instance Instance `mapstructure:"instance"`
39 }
40
41 err := mapstructure.Decode(r.Body, &response)
42
43 return &response.Instance, err
44}