"github.com/spf13/viper"
"log"
"net/http"
+ "time"
)
// API functions
{"GET", "/ric/v1/health/ready", m.getHealthStatus},
{"GET", "/ric/v1/xapps", m.getAllXapps},
+ {"GET", "/ric/v1/xapps/search", m.searchAllXapps},
{"GET", "/ric/v1/xapps/{name}", m.getXappByName},
{"GET", "/ric/v1/xapps/{name}/instances/{id}", m.getXappInstanceByName},
{"POST", "/ric/v1/xapps", m.deployXapp},
respondWithJSON(w, http.StatusOK, xapps)
}
+func (m *XappManager) searchAllXapps(w http.ResponseWriter, r *http.Request) {
+ respondWithJSON(w, http.StatusOK, m.helm.SearchAll())
+}
+
func (m *XappManager) deployXapp(w http.ResponseWriter, r *http.Request) {
if r.Body == nil {
Logger.Error("No xapp data found in request body - url=%s", r.URL.RequestURI())
return
}
+ for i := 0; i < 3; i++ {
+ if xapp, err = m.helm.Status(xapp.Name); xapp.Instances != nil {
+ break
+ }
+ time.Sleep(time.Duration(5) * time.Second)
+ }
+
respondWithJSON(w, http.StatusCreated, xapp)
m.sd.Publish(xapp, EventType("created"))