diff --git a/src/internal/kopia/model_store.go b/src/internal/kopia/model_store.go index dee614218..e9ca49c2a 100644 --- a/src/internal/kopia/model_store.go +++ b/src/internal/kopia/model_store.go @@ -22,12 +22,13 @@ var ( type modelType int -//go:generate stringer -type=modelType +//go:generate go run golang.org/x/tools/cmd/stringer -type=modelType const ( UnknownModel = modelType(iota) BackupOpModel RestoreOpModel RestorePointModel + RestorePointDetailsModel ) func NewModelStore(kw *KopiaWrapper) *ModelStore { diff --git a/src/internal/kopia/modeltype_string.go b/src/internal/kopia/modeltype_string.go index 1acf5e7b5..dd07222ee 100644 --- a/src/internal/kopia/modeltype_string.go +++ b/src/internal/kopia/modeltype_string.go @@ -12,11 +12,12 @@ func _() { _ = x[BackupOpModel-1] _ = x[RestoreOpModel-2] _ = 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 { if i < 0 || i >= modelType(len(_modelType_index)-1) { diff --git a/src/pkg/restorepoint/restorepoint.go b/src/pkg/restorepoint/restorepoint.go new file mode 100644 index 000000000..7987a3321 --- /dev/null +++ b/src/pkg/restorepoint/restorepoint.go @@ -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}) +}