package dag

import (
	"fmt"

	"github.com/tidbcloud/fastflow/pkg/entity"

	"github.com/tidbcloud/tidb-management-service/nextgen-global-service/domain/service/workflow/action"
	"github.com/tidbcloud/tidb-management-service/nextgen-global-service/domain/service/workflow/common"
	"github.com/tidbcloud/tidb-management-service/utilities/workflow"
)

func DeleteResourcePoolDag() *entity.Dag {
	dag := &entity.Dag{
		BaseInfo: entity.BaseInfo{
			ID: common.DeleteResourcePool,
		},
		Name:   common.DeleteResourcePool,
		Status: entity.DagStatusNormal,
		Vars: map[string]entity.DagVar{
			workflow.KeyTraceId:      {},
			workflow.KeyRequestMeta:  {},
			common.KeyResourcePoolId: {},
		},
		Tasks: []entity.Task{
			{
				ID:         action.DeleteResourcePool,
				ActionName: action.DeleteResourcePool,
				Params: map[string]any{
					common.KeyResourcePoolId: fmt.Sprintf("{{%s}}", common.KeyResourcePoolId),
				},
			},
			{
				ID:         action.SendDeleteEventOfResourcePool,
				ActionName: action.SendDeleteEventOfResourcePool,
				Params: map[string]any{
					common.KeyResourcePoolId: fmt.Sprintf("{{%s}}", common.KeyResourcePoolId),
				},
				DependOn: []string{action.DeleteResourcePool},
			},
		},
	}

	return dag
}
