2022-02-11 08:52:14 -06:00
|
|
|
package datasources
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
2022-06-27 11:23:15 -05:00
|
|
|
|
2022-02-11 08:52:14 -06:00
|
|
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
2022-08-10 04:56:48 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
2022-02-11 08:52:14 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// DataSourceService interface for interacting with datasources.
|
|
|
|
type DataSourceService interface {
|
|
|
|
// GetDataSource gets a datasource.
|
2022-06-27 11:23:15 -05:00
|
|
|
GetDataSource(ctx context.Context, query *GetDataSourceQuery) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// GetDataSources gets datasources.
|
2022-06-27 11:23:15 -05:00
|
|
|
GetDataSources(ctx context.Context, query *GetDataSourcesQuery) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
2022-07-12 15:27:37 -05:00
|
|
|
// GetAllDataSources gets all datasources.
|
|
|
|
GetAllDataSources(ctx context.Context, query *GetAllDataSourcesQuery) error
|
|
|
|
|
2022-02-11 08:52:14 -06:00
|
|
|
// GetDataSourcesByType gets datasources by type.
|
2022-06-27 11:23:15 -05:00
|
|
|
GetDataSourcesByType(ctx context.Context, query *GetDataSourcesByTypeQuery) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// AddDataSource adds a new datasource.
|
2022-06-27 11:23:15 -05:00
|
|
|
AddDataSource(ctx context.Context, cmd *AddDataSourceCommand) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DeleteDataSource deletes an existing datasource.
|
2022-06-27 11:23:15 -05:00
|
|
|
DeleteDataSource(ctx context.Context, cmd *DeleteDataSourceCommand) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// UpdateDataSource updates an existing datasource.
|
2022-06-27 11:23:15 -05:00
|
|
|
UpdateDataSource(ctx context.Context, cmd *UpdateDataSourceCommand) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// GetDefaultDataSource gets the default datasource.
|
2022-06-27 11:23:15 -05:00
|
|
|
GetDefaultDataSource(ctx context.Context, query *GetDefaultDataSourceQuery) error
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// GetHTTPTransport gets a datasource specific HTTP transport.
|
2022-06-27 11:23:15 -05:00
|
|
|
GetHTTPTransport(ctx context.Context, ds *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-06-27 11:23:15 -05:00
|
|
|
DecryptedValues(ctx context.Context, ds *DataSource) (map[string]string, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedValue decrypts the encrypted datasource secureJSONData identified by key
|
2022-06-04 05:55:49 -05:00
|
|
|
// and returns the decrypted value.
|
2022-06-27 11:23:15 -05:00
|
|
|
DecryptedValue(ctx context.Context, ds *DataSource, key string) (string, bool, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedBasicAuthPassword decrypts the encrypted datasource basic authentication
|
2022-06-04 05:55:49 -05:00
|
|
|
// password and returns the decrypted value.
|
2022-06-27 11:23:15 -05:00
|
|
|
DecryptedBasicAuthPassword(ctx context.Context, ds *DataSource) (string, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// DecryptedPassword decrypts the encrypted datasource password and returns the
|
2022-06-04 05:55:49 -05:00
|
|
|
// decrypted value.
|
2022-06-27 11:23:15 -05:00
|
|
|
DecryptedPassword(ctx context.Context, ds *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.
|
2022-08-10 04:56:48 -05:00
|
|
|
GetDatasource(ctx context.Context, datasourceID int64, user *user.SignedInUser, skipCache bool) (*DataSource, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
|
|
|
|
// GetDatasourceByUID gets a datasource identified by datasource unique identifier (UID).
|
2022-08-10 04:56:48 -05:00
|
|
|
GetDatasourceByUID(ctx context.Context, datasourceUID string, user *user.SignedInUser, skipCache bool) (*DataSource, error)
|
2022-02-11 08:52:14 -06:00
|
|
|
}
|