package ngoperation

import (
	"fmt"

	opent "github.com/tidbcloud/devops/entity/operation"
	v1beta1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_cloud_open_api/common/v1beta1"
	mgmtv1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_mgmt_service/v1"
)

func rejectEssentialV2ClusterTiProxyAction(cluster *mgmtv1.Cluster, action opent.ActionName) error {
	if cluster.GetServicePlan() != v1beta1.ServicePlan_Essential_V2 {
		return nil
	}
	// Essential V2 tenant clusters own TiDBGroup, while TiProxyGroup belongs to
	// the shared resource pool and must use resource-pool scoped operations.
	return fmt.Errorf("%s is not supported for Essential V2 tenant clusters; use resource-pool TiProxyGroup operations instead", action)
}
