package o11y

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
	AgentAccessARN  string `json:"agentAccessARN" form:"agentAccessARN"`
	AgentManagerARN string `json:"agentManagerARN" form:"agentManagerARN"`
	MonitorSpecID   string `json:"monitorSpecID" form:"monitorSpecID"`
	RuleTemplateID  string `json:"ruleTemplateID" form:"ruleTemplateID"`
}

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 ResourceStatus string

const (
	CREATING        ResourceStatus = "CREATING"
	ACTIVE          ResourceStatus = "ACTIVE"
	UPDATING        ResourceStatus = "UPDATING"
	DELETING        ResourceStatus = "DELETING"
	CREATION_FAILED ResourceStatus = "CREATION_FAILED"
)

type ShareMode string

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

type VersionCode string

type ObservabilityCategory string

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