dashboard_version.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. "github.com/grafana/grafana/pkg/components/simplejson"
  6. )
  7. var (
  8. ErrDashboardVersionNotFound = errors.New("Dashboard version not found")
  9. ErrNoVersionsForDashboardId = errors.New("No dashboard versions found for the given DashboardId")
  10. )
  11. // A DashboardVersion represents the comparable data in a dashboard, allowing
  12. // diffs of the dashboard to be performed.
  13. type DashboardVersion struct {
  14. Id int64 `json:"id"`
  15. DashboardId int64 `json:"dashboardId"`
  16. ParentVersion int `json:"parentVersion"`
  17. RestoredFrom int `json:"restoredFrom"`
  18. Version int `json:"version"`
  19. Created time.Time `json:"created"`
  20. CreatedBy int64 `json:"createdBy"`
  21. Message string `json:"message"`
  22. Data *simplejson.Json `json:"data"`
  23. }
  24. // DashboardVersionMeta extends the dashboard version model with the names
  25. // associated with the UserIds, overriding the field with the same name from
  26. // the DashboardVersion model.
  27. type DashboardVersionMeta struct {
  28. Id int64 `json:"id"`
  29. DashboardId int64 `json:"dashboardId"`
  30. ParentVersion int `json:"parentVersion"`
  31. RestoredFrom int `json:"restoredFrom"`
  32. Version int `json:"version"`
  33. Created time.Time `json:"created"`
  34. Message string `json:"message"`
  35. Data *simplejson.Json `json:"data"`
  36. CreatedBy string `json:"createdBy"`
  37. }
  38. // DashboardVersionDTO represents a dashboard version, without the dashboard
  39. // map.
  40. type DashboardVersionDTO struct {
  41. Id int64 `json:"id"`
  42. DashboardId int64 `json:"dashboardId"`
  43. ParentVersion int `json:"parentVersion"`
  44. RestoredFrom int `json:"restoredFrom"`
  45. Version int `json:"version"`
  46. Created time.Time `json:"created"`
  47. CreatedBy string `json:"createdBy"`
  48. Message string `json:"message"`
  49. }
  50. //
  51. // Queries
  52. //
  53. type GetDashboardVersionQuery struct {
  54. DashboardId int64
  55. OrgId int64
  56. Version int
  57. Result *DashboardVersion
  58. }
  59. type GetDashboardVersionsQuery struct {
  60. DashboardId int64
  61. OrgId int64
  62. Limit int
  63. Start int
  64. Result []*DashboardVersionDTO
  65. }
  66. //
  67. // Commands
  68. //
  69. type DeleteExpiredVersionsCommand struct {
  70. DeletedRows int64
  71. }