diff options
author | Ritu Sood <Ritu.Sood@intel.com> | 2020-04-23 21:30:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-23 21:30:12 +0000 |
commit | b54eda4919487b700554a27cb46b6e6b465ad180 (patch) | |
tree | 0ac7f947f6b0cfb0e13dc1d0af7651474e2b150c /src/ncm/api/netcontrolintenthandler.go | |
parent | bdb527826000c1ab7e832b2bf5fd188f72e3bfb9 (diff) | |
parent | 9e086eb494441de0967b84d0f04d3b4dc7e753c2 (diff) |
Merge "Add code to apply workload network annotations"
Diffstat (limited to 'src/ncm/api/netcontrolintenthandler.go')
-rw-r--r-- | src/ncm/api/netcontrolintenthandler.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/ncm/api/netcontrolintenthandler.go b/src/ncm/api/netcontrolintenthandler.go index c59a389b..48ef1de2 100644 --- a/src/ncm/api/netcontrolintenthandler.go +++ b/src/ncm/api/netcontrolintenthandler.go @@ -196,3 +196,35 @@ func (h netcontrolintentHandler) deleteHandler(w http.ResponseWriter, r *http.Re w.WriteHeader(http.StatusNoContent) } + +// Apply handles POST operations to Apply a particular NetControlIntent to the App Context +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) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} |