Jon Perritt | 85ed523 | 2015-01-16 09:14:51 -0700 | [diff] [blame] | 1 | package base |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | // HomeDocument is a resource that contains all the resources for the CDN API. |
| 9 | type HomeDocument map[string]interface{} |
| 10 | |
| 11 | // GetResult represents the result of a Get operation. |
| 12 | type GetResult struct { |
| 13 | gophercloud.Result |
| 14 | } |
| 15 | |
| 16 | // Extract is a function that accepts a result and extracts a home document resource. |
| 17 | func (r GetResult) Extract() (*HomeDocument, error) { |
| 18 | if r.Err != nil { |
| 19 | return nil, r.Err |
| 20 | } |
| 21 | |
| 22 | var res struct { |
| 23 | HomeDocument *HomeDocument `mapstructure:"resources"` |
| 24 | } |
| 25 | |
| 26 | err := mapstructure.Decode(r.Body, &res) |
| 27 | |
| 28 | return res.HomeDocument, err |
| 29 | } |
| 30 | |
| 31 | // PingResult represents the result of a Ping operation. |
| 32 | type PingResult struct { |
| 33 | gophercloud.ErrResult |
| 34 | } |