2021-03-12 11:26:07 -06:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-03-10 11:38:04 -06:00
|
|
|
"io"
|
2021-03-12 11:26:07 -06:00
|
|
|
|
2021-11-01 04:53:33 -05:00
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
2021-03-12 11:26:07 -06:00
|
|
|
)
|
|
|
|
|
2021-11-01 04:53:33 -05:00
|
|
|
// Store is the storage for plugins.
|
|
|
|
type Store interface {
|
|
|
|
// Plugin finds a plugin by its ID.
|
2021-11-17 05:04:22 -06:00
|
|
|
Plugin(ctx context.Context, pluginID string) (PluginDTO, bool)
|
2021-11-01 04:53:33 -05:00
|
|
|
// Plugins returns plugins by their requested type.
|
2021-11-17 05:04:22 -06:00
|
|
|
Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO
|
2021-11-01 04:53:33 -05:00
|
|
|
// Add adds a plugin to the store.
|
2021-12-14 08:22:40 -06:00
|
|
|
Add(ctx context.Context, pluginID, version string) error
|
2021-11-01 04:53:33 -05:00
|
|
|
// Remove removes a plugin from the store.
|
|
|
|
Remove(ctx context.Context, pluginID string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type UpdateInfo struct {
|
|
|
|
PluginZipURL string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client is used to communicate with backend plugin implementations.
|
|
|
|
type Client interface {
|
|
|
|
backend.QueryDataHandler
|
|
|
|
backend.CheckHealthHandler
|
2021-11-15 07:25:13 -06:00
|
|
|
backend.StreamHandler
|
2021-12-14 04:15:49 -06:00
|
|
|
backend.CallResourceHandler
|
2022-02-09 10:36:53 -06:00
|
|
|
backend.CollectMetricsHandler
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2022-01-14 06:30:39 -06:00
|
|
|
// BackendFactoryProvider provides a backend factory for a provided plugin.
|
|
|
|
type BackendFactoryProvider interface {
|
|
|
|
BackendFactory(ctx context.Context, p *Plugin) backendplugin.PluginFactoryFunc
|
|
|
|
}
|
|
|
|
|
2021-11-01 04:53:33 -05:00
|
|
|
type RendererManager interface {
|
|
|
|
// Renderer returns a renderer plugin.
|
|
|
|
Renderer() *Plugin
|
|
|
|
}
|
|
|
|
|
|
|
|
type StaticRouteResolver interface {
|
|
|
|
Routes() []*StaticRoute
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrorResolver interface {
|
|
|
|
PluginErrors() []*Error
|
|
|
|
}
|
|
|
|
|
|
|
|
type PluginLoaderAuthorizer interface {
|
|
|
|
// CanLoadPlugin confirms if a plugin is authorized to load
|
|
|
|
CanLoadPlugin(plugin *Plugin) bool
|
|
|
|
}
|
|
|
|
|
2022-03-10 11:38:04 -06:00
|
|
|
// ListPluginDashboardFilesArgs list plugin dashboard files argument model.
|
|
|
|
type ListPluginDashboardFilesArgs struct {
|
|
|
|
PluginID string
|
2022-01-28 03:28:33 -06:00
|
|
|
}
|
|
|
|
|
2022-03-10 11:38:04 -06:00
|
|
|
// GetPluginDashboardFilesArgs list plugin dashboard files result model.
|
|
|
|
type ListPluginDashboardFilesResult struct {
|
|
|
|
FileReferences []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPluginDashboardFileContentsArgs get plugin dashboard file content argument model.
|
|
|
|
type GetPluginDashboardFileContentsArgs struct {
|
|
|
|
PluginID string
|
|
|
|
FileReference string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPluginDashboardFileContentsResult get plugin dashboard file content result model.
|
|
|
|
type GetPluginDashboardFileContentsResult struct {
|
|
|
|
Content io.ReadCloser
|
|
|
|
}
|
|
|
|
|
|
|
|
// DashboardFileStore is the interface for plugin dashboard file storage.
|
|
|
|
type DashboardFileStore interface {
|
|
|
|
// ListPluginDashboardFiles lists plugin dashboard files.
|
|
|
|
ListPluginDashboardFiles(ctx context.Context, args *ListPluginDashboardFilesArgs) (*ListPluginDashboardFilesResult, error)
|
|
|
|
|
|
|
|
// GetPluginDashboardFileContents gets the referenced plugin dashboard file content.
|
|
|
|
GetPluginDashboardFileContents(ctx context.Context, args *GetPluginDashboardFileContentsArgs) (*GetPluginDashboardFileContentsResult, error)
|
2021-03-17 10:06:10 -05:00
|
|
|
}
|