blob: 6bfc20c5644fee320285158ceedd70937912944c [file] [log] [blame]
Ash Wilson92457e92014-10-20 15:18:23 -04001package flavors
2
3import (
4 "github.com/rackspace/gophercloud"
5 os "github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
6 "github.com/rackspace/gophercloud/pagination"
7)
8
Ash Wilsonf595dc42014-10-20 15:24:15 -04009// 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.
11type 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.
25func (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 Wilson8a0e24b2014-10-24 14:14:36 -040033// ListDetail enumerates the server images available to your account.
34func ListDetail(client *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
35 return os.ListDetail(client, opts)
Ash Wilson92457e92014-10-20 15:18:23 -040036}
37
38// Get returns details about a single flavor, identity by ID.
39func Get(client *gophercloud.ServiceClient, id string) os.GetResult {
40 return os.Get(client, id)
41}
42
43// ExtractFlavors interprets a page of List results as Flavors.
44func ExtractFlavors(page pagination.Page) ([]os.Flavor, error) {
45 return os.ExtractFlavors(page)
46}