summaryrefslogtreecommitdiff
path: root/pkg/bindings/network.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings/network.go')
-rw-r--r--pkg/bindings/network.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/bindings/network.go b/pkg/bindings/network.go
new file mode 100644
index 000000000..383615e5d
--- /dev/null
+++ b/pkg/bindings/network.go
@@ -0,0 +1,37 @@
+package bindings
+
+import (
+ "fmt"
+ "net/http"
+
+ "github.com/containernetworking/cni/libcni"
+)
+
+func (c Connection) CreateNetwork() {}
+func (c Connection) InspectNetwork(nameOrID string) (map[string]interface{}, error) {
+ n := make(map[string]interface{})
+ response, err := c.newRequest(http.MethodGet, fmt.Sprintf("/networks/%s/json", nameOrID), nil, nil)
+ if err != nil {
+ return n, err
+ }
+ return n, response.Process(&n)
+}
+
+func (c Connection) RemoveNetwork(nameOrID string) error {
+ response, err := c.newRequest(http.MethodDelete, fmt.Sprintf("/networks/%s", nameOrID), nil, nil)
+ if err != nil {
+ return err
+ }
+ return response.Process(nil)
+}
+
+func (c Connection) ListNetworks() ([]*libcni.NetworkConfigList, error) {
+ var (
+ netList []*libcni.NetworkConfigList
+ )
+ response, err := c.newRequest(http.MethodGet, "/networks/json", nil, nil)
+ if err != nil {
+ return netList, err
+ }
+ return netList, response.Process(&netList)
+}