package api

type DescribeClusterConfigInput struct {
	// TenantID is tenant ID in DBaaS
	// Used to get the configuration under a tenant
	// +required
	TenantID *uint64 `json:"tenantId"`

	// ClusterID is cluster ID in DBaaS
	// Used to get the configuration under a cluster. if not specipy, tenant-level configuration will be used
	// +optional
	ClusterID *uint64 `json:"clusterId,omitempty"`

	// Components should be specipy extra information of pd、tidb、tikv. such as instance type information
	// +required
	Components []ComponentInput `json:"components"`
}

type ComponentInput struct {
	// Component is component name of tidb cluster
	Component ComponentName `json:"component"`

	// InstanceType is current instance type of your component (eg: aws.i3.2xlarge)
	InstanceType string `json:"instanceType"`
}

type DescribeClusterConfigOutput struct {
	// Version is tidb cluster version of your cluster
	Version string `json:"version"`

	// ConfigMeta contains metadata information of configurations
	ConfigMeta *ConfigMeta `json:"configMeta"`

	// Components contains detail configuration of all components
	Components []ComponentOutput `json:"components"`
}

type Image struct {
	// BaseImage of the component
	BaseImage string `json:"baseImage"`

	// Tag is image tag of the component
	Tag *string `json:"tag"`
}

type ConfigMeta struct {
	// ID is unique identifier of cluster config
	ID string `json:"id"`

	// GitCommitID is git commit ID of cluster configuration
	GitCommitID string `json:"gitCommitId"`

	// ConfigVersion is configuration version number, auto increment
	ConfigVersion uint64 `json:"configVersion"`
}

type ComponentName string

const (
	ComponentTiKV           ComponentName = "tikv"
	ComponentTiProxy        ComponentName = "tiproxy"
	ComponentPD             ComponentName = "pd"
	ComponentTiDB           ComponentName = "tidb"
	ComponentTiFlash        ComponentName = "tiflash"
	ComponentTiFlashLearner ComponentName = "tiflash-learner"
)

type ComponentOutput struct {
	// Image contains docker image information of component
	Image Image `json:"image"`

	// Component is component name of tidb cluster
	Component ComponentName `json:"component"`

	// InstanceType is current instance type of your component
	InstanceType string `json:"instanceType"`

	// Config is detail configuration of your cluster
	Config *TomlConfig `json:"config"`
}
