blob: 0c43689bb809d95952165ef657861411171e1df8 [file] [log] [blame]
Ash Wilson318666f2014-10-03 08:38:39 -04001package extensions
2
3import (
Jon Perritt27249f42016-02-18 10:35:59 -06004 "github.com/gophercloud/gophercloud"
5 common "github.com/gophercloud/gophercloud/openstack/common/extensions"
6 "github.com/gophercloud/gophercloud/pagination"
Ash Wilson318666f2014-10-03 08:38:39 -04007)
8
9// Extension is a single OpenStack extension.
10type Extension struct {
11 common.Extension
12}
13
14// GetResult wraps a GetResult from common.
15type GetResult struct {
16 common.GetResult
17}
18
19// ExtractExtensions interprets a Page as a slice of Extensions.
20func 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.
33func Get(c *gophercloud.ServiceClient, alias string) GetResult {
Ash Wilsonb4c8c6f2014-10-06 17:35:02 -040034 return GetResult{common.Get(c, alias)}
Ash Wilson318666f2014-10-03 08:38:39 -040035}
36
37// List returns a Pager which allows you to iterate over the full collection of extensions.
38// It does not accept query parameters.
39func List(c *gophercloud.ServiceClient) pagination.Pager {
Ash Wilsonb4c8c6f2014-10-06 17:35:02 -040040 return common.List(c)
Ash Wilson318666f2014-10-03 08:38:39 -040041}