service

package
v11.1.4-modfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheTTL = 5 * time.Second
)

Variables

This section is empty.

Functions

func NewIDScopeResolver

NewIDScopeResolver provides an ScopeAttributeResolver able to translate a scope prefixed with "datasources:id:" into an uid based scope.

func NewNameScopeResolver

NewNameScopeResolver provides an ScopeAttributeResolver able to translate a scope prefixed with "datasources:name:" into an uid based scope.

Types

type CacheServiceImpl

type CacheServiceImpl struct {
	CacheService *localcache.CacheService
	SQLStore     db.DB
	// contains filtered or unexported fields
}

func ProvideCacheService

func ProvideCacheService(cacheService *localcache.CacheService, sqlStore db.DB, dsGuardian guardian.DatasourceGuardianProvider) *CacheServiceImpl

func (*CacheServiceImpl) GetDatasource

func (dc *CacheServiceImpl) GetDatasource(
	ctx context.Context,
	datasourceID int64,
	user identity.Requester,
	skipCache bool,
) (*datasources.DataSource, error)

func (*CacheServiceImpl) GetDatasourceByUID

func (dc *CacheServiceImpl) GetDatasourceByUID(
	ctx context.Context,
	datasourceUID string,
	user identity.Requester,
	skipCache bool,
) (*datasources.DataSource, error)

type DataSourceRetriever

type DataSourceRetriever interface {
	// GetDataSource gets a datasource.
	GetDataSource(ctx context.Context, query *datasources.GetDataSourceQuery) (*datasources.DataSource, error)
}

DataSourceRetriever interface for retrieving a datasource.

type LegacyDataSourceLookup

type LegacyDataSourceLookup interface {
	// Find the UID from either the name or internal id
	// NOTE the orgID will be fetched from the context
	GetDataSourceFromDeprecatedFields(ctx context.Context, name string, id int64) (*data.DataSourceRef, error)
}

LegacyDataSourceRetriever supports finding a reference to datasources using the name or internal ID

func ProvideLegacyDataSourceLookup

func ProvideLegacyDataSourceLookup(p *Service) LegacyDataSourceLookup

type NoopLegacyDataSourcLookup

type NoopLegacyDataSourcLookup struct {
	Ref *data.DataSourceRef
}

NoopLegacyDataSourceRetriever does not even try to lookup, it returns a raw reference

func (*NoopLegacyDataSourcLookup) GetDataSourceFromDeprecatedFields

func (s *NoopLegacyDataSourcLookup) GetDataSourceFromDeprecatedFields(ctx context.Context, name string, id int64) (*data.DataSourceRef, error)

type Service

type Service struct {
	SQLStore       Store
	SecretsStore   kvstore.SecretsKVStore
	SecretsService secrets.Service
	// contains filtered or unexported fields
}

func ProvideService

func ProvideService(
	db db.DB, secretsService secrets.Service, secretsStore kvstore.SecretsKVStore, cfg *setting.Cfg,
	features featuremgmt.FeatureToggles, ac accesscontrol.AccessControl, datasourcePermissionsService accesscontrol.DatasourcePermissionsService,
	quotaService quota.Service, pluginStore pluginstore.Store, pluginClient plugins.Client,
	basePluginContextProvider plugincontext.BasePluginContextProvider,
) (*Service, error)

func (*Service) AddDataSource

func (*Service) CustomHeaders

func (s *Service) CustomHeaders(ctx context.Context, ds *datasources.DataSource) (http.Header, error)

CustomerHeaders returns the custom headers specified in the datasource. The context is used for the decryption operation that might use the store, so consider setting an acceptable timeout for your use case.

func (*Service) DecryptedBasicAuthPassword

func (s *Service) DecryptedBasicAuthPassword(ctx context.Context, ds *datasources.DataSource) (string, error)

func (*Service) DecryptedPassword

func (s *Service) DecryptedPassword(ctx context.Context, ds *datasources.DataSource) (string, error)

func (*Service) DecryptedValue

func (s *Service) DecryptedValue(ctx context.Context, ds *datasources.DataSource, key string) (string, bool, error)

func (*Service) DecryptedValues

func (s *Service) DecryptedValues(ctx context.Context, ds *datasources.DataSource) (map[string]string, error)

func (*Service) DeleteDataSource

func (s *Service) DeleteDataSource(ctx context.Context, cmd *datasources.DeleteDataSourceCommand) error

func (*Service) GetAllDataSources

func (s *Service) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error)

func (*Service) GetDataSource

func (*Service) GetDataSources

func (s *Service) GetDataSources(ctx context.Context, query *datasources.GetDataSourcesQuery) ([]*datasources.DataSource, error)

func (*Service) GetDataSourcesByType

func (s *Service) GetDataSourcesByType(ctx context.Context, query *datasources.GetDataSourcesByTypeQuery) ([]*datasources.DataSource, error)

func (*Service) GetHTTPTransport

func (s *Service) GetHTTPTransport(ctx context.Context, ds *datasources.DataSource, provider httpclient.Provider,
	customMiddlewares ...sdkhttpclient.Middleware) (http.RoundTripper, error)

func (*Service) GetPrunableProvisionedDataSources

func (s *Service) GetPrunableProvisionedDataSources(ctx context.Context) (res []*datasources.DataSource, err error)

func (*Service) UpdateDataSource

func (*Service) Usage

func (s *Service) Usage(ctx context.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error)

type SqlStore

type SqlStore struct {
	// contains filtered or unexported fields
}

func CreateStore

func CreateStore(db db.DB, logger log.Logger) *SqlStore

func (*SqlStore) AddDataSource

func (*SqlStore) Count

func (ss *SqlStore) Count(ctx context.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error)

func (*SqlStore) DeleteDataSource

func (ss *SqlStore) DeleteDataSource(ctx context.Context, cmd *datasources.DeleteDataSourceCommand) error

DeleteDataSource removes a datasource by org_id as well as either uid (preferred), id, or name and is added to the bus. It also removes permissions related to the datasource.

func (*SqlStore) GetAllDataSources

func (ss *SqlStore) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error)

func (*SqlStore) GetDataSource

GetDataSource adds a datasource to the query model by querying by org_id as well as either uid (preferred), id, or name and is added to the bus.

func (*SqlStore) GetDataSources

func (ss *SqlStore) GetDataSources(ctx context.Context, query *datasources.GetDataSourcesQuery) ([]*datasources.DataSource, error)

func (*SqlStore) GetDataSourcesByType

func (ss *SqlStore) GetDataSourcesByType(ctx context.Context, query *datasources.GetDataSourcesByTypeQuery) ([]*datasources.DataSource, error)

GetDataSourcesByType returns all datasources for a given type or an error if the specified type is an empty string

func (*SqlStore) GetPrunableProvisionedDataSources

func (ss *SqlStore) GetPrunableProvisionedDataSources(ctx context.Context) ([]*datasources.DataSource, error)

GetPrunableProvisionedDataSources returns all data sources that can be pruned

func (*SqlStore) UpdateDataSource

type Store

Store is the interface for the datasource Service's storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL