github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dds/v3/flavors/results.go (about) 1 package flavors 2 3 import ( 4 "github.com/huaweicloud/golangsdk/pagination" 5 ) 6 7 // FlavorPage is a single page of Flavor results. 8 type FlavorPage struct { 9 pagination.LinkedPageBase 10 } 11 12 // IsEmpty returns true if the page contains no results. 13 func (r FlavorPage) IsEmpty() (bool, error) { 14 s, err := ExtractFlavors(r) 15 return len(s) == 0, err 16 } 17 18 // ExtractFlavors extracts a slice of Flavors from a List result. 19 func ExtractFlavors(r pagination.Page) ([]Flavor, error) { 20 var s struct { 21 Flavors []Flavor `json:"flavors"` 22 } 23 err := (r.(FlavorPage)).ExtractInto(&s) 24 return s.Flavors, err 25 } 26 27 // Flavor represents a DDS flavor. 28 type Flavor struct { 29 EngineName string `json:"engine_name"` 30 Type string `json:"type"` 31 Vcpus string `json:"vcpus"` 32 Ram string `json:"ram"` 33 SpecCode string `json:"spec_code"` 34 AvailabilityZone []string `json:"availability_zone"` 35 }