diff options
Diffstat (limited to 'src/ovnaction/api')
-rw-r--r-- | src/ovnaction/api/api.go | 41 | ||||
-rw-r--r-- | src/ovnaction/api/chainhandler.go | 16 | ||||
-rw-r--r-- | src/ovnaction/api/netcontrolintenthandler.go | 62 | ||||
-rw-r--r-- | src/ovnaction/api/workloadifintenthandler.go | 24 | ||||
-rw-r--r-- | src/ovnaction/api/workloadintenthandler.go | 24 |
5 files changed, 72 insertions, 95 deletions
diff --git a/src/ovnaction/api/api.go b/src/ovnaction/api/api.go index bffab0a4..36744cb0 100644 --- a/src/ovnaction/api/api.go +++ b/src/ovnaction/api/api.go @@ -75,39 +75,38 @@ func NewRouter(testClient interface{}) *mux.Router { netcontrolintentHandler := netcontrolintentHandler{ client: setClient(moduleClient.NetControlIntent, testClient).(moduleLib.NetControlIntentManager), } - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.createHandler).Methods("POST") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.putHandler).Methods("PUT") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.deleteHandler).Methods("DELETE") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}/apply", netcontrolintentHandler.applyHandler).Methods("POST") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent", netcontrolintentHandler.createHandler).Methods("POST") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent", netcontrolintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.putHandler).Methods("PUT") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{name}", netcontrolintentHandler.deleteHandler).Methods("DELETE") workloadintentHandler := workloadintentHandler{ client: setClient(moduleClient.WorkloadIntent, testClient).(moduleLib.WorkloadIntentManager), } - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.createHandler).Methods("POST") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.putHandler).Methods("PUT") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.deleteHandler).Methods("DELETE") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.createHandler).Methods("POST") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.putHandler).Methods("PUT") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.deleteHandler).Methods("DELETE") workloadifintentHandler := workloadifintentHandler{ client: setClient(moduleClient.WorkloadIfIntent, testClient).(moduleLib.WorkloadIfIntentManager), } - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.createHandler).Methods("POST") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.putHandler).Methods("PUT") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.deleteHandler).Methods("DELETE") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.createHandler).Methods("POST") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.putHandler).Methods("PUT") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.deleteHandler).Methods("DELETE") chainHandler := chainHandler{ client: setClient(moduleClient.Chain, testClient).(moduleLib.ChainManager), } - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.createHandler).Methods("POST") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.putHandler).Methods("PUT") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.getHandler).Methods("GET") - router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.deleteHandler).Methods("DELETE") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.createHandler).Methods("POST") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains", chainHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.putHandler).Methods("PUT") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.getHandler).Methods("GET") + router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/deployment-intent-groups/{deployment-intent-group-name}/network-controller-intent/{net-control-intent}/network-chains/{name}", chainHandler.deleteHandler).Methods("DELETE") return router } diff --git a/src/ovnaction/api/chainhandler.go b/src/ovnaction/api/chainhandler.go index 52ed18e5..daf5b2eb 100644 --- a/src/ovnaction/api/chainhandler.go +++ b/src/ovnaction/api/chainhandler.go @@ -23,8 +23,8 @@ import ( "net/http" "strings" - 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" @@ -141,6 +141,7 @@ func (h chainHandler) createHandler(w http.ResponseWriter, r *http.Request) { project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] err := json.NewDecoder(r.Body).Decode(&ch) @@ -166,7 +167,7 @@ func (h chainHandler) createHandler(w http.ResponseWriter, r *http.Request) { return } - ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, netControlIntent, false) + ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, false) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -189,6 +190,7 @@ func (h chainHandler) putHandler(w http.ResponseWriter, r *http.Request) { project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] err := json.NewDecoder(r.Body).Decode(&ch) @@ -221,7 +223,7 @@ func (h chainHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, netControlIntent, true) + ret, err := h.client.CreateChain(ch, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, true) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -244,18 +246,19 @@ func (h chainHandler) getHandler(w http.ResponseWriter, r *http.Request) { project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] var ret interface{} var err error if len(name) == 0 { - ret, err = h.client.GetChains(project, compositeApp, compositeAppVersion, netControlIntent) + ret, err = h.client.GetChains(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } else { - ret, err = h.client.GetChain(name, project, compositeApp, compositeAppVersion, netControlIntent) + ret, err = h.client.GetChain(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -278,9 +281,10 @@ func (h chainHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] - err := h.client.DeleteChain(name, project, compositeApp, compositeAppVersion, netControlIntent) + err := h.client.DeleteChain(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/src/ovnaction/api/netcontrolintenthandler.go b/src/ovnaction/api/netcontrolintenthandler.go index 631f13c4..85318ccf 100644 --- a/src/ovnaction/api/netcontrolintenthandler.go +++ b/src/ovnaction/api/netcontrolintenthandler.go @@ -22,18 +22,15 @@ import ( "io" "net/http" + "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/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation" - "github.com/gorilla/mux" ) var netCntIntJSONFile string = "json-schemas/metadata.json" - - // Used to store backend implementations objects // Also simplifies mocking for unit testing purposes type netcontrolintentHandler struct { @@ -59,6 +56,7 @@ func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Re project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] err := json.NewDecoder(r.Body).Decode(&nci) @@ -72,11 +70,10 @@ func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Re } err, httpError := validation.ValidateJsonSchemaData(netCntIntJSONFile, nci) -if err != nil { - http.Error(w, err.Error(), httpError) - return -} - + if err != nil { + http.Error(w, err.Error(), httpError) + return + } // Name is required. if nci.Metadata.Name == "" { @@ -90,7 +87,7 @@ if err != nil { return } - ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, false) + ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, deployIntentGroup, false) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -113,6 +110,7 @@ func (h netcontrolintentHandler) putHandler(w http.ResponseWriter, r *http.Reque project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] err := json.NewDecoder(r.Body).Decode(&nci) @@ -144,7 +142,7 @@ func (h netcontrolintentHandler) putHandler(w http.ResponseWriter, r *http.Reque return } - ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, true) + ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, deployIntentGroup, true) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -167,17 +165,18 @@ func (h netcontrolintentHandler) getHandler(w http.ResponseWriter, r *http.Reque project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] var ret interface{} var err error if len(name) == 0 { - ret, err = h.client.GetNetControlIntents(project, compositeApp, compositeAppVersion) + ret, err = h.client.GetNetControlIntents(project, compositeApp, compositeAppVersion, deployIntentGroup) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } else { - ret, err = h.client.GetNetControlIntent(name, project, compositeApp, compositeAppVersion) + ret, err = h.client.GetNetControlIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -200,42 +199,9 @@ func (h netcontrolintentHandler) deleteHandler(w http.ResponseWriter, r *http.Re project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] - err := h.client.DeleteNetControlIntent(name, project, compositeApp, compositeAppVersion) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - w.WriteHeader(http.StatusNoContent) -} - -// Apply handles POST operations to Apply a particular NetControlIntent to the App Context -// TODO: This is a test API - it can be removed once the orchestrator has been implemented to -// invoke the appcontext update via grpc. -func (h netcontrolintentHandler) applyHandler(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - project := vars["project"] - compositeApp := vars["composite-app-name"] - compositeAppVersion := vars["version"] - - var aci struct { - AppContextId string `json:"appContextId"` - } - - err := json.NewDecoder(r.Body).Decode(&aci) - - switch { - case err == io.EOF: - http.Error(w, "Empty body", http.StatusBadRequest) - return - case err != nil: - http.Error(w, err.Error(), http.StatusUnprocessableEntity) - return - } - - err = h.client.ApplyNetControlIntent(name, project, compositeApp, compositeAppVersion, aci.AppContextId) + err := h.client.DeleteNetControlIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/src/ovnaction/api/workloadifintenthandler.go b/src/ovnaction/api/workloadifintenthandler.go index e7be6317..5c396378 100644 --- a/src/ovnaction/api/workloadifintenthandler.go +++ b/src/ovnaction/api/workloadifintenthandler.go @@ -22,8 +22,8 @@ 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" @@ -90,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"] @@ -105,10 +106,10 @@ func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Re } err, httpError := validation.ValidateJsonSchemaData(netIfJSONFile, wif) -if err != nil { - http.Error(w, err.Error(), httpError) - return -} + if err != nil { + http.Error(w, err.Error(), httpError) + return + } // Name is required. if wif.Metadata.Name == "" { @@ -127,7 +128,7 @@ if err != nil { 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 @@ -150,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"] @@ -188,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 @@ -211,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 @@ -246,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 diff --git a/src/ovnaction/api/workloadintenthandler.go b/src/ovnaction/api/workloadintenthandler.go index acf4edbb..485f6f40 100644 --- a/src/ovnaction/api/workloadintenthandler.go +++ b/src/ovnaction/api/workloadintenthandler.go @@ -22,8 +22,8 @@ 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" @@ -71,6 +71,7 @@ func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Requ project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] err := json.NewDecoder(r.Body).Decode(&wi) @@ -85,10 +86,10 @@ func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Requ } err, httpError := validation.ValidateJsonSchemaData(workloadIntJSONFile, wi) -if err != nil { - http.Error(w, err.Error(), httpError) - return -} + if err != nil { + http.Error(w, err.Error(), httpError) + return + } // Name is required. if wi.Metadata.Name == "" { @@ -102,7 +103,7 @@ if err != nil { return } - ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, false) + ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, false) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -125,6 +126,7 @@ func (h workloadintentHandler) putHandler(w http.ResponseWriter, r *http.Request project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] err := json.NewDecoder(r.Body).Decode(&wi) @@ -157,7 +159,7 @@ func (h workloadintentHandler) putHandler(w http.ResponseWriter, r *http.Request return } - ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, true) + ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent, true) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -180,18 +182,19 @@ func (h workloadintentHandler) getHandler(w http.ResponseWriter, r *http.Request project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] var ret interface{} var err error if len(name) == 0 { - ret, err = h.client.GetWorkloadIntents(project, compositeApp, compositeAppVersion, netControlIntent) + ret, err = h.client.GetWorkloadIntents(project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } else { - ret, err = h.client.GetWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent) + ret, err = h.client.GetWorkloadIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -214,9 +217,10 @@ func (h workloadintentHandler) deleteHandler(w http.ResponseWriter, r *http.Requ project := vars["project"] compositeApp := vars["composite-app-name"] compositeAppVersion := vars["version"] + deployIntentGroup := vars["deployment-intent-group-name"] netControlIntent := vars["net-control-intent"] - err := h.client.DeleteWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent) + err := h.client.DeleteWorkloadIntent(name, project, compositeApp, compositeAppVersion, deployIntentGroup, netControlIntent) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return |