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=28efaaa2cd1184345edfab98361f9d642ec07d9d;hpb=05a0f585da0bbf0c931d5667692807c512bb3238;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/restful/restful.go b/a1-go/pkg/restful/restful.go index 28efaaa..f34a5ad 100644 --- a/a1-go/pkg/restful/restful.go +++ b/a1-go/pkg/restful/restful.go @@ -90,14 +90,23 @@ func (r *Restful) setupHandler() *operations.A1API { return a1_mediator.NewA1ControllerGetPolicyInstanceOK().WithPayload(resp) } if r.rh.IsPolicyInstanceNotFound(err) { - return a1_mediator.NewA1ControllerGetPolicyInstanceNotFound + return a1_mediator.NewA1ControllerGetPolicyInstanceNotFound() } - return a1_mediator.NewA1ControllerGetPolicyInstanceServiceUnavailable + 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") - return a1_mediator.NewA1ControllerGetPolicyInstanceOK().WithPayload(r.rh.GetAllPolicyInstance(models.PolicyTypeID(params.PolicyTypeID))) + 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