/*
==================================================================================
  Copyright (c) 2019 AT&T Intellectual Property.
  Copyright (c) 2019 Nokia

   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

       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.
==================================================================================
*/

package control

import (
	"fmt"
	rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
	rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
	"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
	"strconv"
	"strings"
	"time"
)

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
type SubRouteInfo struct {
	EpList RmrEndpointList
	SubID  uint16
}

func (sri *SubRouteInfo) String() string {
	return "routeinfo(" + strconv.FormatUint(uint64(sri.SubID), 10) + "/[" + sri.EpList.String() + "])"
}

//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
type RtmgrClient struct {
	rtClient *rtmgrclient.RoutingManager
}

func (rc *RtmgrClient) SubscriptionRequestCreate(subRouteAction SubRouteInfo) error {
	subID := int32(subRouteAction.SubID)
	xapp.Logger.Debug("CREATE %s ongoing", subRouteAction.String())
	createData := rtmgr_models.XappSubscriptionData{&subRouteAction.EpList.Endpoints[0].Addr, &subRouteAction.EpList.Endpoints[0].Port, &subID}
	createHandle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
	createHandle.WithXappSubscriptionData(&createData)
	_, err := rc.rtClient.Handle.ProvideXappSubscriptionHandle(createHandle)
	if err != nil && !(strings.Contains(err.Error(), "status 200")) {
		return fmt.Errorf("CREATE %s failed with error: %s", subRouteAction.String(), err.Error())
	}
	xapp.Logger.Debug("CREATE %s successful", subRouteAction.String())
	return nil
}

func (rc *RtmgrClient) SubscriptionRequestUpdate(subRouteAction SubRouteInfo) error {
	xapp.Logger.Debug("UPDATE %s ongoing", subRouteAction.String())
	var updateData rtmgr_models.XappList
	for i := range subRouteAction.EpList.Endpoints {
		updateData = append(updateData, &rtmgr_models.XappElement{Address: &subRouteAction.EpList.Endpoints[i].Addr, Port: &subRouteAction.EpList.Endpoints[i].Port})
	}
	updateHandle := rtmgrhandle.NewUpdateXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
	updateHandle.WithSubscriptionID(subRouteAction.SubID)
	updateHandle.WithXappList(updateData)
	_, err := rc.rtClient.Handle.UpdateXappSubscriptionHandle(updateHandle)
	if err != nil && !(strings.Contains(err.Error(), "status 200")) {
		return fmt.Errorf("UPDATE %s failed with error: %s", subRouteAction.String(), err.Error())
	}
	xapp.Logger.Debug("UPDATE %s successful", subRouteAction.String())
	return nil

}

func (rc *RtmgrClient) SubscriptionRequestDelete(subRouteAction SubRouteInfo) error {
	subID := int32(subRouteAction.SubID)
	xapp.Logger.Debug("DELETE %s ongoing", subRouteAction.String())
	deleteData := rtmgr_models.XappSubscriptionData{&subRouteAction.EpList.Endpoints[0].Addr, &subRouteAction.EpList.Endpoints[0].Port, &subID}
	deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
	deleteHandle.WithXappSubscriptionData(&deleteData)
	_, _, err := rc.rtClient.Handle.DeleteXappSubscriptionHandle(deleteHandle)
	if err != nil && !(strings.Contains(err.Error(), "status 200")) {
		return fmt.Errorf("DELETE %s failed with error: %s", subRouteAction.String(), err.Error())
	}
	xapp.Logger.Debug("DELETE %s successful", subRouteAction.String())
	return nil
}
