CloudMigration: Provide a stats rollup in the GetSnapshot response (#90252)
* order session list descending * add snapshot status method to store * query stats while retrieving snapshot * return stats in dto * swagger * fix tests * commit results of bingo get * fix swagger * minor improvement * fix typo * forgot a file
This commit is contained in:
@@ -17,6 +17,8 @@ var (
|
||||
)
|
||||
|
||||
// CloudMigration domain structs
|
||||
|
||||
// CloudMigrationSession represents a configured migration token
|
||||
type CloudMigrationSession struct {
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
UID string `xorm:"uid"`
|
||||
@@ -29,6 +31,7 @@ type CloudMigrationSession struct {
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
// CloudMigrationSnapshot contains all of the metadata about a snapshot
|
||||
type CloudMigrationSnapshot struct {
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
UID string `xorm:"uid"`
|
||||
@@ -45,6 +48,8 @@ type CloudMigrationSnapshot struct {
|
||||
|
||||
// Stored in the cloud_migration_resource table
|
||||
Resources []CloudMigrationResource `xorm:"-"`
|
||||
// Derived by querying the cloud_migration_resource table
|
||||
StatsRollup SnapshotResourceStats `xorm:"-"`
|
||||
}
|
||||
|
||||
type SnapshotStatus string
|
||||
@@ -73,6 +78,28 @@ type CloudMigrationResource struct {
|
||||
SnapshotUID string `xorm:"snapshot_uid"`
|
||||
}
|
||||
|
||||
type MigrateDataType string
|
||||
|
||||
const (
|
||||
DashboardDataType MigrateDataType = "DASHBOARD"
|
||||
DatasourceDataType MigrateDataType = "DATASOURCE"
|
||||
FolderDataType MigrateDataType = "FOLDER"
|
||||
)
|
||||
|
||||
type ItemStatus string
|
||||
|
||||
const (
|
||||
ItemStatusOK ItemStatus = "OK"
|
||||
ItemStatusError ItemStatus = "ERROR"
|
||||
ItemStatusPending ItemStatus = "PENDING"
|
||||
ItemStatusUnknown ItemStatus = "UNKNOWN"
|
||||
)
|
||||
|
||||
type SnapshotResourceStats struct {
|
||||
CountsByType map[MigrateDataType]int
|
||||
CountsByStatus map[ItemStatus]int
|
||||
}
|
||||
|
||||
// Deprecated, use GetSnapshotResult for the async workflow
|
||||
func (s CloudMigrationSnapshot) GetResult() (*MigrateDataResponse, error) {
|
||||
result := MigrateDataResponse{
|
||||
@@ -154,14 +181,6 @@ type Base64HGInstance struct {
|
||||
|
||||
// GMS domain structs
|
||||
|
||||
type MigrateDataType string
|
||||
|
||||
const (
|
||||
DashboardDataType MigrateDataType = "DASHBOARD"
|
||||
DatasourceDataType MigrateDataType = "DATASOURCE"
|
||||
FolderDataType MigrateDataType = "FOLDER"
|
||||
)
|
||||
|
||||
type MigrateDataRequest struct {
|
||||
Items []MigrateDataRequestItem
|
||||
}
|
||||
@@ -173,15 +192,6 @@ type MigrateDataRequestItem struct {
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
type ItemStatus string
|
||||
|
||||
const (
|
||||
ItemStatusOK ItemStatus = "OK"
|
||||
ItemStatusError ItemStatus = "ERROR"
|
||||
ItemStatusPending ItemStatus = "PENDING"
|
||||
ItemStatusUnknown ItemStatus = "UNKNOWN"
|
||||
)
|
||||
|
||||
type MigrateDataResponse struct {
|
||||
RunUID string
|
||||
Items []CloudMigrationResource
|
||||
|
||||
Reference in New Issue
Block a user