package network

// CreateOrCheckDedicatedClusterPrivateEndpointService godoc
//
//	@Summary		CreateOrCheckDedicatedClusterPrivateEndpointService
//	@Description	Create or check the Private Endpoint Service of a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@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		CreatePrivateEndpointServiceRequest	true	"Create or check the Private Endpoint Service request body"
//	@Success		200				{object}	CheckPrivateEndpointServiceResponse	"Returns the response with the status of the created or checked Private Endpoint Service"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/private-endpoint-services [post]
func CreateOrCheckDedicatedClusterPrivateEndpointService() {}

// CreatePrivateEndpointServiceRequest represents the request body for creating or checking a Private Endpoint Service
type CreatePrivateEndpointServiceRequest struct {
	Provider string `json:"provider" example:"aws"`
}

// CheckPrivateEndpointServiceResponse represents the response for checking a Private Endpoint Service
type CheckPrivateEndpointServiceResponse struct {
	AWS *AWSPrivateEndpointServiceInfo `json:"aws,omitempty"`
	GCP *GCPPrivateEndpointServiceInfo `json:"gcp,omitempty"`
}

// AWSPrivateEndpointServiceInfo represents the information of a Private Endpoint Service on AWS
type AWSPrivateEndpointServiceInfo struct {
	ID            int    `json:"id" example:"1"`
	ServiceName   string `json:"service_name" example:"com.amazonaws.vpce.us-west-2.vpce-svc-0b3cd45936052c59e"`
	DNSName       string `json:"dns_name" example:"privatelink-tidb.odxhbtnq69f.clusters.staging.tidb-cloud.com"`
	ServiceStatus string `json:"service_status" example:"ACTIVE"`
	RegionName    string `json:"region_name" example:"Oregon (us-west-2)"`
	Port          int    `json:"port" example:"4000"`
}

// GCPPrivateEndpointServiceInfo represents the information of a Private Endpoint Service on GCP
type GCPPrivateEndpointServiceInfo struct {
	ID            int    `json:"id" example:"1"`
	ServiceName   string `json:"service_name" example:"com.google.vpcendpoints.tidb-cloud.com"`
	DNSName       string `json:"dns_name" example:"privatelink-tidb.odxhbtnq69f.clusters.staging.tidb-cloud.com"`
	ServiceStatus string `json:"service_status" example:"ACTIVE"`
	RegionName    string `json:"region_name" example:"us-west2"`
	Port          int    `json:"port" example:"4000"`
}

// SubmitDedicatedClusterPrivateEndpoint godoc
//
//	@Summary		SubmitDedicatedClusterPrivateEndpoint
//	@Description	Submit the Private Endpoint connection request of a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@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		SubmitPrivateEndpointRequest	true	"Submit Private Endpoint request body"
//	@Success		200				{object}	SubmitPrivateEndpointResponse	"Returns the ID of the submitted Private Endpoint"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/private-endpoints [post]
func SubmitDedicatedClusterPrivateEndpoint() {}

// SubmitPrivateEndpointRequest represents the request body for submitting a Private Endpoint connection request
type SubmitPrivateEndpointRequest struct {
	Provider   string `json:"provider" example:"gcp"`
	EndpointID string `json:"endpoint_id" example:"projects/gcp-autonomous-prod/regions/us-west1/serviceAttachments/o11y-prod-nginx-nlb-a"`
}

// SubmitPrivateEndpointResponse represents the response for submitting a Private Endpoint connection request
type SubmitPrivateEndpointResponse struct {
	ID int `json:"id" example:"1"`
}

// ListDedicatedClusterPrivateEndpoints godoc
//
//	@Summary		ListDedicatedClusterPrivateEndpoints
//	@Description	List all Private Endpoints that have been requested to accept (regardless of whether the acceptance is successful or not) in a specific project of an organization.
//	@Tags			Network
//	@Accept			json
//	@Produce		json
//	@Param			org_id		path		string							true	"Organization ID"
//	@Param			project_id	path		string							true	"Project ID"
//	@Param			cluster-id	query		string							false	"Cluster ID"
//	@Success		200			{object}	ListPrivateEndpointsResponse	"Returns the response with the list of Private Endpoints"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/private-endpoints [get]
func ListDedicatedClusterPrivateEndpoints() {}

// ListPrivateEndpointsResponse represents the response for listing Private Endpoints
type ListPrivateEndpointsResponse struct {
	AWS []*AWSPrivateEndpointInfo `json:"aws,omitempty"`
	GCP []*GCPPrivateEndpointInfo `json:"gcp,omitempty"`
}

// AWSPrivateEndpointInfo represents the information of a Private Endpoint on AWS
type AWSPrivateEndpointInfo struct {
	ID            int    `json:"id" example:"1"`
	ClusterID     string `json:"cluster_id" example:"1373933076661807113"`
	ClusterName   string `json:"cluster_name" example:"yifan-test-keep-2h"`
	RegionName    string `json:"region_name" example:"Oregon (us-west-2)"`
	VpcEndpointID string `json:"vpc_endpoint_id,omitempty" example:"vpce-09b49c676e8715bf0"`
	Status        string `json:"status,omitempty" example:"FAILED"`
	StatusMessage string `json:"status_message,omitempty" example:"The Vpc Endpoint Id 'vpce-09b49c676e8715bf0' does not exist"`
	ServiceName   string `json:"service_name,omitempty" example:"com.amazonaws.vpce.us-west-2.vpce-svc-0b3cd45936052c59e"`
	ServiceStatus string `json:"service_status,omitempty" example:"ACTIVE"`
}

// GCPPrivateEndpointInfo represents the information of a Private Endpoint on GCP
type GCPPrivateEndpointInfo struct {
	ID                    int    `json:"id" example:"1"`
	ClusterID             string `json:"cluster_id" example:"1373933076661807113"`
	ClusterName           string `json:"cluster_name" example:"yifan-test-keep-2h"`
	RegionName            string `json:"region_name" example:"us-west2"`
	ServiceAttachmentName string `json:"service_attachment_name,omitempty" example:"vpce-09b49c676e8715bf0"`
	ConnectionName        string `json:"connection_name,omitempty" example:"promethues-enpoint-a-80b7345b-m"`
	ConnectionID          string `json:"connection_id,omitempty" example:"10498320298297858"`
	Status                string `json:"status,omitempty" example:"FAILED"`
	StatusMessage         string `json:"status_message,omitempty" example:"The Vpc Endpoint Id 'vpce-09b49c676e8715bf0' does not exist"`
	ServiceStatus         string `json:"service_status,omitempty" example:"ACTIVE"`
}

// DeleteDedicatedClusterPrivateEndpoint godoc
//
//	@Summary		DeleteDedicatedClusterPrivateEndpoint
//	@Description	Delete the Private Endpoint connection of a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@Accept			json
//	@Produce		json
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Param			endpoint_id	path	string	true	"Vpc Endpoint ID"
//	@Success		200			"Returns an empty response if the Private Endpoint connection is deleted successfully"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/private-endpoints/{endpoint_id} [delete]
func DeleteDedicatedClusterPrivateEndpoint() {}

// GetDedicatedClusterPrivateAddress godoc
//
//	@Summary		GetDedicatedClusterPrivateAddress
//	@Description	Get the private TiDB address within the VPC of a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@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"
//	@Success		200			{object}	GetPrivateAddressResponse	"Returns the private TiDB address and port"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/{cluster_id}/private-address [get]
func GetDedicatedClusterPrivateAddress() {}

// GetPrivateAddressResponse represents the response for getting the private TiDB address and port
type GetPrivateAddressResponse struct {
	PrivateAddress string `json:"private_address" example:"tidb-xxx.us-east-1.aws.tidbcloud.com"`
	Port           int    `json:"port" example:"4000"`
}

// ListDedicatedClusterVpcPeerings godoc
//
//	@Summary		ListDedicatedClusterVpcPeerings
//	@Description	List all VPC peerings of a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@Accept			json
//	@Produce		json
//	@Param			org_id		path		string					true	"Organization ID"
//	@Param			project_id	path		string					true	"Project ID"
//	@Success		200			{object}	ListVpcPeeringsResponse	"Returns the response with the list of VPC peerings"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/vpc-peerings [get]
func ListDedicatedClusterVpcPeerings() {}

// ListVpcPeeringsResponse represents the response for listing VPC peerings
type ListVpcPeeringsResponse struct {
	AWS []*AWSVpcPeeringInfo `json:"aws,omitempty"`
	GCP []*GCPVpcPeeringInfo `json:"gcp,omitempty"`
}

// AWSVpcPeeringInfo represents the information of a VPC peering connection on AWS
type AWSVpcPeeringInfo struct {
	ID                  int    `json:"id" example:"1"`
	CustomerRegion      string `json:"customer_region" example:"Oregon (us-west-2)"`
	CustomerVpcCidr     string `json:"customer_vpc_cidr" example:"172.31.0.0/16"`
	CustomerVpcID       string `json:"customer_vpc_id" example:"vpc-085f890400d64cd0a"`
	PeeringConnectionID string `json:"peering_connection_id,omitempty" example:"pcx-0b440980960d6526f"`
	Status              string `json:"status" example:"pending"`
}

// GCPVpcPeeringInfo represents the information of a VPC peering connection on GCP
type GCPVpcPeeringInfo struct {
	ID                    int    `json:"id" example:"1"`
	PeeringConnectionName string `json:"peering_connection_name,omitempty" example:"gcp-us-west1-yifan-test-networkpeer"`
	CustomerProjectID     string `json:"customer_project_id" example:"gcp-autonomous-dev"`
	CustomerNetworkName   string `json:"customer_network_name" example:"yifan-test"`
	CustomerVpcCidr       string `json:"customer_vpc_cidr" example:"10.128.0.0/20"`
	CustomerRegion        string `json:"customer_region" example:" Oregon (us-west1)"`
	TiDBCloudNetworkName  string `json:"tidb_cloud_network_name" example:"shoot--staging--a1ae7733"`
	TiDBCloudProjectID    string `json:"tidb_cloud_project_id" example:"pingcap-gardener"`
	TiDBCloudVpcCidr      string `json:"tidb_cloud_vpc_cidr" example:"172.30.168.0/21"`
	TiDBCloudRegion       string `json:"tidb_cloud_region" example:" Oregon (us-west1)"`
	Status                string `json:"status" example:"pending"`
}

// CreateDedicatedClusterVpcPeering godoc
//
//	@Summary		CreateDedicatedClusterVpcPeering
//	@Description	Create a VPC peering connection for a dedicated cluster in a specified project and organization.
//	@Tags			Network
//	@Accept			json
//	@Produce		json
//	@Param			org_id			path		string						true	"Organization ID"
//	@Param			project_id		path		string						true	"Project ID"
//	@Param			request_body	body		CreateVpcPeeringRequest		true	"Request body containing the information for creating a VPC peering connection"
//	@Success		200				{object}	CreateVpcPeeringResponse	"Returns the response with the created VPC peering connection information"
//	@Failure		409				{object}	CreateVpcPeeringResponse	"Returns a conflict response with the existing VPC peering connection information"
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/vpc-peerings [post]
func CreateDedicatedClusterVpcPeering() {}

// CreateVpcPeeringRequest represents the request body for creating a VPC peering connection
type CreateVpcPeeringRequest struct {
	AWS *CreateAWSPeeringRequest `json:"aws,omitempty"`
	GCP *CreateGCPPeeringRequest `json:"gcp,omitempty"`
}

// CreateAWSPeeringRequest represents the request body for creating a VPC peering connection for AWS
type CreateAWSPeeringRequest struct {
	Region    string `json:"region" example:"us-west-2"`
	VpcID     string `json:"vpc_id" example:"vpc-085f890400d64cd0a"`
	AccountID string `json:"account_id" example:"552185537300"`
	VpcCIDR   string `json:"vpc_cidr" example:"172.31.0.0/16"`
}

// CreateGCPPeeringRequest represents the request body for creating a VPC peering connection for GCP
type CreateGCPPeeringRequest struct {
	ProjectID   string `json:"project_id" example:"gcp-project-id"`
	Region      string `json:"region" example:"us-west1"`
	Zone        string `json:"zone" example:"us-west1-a"`
	NetworkName string `json:"network_name" example:"gcp-network-name"`
	NetworkCIDR string `json:"network_cidr" example:"172.31.0.0/16"`
}

// CreateVpcPeeringResponse represents the response for creating a VPC peering connection
type CreateVpcPeeringResponse struct {
	AWS *CreatedAWSPeeringResponse `json:"aws,omitempty"`
	GCP *CreatedGCPPeeringResponse `json:"gcp,omitempty"`
}

// CreatedAWSPeeringResponse represents the response for a created VPC peering connection for AWS
type CreatedAWSPeeringResponse struct {
	ID                  int    `json:"id" example:"1"`
	PeeringConnectionID string `json:"peering_connection_id" example:"pcx-0b440980960d6526f"`
}

// CreatedGCPPeeringResponse represents the response for GCP
type CreatedGCPPeeringResponse struct {
	ID                  int    `json:"id" example:"1"`
	TiDBCloudNetwork    string `json:"tidb_cloud_network_name" example:"shoot--staging--a1ae7733"`
	TiDBCloudProjectID  string `json:"tidb_cloud_project_id" example:"pingcap-gardener"`
	TiDBCloudVPCCIDR    string `json:"tidb_cloud_vpc_cidr" example:"172.30.168.0/21"`
	TiDBCloudRegionName string `json:"tidb_cloud_region_name" example:" Oregon (us-west1)"`
}

// DeleteDedicatedClusterVpcPeering godoc
//
//	@Summary		DeleteDedicatedClusterVpcPeering
//	@Description	Deletes a VPC peering connection.
//	@Tags			Network
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Param			id			path	string	true	"Peering connection ID"
//	@Success		200
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/vpc-peerings/{id} [delete]
func DeleteDedicatedClusterVpcPeering() {}

// GetDedicatedClusterProjectCidrs godoc
//
//	@Summary		GetDedicatedClusterProjectCidrs
//	@Description	Retrieves the CIDRs for different providers and regions of a project's dedicated clusters.
//	@Tags			Network
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Produce		json
//	@Success		200	{array}	ProjectCidrs
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/cidrs [get]
func GetDedicatedClusterProjectCidrs() {}

type ProjectCidrs struct {
	Provider string `json:"provider" example:"aws"`
	Cidr     string `json:"cidr" example:"10.250.0.0/16"`
	Regions  []struct {
		Region     string `json:"region" example:"us-west-2"`
		RegionName string `json:"region_name" example:"Oregon (us-west-2)"`
		Cidr       string `json:"cidr" example:"10.250.24.0/21"`
	} `json:"regions"`
}

// CreateDedicatedClusterProjectCidr godoc
//
//	@Summary		CreateDedicatedClusterProjectCidr
//	@Description	Creates a CIDR for a project and provider, with automatic allocation of different CIDRs for different regions.
//	@Tags			Network
//	@Param			org_id		path	string	true	"Organization ID"
//	@Param			project_id	path	string	true	"Project ID"
//	@Accept			json
//	@Produce		json
//	@Param			request_body	body		ProjectCidrRequest	true	"Request body"
//	@Success		200				{object}	StatusResponse
//	@Router			/orgs/{org_id}/projects/{project_id}/dedicated-clusters/cidrs [post]
func CreateDedicatedClusterProjectCidr() {}

type ProjectCidrRequest struct {
	Provider string `json:"provider" example:"gcp"`
	Cidr     string `json:"cidr" example:"172.30.0.0/16"`
}

type StatusResponse struct {
	Status string `json:"status" example:"success"`
}
