v0alpha1

package
v0.249.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTransport = errors.New("failed to execute request")
)

Functions

func DataQuerySchema

func DataQuerySchema() (*spec.Schema, error)

Get the cached feature list (exposed as a k8s resource)

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

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 NewDataQuery(body map[string]any) DataQuery

func (*DataQuery) DeepCopy

func (in *DataQuery) DeepCopy() *DataQuery

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataQuery.

func (*DataQuery) DeepCopyInto

func (g *DataQuery) DeepCopyInto(out *DataQuery)

func (*DataQuery) Get

func (g *DataQuery) Get(key string) (any, bool)

func (*DataQuery) GetString

func (g *DataQuery) GetString(key string) string

func (DataQuery) MarshalJSON

func (g DataQuery) MarshalJSON() ([]byte, error)

MarshalJSON writes JSON including the common and custom values

func (*DataQuery) Set

func (g *DataQuery) Set(key string, val any) *DataQuery

Set allows setting values using key/value pairs

func (*DataQuery) UnmarshalJSON

func (g *DataQuery) UnmarshalJSON(b []byte) error

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

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

type JSONSchema struct {
	Spec *spec.Schema
}

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

func NewQueryDataClient(url string, client *http.Client, headers map[string]string) QueryDataClient

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

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.

func (*ResultAssertions) Validate

func (r *ResultAssertions) Validate(frames data.Frames) error

type Status added in v0.237.0

type Status struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata,omitempty"`

	// Status is a textual representation of the state.
	Status string `json:"status"`
	// Message is a human-readable description of the state. It should not be parsed.
	Message string `json:"message"`
	// Code is a numeric code describing the state, such as an HTTP status code.
	Code int `json:"code"`
}

Represents the state of some operation.

func (Status) Error added in v0.237.0

func (s Status) Error() error

Error produces a Go error from a status. It assumes the status represents failure.

func (Status) String added in v0.237.0

func (s Status) String() string

String implements stringer

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

func (in *TimeRange) DeepCopy() *TimeRange

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeRange.

func (*TimeRange) DeepCopyInto

func (in *TimeRange) DeepCopyInto(out *TimeRange)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type TypeMeta

type TypeMeta struct {
	Kind       string `json:"kind"`       // "QueryTypeDefinitionList",
	APIVersion string `json:"apiVersion"` // "query.grafana.app/v0alpha1",
}

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{}

Jump to

Keyboard shortcuts

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