RestorePoint and RestorePointDetails models (#279)
RestorePoint and RestorePointDetails models. Refs #268
This commit is contained in:
parent
22ecfba402
commit
233aa43f4c
@ -22,12 +22,13 @@ var (
|
|||||||
|
|
||||||
type modelType int
|
type modelType int
|
||||||
|
|
||||||
//go:generate stringer -type=modelType
|
//go:generate go run golang.org/x/tools/cmd/stringer -type=modelType
|
||||||
const (
|
const (
|
||||||
UnknownModel = modelType(iota)
|
UnknownModel = modelType(iota)
|
||||||
BackupOpModel
|
BackupOpModel
|
||||||
RestoreOpModel
|
RestoreOpModel
|
||||||
RestorePointModel
|
RestorePointModel
|
||||||
|
RestorePointDetailsModel
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModelStore(kw *KopiaWrapper) *ModelStore {
|
func NewModelStore(kw *KopiaWrapper) *ModelStore {
|
||||||
|
|||||||
@ -12,11 +12,12 @@ func _() {
|
|||||||
_ = x[BackupOpModel-1]
|
_ = x[BackupOpModel-1]
|
||||||
_ = x[RestoreOpModel-2]
|
_ = x[RestoreOpModel-2]
|
||||||
_ = x[RestorePointModel-3]
|
_ = x[RestorePointModel-3]
|
||||||
|
_ = x[RestorePointDetailsModel-4]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _modelType_name = "UnknownModelBackupOpModelRestoreOpModelRestorePointModel"
|
const _modelType_name = "UnknownModelBackupOpModelRestoreOpModelRestorePointModelRestorePointDetailsModel"
|
||||||
|
|
||||||
var _modelType_index = [...]uint8{0, 12, 25, 39, 56}
|
var _modelType_index = [...]uint8{0, 12, 25, 39, 56, 80}
|
||||||
|
|
||||||
func (i modelType) String() string {
|
func (i modelType) String() string {
|
||||||
if i < 0 || i >= modelType(len(_modelType_index)-1) {
|
if i < 0 || i >= modelType(len(_modelType_index)-1) {
|
||||||
|
|||||||
75
src/pkg/restorepoint/restorepoint.go
Normal file
75
src/pkg/restorepoint/restorepoint.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package restorepoint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/internal/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RestorePoint represents the result of a backup operation
|
||||||
|
// that can be restored
|
||||||
|
type RestorePoint struct {
|
||||||
|
model.BaseModel
|
||||||
|
CreationTime time.Time `json:"creationTime"`
|
||||||
|
|
||||||
|
// SnapshotID is the kopia snapshot ID
|
||||||
|
SnapshotID string `json:"snapshotID"`
|
||||||
|
|
||||||
|
// Reference to `Details`
|
||||||
|
// We store the ModelStoreID since Details is immutable
|
||||||
|
DetailsID string `json:"detailsId"`
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - Backup "Specification"
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(snapshotID, detailsID string) *RestorePoint {
|
||||||
|
return &RestorePoint{
|
||||||
|
CreationTime: time.Now(),
|
||||||
|
SnapshotID: snapshotID,
|
||||||
|
DetailsID: detailsID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Details describes what was stored in a RestorePoint
|
||||||
|
type Details struct {
|
||||||
|
model.BaseModel
|
||||||
|
Entries []DetailsEntry `json:"entries"`
|
||||||
|
|
||||||
|
// internal
|
||||||
|
mu sync.Mutex `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DetailsEntry describes a single item stored in a RestorePoint
|
||||||
|
type DetailsEntry struct {
|
||||||
|
// TODO: `RepoRef` is currently the full path to the item in Kopia
|
||||||
|
// This can be optimized.
|
||||||
|
RepoRef string `json:"repoRef"`
|
||||||
|
ItemInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemInfo is a oneOf that contains service specific
|
||||||
|
// information about the item it tracks
|
||||||
|
type ItemInfo struct {
|
||||||
|
Exchange *ExchangeInfo `json:"exchange,omitempty"`
|
||||||
|
Sharepoint *SharepointInfo `json:"sharepoint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExchangeInfo describes an exchange item
|
||||||
|
type ExchangeInfo struct {
|
||||||
|
Sender string `json:"sender"`
|
||||||
|
Subject string `json:"subject"`
|
||||||
|
Received time.Time `json:"received"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SharepointInfo describes a sharepoint item
|
||||||
|
// TODO: Implement this. This is currently here
|
||||||
|
// just to illustrate usage
|
||||||
|
type SharepointInfo struct{}
|
||||||
|
|
||||||
|
func (d *Details) Add(repoRef string, info ItemInfo) {
|
||||||
|
d.mu.Lock()
|
||||||
|
defer d.mu.Unlock()
|
||||||
|
d.Entries = append(d.Entries, DetailsEntry{RepoRef: repoRef, ItemInfo: info})
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user