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. Directive string `json:"Directive"`
  36. }
  37. type ExternalPluginNavLink struct {
  38. Text string `json:"text"`
  39. Icon string `json:"icon"`
  40. Href string `json:"href"`
  41. ReqRole models.RoleType `json:"reqRole"`
  42. }
  43. type ExternalPluginCss struct {
  44. Light string `json:"light"`
  45. Dark string `json:"dark"`
  46. }
  47. type ExternalPlugin struct {
  48. Type string `json:"type"`
  49. Routes []*ExternalPluginRoute `json:"routes"`
  50. Js []*ExternalPluginJs `json:"js"`
  51. Css []*ExternalPluginCss `json:"css"`
  52. MainNavLinks []*ExternalPluginNavLink `json:"mainNavLinks"`
  53. StaticRootConfig *StaticRootConfig `json:"staticRoot"`
  54. }
  55. type PluginBundle struct {
  56. Type string `json:"type"`
  57. Enabled bool `json:"enabled"`
  58. PanelPlugins []string `json:"panelPlugins"`
  59. DatasourcePlugins []string `json:"datasourcePlugins"`
  60. ExternalPlugins []string `json:"externalPlugins"`
  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. }