package api

const (
	DefaultTenantLabelValue = "unknown"
)

type Auth0RequestBody struct {
	Audience     string `json:"audience"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	GrantType    string `json:"grant_type"`
}

type Auth0Response struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
}

type CreateRequest struct {
	ClusterBaseInfo
	MonitorSpecID    string           `json:"monitorSpecID" form:"monitorSpecID"`
	RuleTemplateID   string           `json:"ruleTemplateID" form:"ruleTemplateID"`
	MuteAlert        bool             `json:"muteAlert" form:"muteAlert"`
	AgentEnvironment AgentEnvironment `json:"agentEnvironment" form:"agentEnvironment"`
}

// AgentEnvironment Describe the agent's deployment environment
type AgentEnvironment struct {
	ReleaseNameSpace string               `json:"releaseNameSpace,omitempty" form:"releaseNameSpace,omitempty"`
	Dataplane        Dataplane            `json:"dataplane" form:"dataplane"`
	AWS              *AWSAgentEnvironment `json:"aws,omitempty" form:"aws,omitempty"`
	GCP              *GCPAgentEnvironment `json:"gcp,omitempty" form:"gcp,omitempty"`
}
type Dataplane struct {
	ClusterName     string `json:"clusterName"`
	ClusterEndpoint string `json:"clusterEndpoint"`
	// +optional
	ClusterCAData *string `json:"clusterCAData,omitempty"`
}
type AWSAgentEnvironment struct {
	VpcID           string   `json:"vpcID"`
	NodeSubnetIDs   []string `json:"nodeSubnetIDs"`
	SecurityGroupID string   `json:"securityGroupID"`
	Account         string   `json:"account"`
	OIDC            string   `json:"oidc"`
}

type GCPAgentEnvironment struct {
	NetworkName string   `json:"networkName"`
	GCPProject  string   `json:"gcpProject"`
	Subnets     []string `json:"subnets"`
}
type ModifyResponse struct {
	Data    *ObservabilityCluster `json:"data"`
	Code    uint64                `json:"code"`
	Message string                `json:"message"`
}

// ObservabilityCluster is copied from https://github.com/tidbcloud/observability/blob/main/pkg/common/structs/cluster.go
type ObservabilityCluster struct {
	ClusterBaseInfo
	StorageInfo []StorageInfo  `json:"storageInfo" form:"storageInfo"`
	MonitorInfo MonitorInfo    `json:"monitorInfo" form:"monitorInfo"`
	AgentInfo   AgentInfo      `json:"agentInfo" form:"agentInfo"`
	Status      ResourceStatus `json:"status" form:"status"`
}

type CommonReqInfo struct {
	Vendor        string `json:"vendor" form:"vendor"`
	Region        string `json:"region" form:"region"`
	TenantID      string `json:"tenantID" form:"tenantID"`
	ProjectID     string `json:"projectID" form:"projectID"`
	ApplicationID string `json:"applicationID" form:"applicationID"`
	BizType       string `json:"bizType" form:"bizType"`
}

type ClusterBaseInfo struct {
	CommonReqInfo
	ID        string      `json:"id" form:"id"`
	Name      string      `json:"name" form:"name"`
	Tags      []string    `json:"tags" form:"tags"`
	Version   VersionCode `json:"version" form:"version"`
	ShareMode ShareMode   `json:"shareMode" form:"shareMode"`
	Note      string      `json:"note" form:"note"`
}

type StorageInfo struct {
	BucketName string                `json:"bucketName" form:"bucketName"`
	Category   ObservabilityCategory `json:"category" form:"category"`
	DataARN    string                `json:"dataARN" form:"dataARN"`
}

type MonitorInfo struct {
	SpecID              string  `json:"specID" form:"specID"`
	EndpointServiceName string  `json:"endpointServiceName" form:"endpointServiceName"`
	DnsName             *string `json:"dnsName" form:"dnsName"`
}

type AgentInfo struct {
	RoleARN string        `json:"roleARN" form:"roleARN"`
	Configs []AgentConfig `json:"configs" form:"configs"`
}

type AgentConfig struct {
	Category ObservabilityCategory `json:"category" form:"category"`
	Content  string                `json:"content" form:"content"`
}

type ListResponse struct {
	Code    int               `json:"code"`    //http error code
	Message string            `json:"message"` //http error msg
	Data    QueryClustersResp `json:"data"`    //The returned content, storage in JSON format
}

type QueryClustersResp struct {
	Clusters []ClusterBaseInfo `json:"clusters"`
}

type GetResponse struct {
	Code    int                   `json:"code"`    //http error code
	Message string                `json:"message"` //http error msg
	Data    *ObservabilityCluster `json:"data"`    //The returned content, storage in JSON format
}

type PauseResponse struct {
	Code    int                   `json:"code"`    //http error code
	Message string                `json:"message"` //http error msg
	Data    *ObservabilityCluster `json:"data"`    //The returned content, storage in JSON format
}

type ResumeResponse struct {
	Code    int                   `json:"code"`    //http error code
	Message string                `json:"message"` //http error msg
	Data    *ObservabilityCluster `json:"data"`    //The returned content, storage in JSON format
}

type ResourceStatus string

const (
	CREATING        ResourceStatus = "CREATING"
	ACTIVE          ResourceStatus = "ACTIVE"
	UPDATING        ResourceStatus = "UPDATING"
	TO_BE_DELETED   ResourceStatus = "TO_BE_DELETED"
	DELETING        ResourceStatus = "DELETING"
	CREATION_FAILED ResourceStatus = "CREATION_FAILED"
	TO_BE_PAUSED    ResourceStatus = "TO_BE_PAUSED"
	PAUSING         ResourceStatus = "PAUSING"
	PAUSED          ResourceStatus = "PAUSED"
	RESTARTING      ResourceStatus = "RESTARTING"
	RESUMING        ResourceStatus = "RESUMING"
)

type ShareMode string

const (
	EXCLUSIVE ShareMode = "exclusive"
	ENHANCED  ShareMode = "enhanced"
	SHARED    ShareMode = "shared"
)

type VersionCode string

type ObservabilityCategory string

const (
	LOGS      ObservabilityCategory = "logs"
	METRICS   ObservabilityCategory = "metrics"
	TRACE     ObservabilityCategory = "trace"
	PROFILING ObservabilityCategory = "profiling"
)
