package serverless

import (
	"time"

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

// ListServerlessCloudProviders godoc
//
//	@Summary		ListServerlessCloudProviders
//	@Description	List the cloud providers that allow the creation of Serverless clusters.
//	@Tags			Serverless
//	@Produce		json
//	@Success		200	{array}	CloudProvider
//	@Router			/serverless/cloud-providers [get]
func ListServerlessCloudProviders() {}

type CloudProvider struct {
	CloudProvider string `json:"cloud_provider" example:"aws"`
	Description   string `json:"description" example:"Amazon Web Services"`
}

// ListServerlessRegions godoc
//
//	@Summary		ListServerlessRegions
//	@Description	List regions of cloud providers that allow the creation of Serverless clusters.
//	@Tags			Serverless
//	@Produce		json
//	@Param			cloud-provider	query	string	false	"Cloud provider types - Choose from: '' (all) | 'aws' | 'gcp' | 'azure' | ..."
//	@Success		200				{array}	CloudRegion
//	@Router			/serverless/cloud-providers/regions [get]
func ListServerlessRegions() {}

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

// ListServerlessClusters godoc
//
//	@Summary		ListServerlessClusters
//	@Description	List all Serverless Clusters.
//	@Tags			Serverless
//	@Produce		json
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Success		200			{array}	ServerlessCluster
//	@Router			/orgs/{org_id}/projects/{project_id}/serverless [get]
func ListServerlessClusters() {}

// ServerlessCluster represents a Serverless cluster.
// ServerlessCluster represents a Serverless cluster.
type ServerlessCluster 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-east-1"`
	Creator         string    `json:"creator" example:"me@pingcap.com"`
	ClusterVersion  string    `json:"cluster_version" example:"v6.1.0"`
	ClusterStatus   string    `json:"cluster_status" example:"AVAILABLE"`
	SpendLimit      int       `json:"spend_limit" example:"1000"`
	RootPasswordSet bool      `json:"root_password_set" example:"true"`
	FreeCredits     float64   `json:"free_credits" example:"113.86"`
	CreatedAt       time.Time `json:"created_at" example:"2022-03-22T20:23:11.285067Z"`
	UpdatedAt       time.Time `json:"updated_at" example:"2022-03-22T20:23:11.285067Z"`
}

// CreateServerlessCluster godoc
//
//	@Summary		CreateServerlessCluster
//	@Description	Create a Serverless Cluster.
//	@Tags			Serverless
//	@Accept			json
//	@Produce		json
//	@Param			org_id			path		string					true	"Organization ID"
//	@Param			project_id		path		string					true	"Project ID"
//	@Param			request_body	body		CreateClusterRequest	true	"Request body"
//	@Success		200				{object}	CreateClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/serverless [post]
func CreateServerlessCluster() {}

// CreateClusterRequest represents a request body for creating a Serverless cluster.
type CreateClusterRequest struct {
	CloudProvider string `json:"cloud_provider" example:"aws"`
	Region        string `json:"region" example:"us-west-2"`
	ClusterName   string `json:"cluster_name" example:"my-cluster"`
	SpendLimit    int    `json:"spend_limit" example:"0"`
}

// CreateClusterResponse represents a response body for creating a Serverless cluster.
type CreateClusterResponse 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-east-1"`
	Creator         string              `json:"creator" example:"me@pingcap.com"`
	ClusterVersion  string              `json:"cluster_version" example:"v6.1.0"`
	ClusterStatus   string              `json:"cluster_status" example:"AVAILABLE"`
	SpendLimit      int                 `json:"spend_limit" example:"1000"`
	RootPasswordSet bool                `json:"root_password_set" example:"true"`
	FreeCredits     float64             `json:"free_credits" example:"113.86"`
	CreatedAt       time.Time           `json:"created_at" example:"2022-03-22T20:23:11.285067Z"`
	UpdatedAt       time.Time           `json:"updated_at" example:"2022-03-22T20:23:11.285067Z"`
	Operation       operation.Operation `json:"operation"`
}

// GetServerlessCluster godoc
//
//	@Summary		GetServerlessCluster
//	@Description	Get detailed information about Serverless Cluster.
//	@Tags			Serverless
//	@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}	ServerlessCluster
//	@Router			/orgs/{org_id}/projects/{project_id}/serverless/{cluster_id} [get]
func GetServerlessCluster() {}

// DeleteServerlessCluster godoc
//
//	@Summary		DeleteServerlessCluster
//	@Description	Delete Serverless Cluster.
//	@Tags			Serverless
//	@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}	DeleteServerlessClusterResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/serverless/{cluster_id} [delete]
func DeleteServerlessCluster() {}

// DeleteServerlessClusterResponse represents a response body for deleting a Serverless cluster.
type DeleteServerlessClusterResponse 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-east-1"`
	Creator         string              `json:"creator" example:"me@pingcap.com"`
	ClusterVersion  string              `json:"cluster_version" example:"v6.1.0"`
	ClusterStatus   string              `json:"cluster_status" example:"AVAILABLE"`
	SpendLimit      int                 `json:"spend_limit" example:"1000"`
	RootPasswordSet bool                `json:"root_password_set" example:"true"`
	FreeCredits     float64             `json:"free_credits" example:"113.86"`
	CreatedAt       time.Time           `json:"created_at" example:"2022-03-22T20:23:11.285067Z"`
	UpdatedAt       time.Time           `json:"updated_at" example:"2022-03-22T20:23:11.285067Z"`
	Operation       operation.Operation `json:"operation"`
}

// UpdateServerlessClusterSpendLimit godoc
//
//	@Summary		UpdateServerlessClusterSpendLimit
//	@Description	Update the Spend Limit of the given Serverless Cluster.
//	@Tags			Serverless
//
//	@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		SpendLimitUpdateRequest	true	"Spend Limit Update Request"
//	@Success		200				{object}	SpendLimitUpdateResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/serverless/{cluster_id}/spend-limit [put]
func UpdateServerlessClusterSpendLimit() {}

// SpendLimitUpdateRequest represents a request to update the Spend Limit of a Serverless Cluster.
type SpendLimitUpdateRequest struct {
	SpendLimit int `json:"spend_limit" example:"1000"`
}

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

// GetServerlessClusterPublicAddress godoc
//
//	@Summary		GetServerlessClusterPublicAddress
//	@Description	Get public TiDB address.
//	@Tags			Serverless
//	@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}/serverless/{cluster_id}/public-address [get]
func GetServerlessClusterPublicAddress() {}

// 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"`
}
