models.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package plugins
  2. import (
  3. "github.com/grafana/grafana/pkg/models"
  4. )
  5. type PluginCommon struct {
  6. Type string `json:"type"`
  7. Name string `json:"name"`
  8. Id string `json:"id"`
  9. StaticRoot string `json:"staticRoot"`
  10. Info PluginInfo `json:"info"`
  11. }
  12. type PluginInfo struct {
  13. Author PluginInfoLink `json:"author"`
  14. Description string `json:"description"`
  15. Links []PluginInfoLink `json:"links"`
  16. Logos PluginLogos `json:"logos"`
  17. }
  18. type PluginInfoLink struct {
  19. Name string `json:"name"`
  20. Url string `json:"url"`
  21. }
  22. type PluginLogos struct {
  23. Small string `json:"small"`
  24. Large string `json:"large"`
  25. }
  26. type DataSourcePlugin struct {
  27. PluginCommon
  28. Module string `json:"module"`
  29. ServiceName string `json:"serviceName"`
  30. Partials map[string]interface{} `json:"partials"`
  31. DefaultMatchFormat string `json:"defaultMatchFormat"`
  32. Annotations bool `json:"annotations"`
  33. Metrics bool `json:"metrics"`
  34. BuiltIn bool `json:"builtIn"`
  35. App string `json:"app"`
  36. }
  37. type PluginStaticRoute struct {
  38. Directory string
  39. PluginId string
  40. }
  41. type PanelPlugin struct {
  42. PluginCommon
  43. Module string `json:"module"`
  44. App string `json:"app"`
  45. }
  46. type ApiPluginRoute struct {
  47. Path string `json:"path"`
  48. Method string `json:"method"`
  49. ReqSignedIn bool `json:"reqSignedIn"`
  50. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  51. ReqRole models.RoleType `json:"reqRole"`
  52. Url string `json:"url"`
  53. App string `json:"app"`
  54. }
  55. type AppPluginPage struct {
  56. Text string `json:"text"`
  57. Icon string `json:"icon"`
  58. Url string `json:"url"`
  59. ReqRole models.RoleType `json:"reqRole"`
  60. }
  61. type AppPluginCss struct {
  62. Light string `json:"light"`
  63. Dark string `json:"dark"`
  64. }
  65. type ApiPlugin struct {
  66. PluginCommon
  67. Routes []*ApiPluginRoute `json:"routes"`
  68. App string `json:"app"`
  69. }
  70. type AppPlugin struct {
  71. PluginCommon
  72. Enabled bool `json:"enabled"`
  73. Pinned bool `json:"pinned"`
  74. Module string `json:"module"`
  75. Css *AppPluginCss `json:"css"`
  76. Page *AppPluginPage `json:"page"`
  77. }
  78. type EnabledPlugins struct {
  79. Panels []*PanelPlugin
  80. DataSources map[string]*DataSourcePlugin
  81. ApiList []*ApiPlugin
  82. Apps []*AppPlugin
  83. }
  84. func NewEnabledPlugins() EnabledPlugins {
  85. return EnabledPlugins{
  86. Panels: make([]*PanelPlugin, 0),
  87. DataSources: make(map[string]*DataSourcePlugin),
  88. ApiList: make([]*ApiPlugin, 0),
  89. Apps: make([]*AppPlugin, 0),
  90. }
  91. }