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