package brain

import (
	"github.com/BytemarkHosting/bytemark-client/lib/prettyprint"
	"io"
)

// BackupSchedule represents a schedule to take backups on. It is represented as a start date in YYYY-MM-DD hh:mm:ss format (and assuming UK timezones of some kind.)
type BackupSchedule struct {
	StartDate string
	Interval  int
}

// PrettyPrint outputs a nicely-formatted human-readable version of the schedule to the given writer.
// All the detail levels are the same.
func (sched BackupSchedule) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error {
	scheduleTpl := `
{{ define "schedule_sgl" }}{{ printf "Every %d seconds starting from %s" .Interval .StartDate }}{{ end }}
{{ define "schedule_medium" }}{{ template "schedule_sgl" . }}{{ end }}
{{ define "schedule_full" }}{{ template "schedule_medium" . }}{{ end }}
`
	return prettyprint.Run(wr, scheduleTpl, "schedule"+string(detail), sched)
}

package brain

import (
	"github.com/BytemarkHosting/bytemark-client/lib/prettyprint"
	"io"
)

// BackupSchedule represents a schedule to take backups on. It is represented as a start date in YYYY-MM-DD hh:mm:ss format (and assuming UK timezones of some kind.)
type BackupSchedule struct {
	StartDate string `json:"start_at"`
	Interval  int    `json:"interval_seconds"`
}

// PrettyPrint outputs a nicely-formatted human-readable version of the schedule to the given writer.
// All the detail levels are the same.
func (sched BackupSchedule) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error {
	scheduleTpl := `
{{ define "schedule_sgl" }}{{ printf "Every %d seconds starting from %s" .Interval .StartDate }}{{ end }}
{{ define "schedule_medium" }}{{ template "schedule_sgl" . }}{{ end }}
{{ define "schedule_full" }}{{ template "schedule_medium" . }}{{ end }}
`
	return prettyprint.Run(wr, scheduleTpl, "schedule"+string(detail), sched)
}

Add json tags to BackupSchedule
Add json tags to BackupSchedule
