blob: 081ea478cd817a3ad4892bc653b70a1fff4427df [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.
Jon Perritt2571c772015-07-16 15:11:08 -060039func 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 Wilson92457e92014-10-20 15:18:23 -040043}