Documentation ¶
Index ¶
- func DataQuerySchema() (*spec.Schema, error)
- func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition
- type CommonQueryProperties
- type DataQuery
- func (in *DataQuery) DeepCopy() *DataQuery
- func (g *DataQuery) DeepCopyInto(out *DataQuery)
- func (g *DataQuery) Get(key string) (any, bool)
- func (g *DataQuery) GetString(key string) string
- func (g DataQuery) MarshalJSON() ([]byte, error)
- func (g *DataQuery) Set(key string, val any) *DataQuery
- func (g *DataQuery) UnmarshalJSON(b []byte) error
- type DataSourceRef
- type DiscriminatorFieldValue
- type JSONSchema
- type ObjectMeta
- type QueryDataClient
- type QueryDataRequest
- type QueryExample
- type QueryTypeDefinition
- type QueryTypeDefinitionList
- type QueryTypeDefinitionSpec
- type ResultAssertions
- type TimeRange
- type TypeMeta
- type Unstructured
- func (u *Unstructured) DeepCopy() *Unstructured
- func (u *Unstructured) DeepCopyInto(out *Unstructured)
- func (u Unstructured) MarshalJSON() ([]byte, error)
- func (u Unstructured) OpenAPIDefinition() openapi.OpenAPIDefinition
- func (u *Unstructured) SetUnstructuredContent(content map[string]interface{})
- func (u *Unstructured) UnmarshalJSON(b []byte) error
- func (u *Unstructured) UnstructuredContent() map[string]interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataQuerySchema ¶
Get the cached feature list (exposed as a k8s resource)
func GetOpenAPIDefinitions ¶
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition
Types ¶
type CommonQueryProperties ¶
type CommonQueryProperties struct { // RefID is the unique identifier of the query, set by the frontend call. RefID string `json:"refId,omitempty"` // Optionally define expected query result behavior ResultAssertions *ResultAssertions `json:"resultAssertions,omitempty"` // TimeRange represents the query range // NOTE: unlike generic /ds/query, we can now send explicit time values in each query // NOTE: the values for timeRange are not saved in a dashboard, they are constructed on the fly TimeRange *TimeRange `json:"timeRange,omitempty"` // The datasource Datasource *DataSourceRef `json:"datasource,omitempty"` // Deprecated -- use datasource ref instead DatasourceID int64 `json:"datasourceId,omitempty"` // QueryType is an optional identifier for the type of query. // It can be used to distinguish different types of queries. QueryType string `json:"queryType,omitempty"` // MaxDataPoints is the maximum number of data points that should be returned from a time series query. // NOTE: the values for maxDataPoints is not saved in the query model. It is typically calculated // from the number of pixels visible in a visualization MaxDataPoints int64 `json:"maxDataPoints,omitempty"` // Interval is the suggested duration between time points in a time series query. // NOTE: the values for intervalMs is not saved in the query model. It is typically calculated // from the interval required to fill a pixels in the visualization IntervalMS float64 `json:"intervalMs,omitempty"` // true if query is disabled (ie should not be returned to the dashboard) // NOTE: this does not always imply that the query should not be executed since // the results from a hidden query may be used as the input to other queries (SSE etc) Hide bool `json:"hide,omitempty"` }
CommonQueryProperties are properties that can be added to all queries. These properties live in the same JSON level as datasource specific properties, so care must be taken to ensure they do not overlap
func (*CommonQueryProperties) DeepCopy ¶
func (in *CommonQueryProperties) DeepCopy() *CommonQueryProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommonQueryProperties.
func (*CommonQueryProperties) DeepCopyInto ¶
func (in *CommonQueryProperties) DeepCopyInto(out *CommonQueryProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DataQuery ¶
type DataQuery struct { CommonQueryProperties `json:",inline"` // contains filtered or unexported fields }
DataQuery is a replacement for `dtos.MetricRequest` with more explicit typing
func NewDataQuery ¶
func (*DataQuery) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataQuery.
func (*DataQuery) DeepCopyInto ¶
func (DataQuery) MarshalJSON ¶
MarshalJSON writes JSON including the common and custom values
func (*DataQuery) UnmarshalJSON ¶
UnmarshalJSON reads a query from json byte array
type DataSourceRef ¶
type DataSourceRef struct { // The datasource plugin type Type string `json:"type"` // Datasource UID (NOTE: name in k8s) UID string `json:"uid,omitempty"` // The apiserver version APIVersion string `json:"apiVersion,omitempty"` }
func ToDataSourceQueries ¶ added in v0.234.0
func ToDataSourceQueries(req QueryDataRequest) ([]backend.DataQuery, *DataSourceRef, error)
ToDataSourceQueries returns queries that should be sent to a single datasource This will throw an error if the queries reference multiple instances
func (*DataSourceRef) DeepCopy ¶
func (in *DataSourceRef) DeepCopy() *DataSourceRef
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataSourceRef.
func (*DataSourceRef) DeepCopyInto ¶
func (in *DataSourceRef) DeepCopyInto(out *DataSourceRef)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*DataSourceRef) UnmarshalJSON ¶ added in v0.229.0
func (g *DataSourceRef) UnmarshalJSON(b []byte) error
UnmarshalJSON reads a query from json byte array
type DiscriminatorFieldValue ¶
type DiscriminatorFieldValue struct { // DiscriminatorField is the field used to link behavior to this specific // query type. It is typically "queryType", but can be another field if necessary Field string `json:"field"` // The discriminator value Value string `json:"value"` }
func NewDiscriminators ¶
func NewDiscriminators(keyvals ...any) []DiscriminatorFieldValue
using any since this will often be enumerations
func (*DiscriminatorFieldValue) DeepCopy ¶
func (in *DiscriminatorFieldValue) DeepCopy() *DiscriminatorFieldValue
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscriminatorFieldValue.
func (*DiscriminatorFieldValue) DeepCopyInto ¶
func (in *DiscriminatorFieldValue) DeepCopyInto(out *DiscriminatorFieldValue)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type JSONSchema ¶
func (*JSONSchema) DeepCopy ¶
func (s *JSONSchema) DeepCopy() *JSONSchema
func (*JSONSchema) DeepCopyInto ¶
func (s *JSONSchema) DeepCopyInto(out *JSONSchema)
func (JSONSchema) MarshalJSON ¶
func (s JSONSchema) MarshalJSON() ([]byte, error)
func (JSONSchema) OpenAPIDefinition ¶
func (s JSONSchema) OpenAPIDefinition() openapi.OpenAPIDefinition
func (*JSONSchema) UnmarshalJSON ¶
func (s *JSONSchema) UnmarshalJSON(data []byte) error
type ObjectMeta ¶
type ObjectMeta struct { // The name is for k8s and description, but not used in the schema Name string `json:"name,omitempty"` // Changes indicate that *something * changed ResourceVersion string `json:"resourceVersion,omitempty"` // Timestamp CreationTimestamp string `json:"creationTimestamp,omitempty"` }
ObjectMeta is a struct that aims to "look" like a real kubernetes object when written to JSON, however it does not require the pile of dependencies This is really an internal helper until we decide which dependencies make sense to require within the SDK
type QueryDataClient ¶
type QueryDataClient interface {
QueryData(ctx context.Context, req QueryDataRequest) (int, *backend.QueryDataResponse, error)
}
func NewQueryDataClient ¶
type QueryDataRequest ¶
type QueryDataRequest struct { // Time range applied to each query (when not included in the query body) TimeRange `json:",inline"` // Datasource queries Queries []DataQuery `json:"queries"` // Optionally include debug information in the response Debug bool `json:"debug,omitempty"` }
func (*QueryDataRequest) DeepCopy ¶
func (in *QueryDataRequest) DeepCopy() *QueryDataRequest
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueryDataRequest.
func (*QueryDataRequest) DeepCopyInto ¶
func (in *QueryDataRequest) DeepCopyInto(out *QueryDataRequest)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type QueryExample ¶
type QueryExample struct { // Version identifier or empty if only one exists Name string `json:"name,omitempty"` // Optionally explain why the example is interesting Description string `json:"description,omitempty"` // An example value saved that can be saved in a dashboard SaveModel Unstructured `json:"saveModel,omitempty"` }
func (*QueryExample) DeepCopy ¶
func (in *QueryExample) DeepCopy() *QueryExample
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueryExample.
func (*QueryExample) DeepCopyInto ¶
func (in *QueryExample) DeepCopyInto(out *QueryExample)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type QueryTypeDefinition ¶
type QueryTypeDefinition struct { ObjectMeta `json:"metadata,omitempty"` Spec QueryTypeDefinitionSpec `json:"spec,omitempty"` }
QueryTypeDefinition is a kubernetes shaped object that represents a single query definition
type QueryTypeDefinitionList ¶
type QueryTypeDefinitionList struct { TypeMeta `json:",inline"` ObjectMeta `json:"metadata,omitempty"` Items []QueryTypeDefinition `json:"items"` }
QueryTypeDefinitionList is a kubernetes shaped object that represents a list of query types For simple data sources, there may be only a single query type, however when multiple types exist they must be clearly specified with distinct discriminator field+value pairs
type QueryTypeDefinitionSpec ¶
type QueryTypeDefinitionSpec struct { // Multiple schemas can be defined using discriminators Discriminators []DiscriminatorFieldValue `json:"discriminators,omitempty"` // Describe whe the query type is for Description string `json:"description,omitempty"` // The query schema represents the properties that can be sent to the API // In many cases, this may be the same properties that are saved in a dashboard // In the case where the save model is different, we must also specify a save model Schema JSONSchema `json:"schema"` // Examples (include a wrapper) ideally a template! Examples []QueryExample `json:"examples"` // Changelog defines the changed from the previous version // All changes in the same version *must* be backwards compatible // Only notable changes will be shown here, for the full version history see git! Changelog []string `json:"changelog,omitempty"` }
func (*QueryTypeDefinitionSpec) DeepCopy ¶
func (in *QueryTypeDefinitionSpec) DeepCopy() *QueryTypeDefinitionSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueryTypeDefinitionSpec.
func (*QueryTypeDefinitionSpec) DeepCopyInto ¶
func (in *QueryTypeDefinitionSpec) DeepCopyInto(out *QueryTypeDefinitionSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResultAssertions ¶
type ResultAssertions struct { // Type asserts that the frame matches a known type structure. Type data.FrameType `json:"type,omitempty"` // TypeVersion is the version of the Type property. Versions greater than 0.0 correspond to the dataplane // contract documentation https://grafana.github.io/dataplane/contract/. TypeVersion data.FrameTypeVersion `json:"typeVersion"` // Maximum frame count MaxFrames int64 `json:"maxFrames,omitempty"` }
ResultAssertions define the expected response shape and query behavior. This is useful to enforce behavior over time. The assertions are passed to the query engine and can be used to fail queries *before* returning them to a client (select * from bigquery!)
func (*ResultAssertions) DeepCopy ¶
func (in *ResultAssertions) DeepCopy() *ResultAssertions
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResultAssertions.
func (*ResultAssertions) DeepCopyInto ¶
func (in *ResultAssertions) DeepCopyInto(out *ResultAssertions)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type TimeRange ¶
type TimeRange struct { // From is the start time of the query. From string `json:"from" jsonschema:"example=now-1h,default=now-6h"` // To is the end time of the query. To string `json:"to" jsonschema:"example=now,default=now"` }
TimeRange represents a time range for a query and is a property of DataQuery.
func (*TimeRange) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeRange.
func (*TimeRange) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Unstructured ¶
type Unstructured struct { // Object is a JSON compatible map with string, float, int, bool, []interface{}, // or map[string]interface{} children. Object map[string]any }
Unstructured allows objects that do not have Golang structs registered to be manipulated generically.
func AsUnstructured ¶
func AsUnstructured(v any) Unstructured
Create an unstructured value from any input
func (*Unstructured) DeepCopy ¶
func (u *Unstructured) DeepCopy() *Unstructured
func (*Unstructured) DeepCopyInto ¶
func (u *Unstructured) DeepCopyInto(out *Unstructured)
func (Unstructured) MarshalJSON ¶
func (u Unstructured) MarshalJSON() ([]byte, error)
MarshalJSON ensures that the unstructured object produces proper JSON when passed to Go's standard JSON library.
func (Unstructured) OpenAPIDefinition ¶
func (u Unstructured) OpenAPIDefinition() openapi.OpenAPIDefinition
Produce an API definition that represents map[string]any
func (*Unstructured) SetUnstructuredContent ¶
func (u *Unstructured) SetUnstructuredContent(content map[string]interface{})
func (*Unstructured) UnmarshalJSON ¶
func (u *Unstructured) UnmarshalJSON(b []byte) error
UnmarshalJSON ensures that the unstructured object properly decodes JSON when passed to Go's standard JSON library.
func (*Unstructured) UnstructuredContent ¶
func (u *Unstructured) UnstructuredContent() map[string]interface{}