package dedicated

import (
	"time"

	"github.com/tidbcloud/idl/http/operation"
)

// ListDedicatedCloudProviders godoc
//
//	@Summary		ListDedicatedCloudProviders
//	@Description	Fetch info to create dedicated clusters.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Success		200	{array}	DedicatedCloudProvider
//	@Router			/dedicated-clusters/cloud-providers [get]
func ListDedicatedCloudProviders() {}

// DedicatedCloudProvider represents a dedicated cloud provider.
type DedicatedCloudProvider struct {
	CloudProvider string `json:"cloud_provider" example:"aws"`
	Description   string `json:"description" example:"Amazon Web Services"`
}

// ListDedicatedCloudProviderRegions godoc
//
//	@Summary		ListDedicatedCloudProviderRegions
//	@Description	Fetches information about cloud provider regions for creating dedicated clusters.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			cloud-provider	query	string	false	"Cloud provider types, choose from: '' (all) | 'aws' | 'gcp' | 'azure' | ... "
//	@Success		200				{array}	DedicatedCloudProviderRegion
//	@Router			/dedicated-clusters/cloud-providers/regions [get]
func ListDedicatedCloudProviderRegions() {}

// DedicatedCloudProviderRegion represents a cloud provider region for creating dedicated clusters.
type DedicatedCloudProviderRegion struct {
	CloudProvider string `json:"cloud_provider" example:"aws"`
	Region        string `json:"region" example:"us-west-2"`
	Description   string `json:"description" example:"US West (Oregon)"`
}

// ListDedicatedCloudProvidersNodeTypes godoc
//
//	@Summary		ListDedicatedCloudProvidersNodeTypes
//	@Description	This is for fetching info to create cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			cloud-provider	query	string	false	"Cloud provider types. Choose from: '' (all) | 'aws' | 'gcp' | 'azure' | ... "
//	@Param			region			query	string	false	"Region types. Choose from: '' (all) | 'us-west-2' | ... "
//	@Param			instance-type	query	string	false	"Instance types: '' (all) | 'tidb' | 'tikv' | 'tiflash' | ... "
//	@Success		200				{array}	DedicatedCloudProviderNodeType
//	@Router			/dedicated-clusters/cloud-providers/node-types [get]
func ListDedicatedCloudProvidersNodeTypes() {}

// DedicatedCloudProviderNodeType represents a node type for a dedicated cloud provider.
type DedicatedCloudProviderNodeType struct {
	CloudProvider         string `json:"cloud_provider" example:"aws"`
	Region                string `json:"region" example:"us-west-2"`
	InstanceType          string `json:"instance_type" example:"tidb"`
	NodeType              string `json:"node_type" example:"2C4G"`
	Description           string `json:"description" example:"2 vCPU, 4 GiB"`
	NodeCPUCount          int    `json:"node_cpu_num" example:"2"`
	NodeMemoryGiB         int    `json:"node_memory_gi" example:"4"`
	NodeMinStorageSizeGiB int    `json:"node_min_storage_size_gi" example:"0"`
	NodeMaxStorageSizeGiB int    `json:"node_max_storage_size_gi" example:"0"`
}

// CreateDedicatedCluster godoc
//
//	@Summary		CreateDedicatedCluster
//	@Description	Create a Dedicated Cluster.
//	@Tags			Dedicated Clusters
//	@Accept			json
//	@Produce		json
//	@Param			org_id			path		string							true	"Organization ID"
//	@Param			project_id		path		string							true	"Project ID"
//	@Param			request_body	body		CreateDedicatedClusterRequest	true	"Request body"
//	@Success		200				{object}	CreateDedicatedClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters [post]
func CreateDedicatedCluster() {}

// CreateDedicatedClusterRequest represents a request to create a Dedicated Cluster.
type CreateDedicatedClusterRequest struct {
	CloudProvider string                           `json:"cloud_provider" example:"aws"`
	Region        string                           `json:"region" example:"us-west-2"`
	ClusterName   string                           `json:"cluster_name" example:"my-cluster"`
	Instances     []CreateDedicatedClusterInstance `json:"instances"`
}

// CreateDedicatedClusterInstance represents a dedicated instance.
type CreateDedicatedClusterInstance struct {
	InstanceType    string `json:"instance_type" example:"tidb"`
	InstanceCount   int    `json:"instance_count" example:"3"`
	NodeType        string `json:"node_type" example:"4C8G"`
	NodeStorageSize int    `json:"node_storage_size_gi" example:"0"`
}

// CreateDedicatedClusterResponse represents the response of creating a Dedicated Cluster.
type CreateDedicatedClusterResponse struct {
	ClusterID   string              `json:"cluster_id" example:"123456"`
	ClusterName string              `json:"cluster_name" example:"my-cluster"`
	CreatedAt   time.Time           `json:"created_at" example:"2022-03-22T20:23:11.285067Z"`
	Operation   operation.Operation `json:"operation"`
}

// DeleteDedicatedCluster godoc
//
//	@Summary		DeleteDedicatedCluster
//	@Description	Delete Dedicated Cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	DeleteDedicatedClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id} [delete]
func DeleteDedicatedCluster() {}

// DeleteDedicatedClusterResponse represents the response body for deleting a Dedicated Cluster.
type DeleteDedicatedClusterResponse struct {
	ClusterID      string              `json:"cluster_id" example:"123456"`
	ClusterName    string              `json:"cluster_name" example:"my-cluster"`
	CloudProvider  string              `json:"cloud_provider" example:"aws"`
	Region         string              `json:"region" example:"us-west-2"`
	ClusterVersion string              `json:"cluster_version" example:"v6.5.0"`
	HasSetPwd      bool                `json:"has_set_pwd" example:"true"`
	Creator        string              `json:"creator" example:"me@pingcap.com"`
	Instances      []DedicatedInstance `json:"instances"`
	CreatedAt      string              `json:"created_at" example:"2022-03-22T20:13:11.285067Z"`
	UpdatedAt      string              `json:"updated_at" example:"2022-03-22T20:23:11.285067Z"`
	Status         string              `json:"status" example:"DELETING"`
	Operation      operation.Operation `json:"operation"`
}

// DedicatedInstance represents a dedicated instance.
type DedicatedInstance struct {
	InstanceType      string `json:"instance_type" example:"tidb"`
	InstanceCount     int    `json:"instance_count" example:"3"`
	NodeType          string `json:"node_type" example:"4C8G"`
	NodeStorageSizeGi int    `json:"node_storage_size_gi" example:"0"`
}

// GetDedicatedCluster godoc
//
//	@Summary		GetDedicatedCluster
//	@Description	Get detailed information about a Dedicated Cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	DedicatedCluster
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id} [get]
func GetDedicatedCluster() {}

// DedicatedCluster represents a Dedicated cluster.
type DedicatedCluster struct {
	ClusterID      string              `json:"cluster_id" example:"123456"`
	ClusterName    string              `json:"cluster_name" example:"my-cluster"`
	CloudProvider  string              `json:"cloud_provider" example:"aws"`
	Region         string              `json:"region" example:"us-west-2"`
	Creator        string              `json:"creator" example:"me@pingcap.com"`
	ClusterVersion string              `json:"cluster_version" example:"v6.5.0"`
	HasSetPwd      bool                `json:"has_set_pwd" example:"true"`
	Instances      []DedicatedInstance `json:"instances"`
	CreatedAt      string              `json:"created_at" example:"2022-03-22T20:23:11.285067Z"`
	UpdatedAt      string              `json:"updated_at" example:"2022-03-22T20:23:11.285067Z"`
	Status         string              `json:"status" example:"AVAILABLE"`
}

// ListDedicatedClusters godoc
//
//	@Summary		ListDedicatedClusters
//	@Description	List all Dedicated Clusters.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id			path	string	true	"Organization ID"
//	@Param			project_id		path	string	true	"Project ID"
//	@Param			cloud-provider	query	string	false	"Cloud provider types. Choose from: ” (all) | 'aws' | 'gcp' | 'azure' | ..."
//	@Param			region			query	string	false	"Region types. Choose from: ” (all) | 'us-west-2' | ..."
//	@Success		200				{array}	DedicatedCluster
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters [get]
func ListDedicatedClusters() {}

// PauseDedicatedCluster godoc
//
//	@Summary		PauseDedicatedCluster
//	@Description	Pause a Dedicated Cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	PauseDedicatedClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/pause [post]
func PauseDedicatedCluster() {}

// PauseDedicatedClusterResponse represents the response body of the PauseDedicatedCluster API.
type PauseDedicatedClusterResponse struct {
	Operation operation.Operation `json:"operation"`
}

// ResumeDedicatedCluster godoc
//
//	@Summary		ResumeDedicatedCluster
//	@Description	Resume a Dedicated Cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	ResumeDedicatedClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/resume [post]
func ResumeDedicatedCluster() {}

// ResumeDedicatedClusterResponse represents the response body of the ResumeDedicatedCluster API.
type ResumeDedicatedClusterResponse struct {
	Operation operation.Operation `json:"operation"`
}

// ScaleDedicatedCluster godoc
//
//	@Summary		ScaleDedicatedCluster
//	@Description	Scale a Dedicated Cluster.
//	@Tags			Dedicated Clusters
//
//	@Accept			json
//
//	@Produce		json
//	@Param			org_id			path		string				true	"Organization ID"
//	@Param			project_id		path		string				true	"Project ID"
//	@Param			cluster_id		path		string				true	"Cluster ID"
//	@Param			request_body	body		ScaleClusterRequest	true	"Request body containing the cluster scaling information"
//	@Success		200				{object}	ScaleClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/scale [post]
func ScaleDedicatedCluster() {}

// ScaleClusterRequest represents the request for scaling a Dedicated Cluster.
type ScaleClusterRequest struct {
	Instances []DedicatedInstance `json:"instances"`
}

// ScaleClusterResponse represents the response body of the ScaleDedicatedCluster API.
type ScaleClusterResponse struct {
	Operation operation.Operation `json:"operation"`
}

// GetDedicatedClusterPublicAddress godoc
//
//	@Summary		GetDedicatedClusterPublicAddress
//	@Description	Get public TiDB address.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	PublicAddress
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/public-address [get]
func GetDedicatedClusterPublicAddress() {}

// PublicAddress represents the public address of a Dedicated Cluster.
type PublicAddress struct {
	PublicAddress string `json:"public_address" example:"tidb-xxx.us-east-1.aws.tidbcloud.com"`
	Port          int    `json:"port" example:"4000"`
}

// GetDedicatedClusterIPAccessList godoc
//
//	@Summary		GetDedicatedClusterIPAccessList
//	@Description	Get the list of CIDR addresses that are allowed to connect to the public TiDB address.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Param			cluster_id	path	string	true	"Cluster ID"
//	@Success		200			{array}	IPAccessListItem
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/ip-access-list [get]
func GetDedicatedClusterIPAccessList() {}

// IPAccessListItem represents an item in the IP access list for a dedicated cluster.
type IPAccessListItem struct {
	CIDR        string `json:"cidr" example:"0.0.0.0/0"`
	Description string `json:"description" example:"Allow Access from Anywhere."`
}

// UpdateDedicatedClusterIPAccessList godoc
//
//	@Summary		UpdateDedicatedClusterIPAccessList
//	@Description	Update (overwrite) IP whitelist of a dedicated cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string			true	"Organization ID"
//	@Param			project_id	path		string			true	"Project ID"
//	@Param			cluster_id	path		string			true	"Cluster ID"
//	@Param			access_list	body		[]IPAccessRule	true	"IP access list"
//	@Success		200			{object}	Status
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/ip-access-list [put]
func UpdateDedicatedClusterIPAccessList() {}

// IPAccessRule represents a rule in IP access list.
type IPAccessRule struct {
	CIDR        string `json:"cidr"`
	Description string `json:"description"`
}

// Status represents the response of the successful request.
type Status struct {
	Status string `json:"status" example:"success"`
}

// GetDedicatedClusterCaCertDownloadUrl godoc
//
//	@Summary		GetDedicatedClusterCaCertDownloadUrl
//	@Description	Get the URL to download the CA certificate of a dedicated cluster.
//	@Tags			Dedicated Clusters
//	@Produce		json
//	@Param			org_id		path		string	true	"Organization ID"
//	@Param			project_id	path		string	true	"Project ID"
//	@Param			cluster_id	path		string	true	"Cluster ID"
//	@Success		200			{object}	CaCertDownloadUrl
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/ca-cert-download-url [get]
func GetDedicatedClusterCaCertDownloadUrl() {}

// CaCertDownloadUrl represents the URL to download the CA certificate of a dedicated cluster.
type CaCertDownloadUrl struct {
	DownloadUrl string `json:"download_url" example:"https://tidb-xxx.us-east-1.aws.tidbcloud.com/ca-cert"`
}
