models.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package plugins
  2. import "github.com/grafana/grafana/pkg/models"
  3. type DataSourcePlugin struct {
  4. Type string `json:"type"`
  5. Name string `json:"name"`
  6. ServiceName string `json:"serviceName"`
  7. Module string `json:"module"`
  8. Partials map[string]interface{} `json:"partials"`
  9. DefaultMatchFormat string `json:"defaultMatchFormat"`
  10. Annotations bool `json:"annotations"`
  11. Metrics bool `json:"metrics"`
  12. BuiltIn bool `json:"builtIn"`
  13. StaticRootConfig *StaticRootConfig `json:"staticRoot"`
  14. }
  15. type PanelPlugin struct {
  16. Type string `json:"type"`
  17. Name string `json:"name"`
  18. Module string `json:"module"`
  19. StaticRootConfig *StaticRootConfig `json:"staticRoot"`
  20. }
  21. type StaticRootConfig struct {
  22. Url string `json:"url"`
  23. Path string `json:"path"`
  24. }
  25. type ExternalPluginRoute struct {
  26. Path string `json:"path"`
  27. Method string `json:"method"`
  28. ReqSignedIn bool `json:"reqSignedIn"`
  29. ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
  30. ReqRole models.RoleType `json:"reqRole"`
  31. Url string `json:"url"`
  32. }
  33. type ExternalPluginJs struct {
  34. Module string `json:"module"`
  35. }
  36. type ExternalPluginNavLink struct {
  37. Text string `json:"text"`
  38. Icon string `json:"icon"`
  39. Href string `json:"href"`
  40. ReqRole models.RoleType `json:"reqRole"`
  41. }
  42. type ExternalPluginCss struct {
  43. Light string `json:"light"`
  44. Dark string `json:"dark"`
  45. }
  46. type ExternalPlugin struct {
  47. Type string `json:"type"`
  48. Routes []*ExternalPluginRoute `json:"routes"`
  49. Js []*ExternalPluginJs `json:"js"`
  50. Css []*ExternalPluginCss `json:"css"`
  51. MainNavLinks []*ExternalPluginNavLink `json:"mainNavLinks"`
  52. StaticRootConfig *StaticRootConfig `json:"staticRoot"`
  53. }
  54. type PluginBundle struct {
  55. Type string `json:"type"`
  56. Enabled bool `json:"enabled"`
  57. PanelPlugins []string `json:"panelPlugins"`
  58. DatasourcePlugins []string `json:"datasourcePlugins"`
  59. ExternalPlugins []string `json:"externalPlugins"`
  60. Module string `json:"module"`
  61. }
  62. type EnabledPlugins struct {
  63. PanelPlugins []*PanelPlugin
  64. DataSourcePlugins map[string]*DataSourcePlugin
  65. ExternalPlugins []*ExternalPlugin
  66. }
  67. func NewEnabledPlugins() EnabledPlugins {
  68. return EnabledPlugins{
  69. PanelPlugins: make([]*PanelPlugin, 0),
  70. DataSourcePlugins: make(map[string]*DataSourcePlugin),
  71. ExternalPlugins: make([]*ExternalPlugin, 0),
  72. }
  73. }