Implement health check for xApp
[ric-plt/ricdms.git] / pkg / restful / restful.go
index 9b784a1..b17c7ad 100644 (file)
@@ -27,11 +27,13 @@ import (
        "os"
 
        ch "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/charts"
+       dm "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/deploy"
        ph "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/health"
        po "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/onboard"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/charts"
+       "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/deploy"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/health"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/onboard"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/resthooks"
@@ -47,6 +49,7 @@ func NewRestful() *Restful {
                        ph.NewHealthChecker(),
                        po.NewOnboarder(),
                        ch.NewChartmgr(),
+                       dm.NewDeploymentManager(),
                ),
        }
        r.setupHandler()
@@ -67,6 +70,12 @@ func (r *Restful) setupHandler() {
                return resp
        })
 
+       api.HealthGetHealthcheckXAppXAppNameNamespaceNamespaceHandler = health.GetHealthcheckXAppXAppNameNamespaceNamespaceHandlerFunc(func(param health.GetHealthcheckXAppXAppNameNamespaceNamespaceParams) middleware.Responder {
+               ricdms.Logger.Debug("==> Healthcheck for xApp is invoked")
+               resp := r.rh.GetxAppHealth(param.XAppName, param.Namespace)
+               return resp
+       })
+
        api.OnboardPostOnboardxAppsHandler = onboard.PostOnboardxAppsHandlerFunc(func(poap onboard.PostOnboardxAppsParams) middleware.Responder {
                ricdms.Logger.Debug("==> onboard API invoked.")
                resp := r.rh.OnBoard(poap.Body)
@@ -97,6 +106,12 @@ func (r *Restful) setupHandler() {
                return resp
        })
 
+       api.DeployPostDeployHandler = deploy.PostDeployHandlerFunc(func(param deploy.PostDeployParams) middleware.Responder {
+               ricdms.Logger.Debug("==> deployment of xApp")
+               resp := r.rh.DownloadAndInstallChart(param.Body.XAppname, param.Body.Version, *param.Body.Namespace)
+               return resp
+       })
+
        api.ApplicationZipProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
                if zp, ok := data.(io.ReadCloser); ok {
                        defer zp.Close()