| 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 |  | 
| Jamie Hannaford | c65e192 | 2014-09-22 13:20:58 +0200 | [diff] [blame^] | 9 | // Get retrieves information for a specific extension using its alias. If no | 
|  | 10 | // extension exists with this alias, an error will be returned. | 
|  | 11 | func Get(c *gophercloud.ServiceClient, alias string) (*Extension, error) { | 
| Jamie Hannaford | 1ce30f2 | 2014-09-16 11:23:34 +0200 | [diff] [blame] | 12 | var ext Extension | 
| Jamie Hannaford | c65e192 | 2014-09-22 13:20:58 +0200 | [diff] [blame^] | 13 | _, err := perigee.Request("GET", extensionURL(c, alias), perigee.Options{ | 
| Jamie Hannaford | 1ce30f2 | 2014-09-16 11:23:34 +0200 | [diff] [blame] | 14 | MoreHeaders: c.Provider.AuthenticatedHeaders(), | 
|  | 15 | Results: &struct { | 
|  | 16 | Extension *Extension `json:"extension"` | 
|  | 17 | }{&ext}, | 
|  | 18 | OkCodes: []int{200}, | 
|  | 19 | }) | 
|  | 20 |  | 
|  | 21 | if err != nil { | 
|  | 22 | return nil, err | 
|  | 23 | } | 
|  | 24 | return &ext, nil | 
|  | 25 | } | 
| Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 26 |  | 
| Jamie Hannaford | c65e192 | 2014-09-22 13:20:58 +0200 | [diff] [blame^] | 27 | // List returns a Pager which allows you to iterate over the full collection of | 
|  | 28 | // extensions. It does not accept query parameters. | 
| Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame] | 29 | func List(c *gophercloud.ServiceClient) pagination.Pager { | 
| Jamie Hannaford | c65e192 | 2014-09-22 13:20:58 +0200 | [diff] [blame^] | 30 | return pagination.NewPager(c, listExtensionURL(c), func(r pagination.LastHTTPResponse) pagination.Page { | 
| Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame] | 31 | return ExtensionPage{pagination.SinglePageBase(r)} | 
|  | 32 | }) | 
| Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 33 | } |