package remediationticket

import (
	"github.com/tidbcloud/devops/entity"
	tntent "github.com/tidbcloud/devops/entity/tenant"
)

type CreateRemediationTicketReq struct {
	IncidentID  uint64                              `json:"incident_id" binding:"required"`
	BizRegion   *tntent.TenantRegion                `json:"biz_region"`
	Customer    string                              `json:"customer"`
	TenantID    string                              `json:"tenant_id" binding:"required"`
	ClusterID   string                              `json:"cluster_id" binding:"required"`
	ClusterType entity.RemediationTicketClusterType `json:"cluster_type" binding:"required"`
	Month       string                              `json:"month" binding:"required"` // should be in the format "2006/1"
}

type CreateRemediationTicketResp struct {
	TicketID uint64 `json:"ticket_id"`
}

type ListRemediationTicketsReq struct {
	BizRegion *string `json:"biz_region"`
	Creator   *string `json:"creator"`
}

type ListRemediationTicketsResp struct {
	Tickets []*entity.RemediationTicket `json:"items" binding:"required"`
	Count   uint64                      `json:"total" binding:"required"`
}

type GetRemediationTicketResp struct {
	Ticket entity.RemediationTicket `json:"ticket" binding:"required"`
}

type TransferToReq struct {
	NewPhase   entity.RemediationTicketPhase   `json:"new_phase" binding:"required"`
	Reason     *entity.RemediationTicketReason `json:"reason"`
	ReportLink *string                         `json:"report_link"`
}

type SubmitTicketPhaseReq struct {
	// Patch From Region TSE Leader
	RootCauseFromGS string `json:"root_cause_from_gs"`

	// Patch From RDG SLA Owner
	RootCauseFromRDG   string `json:"root_cause_from_rdg"`
	AccidentReportLink string `json:"accident_report_link"`

	// Patch From Global Deal Desk
	ClusterBilling    string `json:"cluster_billing"`
	PredefinedPercent string `json:"predefined_percent"`
	ExtraPercent      string `json:"extra_percent"`
	TotalCompensation string `json:"total_compensation"`

	Version int64 `json:"version"`

	// Will be deprecated
	Reason                  *entity.RemediationTicketReason `json:"reason"`
	ReportLink              *string                         `json:"report_link"`
	AccumulatedDownMinutes  *int                            `json:"accumulated_down_minutes"`
	MonthlyUptimePercentage string                          `json:"monthly_uptime_percentage"`
}

type ApproveTicketPhaseReq struct {
	ApprID  uint64 `json:"appr_id" binding:"required"`
	Version int64  `json:"version" binding:"required"`

	// Patch From Region TSE Leader
	RootCauseFromGS string `json:"root_cause_from_gs"`

	// Patch From RDG SLA Owner
	RootCauseFromRDG   string `json:"root_cause_from_rdg"`
	AccidentReportLink string `json:"accident_report_link"`

	// Patch From Global Deal Desk
	ClusterBilling    string `json:"cluster_billing"`
	PredefinedPercent string `json:"predefined_percent"`
	ExtraPercent      string `json:"extra_percent"`
	TotalCompensation string `json:"total_compensation"`

	// Will be deprecated
	Reason                  *entity.RemediationTicketReason `json:"reason"`
	ReportLink              *string                         `json:"report_link"`
	AccumulatedDownMinutes  *int                            `json:"accumulated_down_minutes"`
	MonthlyUptimePercentage string                          `json:"monthly_uptime_percentage"`
}

type RejectTicketPhaseReq struct {
	ApprID  uint64 `json:"appr_id" binding:"required"`
	Message string `json:"message"`
	Version int64  `json:"version" binding:"required"`
}

type GetProgressResp struct {
	Phases       []entity.RemediationTicketPhaseInfo `json:"phases" binding:"required"`
	CurrentPhase entity.RemediationTicketPhase       `json:"current_phase" binding:"required"`
}

type GetTicketApprovalsResp struct {
	PhaseApprovals []*entity.RemediationTicketPhaseApproval `json:"phase_approvals" binding:"required"`
}

type GetApprovalFlowResp struct {
	Flow entity.RemediationApprovalFlow `json:"flow" binding:"required"`
}

type GenerateFinalDocReq struct {
	ForcedRegenerate bool `json:"forced_regenerate"`
}
