Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 1 | package extensions |
Jamie Hannaford | 1ce30f2 | 2014-09-16 11:23:34 +0200 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "github.com/racker/perigee" |
| 5 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame^] | 6 | "github.com/rackspace/gophercloud/pagination" |
Jamie Hannaford | 1ce30f2 | 2014-09-16 11:23:34 +0200 | [diff] [blame] | 7 | ) |
| 8 | |
| 9 | func 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 Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 24 | |
Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame^] | 25 | func 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 Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 29 | } |