blob: 47eb172a9f8908ff6451a752525ebdd9638a5485 [file] [log] [blame]
Samuel A. Falvo II10decf92014-02-13 17:05:35 -08001package flavors
2
3import (
Samuel A. Falvo II10decf92014-02-13 17:05:35 -08004 "github.com/racker/perigee"
Ash Wilson16e75ef2014-09-17 09:54:57 -04005 "github.com/rackspace/gophercloud"
6 "github.com/rackspace/gophercloud/pagination"
Samuel A. Falvo II10decf92014-02-13 17:05:35 -08007)
8
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -07009// ListFilterOptions helps control the results returned by the List() function.
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070010// For example, a flavor with a minDisk field of 10 will not be returned if you specify MinDisk set to 20.
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070011// Typically, software will use the last ID of the previous call to List to set the Marker for the current call.
12type ListFilterOptions struct {
Ash Wilson16e75ef2014-09-17 09:54:57 -040013
14 // ChangesSince, if provided, instructs List to return only those things which have changed since the timestamp provided.
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070015 ChangesSince string
Ash Wilson16e75ef2014-09-17 09:54:57 -040016
17 // MinDisk and MinRAM, if provided, elides flavors which do not meet your criteria.
18 MinDisk, MinRAM int
19
20 // Marker and Limit control paging.
21 // Marker instructs List where to start listing from.
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070022 Marker string
Ash Wilson16e75ef2014-09-17 09:54:57 -040023
24 // Limit instructs List to refrain from sending excessively large lists of flavors.
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070025 Limit int
26}
27
28// List instructs OpenStack to provide a list of flavors.
29// You may provide criteria by which List curtails its results for easier processing.
30// See ListFilterOptions for more details.
Ash Wilson16e75ef2014-09-17 09:54:57 -040031func List(client *gophercloud.ServiceClient, lfo ListFilterOptions) pagination.Pager {
32 createPage := func(r pagination.LastHTTPResponse) pagination.Page {
Ash Wilson0d2c2422014-09-25 14:50:45 -040033 return FlavorPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
Samuel A. Falvo II10decf92014-02-13 17:05:35 -080034 }
35
Ash Wilson31f6bde2014-09-25 14:52:12 -040036 return pagination.NewPager(client, listURL(client, lfo), createPage)
Samuel A. Falvo II10decf92014-02-13 17:05:35 -080037}
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070038
39// Get instructs OpenStack to provide details on a single flavor, identified by its ID.
Ash Wilson16e75ef2014-09-17 09:54:57 -040040// Use ExtractFlavor to convert its result into a Flavor.
Ash Wilson8a8b86f2014-09-25 11:26:51 -040041func Get(client *gophercloud.ServiceClient, id string) GetResult {
42 var gr GetResult
Ash Wilson31f6bde2014-09-25 14:52:12 -040043 gr.Err = perigee.Get(flavorURL(client, id), perigee.Options{
Ash Wilson8a8b86f2014-09-25 11:26:51 -040044 Results: &gr.Resp,
Ash Wilson16e75ef2014-09-17 09:54:57 -040045 MoreHeaders: client.Provider.AuthenticatedHeaders(),
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070046 })
Ash Wilson8a8b86f2014-09-25 11:26:51 -040047 return gr
Samuel A. Falvo II38c6ad02014-05-06 18:09:46 -070048}