dataquery

package
v1.0.1177 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 30 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBFromResultsets added in v1.0.989

func DBFromResultsets(ctx context.Context, resultsets []QueryResultSet) (context.Context, func() error, error)

func InferColumnTypes added in v1.0.982

func InferColumnTypes(rows []QueryResultRow) map[string]string

InferColumnTypes analyzes the first few rows to determine the most appropriate column types

Types

type HTTPQuery added in v1.0.1171

type HTTPQuery struct {
	connection.HTTPConnection `json:",inline" yaml:",inline"`

	// Method is the HTTP method (GET, POST, PUT, DELETE, PATCH, etc.)
	// Default: GET
	Method string `json:"method,omitempty" yaml:"method,omitempty" template:"true"`

	// Body is the request body for POST/PUT/PATCH requests (can be templated)
	Body string `json:"body,omitempty" yaml:"body,omitempty" template:"true"`

	// JSONPath is a JSONPath expression to extract data from the response.
	// Use when the API returns a wrapper object and you need to extract an inner array/object.
	// Example: "$.recipes" for {"recipes": [...], "total": 30} returns the recipes array as rows.
	JSONPath string `json:"jsonpath,omitempty" yaml:"jsonpath,omitempty"`
}

+kubebuilder:object:generate=true HTTPQuery defines an HTTP query configuration

func (*HTTPQuery) DeepCopy added in v1.0.1171

func (in *HTTPQuery) DeepCopy() *HTTPQuery

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

func (*HTTPQuery) DeepCopyInto added in v1.0.1171

func (in *HTTPQuery) DeepCopyInto(out *HTTPQuery)

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

type PrometheusQuery

type PrometheusQuery struct {
	connection.PrometheusConnection `json:",inline" yaml:",inline"`

	// Query is the PromQL query string
	Query string `json:"query" yaml:"query" template:"true"`

	// Range runs a PromQL range query when specified
	Range *PrometheusRange `json:"range,omitempty" yaml:"range,omitempty" template:"true"`

	// MatchLabels is a list of labels, when provided, are included in the result.
	// Example:
	// If a query produces {a:1, b:2, c:3, d:4} value=30.0
	// then, with matchLabels = [a,b]
	// The result will only have {a:1, b:2} value=30.0
	//
	// This helps in have a deterministic schema for the query result.
	//
	// Deprecated: use SelectLabels
	MatchLabels []string `json:"matchLabels,omitempty" yaml:"matchLabels,omitempty"`

	// SelectLabels is a list of labels, when provided, are included in the result.
	// Example:
	// If a query produces {a:1, b:2, c:3, d:4} value=30.0
	// then, with matchLabels = [a,b]
	// The result will only have {a:1, b:2} value=30.0
	//
	// This helps in have a deterministic schema for the query result.
	SelectLabels []string `json:"selectLabels,omitempty"`
}

+kubebuilder:object:generate=true PrometheusQuery defines a Prometheus query configuration

func (*PrometheusQuery) DeepCopy

func (in *PrometheusQuery) DeepCopy() *PrometheusQuery

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

func (*PrometheusQuery) DeepCopyInto

func (in *PrometheusQuery) DeepCopyInto(out *PrometheusQuery)

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

type PrometheusRange added in v1.0.1125

type PrometheusRange struct {
	Start string `json:"start" yaml:"start" template:"true"`
	End   string `json:"end" yaml:"end" template:"true"`
	Step  string `json:"step" yaml:"step" template:"true"`
}

PrometheusRange defines parameters for running a range query.

type Query

type Query struct {
	// Prometheus queries metrics from Prometheus
	Prometheus *PrometheusQuery `json:"prometheus,omitempty" yaml:"prometheus,omitempty"`

	// SQL runs arbitrary SQL queries against a configured SQL connection
	SQL *SQLQuery `json:"sql,omitempty" yaml:"sql,omitempty"`

	// HTTP executes an HTTP request and extracts data from the JSON response
	HTTP *HTTPQuery `json:"http,omitempty" yaml:"http,omitempty"`
}

+kubebuilder:object:generate=true

func (*Query) DeepCopy

func (in *Query) DeepCopy() *Query

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

func (*Query) DeepCopyInto

func (in *Query) DeepCopyInto(out *Query)

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

func (*Query) IsEmpty

func (v *Query) IsEmpty() bool

type QueryResultRow

type QueryResultRow map[string]any

func ExecuteQuery

func ExecuteQuery(ctx context.Context, q Query) ([]QueryResultRow, error)

ExecuteQuery executes a single query and returns results with query name

func RunSQL added in v1.0.989

func RunSQL(ctx context.Context, query string, values ...any) ([]QueryResultRow, error)

RunSQL runs a query and returns the results

type QueryResultSet added in v1.0.982

type QueryResultSet struct {
	Name    string
	Results []QueryResultRow

	// Map column name to column type
	ColumnDefs map[string]models.ColumnType
}

QueryResultSet contains the query name and the results

func (QueryResultSet) CreateDBTable added in v1.0.982

func (resultSet QueryResultSet) CreateDBTable(ctx context.Context) error

CreateDBTable creates a SQLite table based on the result set schema

func (QueryResultSet) InsertToDB added in v1.0.982

func (rs QueryResultSet) InsertToDB(ctx context.Context) error

InsertToDB inserts QueryResultRow data into the specified table

type SQLQuery added in v1.0.1114

type SQLQuery struct {
	connection.SQLConnection `json:",inline" yaml:",inline"`

	// Query is the SQL query string to execute against the configured connection.
	Query string `json:"query" yaml:"query"`
}

+kubebuilder:object:generate=true SQLQuery defines a SQL query configuration

func (*SQLQuery) DeepCopy added in v1.0.1114

func (in *SQLQuery) DeepCopy() *SQLQuery

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

func (*SQLQuery) DeepCopyInto added in v1.0.1114

func (in *SQLQuery) DeepCopyInto(out *SQLQuery)

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

Jump to

Keyboard shortcuts

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