Samuel A. Falvo II | bc0d54a | 2013-07-08 14:45:21 -0700 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 3 | import ( |
| 4 | "github.com/racker/perigee" |
| 5 | ) |
| 6 | |
| 7 | // See CloudServersProvider interface for details. |
| 8 | func (gsp *genericServersProvider) ListFlavors() ([]Flavor, error) { |
| 9 | var fs []Flavor |
| 10 | |
Samuel A. Falvo II | 7bd1fba | 2013-07-16 17:30:43 -0700 | [diff] [blame] | 11 | err := gsp.context.WithReauth(gsp.access, func() error { |
Samuel A. Falvo II | bc68123 | 2013-07-30 12:01:13 -0700 | [diff] [blame] | 12 | url := gsp.endpoint + "/flavors/detail" |
Samuel A. Falvo II | 20f1aa4 | 2013-07-31 14:32:03 -0700 | [diff] [blame] | 13 | return perigee.Get(url, perigee.Options{ |
Samuel A. Falvo II | 7bd1fba | 2013-07-16 17:30:43 -0700 | [diff] [blame] | 14 | CustomClient: gsp.context.httpClient, |
| 15 | Results: &struct{ Flavors *[]Flavor }{&fs}, |
| 16 | MoreHeaders: map[string]string{ |
| 17 | "X-Auth-Token": gsp.access.AuthToken(), |
| 18 | }, |
| 19 | }) |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 20 | }) |
| 21 | return fs, err |
| 22 | } |
| 23 | |
Samuel A. Falvo II | bc0d54a | 2013-07-08 14:45:21 -0700 | [diff] [blame] | 24 | // FlavorLink provides a reference to a flavor by either ID or by direct URL. |
| 25 | // Some services use just the ID, others use just the URL. |
| 26 | // This structure provides a common means of expressing both in a single field. |
| 27 | type FlavorLink struct { |
| 28 | Id string `json:"id"` |
| 29 | Links []Link `json:"links"` |
| 30 | } |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 31 | |
| 32 | // Flavor records represent (virtual) hardware configurations for server resources in a region. |
| 33 | // |
| 34 | // The Id field contains the flavor's unique identifier. |
| 35 | // For example, this identifier will be useful when specifying which hardware configuration to use for a new server instance. |
| 36 | // |
| 37 | // The Disk and Ram fields provide a measure of storage space offered by the flavor, in GB and MB, respectively. |
| 38 | // |
| 39 | // The Name field provides a human-readable moniker for the flavor. |
| 40 | // |
| 41 | // Swap indicates how much space is reserved for swap. |
| 42 | // If not provided, this field will be set to 0. |
| 43 | // |
| 44 | // VCpus indicates how many (virtual) CPUs are available for this flavor. |
| 45 | type Flavor struct { |
| 46 | OsFlvDisabled bool `json:"OS-FLV-DISABLED:disabled"` |
| 47 | Disk int `json:"disk"` |
| 48 | Id string `json:"id"` |
| 49 | Links []Link `json:"links"` |
| 50 | Name string `json:"name"` |
| 51 | Ram int `json:"ram"` |
| 52 | RxTxFactor float64 `json:"rxtx_factor"` |
| 53 | Swap int `json:"swap"` |
| 54 | VCpus int `json:"vcpus"` |
| 55 | } |