feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 1 | package volumeactions |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | type commonResult struct { |
| 9 | gophercloud.Result |
| 10 | } |
| 11 | |
| 12 | // AttachResult contains the response body and error from a Get request. |
| 13 | type AttachResult struct { |
Jamie Hannaford | 531e0cc | 2016-05-13 13:03:39 +0200 | [diff] [blame^] | 14 | gophercloud.ErrResult |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | // DetachResult contains the response body and error from a Get request. |
| 18 | type DetachResult struct { |
Jamie Hannaford | 531e0cc | 2016-05-13 13:03:39 +0200 | [diff] [blame^] | 19 | gophercloud.ErrResult |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | // ReserveResult contains the response body and error from a Get request. |
| 23 | type ReserveResult struct { |
Jamie Hannaford | 531e0cc | 2016-05-13 13:03:39 +0200 | [diff] [blame^] | 24 | gophercloud.ErrResult |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | // UnreserveResult contains the response body and error from a Get request. |
| 28 | type UnreserveResult struct { |
Jamie Hannaford | 531e0cc | 2016-05-13 13:03:39 +0200 | [diff] [blame^] | 29 | gophercloud.ErrResult |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | // InitializeConnectionResult contains the response body and error from a Get request. |
| 33 | type InitializeConnectionResult struct { |
| 34 | commonResult |
| 35 | } |
| 36 | |
| 37 | // TerminateConnectionResult contains the response body and error from a Get request. |
| 38 | type TerminateConnectionResult struct { |
Jamie Hannaford | 531e0cc | 2016-05-13 13:03:39 +0200 | [diff] [blame^] | 39 | gophercloud.ErrResult |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | // Extract will get the Volume object out of the commonResult object. |
| 43 | func (r commonResult) Extract() (map[string]interface{}, error) { |
| 44 | if r.Err != nil { |
| 45 | return nil, r.Err |
| 46 | } |
| 47 | |
| 48 | var res map[string]interface{} |
feisky | cf0c7fe | 2015-11-05 22:06:17 +0800 | [diff] [blame] | 49 | err := mapstructure.Decode(r.Body, &res) |
| 50 | |
| 51 | return res, err |
| 52 | } |