schemabuilder

package
v0.214.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuerySchema

func GetQuerySchema(opts QuerySchemaOptions) (*spec.Schema, error)

Given definitions for a plugin, return a valid spec

Types

type Builder

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

SchemaBuilder is a helper function that can be used by backend build processes to produce static schema definitions This is not intended as runtime code, and is not the only way to produce a schema (we may also want/need to use typescript as the source)

func NewSchemaBuilder

func NewSchemaBuilder(opts BuilderOptions) (*Builder, error)

func (*Builder) AddQueries

func (b *Builder) AddQueries(inputs ...QueryTypeInfo) error

func (*Builder) UpdateQueryDefinition

func (b *Builder) UpdateQueryDefinition(t *testing.T, outdir string) sdkapi.QueryTypeDefinitionList

Update the schema definition file When placed in `static/schema/query.types.json` folder of a plugin distribution, it can be used to advertise various query types If the spec contents have changed, the test will fail (but still update the output)

type BuilderOptions

type BuilderOptions struct {
	// The plugin type ID used in the DataSourceRef type property
	PluginID []string

	// Scan comments and enumerations
	ScanCode []CodePaths

	// explicitly define the enumeration fields
	Enums []reflect.Type
}

type CodePaths

type CodePaths struct {
	// ex "github.com/grafana/github-datasource/pkg/models"
	BasePackage string

	// ex "./"
	CodePath string
}

type EnumField

type EnumField struct {
	Package string
	Name    string
	Comment string
	Values  []EnumValue
}

type EnumValue

type EnumValue struct {
	Value   string
	Comment string
}

type QuerySchemaOptions

type QuerySchemaOptions struct {
	PluginID   []string
	QueryTypes []sdkapi.QueryTypeDefinition
	Mode       SchemaType
}

type QueryTypeInfo

type QueryTypeInfo struct {
	// The management name
	Name string
	// Optional description
	Description string
	// Optional discriminators
	Discriminators []sdkapi.DiscriminatorFieldValue
	// Raw GO type used for reflection
	GoType reflect.Type
	// Add sample queries
	Examples []sdkapi.QueryExample
}

type SchemaType

type SchemaType string

Supported expression types +enum

const (
	// Single query target saved in a dashboard/panel/alert JSON
	SchemaTypeSaveModel SchemaType = "save"

	// Single query payload included in a query request
	SchemaTypeQueryPayload SchemaType = "payload"

	// Pseudo panel model including multiple targets (not mixed)
	SchemaTypePanelModel SchemaType = "panel"

	// Query request against a single data source (not mixed)
	SchemaTypeQueryRequest SchemaType = "request"
)

type SettingTypeInfo

type SettingTypeInfo struct {
	// The management name
	Name string
	// Optional discriminators
	Discriminators []sdkapi.DiscriminatorFieldValue
	// Raw GO type used for reflection
	GoType reflect.Type
	// Map[string]string
	SecureGoType reflect.Type
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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