package template_display

import "errors"

type EventType int

const (
	BackupStart EventType = iota
	BackupFinish
	BackupTooLong
	RestoreStart
	RestoreFinish
	RestoreTooLong
	ImportStart
	ImportFinish
	ImportTooLong
	ClusterCreationStart
	ClusterCreationFinish
	ClusterCreationTooLong
	ClusterOperationStart
	ClusterOperationFinish
	ClusterOperationTooLong
	DFJobStart
	DFJobFinish
	DFJobTooLong
	NewTenant
)

var eventTemplateMap = map[EventType]string{
	BackupStart:             "templates/backup_started.template",
	BackupFinish:            "templates/backup_finished.template",
	BackupTooLong:           "templates/backup_toolong.template",
	RestoreStart:            "templates/restore_started.template",
	RestoreFinish:           "templates/restore_finished.template",
	RestoreTooLong:          "templates/restore_toolong.template",
	ImportStart:             "templates/import_started.template",
	ImportFinish:            "templates/import_finished.template",
	ImportTooLong:           "templates/import_toolong.template",
	ClusterCreationStart:    "templates/cluster_creation_started.template",
	ClusterCreationFinish:   "templates/cluster_creation_finished.template",
	ClusterCreationTooLong:  "templates/cluster_creation_toolong.template",
	ClusterOperationStart:   "templates/cluster_operation_started.template",
	ClusterOperationFinish:  "templates/cluster_operation_finished.template",
	ClusterOperationTooLong: "templates/cluster_operation_toolong.template",
	DFJobStart:              "templates/df_job_started.template",
	DFJobFinish:             "templates/df_job_finished.template",
	DFJobTooLong:            "templates/df_job_toolong.template",
	NewTenant:               "templates/new_tenant.template",
}

func getTemplateFilePath(eventType EventType) (string, error) {
	path, ok := eventTemplateMap[eventType]
	if ok {
		return path, nil
	} else {
		return "", errors.New("Event not registered.")
	}
}

func IsTooLongType(tp EventType) bool {
	if tp == BackupTooLong || tp == RestoreTooLong || tp == ImportTooLong || tp == ClusterOperationTooLong || tp == ClusterCreationTooLong || tp == DFJobTooLong {
		return true
	}
	return false
}
