1package apiversions 2 3import ( 4 "github.com/gophercloud/gophercloud" 5) 6 7// APIVersions represents the result from getting a list of all versions available 8type APIVersions struct { 9 DefaultVersion APIVersion `json:"default_version"` 10 Versions []APIVersion `json:"versions"` 11} 12 13// APIVersion represents an API version for Ironic 14type APIVersion struct { 15 // ID is the unique identifier of the API version. 16 ID string `json:"id"` 17 18 // MinVersion is the minimum microversion supported. 19 MinVersion string `json:"min_version"` 20 21 // Status is the API versions status. 22 Status string `json:"status"` 23 24 // Version is the maximum microversion supported. 25 Version string `json:"version"` 26} 27 28// GetResult represents the result of a get operation. 29type GetResult struct { 30 gophercloud.Result 31} 32 33// ListResult represents the result of a list operation. 34type ListResult struct { 35 gophercloud.Result 36} 37 38// Extract is a function that accepts a get result and extracts an API version resource. 39func (r GetResult) Extract() (*APIVersion, error) { 40 var s struct { 41 Version APIVersion `json:"version"` 42 } 43 44 err := r.ExtractInto(&s) 45 if err != nil { 46 return nil, err 47 } 48 49 return &s.Version, nil 50} 51 52// Extract is a function that accepts a list result and extracts an APIVersions resource 53func (r ListResult) Extract() (*APIVersions, error) { 54 var version APIVersions 55 56 err := r.ExtractInto(&version) 57 if err != nil { 58 return nil, err 59 } 60 61 return &version, nil 62} 63