| package drivers |
| |
| import ( |
| "gerrit.mcp.mirantis.net/debian/gophercloud.git" |
| "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination" |
| ) |
| |
| type commonResult struct { |
| gophercloud.Result |
| } |
| |
| func (r commonResult) Extract() (*Driver, error) { |
| var d struct { |
| Driver *Driver `json:"driver"` |
| } |
| err := r.ExtractInto(&d) |
| return d.Driver, err |
| } |
| |
| type GetResult struct { |
| commonResult |
| } |
| |
| type Link struct { |
| Href string `json:"href"` |
| Rel string `json:"rel"` |
| } |
| |
| type Driver struct { |
| Name string `json:"name"` |
| Type string `json:"type"` |
| Hosts []string `json:"hosts"` |
| Links []Link `json:"links"` |
| Properties []Link `json:"properties"` |
| } |
| |
| type DriverPage struct { |
| pagination.SinglePageBase |
| } |
| |
| func (r DriverPage) NextPageURL() (string, error) { |
| var d struct { |
| Links []gophercloud.Link `json:"drivers_links"` |
| } |
| err := r.ExtractInto(&d) |
| if err != nil { |
| return "", err |
| } |
| return gophercloud.ExtractNextURL(d.Links) |
| } |
| |
| func (r DriverPage) IsEmpty() (bool, error) { |
| is, err := ExtractDrivers(r) |
| return len(is) == 0, err |
| } |
| |
| func ExtractDrivers(r pagination.Page) ([]Driver, error) { |
| var d struct { |
| Drivers []Driver `json:"drivers"` |
| } |
| err := (r.(DriverPage)).ExtractInto(&d) |
| return d.Drivers, err |
| } |