package forms

type NodeProfileCompute struct {
	CpuNum   int `json:"cpu"`
	MemoryMi int `json:"memory_mi"`
}

type NodeProfileOfComponent struct {
	Compute       NodeProfileCompute `json:"compute"`
	StorageGi     int                `json:"storage_gi"`
	NodeProfileID uint64             `json:"node_profile_id,string"`
	Name          string             `json:"name"`
}

type TenantComponent struct {
	Replicas    uint32                 `json:"replicas"`
	NodeProfile NodeProfileOfComponent `json:"node_profile"`
	MachineType string                 `json:"machineType"` // TODO(chenfei): remove. used by gitops to overlay configuration for component for now
}

type TenantComponents struct {
	PD      TenantComponent `json:"pd"`
	TiKV    TenantComponent `json:"tikv"`
	TiDB    TenantComponent `json:"tidb"`
	TiFlash TenantComponent `json:"tiflash"`
}

type TenantCluster struct {
	ID                       int64            `json:"id,string"`
	Name                     string           `json:"name"`
	Provider                 string           `json:"provider"`
	Region                   string           `json:"region"`
	Profile                  string           `json:"profile"`
	Version                  string           `json:"version"`
	CreateTime               uint64           `json:"create_time"`
	TenantComponents         TenantComponents `json:"tenant_components"`
	Status                   string           `json:"status"`
	ProjectID                int64            `json:"project_id,string"`
	ProjectName              string           `json:"project_name"`
	IsDevTier                bool             `json:"is_dev_tier"`
	CrossAccountDeploymentID uint64           `json:"cross_account_deployment_id,string"`
}

type ListTenantClustersResp struct {
	CodeMsgResponse
	Total int64           `json:"total"`
	Items []TenantCluster `json:"items"`
}

type ListTenantClusterLifeCycleResp struct {
	Total int64                    `json:"total"`
	Items []TenantClusterLifecycle `json:"items"`
}

type TenantClusterLifecycle struct {
	Id        uint64 `json:"id,string"`
	ProjectID uint64 `json:"project_id,string"`
	CreatedAt int64  `json:"created_at"`
	DeletedAt int64  `json:"deleted_at"`
}

type ComponentScale struct {
	ComponentType string `json:"component_type" binding:"required,oneof=COMPONENT_TYPE_TIDB COMPONENT_TYPE_TIKV COMPONENT_TYPE_TIFLASH"`
	NodeProfileId uint64 `json:"node_profile_id,string" binding:"required"`
	Replicas      int32  `json:"replicas" binding:"required,gte=0"`
	StorageSizeGi int64  `json:"storage_size_gi" binding:"gte=0"`
}

type ScaleComponentReq struct {
	Components []ComponentScale `json:"components" binding:"required"`
}
