dashboard_version.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. DashboardVersion
  29. CreatedBy string `json:"createdBy"`
  30. }
  31. // DashboardVersionDTO represents a dashboard version, without the dashboard
  32. // map.
  33. type DashboardVersionDTO struct {
  34. Id int64 `json:"id"`
  35. DashboardId int64 `json:"dashboardId"`
  36. ParentVersion int `json:"parentVersion"`
  37. RestoredFrom int `json:"restoredFrom"`
  38. Version int `json:"version"`
  39. Created time.Time `json:"created"`
  40. CreatedBy string `json:"createdBy"`
  41. Message string `json:"message"`
  42. }
  43. //
  44. // Queries
  45. //
  46. type GetDashboardVersionQuery struct {
  47. DashboardId int64
  48. OrgId int64
  49. Version int
  50. Result *DashboardVersion
  51. }
  52. type GetDashboardVersionsQuery struct {
  53. DashboardId int64
  54. OrgId int64
  55. Limit int
  56. Start int
  57. Result []*DashboardVersionDTO
  58. }
  59. //
  60. // Commands
  61. //
  62. type DeleteExpiredVersionsCommand struct {
  63. DeletedRows int64
  64. }