import { type Observable } from 'rxjs'; import { type DataFrame, type DataQuery, type DataQueryRequest, type DataQueryResponse, type TestDataSourceResponse, DataSourceApi, type DataSourceInstanceSettings, type DataSourceJsonData, type DataSourceRef, type ScopedVars, type AdHocVariableFilter } from '@grafana/data'; import { type BackendSrvRequest, type StreamingFrameOptions } from '../services'; import { UserStorage } from './userStorage'; /** * @internal */ export declare const ExpressionDatasourceRef: Readonly<{ type: "__expr__"; uid: "__expr__"; name: "Expression"; }>; /** * @public */ export declare function isExpressionReference(ref?: DataSourceRef | string | null): boolean; export declare class HealthCheckError extends Error { details: HealthCheckResultDetails; constructor(message: string, details: HealthCheckResultDetails); } /** * Describes the current health status of a data source plugin. * * @public */ export declare enum HealthStatus { Unknown = "UNKNOWN", OK = "OK", Error = "ERROR" } /** * Describes the details in the payload returned when checking the health of a data source * plugin. * * If the 'message' key exists, this will be displayed in the error message in DataSourceSettingsPage * If the 'verboseMessage' key exists, this will be displayed in the expandable details in the error message in DataSourceSettingsPage * * @public */ export type HealthCheckResultDetails = Record | undefined; /** * Describes the payload returned when checking the health of a data source * plugin. * * @public */ export interface HealthCheckResult { status: HealthStatus; message: string; details: HealthCheckResultDetails; } /** * Response shape from the /apis/{group}/v0alpha1/.../datasources/{uid}/health endpoint. * Used when datasourcesApiServerEnableHealthEndpointFrontend is enabled. * * @internal */ export interface DatasourcesV0HealthCheckResult { kind?: string; apiVersion?: string; status: string; code?: number; message: string; details?: HealthCheckResultDetails; } /** * Extend this class to implement a data source plugin that is depending on the Grafana * backend API. * * @public */ declare class DataSourceWithBackend extends DataSourceApi { userStorage: UserStorage; constructor(instanceSettings: DataSourceInstanceSettings); /** * Ideally final -- any other implementation may not work as expected */ query(request: DataQueryRequest): Observable; /** Get request headers with plugin ID+UID set */ protected getRequestHeaders(): Record; /** * Apply template variables for explore */ interpolateVariablesInQueries(queries: TQuery[], scopedVars: ScopedVars, filters?: AdHocVariableFilter[]): TQuery[]; /** * Override to apply template variables and adhoc filters. The result is usually also `TQuery`, but sometimes this can * be used to modify the query structure before sending to the backend. * * NOTE: if you do modify the structure or use template variables, alerting queries may not work * as expected * * @virtual */ applyTemplateVariables(query: TQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]): TQuery; /** * Optionally override the streaming behavior */ streamOptionsProvider: StreamOptionsProvider; /** * Make a GET request to the datasource resource path */ getResource(path: string, params?: BackendSrvRequest['params'], options?: Partial): Promise; /** * Send a POST request to the datasource resource path */ postResource(path: string, data?: BackendSrvRequest['data'], options?: Partial): Promise; /** * Internal function to build the datasource URL based on the feature toggle */ buildResourcesDatasourceUrl(path: string): string; /** * Run the datasource healthcheck */ callHealthCheck(): Promise; /** * Checks the plugin health * see public/app/features/datasources/state/actions.ts for what needs to be returned here */ testDatasource(): Promise; } /** * @internal exported for tests */ export declare function toStreamingDataResponse(rsp: DataQueryResponse, req: DataQueryRequest, getter: (req: DataQueryRequest, frame: DataFrame) => Partial): Observable; /** * This allows data sources to customize the streaming connection query * * @public */ export type StreamOptionsProvider = (request: DataQueryRequest, frame: DataFrame) => Partial; /** * @public */ export declare const standardStreamOptionsProvider: StreamOptionsProvider; export { DataSourceWithBackend };