package model

import (
	. "github.com/pingcap/test-infra/common/model"
)

type UserListResponse struct {
	Total int     `json:"total"`
	Data  []*User `json:"data"`
}

type PersonalAccessTokenInfo struct {
	PersonalToken
	User *User `json:"user,omitempty"`
}

type PersonalAccessTokenInfoListResponse struct {
	Total int              `json:"total"`
	Data  []*PersonalToken `json:"data"`
}

type CaseListResponse struct {
	Total int         `json:"total"`
	Data  []*TestCase `json:"data"`
}

type CaseSearchResponse struct {
	Total int `json:"total"`
	Data  []*struct {
		TestCase

		Formatted *TestCase `json:"_formatted,omitempty"`
	} `json:"data"`
}

type PlanCreateResponse struct {
	*TestPlan

	// Only oneshot plan has this field.
	PlanExecutionURL string `json:"planExecutionURL,omitempty"`
}

type PlanListResponse struct {
	Total int         `json:"total"`
	Data  []*TestPlan `json:"data"`
}

type PlanSearchResponse struct {
	Total int `json:"total"`
	Data  []*struct {
		TestPlan

		Formatted *TestPlan `json:"_formatted,omitempty"`
	} `json:"data"`
}

type TriggerListResponse struct {
	Total int            `json:"total"`
	Data  []*TestTrigger `json:"data"`
}

type PlanExecutionListResponse struct {
	Total int                  `json:"total"`
	Data  []*TestPlanExecution `json:"data"`
}

type PlanExecutionSearchResponse struct {
	Total int `json:"total"`
	Data  []*struct {
		TestPlanExecution

		Formatted *TestPlanExecution `json:"_formatted,omitempty"`
	} `json:"data"`
}

type PlanExecutionRerunResponse struct {
	// ID is the new plan-execution's ID.
	ID ID `json:"id"`
	// URL is the new plan-execution's detail URL.
	URL string `json:"url"`
}

type CaseExecutionListResponse struct {
	Total int                  `json:"total"`
	Data  []*TestCaseExecution `json:"data"`
}

type TestBedInfoListResponse struct {
	Total int            `json:"total"`
	Data  []*TestBedInfo `json:"data"`
}

type ResourcePoolListResponse struct {
	Total int             `json:"total"`
	Data  []*ResourcePool `json:"data"`
}

type ResourceCohortListResponse struct {
	Total int               `json:"total"`
	Data  []*ResourceCohort `json:"data"`
}

type TestPlanWithTriggerred struct {
	*TestPlan
	Triggerred bool `json:"triggerred"`
}

type ListReleasePlansResponse struct {
	Total int                       `json:"total"`
	Data  []*TestPlanWithTriggerred `json:"data"`
}

type CaseTriageSummary struct {
	Triage    *CaseTriage       `json:"triage,omitempty"`
	Case      TestCase          `json:"case"`
	Execution TestCaseExecution `json:"execution"`
}

type GetPlanExecSummaryResponse struct {
	// ID: tcms ui need planExecutionID as id here,
	ID                  ID                   `json:"id"`
	CaseExecTotal       int                  `json:"caseExecTotal"`
	CaseExecFailureCnt  int                  `json:"caseExecFailureCnt"`
	PlanExec            *TestPlanExecution   `json:"planExec"`
	PlanTriage          *Triage              `json:"planTriage"`
	CaseTriageSummaries []*CaseTriageSummary `json:"caseTriageSummaries"`
}

type GetReleaseSummaryResponse struct {
	PlanExecTotal          int                           `json:"planExecTotal"`
	PlanExecFailureCnt     int                           `json:"planExecFailureCnt"`
	PlanExecErrorCnt       int                           `json:"planExecErrorCnt"`
	CaseExecTotal          int                           `json:"caseExecTotal"`
	CaseExecFailureCnt     int                           `json:"caseExecFailureCnt"`
	FailedPlanExecsSummary []*GetPlanExecSummaryResponse `json:"failedPlanExecsSummary"`
	ErrorPlanExecsSummary  []*GetPlanExecSummaryResponse `json:"errorPlanExecsSummary"`
}
