package server

import (
	"context"
	"fmt"

	"github.com/tidbcloud/cluster-service-ng/domain/server/br"
	"github.com/tidbcloud/tiinf/monitor/tilog"
	"go.uber.org/zap"
)

func (s *serverImpl) GetLightweightRestorePostActions(ctx context.Context, req *br.GetLightweightRestorePostActionsInput) (*br.GetLightweightRestorePostActionsOutput, error) {
	restore, err := s.lwRestoreRepo.Load(ctx, req.RestoreId, false)
	if err != nil {
		tilog.Error(ctx, "failed to load lw restore record", zap.Error(err), zap.String("restoreId", req.RestoreId))
		return nil, fmt.Errorf("failed to load lw restore record: %w", err)
	}
	restoreAdaptor := br.GetLightweightRestoreAdaptor(restore, s.clustergatewayCli, s.sharedPoolRepo)
	return restoreAdaptor.GetPostActions(ctx, restore)
}
