blob: eb864d5787f377ec2a792052d822df9f834e5213 [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
Samuel A. Falvo II7bd1fba2013-07-16 17:30:43 -070011 err := gsp.context.WithReauth(gsp.access, func() error {
Samuel A. Falvo IIbc681232013-07-30 12:01:13 -070012 url := gsp.endpoint + "/flavors/detail"
Samuel A. Falvo II20f1aa42013-07-31 14:32:03 -070013 return perigee.Get(url, perigee.Options{
Samuel A. Falvo II7bd1fba2013-07-16 17:30:43 -070014 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 IIbc3f10f2013-07-11 17:13:24 -070020 })
21 return fs, err
22}
23
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070024// 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.
27type FlavorLink struct {
28 Id string `json:"id"`
29 Links []Link `json:"links"`
30}
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -070031
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.
45type 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}