Ash Wilson | 92457e9 | 2014-10-20 15:18:23 -0400 | [diff] [blame] | 1 | package flavors |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors" |
| 6 | "github.com/rackspace/gophercloud/pagination" |
| 7 | ) |
| 8 | |
Ash Wilson | f595dc4 | 2014-10-20 15:24:15 -0400 | [diff] [blame] | 9 | // ListOpts helps control the results returned by the List() function. For example, a flavor with a |
| 10 | // minDisk field of 10 will not be returned if you specify MinDisk set to 20. |
| 11 | type ListOpts struct { |
| 12 | |
| 13 | // MinDisk and MinRAM, if provided, elide flavors that do not meet your criteria. |
| 14 | MinDisk int `q:"minDisk"` |
| 15 | MinRAM int `q:"minRam"` |
| 16 | |
| 17 | // Marker specifies the ID of the last flavor in the previous page. |
| 18 | Marker string `q:"marker"` |
| 19 | |
| 20 | // Limit instructs List to refrain from sending excessively large lists of flavors. |
| 21 | Limit int `q:"limit"` |
| 22 | } |
| 23 | |
| 24 | // ToFlavorListQuery formats a ListOpts into a query string. |
| 25 | func (opts ListOpts) ToFlavorListQuery() (string, error) { |
| 26 | q, err := gophercloud.BuildQueryString(opts) |
| 27 | if err != nil { |
| 28 | return "", err |
| 29 | } |
| 30 | return q.String(), nil |
| 31 | } |
| 32 | |
Ash Wilson | 8a0e24b | 2014-10-24 14:14:36 -0400 | [diff] [blame] | 33 | // ListDetail enumerates the server images available to your account. |
| 34 | func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager { |
| 35 | return os.ListDetail(client, opts) |
Ash Wilson | 92457e9 | 2014-10-20 15:18:23 -0400 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | // Get returns details about a single flavor, identity by ID. |
Jon Perritt | 2571c77 | 2015-07-16 15:11:08 -0600 | [diff] [blame] | 39 | func Get(client *gophercloud.ServiceClient, id string) GetResult { |
| 40 | var res GetResult |
| 41 | _, res.Err = client.Get(getURL(client, id), &res.Body, nil) |
| 42 | return res |
Ash Wilson | 92457e9 | 2014-10-20 15:18:23 -0400 | [diff] [blame] | 43 | } |