models.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package plugins
  2. import (
  3. "encoding/json"
  4. "github.com/grafana/grafana/pkg/models"
  5. )
  6. type PluginLoader interface {
  7. Load(decoder *json.Decoder, pluginDir string) error
  8. }
  9. type PluginBase struct {
  10. Type string `json:"type"`
  11. Name string `json:"name"`
  12. Id string `json:"id"`
  13. App string `json:"app"`
  14. Info PluginInfo `json:"info"`
  15. PluginDir string `json:"-"`
  16. }
  17. type PluginInfo struct {
  18. Author PluginInfoLink `json:"author"`
  19. Description string `json:"description"`
  20. Links []PluginInfoLink `json:"links"`
  21. Logos PluginLogos `json:"logos"`
  22. }
  23. type PluginInfoLink struct {
  24. Name string `json:"name"`
  25. Url string `json:"url"`
  26. }
  27. type PluginLogos struct {
  28. Small string `json:"small"`
  29. Large string `json:"large"`
  30. }
  31. type PluginStaticRoute struct {
  32. Directory string
  33. PluginId string
  34. }
  35. type ApiPluginRoute struct {
  36. Path string `json:"path"`
  37. Method string `json:"method"`
  38. ReqSignedIn bool `json:"reqSignedIn"`
  39. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  40. ReqRole models.RoleType `json:"reqRole"`
  41. Url string `json:"url"`
  42. }
  43. type ApiPlugin struct {
  44. PluginBase
  45. Routes []*ApiPluginRoute `json:"routes"`
  46. }
  47. type EnabledPlugins struct {
  48. Panels []*PanelPlugin
  49. DataSources map[string]*DataSourcePlugin
  50. ApiList []*ApiPlugin
  51. Apps []*AppPlugin
  52. }
  53. func NewEnabledPlugins() EnabledPlugins {
  54. return EnabledPlugins{
  55. Panels: make([]*PanelPlugin, 0),
  56. DataSources: make(map[string]*DataSourcePlugin),
  57. ApiList: make([]*ApiPlugin, 0),
  58. Apps: make([]*AppPlugin, 0),
  59. }
  60. }