package dag

import (
	"fmt"

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

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

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

	return dag
}
