models.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. Version string `json:"version"`
  23. Updated string `json:"updated"`
  24. }
  25. type PluginInfoLink struct {
  26. Name string `json:"name"`
  27. Url string `json:"url"`
  28. }
  29. type PluginLogos struct {
  30. Small string `json:"small"`
  31. Large string `json:"large"`
  32. }
  33. type PluginStaticRoute struct {
  34. Directory string
  35. PluginId string
  36. }
  37. type ApiPluginRoute struct {
  38. Path string `json:"path"`
  39. Method string `json:"method"`
  40. ReqSignedIn bool `json:"reqSignedIn"`
  41. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  42. ReqRole models.RoleType `json:"reqRole"`
  43. Url string `json:"url"`
  44. }
  45. type ApiPlugin struct {
  46. PluginBase
  47. Routes []*ApiPluginRoute `json:"routes"`
  48. }
  49. type EnabledPlugins struct {
  50. Panels []*PanelPlugin
  51. DataSources map[string]*DataSourcePlugin
  52. ApiList []*ApiPlugin
  53. Apps []*AppPlugin
  54. }
  55. func NewEnabledPlugins() EnabledPlugins {
  56. return EnabledPlugins{
  57. Panels: make([]*PanelPlugin, 0),
  58. DataSources: make(map[string]*DataSourcePlugin),
  59. ApiList: make([]*ApiPlugin, 0),
  60. Apps: make([]*AppPlugin, 0),
  61. }
  62. }