package api

import (
	"mime/multipart"
	"time"

	"github.com/pingcap-inc/clinic/pkg/db"
)

type PreCreateResponse struct {
	Partseq    int
	BlockBytes int64
}

type BaseResponse struct {
	Status string
}

type UploadForm struct {
	File *multipart.FileHeader `form:"file" binding:"required"`
}

type FileIDListResponse struct {
	Ids []string
}

type PromResponse struct {
	Status string              `json:"status"`
	Data   []map[string]string `json:"data"`
}

type GrafanaSearchResponse []struct {
	ID          int      `json:"id"`
	UID         string   `json:"uid"`
	Title       string   `json:"title"`
	URI         string   `json:"uri"`
	URL         string   `json:"url"`
	Slug        string   `json:"slug"`
	Type        string   `json:"type"`
	Tags        []string `json:"tags"`
	IsStarred   bool     `json:"isStarred"`
	FolderID    int      `json:"folderId"`
	FolderUID   string   `json:"folderUid"`
	FolderTitle string   `json:"folderTitle"`
	FolderURL   string   `json:"folderUrl"`
	SortMeta    int      `json:"sortMeta"`
}

type IssueListResponse struct {
	Issues []db.JiraIssue `json:"issues"`
}

type BindRequestResponse struct {
	Requests []db.JiraIssueBindRequest `json:"requests"`
}

type FileMetaResponse struct {
	ClusterID   string         `json:"cluster_id"`
	ClusterName string         `json:"cluster_name"`
	BeginTime   *time.Time     `json:"collect_begin_time"`
	EndTime     *time.Time     `json:"collect_end_time"`
	JiraIssues  []db.JiraIssue `json:"jira_issues"`
	FileSize    string         `json:"file_size"`
	UUID        string         `json:"uuid"`

	RebuildMetric   bool   `json:"rebuild_metric"`
	RebuildLog      string `json:"rebuild_log"`
	RebuildReport   bool   `json:"report_status"`
	FileName        string `json:"file_name"`
	FetchConfStatus bool   `json:"fetch_conf_status"`
	FetchConfSize   string `json:"fetch_conf_size"`
}

type RelatedFileResponse struct {
	ClusterID uint64             `json:"cluster_id"`
	Files     []FileMetaResponse `json:"files"`
}

type LogSymptomsResponse struct {
	Symptoms []LogSymptom `json:"symptoms"`
}

type LogSymptom struct {
	Name   string   `json:"symptom"`
	Kibana string   `json:"kibana"`
	KB     []string `json:"kb"`
	Jira   []string `json:"jira"`
}

type Dashboard struct {
	Title string `json:"title"`
	Uid   string `json:"uid"`
}

type LogLevelReporter struct {
	LogLevels []LogLevel `json:"levels"`
}

type LogLevel struct {
	Level string `json:"level"`
	Count int64  `json:"count"`
}

type LoginSuccess struct {
	Message string `json:"message"`
}

type LogConfIndex struct {
	Title        string `json:"title"`
	IndexPattern string `json:"index_pattern"`
}

type GetSlowQueryListRequest struct {
	BeginTime int      `json:"begin_time" form:"begin_time"`
	EndTime   int      `json:"end_time" form:"end_time"`
	DB        []string `json:"db" form:"db"`
	Limit     int      `json:"limit" form:"limit"`
	Text      string   `json:"text" form:"text"`
	OrderBy   string   `json:"orderBy" form:"orderBy"`
	IsDesc    bool     `json:"desc" form:"desc"`

	// for showing slow queries in the statement detail page
	Plans  []string `json:"plans" form:"plans"`
	Digest string   `json:"digest" form:"digest"`

	// Fields string `json:"fields" form:"fields"` // example: "Query,Digest"
}
