raidcheck/state.go
2021-12-21 20:51:12 +01:00

31 lines
923 B
Go

package main
import (
"encoding/json"
"time"
)
type RaidState struct {
Name string `json:"name"`
State string `json:"state"`
Level string `json:"level"`
Devices []string `json:"devices"`
RegisteredDeviceCount int `json:"registered_device_count"`
UsedDeviceCount int `json:"used_device_count"`
DevicesUp map[string]bool `json:"devices_up"`
Action *RaidAction `json:"action"`
}
type RaidAction struct {
Name string `json:"name"`
Progress float64 `json:"progress"`
Duration time.Duration `json:"-"`
DurationFormatted string `json:"duration"`
Finished time.Time `json:"finished"`
}
func (s RaidState) String() string {
data, _ := json.MarshalIndent(s, "", "\t")
return string(data)
}