package utils

import (
	"oc-monitord/conf"

	oclib "cloud.o-forge.io/core/oc-lib"
	"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
)

func GetExecution(exec_id string) *workflow_execution.WorkflowExecution {
	res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", conf.GetConfig().PeerID, []string{}, nil).LoadOne(exec_id)
	if res.Code != 200 {
		logger := oclib.GetLogger()
		logger.Error().Msg("Could not retrieve workflow ID from execution ID " + exec_id)
		return nil
	}
	return res.ToWorkflowExecution()
}