blob: 7120490362139bd3ae3ee39c586a8fd0cd5c2742 [file] [log] [blame]
Jamie Hannaford4721abc2014-09-16 16:29:04 +02001package extensions
Jamie Hannaford1ce30f22014-09-16 11:23:34 +02002
3import (
4 "github.com/racker/perigee"
5 "github.com/rackspace/gophercloud"
Jamie Hannafordf0c615b2014-09-17 10:56:52 +02006 "github.com/rackspace/gophercloud/pagination"
Jamie Hannaford1ce30f22014-09-16 11:23:34 +02007)
8
9func Get(c *gophercloud.ServiceClient, name string) (*Extension, error) {
10 var ext Extension
11 _, err := perigee.Request("GET", ExtensionURL(c, name), perigee.Options{
12 MoreHeaders: c.Provider.AuthenticatedHeaders(),
13 Results: &struct {
14 Extension *Extension `json:"extension"`
15 }{&ext},
16 OkCodes: []int{200},
17 })
18
19 if err != nil {
20 return nil, err
21 }
22 return &ext, nil
23}
Jamie Hannaford4721abc2014-09-16 16:29:04 +020024
Jamie Hannafordf0c615b2014-09-17 10:56:52 +020025func List(c *gophercloud.ServiceClient) pagination.Pager {
26 return pagination.NewPager(c, ListExtensionURL(c), func(r pagination.LastHTTPResponse) pagination.Page {
27 return ExtensionPage{pagination.SinglePageBase(r)}
28 })
Jamie Hannaford4721abc2014-09-16 16:29:04 +020029}