Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 1 | package flavors |
| 2 | |
| 3 | import ( |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 4 | "github.com/gophercloud/gophercloud" |
| 5 | "github.com/gophercloud/gophercloud/pagination" |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 6 | ) |
| 7 | |
Jamie Hannaford | 9793d94 | 2015-02-18 15:13:20 +0100 | [diff] [blame] | 8 | // List will list all available hardware flavors that an instance can use. The |
| 9 | // operation is identical to the one supported by the Nova API, but without the |
| 10 | // "disk" property. |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 11 | func List(client *gophercloud.ServiceClient) pagination.Pager { |
| 12 | createPage := func(r pagination.PageResult) pagination.Page { |
| 13 | return FlavorPage{pagination.LinkedPageBase{PageResult: r}} |
| 14 | } |
| 15 | |
| 16 | return pagination.NewPager(client, listURL(client), createPage) |
| 17 | } |
| 18 | |
Jamie Hannaford | 9793d94 | 2015-02-18 15:13:20 +0100 | [diff] [blame] | 19 | // Get will retrieve information for a specified hardware flavor. |
Jamie Hannaford | 8803f83 | 2015-02-23 10:44:55 +0100 | [diff] [blame] | 20 | func Get(client *gophercloud.ServiceClient, id string) GetResult { |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 21 | var gr GetResult |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 22 | |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 23 | _, gr.Err = client.Request("GET", getURL(client, id), &gophercloud.RequestOpts{ |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 24 | JSONResponse: &gr.Body, |
| 25 | OkCodes: []int{200}, |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 26 | }) |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 27 | |
Jamie Hannaford | 5b7acc1 | 2015-02-13 09:14:25 +0100 | [diff] [blame] | 28 | return gr |
| 29 | } |