summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/networks.go25
-rw-r--r--pkg/api/handlers/libpod/swagger.go14
2 files changed, 16 insertions, 23 deletions
diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go
index 122ab1d3d..fcd8e0231 100644
--- a/pkg/api/handlers/libpod/networks.go
+++ b/pkg/api/handlers/libpod/networks.go
@@ -6,7 +6,7 @@ import (
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
- "github.com/containers/podman/v3/libpod/network"
+ "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
api "github.com/containers/podman/v3/pkg/api/types"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -18,27 +18,14 @@ import (
func CreateNetwork(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
- decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
- options := entities.NetworkCreateOptions{}
- if err := json.NewDecoder(r.Body).Decode(&options); err != nil {
- utils.Error(w, "unable to marshall input", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ network := types.Network{}
+ if err := json.NewDecoder(r.Body).Decode(&network); err != nil {
+ utils.Error(w, "unable to marshall input", http.StatusInternalServerError, errors.Wrap(err, "decode body"))
return
}
- query := struct {
- Name string `schema:"name"`
- }{
- // override any golang type defaults
- }
- if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
- return
- }
- if len(options.Driver) < 1 {
- options.Driver = network.DefaultNetworkDriver
- }
+
ic := abi.ContainerEngine{Libpod: runtime}
- report, err := ic.NetworkCreate(r.Context(), query.Name, options)
+ report, err := ic.Libpod.Network().NetworkCreate(network)
if err != nil {
utils.InternalServerError(w, err)
return
diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go
index 6116a7274..7ccfdd0f3 100644
--- a/pkg/api/handlers/libpod/swagger.go
+++ b/pkg/api/handlers/libpod/swagger.go
@@ -4,9 +4,9 @@ import (
"net/http"
"os"
- "github.com/containernetworking/cni/libcni"
"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v3/libpod/define"
+ "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/pkg/errors"
@@ -103,21 +103,27 @@ type swagNetworkRmReport struct {
// swagger:response NetworkInspectReport
type swagNetworkInspectReport struct {
// in:body
- Body libcni.NetworkConfigList
+ Body types.Network
}
// Network list
// swagger:response NetworkListReport
type swagNetworkListReport struct {
// in:body
- Body []entities.NetworkListReport
+ Body []types.Network
+}
+
+// Network create
+// swagger:model NetworkCreateLibpod
+type swagNetworkCreateLibpod struct {
+ types.Network
}
// Network create
// swagger:response NetworkCreateReport
type swagNetworkCreateReport struct {
// in:body
- Body entities.NetworkCreateReport
+ Body types.Network
}
// Network prune