Revert "Support for XApp configuration update"
[ric-plt/appmgr.git] / cmd / appmgr / api.go
index 8450d02..2e7ddc7 100755 (executable)
@@ -30,11 +30,7 @@ import (
 
 // API functions
 
-func (m *XappManager) Initialize(h Helmer, cm ConfigMapper) {
-       m.cm = cm
-       m.helm = h
-       m.helm.SetCM(cm)
-
+func (m *XappManager) Initialize(h Helmer) {
        m.router = mux.NewRouter().StrictSlash(true)
 
        resources := []Resource{
@@ -55,7 +51,6 @@ func (m *XappManager) Initialize(h Helmer, cm ConfigMapper) {
 
                {"GET", "/ric/v1/config", m.getConfig},
                {"POST", "/ric/v1/config", m.createConfig},
-               {"PUT", "/ric/v1/config", m.updateConfig},
                {"DELETE", "/ric/v1/config", m.deleteConfig},
        }
 
@@ -72,6 +67,7 @@ func (m *XappManager) finalize(h Helmer) {
        m.sd = SubscriptionDispatcher{}
        m.sd.Initialize()
 
+       m.helm = h
        m.helm.Initialize()
 
        m.notifyClients()
@@ -161,7 +157,7 @@ func (m *XappManager) deployXapp(w http.ResponseWriter, r *http.Request) {
                return
        }
 
-       var cm XappDeploy
+       var cm ConfigMetadata
        if err := json.NewDecoder(r.Body).Decode(&cm); err != nil {
                mdclog(MdclogErr, "Invalid xapp data in request body - url="+r.URL.RequestURI())
                respondWithError(w, http.StatusMethodNotAllowed, "Invalid xapp data!")
@@ -266,8 +262,7 @@ func (m *XappManager) notifyClients() {
 }
 
 func (m *XappManager) getConfig(w http.ResponseWriter, r *http.Request) {
-       cfg := m.cm.UploadConfig()
-       respondWithJSON(w, http.StatusOK, cfg)
+       respondWithJSON(w, http.StatusOK, UploadConfig())
 }
 
 func (m *XappManager) createConfig(w http.ResponseWriter, r *http.Request) {
@@ -276,41 +271,20 @@ func (m *XappManager) createConfig(w http.ResponseWriter, r *http.Request) {
                return
        }
 
-       if errList, err := m.cm.CreateConfigMap(c); err != nil {
-               if err.Error() != "Validation failed!" {
-                       respondWithError(w, http.StatusInternalServerError, err.Error())
-               } else {
-                       respondWithJSON(w, http.StatusUnprocessableEntity, errList)
-               }
+       if err := CreateConfigMap(c); err != nil {
+               respondWithError(w, http.StatusInternalServerError, err.Error())
                return
        }
        respondWithJSON(w, http.StatusCreated, nil)
 }
 
-func (m *XappManager) updateConfig(w http.ResponseWriter, r *http.Request) {
-       var c XAppConfig
-       if parseConfig(w, r, &c) != nil {
-               return
-       }
-
-       if errList, err := m.cm.UpdateConfigMap(c); err != nil {
-               if err.Error() != "Validation failed!" {
-                       respondWithError(w, http.StatusInternalServerError, err.Error())
-               } else {
-                       respondWithJSON(w, http.StatusUnprocessableEntity, errList)
-               }
-               return
-       }
-       respondWithJSON(w, http.StatusOK, nil)
-}
-
 func (m *XappManager) deleteConfig(w http.ResponseWriter, r *http.Request) {
        var c XAppConfig
        if parseConfig(w, r, &c) != nil {
                return
        }
 
-       if _, err := m.cm.DeleteConfigMap(c); err != nil {
+       if _, err := DeleteConfigMap(c); err != nil {
                respondWithError(w, http.StatusInternalServerError, err.Error())
                return
        }