X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=pkg%2Frestful%2Frestful.go;fp=pkg%2Frestful%2Frestful.go;h=f7ce15bc2c6c616b313ff07142cfe490cade9da1;hb=5152bd39551f19139752d89a795327ca9dd189db;hp=44b34228080caaf0f9c49cc86fee9c3dc2a6e703;hpb=272fb5b36779f68a944ca317fa6a6159da0128e3;p=ric-plt%2Fa1.git diff --git a/pkg/restful/restful.go b/pkg/restful/restful.go index 44b3422..f7ce15b 100644 --- a/pkg/restful/restful.go +++ b/pkg/restful/restful.go @@ -1,21 +1,23 @@ /* ================================================================================== - Copyright (c) 2021 Samsung - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Copyright (c) 2021 Samsung - http://www.apache.org/licenses/LICENSE-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This source code is part of the near-RT RIC (RAN Intelligent Controller) + platform project (RICP). - This source code is part of the near-RT RIC (RAN Intelligent Controller) - platform project (RICP). ================================================================================== */ package restful @@ -85,7 +87,12 @@ func (r *Restful) setupHandler() *operations.A1API { api.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler = a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerCreateOrReplacePolicyInstanceParams) middleware.Responder { a1.Logger.Debug("handler for create policy type instance ") - if err = r.rh.CreatePolicyInstance(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID), params.Body); err == nil { + var notificationDestination string + if params.NotificationDestination != nil { + notificationDestination = *params.NotificationDestination + } + if err = r.rh.CreatePolicyInstance(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID), params.Body, notificationDestination); err == nil { + return a1_mediator.NewA1ControllerCreateOrReplacePolicyInstanceAccepted() } if r.rh.IsValidJson(err) { @@ -137,8 +144,7 @@ func (r *Restful) setupHandler() *operations.A1API { a1.Logger.Debug("handler for get policy instance status") if resp, err := r.rh.GetPolicyInstanceStatus(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID)); err == nil { return a1_mediator.NewA1ControllerGetPolicyInstanceStatusOK().WithPayload(resp) - } - if r.rh.IsPolicyInstanceNotFound(err) { + } else if r.rh.IsPolicyInstanceNotFound(err) { return a1_mediator.NewA1ControllerGetPolicyInstanceStatusNotFound() } return a1_mediator.NewA1ControllerGetPolicyInstanceStatusServiceUnavailable()