blob: c76760654ce28bfbfcfeb9e81510833d6549b009 [file] [log] [blame]
Jamie Hannaford5b7acc12015-02-13 09:14:25 +01001package flavors
2
3import (
Jon Perritt27249f42016-02-18 10:35:59 -06004 "github.com/gophercloud/gophercloud"
5 "github.com/gophercloud/gophercloud/pagination"
Jamie Hannaford5b7acc12015-02-13 09:14:25 +01006)
7
Jamie Hannaford9793d942015-02-18 15:13:20 +01008// 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 Hannaford5b7acc12015-02-13 09:14:25 +010011func 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 Hannaford9793d942015-02-18 15:13:20 +010019// Get will retrieve information for a specified hardware flavor.
Jamie Hannaford8803f832015-02-23 10:44:55 +010020func Get(client *gophercloud.ServiceClient, id string) GetResult {
Jamie Hannaford5b7acc12015-02-13 09:14:25 +010021 var gr GetResult
Jamie Hannaforda50d1352015-02-18 11:38:38 +010022
Jon Perritta33da232016-03-02 04:43:08 -060023 _, gr.Err = client.Request("GET", getURL(client, id), &gophercloud.RequestOpts{
Jamie Hannaforda50d1352015-02-18 11:38:38 +010024 JSONResponse: &gr.Body,
25 OkCodes: []int{200},
Jamie Hannaford5b7acc12015-02-13 09:14:25 +010026 })
Jamie Hannaforda50d1352015-02-18 11:38:38 +010027
Jamie Hannaford5b7acc12015-02-13 09:14:25 +010028 return gr
29}