| 1 |
package proton |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
|
| 6 |
"github.com/go-resty/resty/v2" |
| 7 |
) |
| 8 |
|
| 9 |
func (c *Client) ListVolumes(ctx context.Context) ([]Volume, error) { |
| 10 |
var res struct { |
| 11 |
Volumes []Volume |
| 12 |
} |
| 13 |
|
| 14 |
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) { |
| 15 |
return r.SetResult(&res).Get("/drive/volumes") |
| 16 |
}); err != nil { |
| 17 |
return nil, err |
| 18 |
} |
| 19 |
|
| 20 |
return res.Volumes, nil |
| 21 |
} |
| 22 |
|
| 23 |
func (c *Client) GetVolume(ctx context.Context, volumeID string) (Volume, error) { |
| 24 |
var res struct { |
| 25 |
Volume Volume |
| 26 |
} |
| 27 |
|
| 28 |
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) { |
| 29 |
return r.SetResult(&res).Get("/drive/volumes/" + volumeID) |
| 30 |
}); err != nil { |
| 31 |
return Volume{}, err |
| 32 |
} |
| 33 |
|
| 34 |
return res.Volume, nil |
| 35 |
} |