package dto

type QueryUserExecutionLogParam struct {
	Org        string `json:"org"`
	DataApp    string `json:"data_app"`
	Start      uint64 `json:"start"`
	End        uint64 `json:"end"`
	ClusterID  string `json:"cluster_id"`
	LogLevel   string `json:"status"`
	Type       string `json:"type"`
	ReqID      string `json:"request_id"`
	TraceID    string `json:"trace_id"`
	EndpointID string `json:"endpoint_id"`
	Source     string `json:"source"`
}

type QueryUserExecutionLogReq struct {
	QueryUserExecutionLogParam
	Page     uint64 `json:"page"`
	PageSize uint64 `json:"page_size"`
	// base64 encoded protobuf DataAppLogQueryPassback:
	Passback string `json:"passback"`
}

type LokiQueryResItem struct {
	Stream map[string]string `json:"stream"`
	Values [][2]string       `json:"values"`
}

type LokiQueryData struct {
	ResultType string             `json:"result_type"`
	Result     []LokiQueryResItem `json:"result"`
}

type LokiQueryRes struct {
	Status string        `json:"status"`
	Data   LokiQueryData `json:"data"`
}

type CustomExecLogRaw struct {
	LogTime         uint64 `json:"log_time"`
	EndpointId      string `json:"endpoint_id"`
	EndpoitName     string `json:"endpoint_name"`
	Latency         string `json:"latency"`
	Level           string `json:"level"`
	Message         string `json:"message"`
	ReqID           string `json:"req_id"`
	TraceID         string `json:"trace_id"`
	RspSize         string `json:"rsp_size"`
	QueryParam      string `json:"query_param"`
	ReqHeader       string `json:"req_header"`
	ReqBody         string `json:"req_body"`
	ReqUrl          string `json:"req_url"`
	ClientInfo      string `json:"client_info"`
	HttpCode        int    `json:"http_code"`
	HttpCodeMessage string `json:"http_code_message"`
	RspRowCnt       int    `json:"resp_row_count"`
	RspCached       bool   `json:"rsp_cached"`
	Method          string `json:"method"`
	DataappID       string `json:"dataapp_id"`
}

type QueryUserExecutionLogRsp struct {
	Data    []CustomExecLogRaw `json:"data"`
	HasMore bool               `json:"has_more"`
	// base64 encoded protobuf DataAppLogQueryPassback:
	Passback string `json:"passback"`
}

type DownloadLogReq struct {
	QueryUserExecutionLogReq
	TaskId      string `json:"task_id"`
	DataAppName string `json:"dataapp_name"`
}

type DownloadLogResult struct {
	TaskId string `json:"task_id"`
	Result string `json:"result"`
	URL    string `json:"url"`
}

type DataAppAccessEvent struct {
	Ip    uint32 `json:"ip"`
	Ts    int64  `json:"ts"`
	AppId uint64 `json:"app_id"`
}

type CustomExecLogDownloadFormat struct {
	DateTime        string                 `json:"date_time"`
	EndpoitName     string                 `json:"name"`
	Method          string                 `json:"method"`
	Latency         string                 `json:"response_time"`
	Message         map[string]interface{} `json:"response_body"`
	ReqID           string                 `json:"request_id"`
	EndpointId      string                 `json:"operation_id"`
	RspSize         string                 `json:"response_size"`
	QueryParam      map[string]interface{} `json:"query_params"`
	ReqHeader       map[string]interface{} `json:"request_headers"`
	ReqBody         string                 `json:"request_body"`
	ReqUrl          string                 `json:"url"`
	ClientInfo      map[string]interface{} `json:"client"`
	HttpCode        int                    `json:"response_status"`
	HttpCodeMessage string                 `json:"response_message"`
	RspRowCnt       int                    `json:"resp_row_count"`
	RspCached       bool                   `json:"cached"`
}
