1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package bindings
import (
"fmt"
"net/http"
"strconv"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/api/handlers"
)
func (c Connection) CreateVolume(config handlers.VolumeCreateConfig) (string, error) {
var (
volumeID string
)
response, err := c.newRequest(http.MethodPost, "/volumes/create", nil, nil)
if err != nil {
return volumeID, err
}
return volumeID, response.Process(&volumeID)
}
func (c Connection) InspectVolume(nameOrID string) (*libpod.InspectVolumeData, error) {
var (
inspect libpod.InspectVolumeData
)
response, err := c.newRequest(http.MethodPost, fmt.Sprintf("/volumes/%s/json", nameOrID), nil, nil)
if err != nil {
return &inspect, err
}
return &inspect, response.Process(&inspect)
}
func (c Connection) ListVolumes() error {
// TODO
// The API side of things for this one does a lot in main and therefore
// is not implemented yet.
return ErrNotImplemented // nolint:typecheck
}
func (c Connection) PruneVolumes() ([]string, error) {
var (
pruned []string
)
response, err := c.newRequest(http.MethodPost, "/volumes/prune", nil, nil)
if err != nil {
return pruned, err
}
return pruned, response.Process(&pruned)
}
func (c Connection) RemoveVolume(nameOrID string, force bool) error {
params := make(map[string]string)
params["force"] = strconv.FormatBool(force)
response, err := c.newRequest(http.MethodPost, fmt.Sprintf("/volumes/prune", nameOrID), nil, params)
if err != nil {
return err
}
return response.Process(nil)
}
|