models.go 3.1 KB

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