2022-02-11 08:52:14 -06:00
|
|
|
package datasources
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DataSourceService interface for interacting with datasources.
|
|
|
|
type DataSourceService interface {
|
|
|
|
// GetDataSource gets a datasource.
|
|
|
|
GetDataSource(ctx context.Context, query *models.GetDataSourceQuery) error
|
|
|
|
|
|
|
|
// GetDataSources gets datasources.
|
|
|
|
GetDataSources(ctx context.Context, query *models.GetDataSourcesQuery) error
|
|
|
|
|
|
|
|
// GetDataSourcesByType gets datasources by type.
|
|
|
|
GetDataSourcesByType(ctx context.Context, query *models.GetDataSourcesByTypeQuery) error
|
|
|
|
|
|
|
|
// AddDataSource adds a new datasource.
|
|
|
|
AddDataSource(ctx context.Context, cmd *models.AddDataSourceCommand) error
|
|
|
|
|
|
|
|
// DeleteDataSource deletes an existing datasource.
|
|
|
|
DeleteDataSource(ctx context.Context, cmd *models.DeleteDataSourceCommand) error
|
|
|
|
|
|
|
|
// UpdateDataSource updates an existing datasource.
|
|
|
|
UpdateDataSource(ctx context.Context, cmd *models.UpdateDataSourceCommand) error
|
|
|
|
|
|
|
|
// GetDefaultDataSource gets the default datasource.
|
|
|
|
GetDefaultDataSource(ctx context.Context, query *models.GetDefaultDataSourceQuery) error
|
|
|
|
|
|
|
|
// GetHTTPTransport gets a datasource specific HTTP transport.
|
2022-04-25 11:57:45 -05:00
|
|
|
GetHTTPTransport(ctx context.Context, ds *models.DataSource, provider httpclient.Provider, customMiddlewares ...sdkhttpclient.Middleware) (http.RoundTripper, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedValues decrypts the encrypted secureJSONData of the provided datasource and
|
|
|
|
// returns the decrypted values.
|
2022-04-25 11:57:45 -05:00
|
|
|
DecryptedValues(ctx context.Context, ds *models.DataSource) (map[string]string, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedValue decrypts the encrypted datasource secureJSONData identified by key
|
|
|
|
// and returns the decryped value.
|
2022-04-25 11:57:45 -05:00
|
|
|
DecryptedValue(ctx context.Context, ds *models.DataSource, key string) (string, bool, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedBasicAuthPassword decrypts the encrypted datasource basic authentication
|
|
|
|
// password and returns the decryped value.
|
2022-04-25 11:57:45 -05:00
|
|
|
DecryptedBasicAuthPassword(ctx context.Context, ds *models.DataSource) (string, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedPassword decrypts the encrypted datasource password and returns the
|
|
|
|
// decryped value.
|
2022-04-25 11:57:45 -05:00
|
|
|
DecryptedPassword(ctx context.Context, ds *models.DataSource) (string, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// CacheService interface for retrieving a cached datasource.
|
|
|
|
type CacheService interface {
|
|
|
|
// GetDatasource gets a datasource identified by datasource numeric identifier.
|
|
|
|
GetDatasource(ctx context.Context, datasourceID int64, user *models.SignedInUser, skipCache bool) (*models.DataSource, error)
|
|
|
|
|
|
|
|
// GetDatasourceByUID gets a datasource identified by datasource unique identifier (UID).
|
|
|
|
GetDatasourceByUID(ctx context.Context, datasourceUID string, user *models.SignedInUser, skipCache bool) (*models.DataSource, error)
|
|
|
|
}
|