package collector

import (
	"context"
)

type AiCollector interface {
	GetResourceStats(ctx context.Context) (*ResourceStats, error)
	GetDatasetsSpecs(ctx context.Context) ([]*DatasetsSpecs, error)
	GetAlgorithms(ctx context.Context) ([]*Algorithm, error)
	GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error)
	GetTrainingTask(ctx context.Context, taskId string) (*Task, error)
	DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error)
	UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error
	GetComputeCards(ctx context.Context) ([]string, error)
	GetUserBalance(ctx context.Context) (float64, error)
	GetResourceSpecs(ctx context.Context, resrcType string) (*ResourceSpec, error)
}

type ResourceSpec struct {
	ClusterId   string        `json:"clusterID"`
	ClusterType string        `json:"clusterType"`
	Region      string        `json:"region"`
	Tag         string        `json:"tag"`
	Resources   []interface{} `json:"resources"`
	Msg         string        `json:"msg"`
}

type ClusterResource struct {
	Resource      *Usage   `json:"resource"`
	BaseResources []*Usage `json:"baseResources,omitempty"`
}

type UnitValue struct {
	Unit  string      `json:"unit"`
	Value interface{} `json:"value"`
}

type Usage struct {
	Total     *UnitValue `json:"total"`
	Type      string     `json:"type"`
	Name      string     `json:"name,omitempty"`
	Available *UnitValue `json:"available,omitempty"`
}

//type Balance struct {
//	Total UnitValue `json:"total"`
//	Type  string    `json:"type"`
//}
//
//type Rate struct {
//	Price interface{} `json:"price"`
//	Type  string      `json:"type"`
//}

type ResourceStats struct {
	ClusterId     string
	Name          string
	CpuCoreAvail  int64
	CpuCoreTotal  int64
	MemAvail      float64
	MemTotal      float64
	DiskAvail     float64
	DiskTotal     float64
	GpuAvail      int64
	GpuTotal      int64
	CardsAvail    []*Card
	CpuCoreHours  float64
	Balance       float64
	TaskCompleted int64
}

type Card struct {
	Platform   string
	Type       string
	Name       string
	TOpsAtFp16 float64
	CardHours  float64
	CardNum    int32
}

type DatasetsSpecs struct {
	Name string
	Size string
}

type Algorithm struct {
	Name     string
	Platform string
	TaskType string
}

type Task struct {
	Id     string
	Start  string
	End    string
	Status string
}
