blob: de785f9121d15f669714682016c855e4824d9733 [file] [log] [blame]
Ash Wilson318666f2014-10-03 08:38:39 -04001package extensions
2
3import (
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02004 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02005 common "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/common/extensions"
6 "gerrit.mcp.mirantis.net/debian/gophercloud.git/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}