blob: bef1da8a1757ede1fa02efa7a79fdfc5f4154707 [file] [log] [blame]
Jon Perritt85ed5232015-01-16 09:14:51 -07001package base
2
3import (
Jon Perritt6bb59442015-01-27 11:18:22 -07004 "errors"
5
Jon Perritt85ed5232015-01-16 09:14:51 -07006 "github.com/rackspace/gophercloud"
7)
8
9// HomeDocument is a resource that contains all the resources for the CDN API.
10type HomeDocument map[string]interface{}
11
12// GetResult represents the result of a Get operation.
13type GetResult struct {
14 gophercloud.Result
15}
16
17// Extract is a function that accepts a result and extracts a home document resource.
18func (r GetResult) Extract() (*HomeDocument, error) {
19 if r.Err != nil {
20 return nil, r.Err
21 }
22
Jon Perritt6bb59442015-01-27 11:18:22 -070023 submap, ok := r.Body.(map[string]interface{})["resources"]
24 if !ok {
25 return nil, errors.New("Unexpected HomeDocument structure")
Jon Perritt85ed5232015-01-16 09:14:51 -070026 }
Jon Perritt6bb59442015-01-27 11:18:22 -070027 casted := HomeDocument(submap.(map[string]interface{}))
Jon Perritt85ed5232015-01-16 09:14:51 -070028
Jon Perritt6bb59442015-01-27 11:18:22 -070029 return &casted, nil
Jon Perritt85ed5232015-01-16 09:14:51 -070030}
31
32// PingResult represents the result of a Ping operation.
33type PingResult struct {
34 gophercloud.ErrResult
35}