package dag

import (
	flowentity "github.com/tidbcloud/fastflow/pkg/entity"

	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/constant"
	"github.com/tidbcloud/tidb-management-service/utilities/workflow"
)

func RestoreNextGenClusterDag() *flowentity.Dag {
	dag := &flowentity.Dag{
		BaseInfo: flowentity.BaseInfo{
			ID: constant.DagNextGenRestoreCluster,
		},
		Name:   constant.DagNextGenRestoreCluster,
		Status: flowentity.DagStatusNormal,
		Vars: map[string]flowentity.DagVar{
			constant.KeyRequest:     {},
			workflow.KeyTraceId:     {},
			workflow.KeySpanName:    {},
			workflow.KeyRequestMeta: {},
		},
		Tasks: []flowentity.Task{
			{
				ID:         constant.TaskNextGenGlobalWaitClusterReady,
				ActionName: constant.TaskNextGenGlobalWaitClusterReady,
			},
			{
				ID:         constant.TaskNextGenGlobalRestoreCluster,
				ActionName: constant.TaskNextGenGlobalRestoreCluster,
				DependOn:   []string{constant.TaskNextGenGlobalWaitClusterReady},
			},
			{
				ID:         constant.TaskNextGenGlobalClearRestoreStatus,
				ActionName: constant.TaskNextGenGlobalClearRestoreStatus,
				DependOn:   []string{constant.TaskNextGenGlobalRestoreCluster},
			},
			{
				ID:         constant.TaskNextGenGlobalEmitRestoredEvent,
				ActionName: constant.TaskNextGenGlobalEmitRestoredEvent,
				DependOn:   []string{constant.TaskNextGenGlobalClearRestoreStatus},
			},
		},
	}

	return dag
}
