X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Frestful%2Frestful.go;h=b7e209495f5914729edf44c1ae53d980b4119f57;hb=44f5c8a90e9aabb096d8f6100e49f34eb4f89b01;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..b7e2094 100644 --- a/a1-go/pkg/restful/restful.go +++ b/a1-go/pkg/restful/restful.go @@ -97,7 +97,16 @@ func (r *Restful) setupHandler() *operations.A1API { 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