blob: f50baa699a1943200a086bcf90f81f749a775c0a [file] [log] [blame]
Michal Kobusa1c3ca92019-08-21 14:29:23 +02001package drivers
2
3import (
4 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
5 "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
6)
7
Michal Kobusf6113582019-09-09 15:58:21 +02008// ListDriversOptsBuilder allows extensions to add additional parameters to the
9// ListDrivers request.
10type ListDriversOptsBuilder interface {
11 ToListDriversOptsQuery() (string, error)
12}
13
14// ListDriversOpts defines query options that can be passed to ListDrivers
15type 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
24func (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
30func 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 Kobusa1c3ca92019-08-21 14:29:23 +020041 })
42}
Michal Kobusf6113582019-09-09 15:58:21 +020043
44// GetDriverDetails Shows details for a driver
45func 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
55func 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.
65func 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}