package action

import (
	"github.com/tidbcloud/devops/api"
	relent "github.com/tidbcloud/devops/entity/release"
	"github.com/tidbcloud/devops/pkg/infra/errs"
	relsvcapi "github.com/tidbcloud/devops/pkg/service/release/api"
)

type actionWhenWaitForDeploy struct {
	*actionBase
}

func (a *actionWhenWaitForDeploy) ExecuteDeployment(order relent.ChangeDeployOrder, force bool) error {
	if !order.IsFirst() {
		return errs.APIErrorf(api.ErrCodeInvalidArgument, "order must 0 for the first deployment")
	}
	return a.actionBase.executeDeployment(order, force)
}

func (a *actionWhenWaitForDeploy) Cancel() error {
	return a.actionBase.cancel()
}

func (a *actionWhenWaitForDeploy) UpdateChangeBeforeDeploy(update relsvcapi.UpdateChangeParam) error {
	return a.updateBeforeApproved(update)
}
