models.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package plugins
  2. import (
  3. "github.com/grafana/grafana/pkg/models"
  4. )
  5. type DataSourcePlugin struct {
  6. Type string `json:"type"`
  7. Name string `json:"name"`
  8. ServiceName string `json:"serviceName"`
  9. Module string `json:"module"`
  10. Partials map[string]interface{} `json:"partials"`
  11. DefaultMatchFormat string `json:"defaultMatchFormat"`
  12. Annotations bool `json:"annotations"`
  13. Metrics bool `json:"metrics"`
  14. BuiltIn bool `json:"builtIn"`
  15. App string `json:"app"`
  16. PublicContent *PublicContent `json:"public"`
  17. }
  18. type PanelPlugin struct {
  19. Type string `json:"type"`
  20. Name string `json:"name"`
  21. Module string `json:"module"`
  22. PublicContent *PublicContent `json:"public"`
  23. App string `json:"app"`
  24. }
  25. type PublicContent struct {
  26. UrlFragment string `json:"urlFragment"`
  27. Dir string `json:"dir"`
  28. }
  29. type ApiPluginRoute struct {
  30. Path string `json:"path"`
  31. Method string `json:"method"`
  32. ReqSignedIn bool `json:"reqSignedIn"`
  33. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  34. ReqRole models.RoleType `json:"reqRole"`
  35. Url string `json:"url"`
  36. App string `json:"app"`
  37. }
  38. type AppPluginPage struct {
  39. Text string `json:"text"`
  40. Icon string `json:"icon"`
  41. Url string `json:"url"`
  42. ReqRole models.RoleType `json:"reqRole"`
  43. }
  44. type AppPluginCss struct {
  45. Light string `json:"light"`
  46. Dark string `json:"dark"`
  47. }
  48. type ApiPlugin struct {
  49. Type string `json:"type"`
  50. Routes []*ApiPluginRoute `json:"routes"`
  51. App string `json:"app"`
  52. }
  53. type AppPlugin struct {
  54. Type string `json:"type"`
  55. Enabled bool `json:"enabled"`
  56. Pinned bool `json:"pinned"`
  57. Module string `json:"module"`
  58. Css *AppPluginCss `json:"css"`
  59. Page *AppPluginPage `json:"page"`
  60. PublicContent *PublicContent `json:"public"`
  61. }
  62. type EnabledPlugins struct {
  63. Panels []*PanelPlugin
  64. DataSources map[string]*DataSourcePlugin
  65. ApiList []*ApiPlugin
  66. Apps []*AppPlugin
  67. }
  68. func NewEnabledPlugins() EnabledPlugins {
  69. return EnabledPlugins{
  70. Panels: make([]*PanelPlugin, 0),
  71. DataSources: make(map[string]*DataSourcePlugin),
  72. ApiList: make([]*ApiPlugin, 0),
  73. Apps: make([]*AppPlugin, 0),
  74. }
  75. }