package enum

import "fmt"

type StorageSize int

// StorageType - Enum that defines the type of storage
const (
	GB StorageSize = iota
	MB
	KB
	TB
)

var argoType = [...]string{
	"Gi",
	"Mi",
	"Ki",
	"Ti",
}

// Size to string
func (t StorageSize) String() string {
	return [...]string{"GB", "MB", "KB", "TB"}[t]
}

func SizeList() []StorageSize {
	return []StorageSize{GB, MB, KB, TB}
}

// New creates a new instance of the StorageResource struct
func (dma StorageSize) ToArgo() string {
	return argoType[dma]
}

// enum of a data type
type StorageType int

const (
	FILE = iota
	STREAM
	API
	DATABASE
	S3
	MEMORY
	HARDWARE
	AZURE
	GCS
)

// String() - Returns the string representation of the storage type
func (t StorageType) String() string {
	return [...]string{"FILE", "STREAM", "API", "DATABASE", "S3", "MEMORY", "HARDWARE", "AZURE", "GCS"}[t]
}

func TypeList() []StorageType {
	return []StorageType{FILE, STREAM, API, DATABASE, S3, MEMORY, HARDWARE, AZURE, GCS}
}

func (d StorageType) Compare(indexStr interface{}) bool {
	return fmt.Sprintf("%v", indexStr) == fmt.Sprintf("%v", d.EnumIndex()) || fmt.Sprintf("%v", indexStr) == d.String()
}

func (d StorageType) EnumIndex() int {
	return int(d)
}
