Ash Wilson | 318666f | 2014-10-03 08:38:39 -0400 | [diff] [blame^] | 1 | package extensions |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | common "github.com/rackspace/gophercloud/openstack/common/extensions" |
| 6 | "github.com/rackspace/gophercloud/pagination" |
| 7 | ) |
| 8 | |
| 9 | // Extension is a single OpenStack extension. |
| 10 | type Extension struct { |
| 11 | common.Extension |
| 12 | } |
| 13 | |
| 14 | // GetResult wraps a GetResult from common. |
| 15 | type GetResult struct { |
| 16 | common.GetResult |
| 17 | } |
| 18 | |
| 19 | // ExtractExtensions interprets a Page as a slice of Extensions. |
| 20 | func ExtractExtensions(page pagination.Page) ([]Extension, error) { |
| 21 | inner, err := common.ExtractExtensions(page) |
| 22 | if err != nil { |
| 23 | return nil, err |
| 24 | } |
| 25 | outer := make([]Extension, len(inner)) |
| 26 | for index, ext := range inner { |
| 27 | outer[index] = Extension{ext} |
| 28 | } |
| 29 | return outer, nil |
| 30 | } |
| 31 | |
| 32 | // Get retrieves information for a specific extension using its alias. |
| 33 | func Get(c *gophercloud.ServiceClient, alias string) GetResult { |
| 34 | return GetResult{common.Get(c, alias)} |
| 35 | } |
| 36 | |
| 37 | // List returns a Pager which allows you to iterate over the full collection of extensions. |
| 38 | // It does not accept query parameters. |
| 39 | func List(c *gophercloud.ServiceClient) pagination.Pager { |
| 40 | return common.List(c) |
| 41 | } |