models.go 2.8 KB

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