X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Frestful%2Frestful.go;h=f34a5ad208a730688c168ac5fe29bfe7f9be69e0;hb=6242a3ff1b95eb8fc89931b11115ec9c06d08e96;hp=b494dab76e826db5e8cdcd45044c730a3f835912;hpb=3ad6de4df1dfe70e467064e6477f2e6068e87048;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/restful/restful.go b/a1-go/pkg/restful/restful.go index b494dab..f34a5ad 100644 --- a/a1-go/pkg/restful/restful.go +++ b/a1-go/pkg/restful/restful.go @@ -84,6 +84,31 @@ func (r *Restful) setupHandler() *operations.A1API { }) + api.A1MediatorA1ControllerGetPolicyInstanceHandler = a1_mediator.A1ControllerGetPolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerGetPolicyInstanceParams) middleware.Responder { + a1.Logger.Debug("handler for get policy instance from policytypeID") + if resp, err := r.rh.GetPolicyInstance(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID)); err == nil { + return a1_mediator.NewA1ControllerGetPolicyInstanceOK().WithPayload(resp) + } + if r.rh.IsPolicyInstanceNotFound(err) { + return a1_mediator.NewA1ControllerGetPolicyInstanceNotFound() + } + return a1_mediator.NewA1ControllerGetPolicyInstanceServiceUnavailable() + }) + + api.A1MediatorA1ControllerGetAllInstancesForTypeHandler = a1_mediator.A1ControllerGetAllInstancesForTypeHandlerFunc(func(params a1_mediator.A1ControllerGetAllInstancesForTypeParams) middleware.Responder { + a1.Logger.Debug("handler for get all policy instance") + if resp, err := r.rh.GetAllPolicyInstance(models.PolicyTypeID(params.PolicyTypeID)); err == nil { + if resp != nil { + return a1_mediator.NewA1ControllerGetAllInstancesForTypeOK().WithPayload(resp) + } + } + if r.rh.IsPolicyInstanceNotFound(err) { + return a1_mediator.NewA1ControllerGetPolicyInstanceNotFound() + } + return a1_mediator.NewA1ControllerGetAllInstancesForTypeServiceUnavailable() + + }) + return api }