package tidbcluster

import (
	"context"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"

	cloudv1 "github.com/tidbcloud/infra-api/api/v1"
)

// Getter is an interface to get the information from TiDB Operator CRs.
type Getter interface {
	Name() string
	Namespace() string
	Version() string
	Object() metav1.Object
	TiKVImage() string
	PDImage() string
	BootstrapSQLConfigMapName() string
	ComponentReplicas(componentType cloudv1.ComponentType) int32
	// if the component is suspended, return 0 instead of the `replicas` field in the CR.
	// in TiDB Operator v1, this also considers "failed" members with auto failover enabled.
	ComponentDesiredReplicas(componentType cloudv1.ComponentType) int32
	ComponentActualReplicas(componentType cloudv1.ComponentType) int32
	ComponentUpdatedReplicas(componentType cloudv1.ComponentType) int32
	ComponentReadyReplicas(componentType cloudv1.ComponentType) int32
	ComponentAnnotations(componentType cloudv1.ComponentType) map[string]string
	ComponentAllInstancesReady(componentType cloudv1.ComponentType) bool
	ComponentNodeSelector(componentType cloudv1.ComponentType) map[string]string
	ComponentTerminationGracePeriodSeconds(componentType cloudv1.ComponentType) *int64
	IsDeleted(ctx context.Context, cli client.Client, name, ns string) bool
	IsNil() bool
	IsReady() bool
	IsTLSEnabled() bool
	IsTiProxyEnabled() bool
}
