github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/pkg/bindings/network/network.go (about) 1 package network 2 3 import ( 4 "context" 5 "net/http" 6 7 "github.com/containernetworking/cni/libcni" 8 "github.com/containers/libpod/pkg/bindings" 9 ) 10 11 func Create() {} 12 func Inspect(ctx context.Context, nameOrID string) (map[string]interface{}, error) { 13 conn, err := bindings.GetClient(ctx) 14 if err != nil { 15 return nil, err 16 } 17 n := make(map[string]interface{}) 18 response, err := conn.DoRequest(nil, http.MethodGet, "/networks/%s/json", nil, nameOrID) 19 if err != nil { 20 return n, err 21 } 22 return n, response.Process(&n) 23 } 24 25 func Remove(ctx context.Context, nameOrID string) error { 26 conn, err := bindings.GetClient(ctx) 27 if err != nil { 28 return err 29 } 30 response, err := conn.DoRequest(nil, http.MethodDelete, "/networks/%s", nil, nameOrID) 31 if err != nil { 32 return err 33 } 34 return response.Process(nil) 35 } 36 37 func List(ctx context.Context) ([]*libcni.NetworkConfigList, error) { 38 var ( 39 netList []*libcni.NetworkConfigList 40 ) 41 conn, err := bindings.GetClient(ctx) 42 if err != nil { 43 return nil, err 44 } 45 response, err := conn.DoRequest(nil, http.MethodGet, "/networks/json", nil) 46 if err != nil { 47 return netList, err 48 } 49 return netList, response.Process(&netList) 50 }