package scrape

const (
	TiDBClusterConfig = "billing-tidb-config"
)

// TidbClusterHeartbeatInfo describe the tidbcluster info in each heartbeat probe
type TidbClusterHeartbeatInfo struct {
	Name             string `json:"name"`
	Namespace        string `json:"namespace"`
	TenantId         uint64 `json:"tenantId"`
	ClusterId        uint64 `json:"clusterId"`
	ClusterProfileId uint32 `json:"clusterProfileId"`
	// Health describes whether the TiDBCluster is available
	Status string `json:"status"`
	// TimeStamp describes the timestamp the Heartbeat info generated
	Timestamp int64 `json:"timestamp"`
	// Tikv describe basic tikv heartbeat information
	Tikvs []TikvHeartbeatInfo `json:"tikvs"`
	// Tidb describe basic tidb heartbeat information
	Tidbs []TidbHeartbeatInfo `json:"tidbs"`
	// Tidb describe basic tidb heartbeat information
	Tiflashes []TiflashHeartbeatInfo `json:"tiflashes"`
	// Msg describe the message we need to throw, eg: error message
	Msg           string                     `json:"msg"`
	ClusterConfig HeterogeneousClusterConfig `json:"clusterConfig"`
}

type TikvHeartbeatInfo struct {
	BasicInfo `json:",inline"`
	Store     StoreInfo `json:"store"`
}

type TidbHeartbeatInfo struct {
	BasicInfo `json:",inline"`
	Tidb      TidbInfo `json:"tidb"`
}

type TiflashHeartbeatInfo struct {
	BasicInfo `json:",inline"`
	Tiflash   TiflashInfo `json:"tiflash"`
}

type BasicInfo struct {
	Name string `json:"name"`
	// Heartbeat indicates whether the scraping for single instance is successful
	Heartbeat bool     `json:"heartbeat"`
	Podphase  string   `json:"phase"`
	NodeInfo  NodeInfo `json:"node"`
}

type NodeInfo struct {
	Labels map[string]string `json:"labels"`
	Name   string            `json:"name"`
}

type HeterogeneousClusterConfig struct {
	TiKV    []Component `json:"tikv"`
	TiDB    []Component `json:"tidb"`
	TiFlash []Component `json:"tiflash"`
}

type Component struct {
	Provider     string `json:"provider"`
	Region       string `json:"region"`
	InstanceType string `json:"instanceType"`
	Disks        []Disk `json:"disks"`
}

type Disk struct {
	DiskType string `json:"diskType"`
	Capacity uint32 `json:"capactity"`
}

type StoreInfo struct {
	StoreId uint64            `json:"storeId"`
	State   string            `json:"state"`
	Labels  map[string]string `json:"labels"`
}

type TidbInfo struct {
	// health indicates whether the querying of /status is successful
	Health bool `json:"health"`
}

type TiflashInfo struct {
	// health indicates whether the querying of /status is successful
	Health bool `json:"health"`
}

type HomogenousClusterConfig struct {
	TiKV    HomogenousComponent `json:"tikv"`
	TiDB    HomogenousComponent `json:"tidb"`
	TiFlash HomogenousComponent `json:"tiflash"`
}

type HomogenousComponent struct {
	Provider     string `json:"provider"`
	Replicas     int    `json:"replicas"`
	Region       string `json:"region"`
	InstanceType string `json:"instanceType"`
	Disks        []Disk `json:"disks"`
}
