diff options
Diffstat (limited to 'src/ovnaction/api/workloadifintenthandler.go')
-rw-r--r-- | src/ovnaction/api/workloadifintenthandler.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ovnaction/api/workloadifintenthandler.go b/src/ovnaction/api/workloadifintenthandler.go index cf8f45bf..5c396378 100644 --- a/src/ovnaction/api/workloadifintenthandler.go +++ b/src/ovnaction/api/workloadifintenthandler.go @@ -22,13 +22,15 @@ import ( "io" "net/http" - moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module" "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" + moduleLib "github.com/onap/multicloud-k8s/src/ovnaction/pkg/module" pkgerrors "github.com/pkg/errors" "github.com/gorilla/mux" ) +var netIfJSONFile string = "json-schemas/network-load-interface.json" + // Used to store backend implementations objects // Also simplifies mocking for unit testing purposes type workloadifintentHandler struct { @@ -88,6 +90,7 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] workloadIntent := vars["workload-intent"] @@ -102,6 +105,12 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re return } + err, httpError := validation.ValidateJsonSchemaData(netIfJSONFile, wif) + if err != nil { + http.Error(w, err.Error(), httpError) + return + } + // Name is required. if wif.Metadata.Name == "" { http.Error(w, "Missing name in POST request", http.StatusBadRequest) @@ -119,7 +128,7 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re return } - ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, false) + ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent, false) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -142,6 +151,7 @@ func (h workloadifintentHandler) putHandler(w http.ResponseWriter, r *http.Reque project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] workloadIntent := vars["workload-intent"] @@ -180,7 +190,7 @@ func (h workloadifintentHandler) putHandler(w http.ResponseWriter, r *http.Reque return } - ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, true) + ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent, true) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -203,19 +213,20 @@ func (h workloadifintentHandler) getHandler(w http.ResponseWriter, r *http.Reque project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] workloadIntent := vars["workload-intent"] var ret interface{} var err error if len(name) == 0 { - ret, err = h.client.GetWorkloadIfIntents(project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent) + ret, err = h.client.GetWorkloadIfIntents(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } else { - ret, err = h.client.GetWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent) + ret, err = h.client.GetWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -238,10 +249,11 @@ func (h workloadifintentHandler) deleteHandler(w http.ResponseWriter, r *http.Re project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] workloadIntent := vars["workload-intent"] - err := h.client.DeleteWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent) + err := h.client.DeleteWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, workloadIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return |