package v1

import (
	"k8s.io/apimachinery/pkg/api/resource"
	"k8s.io/apimachinery/pkg/types"
)

// the api deisign is for get upstream cluster of ticdc
func (c *TiCDC) GetClusterRef() types.NamespacedName {
	if c.Spec.ClusterName != "" {
		return types.NamespacedName{
			Namespace: c.Namespace,
			Name:      c.Spec.ClusterName,
		}
	}
	return types.NamespacedName{
		Namespace: c.Namespace,
		Name:      c.Spec.UpstreamClusterName,
	}
}

// the api deisign is for get network of ticdc
func (c *TiCDC) GetNetworkRef() types.NamespacedName {
	return types.NamespacedName{
		Namespace: c.Namespace,
		Name:      c.Spec.NetworkName,
	}
}

func (c *TiCDC) GetReplicas() int {
	return c.Spec.Replicas
}

func (c *TiCDC) GetInstanceType() string {
	return c.Spec.InstanceType
}

func (c *TiCDC) GetComponentType() ComponentType {
	return ComponentTiCDC
}

func (c *TiCDC) GetStorageClassName() (string, bool) {
	return "", false
}

func (c *TiCDC) GetStorageSize() (*resource.Quantity, bool) {
	return &c.Spec.StorageSize, false
}

func (c *TiCDC) GetUseLocalStorage() bool {
	return false
}

func (c *TiCDC) SetReplicas(replicas int) {
	c.Spec.Replicas = replicas
}

func (c *TiCDC) SetInstanceType(instanceType string) {
	c.Spec.InstanceType = instanceType
}

func (c *TiCDC) SetStorageClassName(className string) {
	panic("not supported")
}

func (c *TiCDC) SetStorageSize(size resource.Quantity) {
	c.Spec.StorageSize = size
}

func (c *TiCDC) SetUseLocalStorage(useLocalStorage bool) {
	panic("not supported")
}
func (c *TiCDC) GetSuspendActions(base *SuspendAction) *SuspendAction {
	return nil
}
func (c *TiCDC) NeedSuspend(base *SuspendAction) bool {
	return false
}
