Implement get the charts by name
[ric-plt/ricdms.git] / pkg / restful / restful.go
index 4255e2b..ca45417 100644 (file)
@@ -23,10 +23,14 @@ import (
        "log"
        "os"
 
+       ch "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/charts"
        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/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"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/ricdms"
        "github.com/go-openapi/loads"
@@ -37,6 +41,8 @@ func NewRestful() *Restful {
        r := &Restful{
                rh: resthooks.NewResthook(
                        ph.NewHealthChecker(),
+                       po.NewOnboarder(),
+                       ch.NewChartmgr(),
                ),
        }
        r.setupHandler()
@@ -57,6 +63,30 @@ func (r *Restful) setupHandler() {
                return resp
        })
 
+       api.OnboardPostOnboardxAppsHandler = onboard.PostOnboardxAppsHandlerFunc(func(poap onboard.PostOnboardxAppsParams) middleware.Responder {
+               ricdms.Logger.Debug("==> onboard API invoked.")
+               resp := r.rh.OnBoard(poap.Body)
+               return resp
+       })
+
+       api.ChartsGetChartsListHandler = charts.GetChartsListHandlerFunc(func(param charts.GetChartsListParams) middleware.Responder {
+               ricdms.Logger.Debug("==> GetChartList")
+               resp := r.rh.GetCharts()
+               return resp
+       })
+
+       api.ChartsDownloadHelmChartHandler = charts.DownloadHelmChartHandlerFunc(func(param charts.DownloadHelmChartParams) middleware.Responder {
+               ricdms.Logger.Debug("==> Download helm chart")
+               resp := r.rh.DownloadChart(param.XAppName, param.Version)
+               return resp
+       })
+
+       api.ChartsGetChartHandler = charts.GetChartHandlerFunc(func(param charts.GetChartParams) middleware.Responder {
+               ricdms.Logger.Debug("==> Get Charts by name is invoked")
+               resp := r.rh.GetChartsByName(param.XAppName)
+               return resp
+       })
+
        r.api = api
 }