Michal Kobus | a1c3ca9 | 2019-08-21 14:29:23 +0200 | [diff] [blame] | 1 | package drivers |
| 2 | |
| 3 | import ( |
| 4 | "gerrit.mcp.mirantis.net/debian/gophercloud.git" |
| 5 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination" |
| 6 | ) |
| 7 | |
Michal Kobus | f611358 | 2019-09-09 15:58:21 +0200 | [diff] [blame] | 8 | // ListDriversOptsBuilder allows extensions to add additional parameters to the |
| 9 | // ListDrivers request. |
| 10 | type ListDriversOptsBuilder interface { |
| 11 | ToListDriversOptsQuery() (string, error) |
| 12 | } |
| 13 | |
| 14 | // ListDriversOpts defines query options that can be passed to ListDrivers |
| 15 | type ListDriversOpts struct { |
| 16 | // Provide detailed information about the drivers |
| 17 | Detail bool `q:"detail"` |
| 18 | |
| 19 | // Filter the list by the type of the driver |
| 20 | Type string `q:"type"` |
| 21 | } |
| 22 | |
| 23 | // ToListDriversOptsQuery formats a ListOpts into a query string |
| 24 | func (opts ListDriversOpts) ToListDriversOptsQuery() (string, error) { |
| 25 | q, err := gophercloud.BuildQueryString(opts) |
| 26 | return q.String(), err |
| 27 | } |
| 28 | |
| 29 | // ListDrivers makes a request against the API to list all drivers |
| 30 | func ListDrivers(client *gophercloud.ServiceClient, opts ListDriversOptsBuilder) pagination.Pager { |
| 31 | url := driversURL(client) |
| 32 | if opts != nil { |
| 33 | query, err := opts.ToListDriversOptsQuery() |
| 34 | if err != nil { |
| 35 | return pagination.Pager{Err: err} |
| 36 | } |
| 37 | url += query |
| 38 | } |
| 39 | return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { |
| 40 | return DriverPage{pagination.LinkedPageBase{PageResult: r}} |
Michal Kobus | a1c3ca9 | 2019-08-21 14:29:23 +0200 | [diff] [blame] | 41 | }) |
| 42 | } |
Michal Kobus | f611358 | 2019-09-09 15:58:21 +0200 | [diff] [blame] | 43 | |
| 44 | // GetDriverDetails Shows details for a driver |
| 45 | func GetDriverDetails(client *gophercloud.ServiceClient, driverName string) (r GetDriverResult) { |
| 46 | _, r.Err = client.Get(driverDetailsURL(client, driverName), &r.Body, &gophercloud.RequestOpts{ |
| 47 | OkCodes: []int{200}, |
| 48 | }) |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | // GetDriverProperties Shows the required and optional parameters that |
| 53 | // driverName expects to be supplied in the driver_info field for every |
| 54 | // Node it manages |
| 55 | func GetDriverProperties(client *gophercloud.ServiceClient, driverName string) (r GetPropertiesResult) { |
| 56 | _, r.Err = client.Get(driverPropertiesURL(client, driverName), &r.Body, &gophercloud.RequestOpts{ |
| 57 | OkCodes: []int{200}, |
| 58 | }) |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | // GetDriverDiskProperties Show the required and optional parameters that |
| 63 | // driverName expects to be supplied in the node’s raid_config field, if a |
| 64 | // RAID configuration change is requested. |
| 65 | func GetDriverDiskProperties(client *gophercloud.ServiceClient, driverName string) (r GetDiskPropertiesResult) { |
| 66 | _, r.Err = client.Get(driverDiskPropertiesURL(client, driverName), &r.Body, &gophercloud.RequestOpts{ |
| 67 | OkCodes: []int{200}, |
| 68 | }) |
| 69 | return |
| 70 | } |