package domain

import (
	"time"

	"github.com/tidbcloud/dataflow-service/app/repo/entity"
)

// CreateReplayReq create the Replay request
type CreateReplayReq struct {
	TenantID              uint64
	ProjectID             uint64
	CloudProvider         string
	Region                string
	SourceClusterID       uint64
	TargetClusterID       uint64
	ReplayTasks           entity.ReplayTaskList
	ReplayConfig          *entity.ReplayCommonConfig
	TaskResources         *entity.ReplayTaskResources
	ReplayImage           string
	Replicas              int32
	SourceAuditCredential *entity.AuditLogAddr
}

// CreateReplayResp create the Replay response
type CreateReplayResp struct {
	ReplayID uint64
}

// GetReplayReq get the Replay request
type GetReplayReq struct {
	ReplayID uint64
}

// GetReplayResp get the Replay response
type GetReplayResp struct {
	Replay *Replay
}

// ListReplayReq list the Replay request
type ListReplayReq struct {
	TenantID  uint64
	ProjectID uint64
	ClusterID uint64
	Page      uint32
	PageSize  uint32
}

// ListReplayResp list the Replay response
type ListReplayResp struct {
	Replays []*Replay
	Total   uint32
}

// UpdateReplayReq update the Replay request
type UpdateReplayReq struct {
	ReplayID              uint64
	CloudProvider         *string
	Region                *string
	SourceClusterID       *uint64
	TargetClusterID       *uint64
	ReplayTasks           entity.ReplayTaskList
	ReplayConfig          *entity.ReplayCommonConfig
	TaskResources         *entity.ReplayTaskResources
	ReplayImage           *string
	Replicas              *int32
	SourceAuditCredential *entity.AuditLogAddr
}

// UpdateReplayResp update the Replay response
type UpdateReplayResp struct {
	Replay *Replay
}

// DeleteReplayReq delete the Replay request
type DeleteReplayReq struct {
	ReplayID uint64
}

// PauseReplayReq pause the Replay request
type PauseReplayReq struct {
	ReplayID uint64
}

// ResumeReplayReq resume the Replay request
type ResumeReplayReq struct {
	ReplayID uint64
}

// Replay represent the domain model of the Replay task
type Replay struct {
	ID                    uint64
	TenantID              uint64
	ProjectID             uint64
	CloudProvider         string
	Region                string
	SourceClusterID       uint64
	TargetClusterID       uint64
	DesiredState          entity.ReplayDesiredState
	CurrentState          entity.ReplayCurrentState
	ReplayTasks           entity.ReplayTaskList
	ReplayConfig          *entity.ReplayCommonConfig
	TaskResources         *entity.ReplayTaskResources
	ReplayImage           string
	Replicas              int32
	SourceAuditCredential *entity.AuditLogAddr
	ReplayStatus          *entity.ReplayStatus
	CreatedAt             time.Time
	UpdatedAt             *time.Time
}

// DeployReplayReq deploy the Replay request
type DeployReplayReq struct {
	Replay *entity.Replay
}

// DeployReplayResp deploy the Replay response
type DeployReplayResp struct {
	Success bool
	Message string
}

// StartReplayReq start the Replay request
type StartReplayReq struct {
	Replay *entity.Replay
}

// StartReplayResp start the Replay response
type StartReplayResp struct {
	Success bool
	Message string
}

// StopReplayReq stop the Replay request
type StopReplayReq struct {
	Replay *entity.Replay
}

// StopReplayResp stop the Replay response
type StopReplayResp struct {
	Success bool
	Message string
}

// DestroyReplayReq destroy the Replay request
type DestroyReplayReq struct {
	Replay *entity.Replay
}

// DestroyReplayResp destroy the Replay response
type DestroyReplayResp struct {
	Success bool
	Message string
}

// GetReplayStatusReq get the Replay status request
type GetReplayStatusReq struct {
	Replay *entity.Replay
}

// GetReplayStatusResp get the Replay status response
type GetReplayStatusResp struct {
	Phase   entity.ReplayPhase
	Status  *entity.ReplayStatus
	Message string
	State   entity.ReplayDesiredState
}

// ModifyReplayReq update the Replay request
type ModifyReplayReq struct {
	Replay *entity.Replay
	State  entity.ReplayDesiredState
}

// ModifyReplayResp update the Replay response
type ModifyReplayResp struct {
	Success bool
	Message string
}
