From b4738c57e422fec969c722c97550ee555372fc14 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Wed, 16 Jul 2025 14:22:50 +0200 Subject: [PATCH] Dashboards API: Add v2alpha2 (#108121) * Dashboards API: Register v2alpha2 API * Prepare conversion functions * Fix test * Move to the bottom the v2aplha2 until is ready --------- Co-authored-by: Ivan Ortega --- apps/dashboard/Makefile | 9 +- apps/dashboard/kinds/dashboard.cue | 11 +- .../kinds/v2alpha2/dashboard_spec.cue | 964 ++++ .../dashboard/v2alpha1/dashboard_spec_gen.go | 20 +- .../pkg/apis/dashboard/v2alpha2/constants.go | 18 + .../dashboard/v2alpha2/dashboard_codec_gen.go | 28 + .../v2alpha2/dashboard_metadata_gen.go | 31 + .../v2alpha2/dashboard_object_gen.go | 319 ++ .../v2alpha2/dashboard_schema_gen.go | 34 + .../dashboard/v2alpha2/dashboard_spec.cue | 968 ++++ .../dashboard/v2alpha2/dashboard_spec_gen.go | 2540 ++++++++ .../v2alpha2/dashboard_status_gen.go | 34 + .../pkg/apis/dashboard/v2alpha2/doc.go | 10 + .../pkg/apis/dashboard/v2alpha2/register.go | 103 + .../pkg/apis/dashboard/v2alpha2/types.go | 149 + .../pkg/apis/dashboard/v2alpha2/validation.go | 84 + .../v2alpha2/zz_generated.conversion.go | 175 + .../v2alpha2/zz_generated.deepcopy.go | 283 + .../v2alpha2/zz_generated.defaults.go | 19 + .../v2alpha2/zz_generated.openapi.go | 5094 +++++++++++++++++ ...enerated.openapi_violation_exceptions.list | 67 + apps/dashboard/pkg/apis/dashboard_manifest.go | 6 + .../pkg/migration/conversion/conversion.go | 178 +- .../migration/conversion/conversion_test.go | 6 +- apps/dashboard/pkg/migration/conversion/v0.go | 78 + apps/dashboard/pkg/migration/conversion/v1.go | 71 + apps/dashboard/pkg/migration/conversion/v2.go | 105 + .../v2alpha2/dashboard_object_gen.ts | 49 + .../dashboard/v2alpha2/types.metadata.gen.ts | 30 + .../dashboard/v2alpha2/types.spec.gen.ts | 1404 +++++ .../dashboard/v2alpha2/types.status.gen.ts | 30 + pkg/registry/apis/dashboard/register.go | 46 +- pkg/registry/apis/dashboard/register_test.go | 12 +- 33 files changed, 12818 insertions(+), 157 deletions(-) create mode 100644 apps/dashboard/kinds/v2alpha2/dashboard_spec.cue create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_codec_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_metadata_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_object_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_schema_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_status_gen.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.conversion.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.deepcopy.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.defaults.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go create mode 100644 apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi_violation_exceptions.list create mode 100644 apps/dashboard/pkg/migration/conversion/v0.go create mode 100644 apps/dashboard/pkg/migration/conversion/v1.go create mode 100644 apps/dashboard/pkg/migration/conversion/v2.go create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha2/dashboard_object_gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha2/types.metadata.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha2/types.spec.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha2/types.status.gen.ts diff --git a/apps/dashboard/Makefile b/apps/dashboard/Makefile index 1a948f1b9a8..950c809c0ec 100644 --- a/apps/dashboard/Makefile +++ b/apps/dashboard/Makefile @@ -1,4 +1,4 @@ -APP_SDK_VERSION := v0.39.0 +APP_SDK_VERSION := v0.39.2 APP_SDK_DIR := $(shell go env GOPATH)/bin/app-sdk-$(APP_SDK_VERSION) APP_SDK_BIN := $(APP_SDK_DIR)/grafana-app-sdk @@ -60,3 +60,10 @@ post-generate-cleanup: ## Clean up the generated code @echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue @echo "" >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue @cat ./kinds/v2alpha1/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue + + # Copy dashboard/v2alpha2 spec so we can use it for schema validation + @echo "// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY" > ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue + @echo "// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue + @echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue + @echo "" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue + @cat ./kinds/v2alpha2/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue diff --git a/apps/dashboard/kinds/dashboard.cue b/apps/dashboard/kinds/dashboard.cue index b8aaf17bc7c..d48765539c8 100644 --- a/apps/dashboard/kinds/dashboard.cue +++ b/apps/dashboard/kinds/dashboard.cue @@ -3,7 +3,8 @@ package kinds import ( v0 "github.com/grafana/grafana/sdkkinds/dashboard/v0alpha1" v1 "github.com/grafana/grafana/sdkkinds/dashboard/v1beta1" - v2 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1" + v2alpha1 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1" + v2alpha2 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha2" ) // Status is the shared status of all dashboard versions. @@ -63,7 +64,13 @@ dashboard: { } "v2alpha1": { schema: { - spec: v2.DashboardSpec + spec: v2alpha1.DashboardSpec + status: DashboardStatus + } + } + "v2alpha2": { + schema: { + spec: v2alpha2.DashboardSpec status: DashboardStatus } } diff --git a/apps/dashboard/kinds/v2alpha2/dashboard_spec.cue b/apps/dashboard/kinds/v2alpha2/dashboard_spec.cue new file mode 100644 index 00000000000..4c1202caea7 --- /dev/null +++ b/apps/dashboard/kinds/v2alpha2/dashboard_spec.cue @@ -0,0 +1,964 @@ +package v2alpha2 + +DashboardSpec: { + annotations: [...AnnotationQueryKind] | *[] + + // Configuration of dashboard cursor sync behavior. + // "Off" for no shared crosshair or tooltip (default). + // "Crosshair" for shared crosshair. + // "Tooltip" for shared crosshair AND shared tooltip. + cursorSync: DashboardCursorSync + + // Description of dashboard. + description?: string + + // Whether a dashboard is editable or not. + editable?: bool | *true + + elements: [ElementReference.name]: Element | *{} + + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind + + // Links with references to other dashboards or external websites. + links: [...DashboardLink] | *[] + + // When set to true, the dashboard will redraw panels at an interval matching the pixel width. + // This will keep data "moving left" regardless of the query refresh rate. This setting helps + // avoid dashboards presenting stale live data. + liveNow?: bool + + // When set to true, the dashboard will load all panels in the dashboard when it's loaded. + preload: bool | *false + + // Plugins only. The version of the dashboard installed together with the plugin. + // This is used to determine if the dashboard should be updated when the plugin is updated. + revision?: uint16 + + // Tags associated with dashboard. + tags: [...string] | *[] + + timeSettings: TimeSettingsSpec + + // Title of dashboard. + title: string + + // Configured template variables. + variables: [...VariableKind] | *[] +} + +// Supported dashboard elements +Element: PanelKind | LibraryPanelKind // |* more element types in the future + +LibraryPanelKind: { + kind: "LibraryPanel" + spec: LibraryPanelKindSpec +} + +LibraryPanelKindSpec: { + // Panel ID for the library panel in the dashboard + id: number + // Title for the library panel in the dashboard + title: string + + libraryPanel: LibraryPanelRef +} + +// A library panel is a reusable panel that you can use in any dashboard. +// When you make a change to a library panel, that change propagates to all instances of where the panel is used. +// Library panels streamline reuse of panels across multiple dashboards. +LibraryPanelRef: { + // Library panel name + name: string + // Library panel uid + uid: string +} + +AnnotationPanelFilter: { + // Should the specified panels be included or excluded + exclude?: bool | *false + + // Panel IDs that should be included or excluded + ids: [...uint32] +} + +// "Off" for no shared crosshair or tooltip (default). +// "Crosshair" for shared crosshair. +// "Tooltip" for shared crosshair AND shared tooltip. +DashboardCursorSync: "Crosshair" | "Tooltip" | *"Off" + +// Links with references to other dashboards or external resources +DashboardLink: { + // Title to display with the link + title: string + // Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) + // FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType` + type: DashboardLinkType + // Icon name to be displayed with the link + icon: string + // Tooltip to display when the user hovers their mouse over it + tooltip: string + // Link URL. Only required/valid if the type is link + url?: string + // List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards + tags: [...string] | *[] + // If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards + asDropdown: bool | *false + // If true, the link will be opened in a new tab + targetBlank: bool | *false + // If true, includes current template variables values in the link as query params + includeVars: bool | *false + // If true, includes current time range in the link as query params + keepTime: bool | *false +} + +DataSourceRef: { + // The plugin type-id + type?: string + + // Specific datasource instance + uid?: string +} + +// A topic is attached to DataFrame metadata in query results. +// This specifies where the data should be used. +DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates") + +// Transformations allow to manipulate data returned by a query before the system applies a visualization. +// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, +// use the output of one transformation as the input to another transformation, etc. +DataTransformerConfig: { + // Unique identifier of transformer + id: string + // Disabled transformations are skipped + disabled?: bool + // Optional frame matcher. When missing it will be applied to all results + filter?: MatcherConfig + // Where to pull DataFrames from as input to transformation + topic?: DataTopic + // Options to be passed to the transformer + // Valid options depend on the transformer id + options: _ +} + +DataLink: { + title: string + url: string + targetBlank?: bool +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +FieldConfigSource: { + // Defaults are the options applied to all fields. + defaults: FieldConfig + // Overrides are the options applied to specific fields overriding the defaults. + overrides: [...{ + matcher: MatcherConfig + properties: [...DynamicConfigValue] + }] +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +FieldConfig: { + // The display value for this field. This supports template variables blank is auto + displayName?: string + + // This can be used by data sources that return and explicit naming structure for values and labels + // When this property is configured, this value is used rather than the default naming strategy. + displayNameFromDS?: string + + // Human readable field metadata + description?: string + + // An explicit path to the field in the datasource. When the frame meta includes a path, + // This will default to `${frame.meta.path}/${field.name} + // + // When defined, this value can be used as an identifier within the datasource scope, and + // may be used to update the results + path?: string + + // True if data source can write a value to the path. Auth/authz are supported separately + writeable?: bool + + // True if data source field supports ad-hoc filters + filterable?: bool + + // Unit a field should use. The unit you select is applied to all fields except time. + // You can use the units ID availables in Grafana or a custom unit. + // Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts + // As custom unit, you can use the following formats: + // `suffix:` for custom unit that should go after value. + // `prefix:` for custom unit that should go before value. + // `time:` For custom date time formats type for example `time:YYYY-MM-DD`. + // `si:` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. + // `count:` for a custom count unit. + // `currency:` for custom a currency unit. + unit?: string + + // Specify the number of decimals Grafana includes in the rendered value. + // If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. + // For example 1.1234 will display as 1.12 and 100.456 will display as 100. + // To display all decimals, set the unit to `String`. + decimals?: number + + // The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + min?: number + // The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + max?: number + + // Convert input values into a display string + mappings?: [...ValueMapping] + + // Map numeric values to states + thresholds?: ThresholdsConfig + + // Panel color configuration + color?: FieldColor + + // The behavior when clicking on a result + links?: [...] + + // Alternative to empty string + noValue?: string + + // custom is specified by the FieldConfig field + // in panel plugin schemas. + custom?: {...} +} + +DynamicConfigValue: { + id: string | *"" + value?: _ +} + +// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. +// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type. +MatcherConfig: { + // The matcher id. This is used to find the matcher implementation from registry. + id: string | *"" + // The matcher options. This is specific to the matcher implementation. + options?: _ +} + +Threshold: { + value: number + color: string +} + +ThresholdsMode: "absolute" | "percentage" + +ThresholdsConfig: { + mode: ThresholdsMode + steps: [...Threshold] +} + +ValueMapping: ValueMap | RangeMap | RegexMap | SpecialValueMap + +// Supported value mapping types +// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A. +MappingType: "value" | "range" | "regex" | "special" + +// Maps text values to a color or different display text and color. +// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +ValueMap: { + type: MappingType & "value" + // Map with : ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } + options: [string]: ValueMappingResult +} + +// Maps numerical ranges to a display text and color. +// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +RangeMap: { + type: MappingType & "range" + // Range to match against and the result to apply when the value is within the range + options: { + // Min value of the range. It can be null which means -Infinity + from: float64 | null + // Max value of the range. It can be null which means +Infinity + to: float64 | null + // Config to apply when the value is within the range + result: ValueMappingResult + } +} + +// Maps regular expressions to replacement text and a color. +// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +RegexMap: { + type: MappingType & "regex" + // Regular expression to match against and the result to apply when the value matches the regex + options: { + // Regular expression to match against + pattern: string + // Config to apply when the value matches the regex + result: ValueMappingResult + } +} + +// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. +// See SpecialValueMatch to see the list of special values. +// For example, you can configure a special value mapping so that null values appear as N/A. +SpecialValueMap: { + type: MappingType & "special" + options: { + // Special value to match against + match: SpecialValueMatch + // Config to apply when the value matches the special value + result: ValueMappingResult + } +} + +// Special value types supported by the `SpecialValueMap` +SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cog(kind="enum",memberNames="True|False|Null|NaN|NullAndNaN|Empty") + +// Result used as replacement with text and color when the value matches +ValueMappingResult: { + // Text to display when the value matches + text?: string + // Text to use when the value matches + color?: string + // Icon to display when the value matches. Only specific visualizations. + icon?: string + // Position in the mapping array. Only used internally. + index?: int32 +} + +// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. +// Continuous color interpolates a color using the percentage of a value relative to min and max. +// Accepted values are: +// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold +// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations +// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations +// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode +// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode +// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode +// `continuous-YlRd`: Continuous Yellow-Red palette mode +// `continuous-BlPu`: Continuous Blue-Purple palette mode +// `continuous-YlBl`: Continuous Yellow-Blue palette mode +// `continuous-blues`: Continuous Blue palette mode +// `continuous-reds`: Continuous Red palette mode +// `continuous-greens`: Continuous Green palette mode +// `continuous-purples`: Continuous Purple palette mode +// `shades`: Shades of a single color. Specify a single color, useful in an override rule. +// `fixed`: Fixed color mode. Specify a single color, useful in an override rule. +FieldColorModeId: "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades" + +// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value. +FieldColorSeriesByMode: "min" | "max" | "last" + +// Map a field to a color. +FieldColor: { + // The main color scheme mode. + mode: FieldColorModeId + // The fixed color value for fixed or shades color modes. + fixedColor?: string + // Some visualizations need to know how to assign a series color from by value color schemes. + seriesBy?: FieldColorSeriesByMode +} + +// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) +DashboardLinkType: "link" | "dashboards" + +// --- Common types --- +Kind: { + kind: string + spec: _ + metadata?: _ +} + +// --- Kinds --- +VizConfigSpec: { + pluginVersion: string + options: [string]: _ + fieldConfig: FieldConfigSource +} + +VizConfigKind: { + // The kind of a VizConfigKind is the plugin ID + kind: string + spec: VizConfigSpec +} + +AnnotationQuerySpec: { + datasource?: DataSourceRef + query?: DataQueryKind + enable: bool + hide: bool + iconColor: string + name: string + builtIn?: bool | *false + filter?: AnnotationPanelFilter + legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties +} + +AnnotationQueryKind: { + kind: "AnnotationQuery" + spec: AnnotationQuerySpec +} + +QueryOptionsSpec: { + timeFrom?: string + maxDataPoints?: int + timeShift?: string + queryCachingTTL?: int + interval?: string + cacheTimeout?: string + hideTimeOverride?: bool +} + +DataQueryKind: { + // The kind of a DataQueryKind is the datasource type + kind: string + spec: [string]: _ +} + +PanelQuerySpec: { + query: DataQueryKind + datasource?: DataSourceRef + + refId: string + hidden: bool +} + +PanelQueryKind: { + kind: "PanelQuery" + spec: PanelQuerySpec +} + +TransformationKind: { + // The kind of a TransformationKind is the transformation ID + kind: string + spec: DataTransformerConfig +} + +QueryGroupSpec: { + queries: [...PanelQueryKind] + transformations: [...TransformationKind] + queryOptions: QueryOptionsSpec +} + +QueryGroupKind: { + kind: "QueryGroup" + spec: QueryGroupSpec +} + +TimeRangeOption: { + display: string | *"Last 6 hours" + from: string | *"now-6h" + to: string | *"now" +} + +// Time configuration +// It defines the default time config for the time picker, the refresh picker for the specific dashboard. +TimeSettingsSpec: { + // Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". + timezone?: string | *"browser" + // Start time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + from: string | *"now-6h" + // End time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + to: string | *"now" + // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". + autoRefresh: string | *"" // v1: refresh + // Interval options available in the refresh picker dropdown. + autoRefreshIntervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] // v1: timepicker.refresh_intervals + // Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. + quickRanges?: [...TimeRangeOption] // v1: timepicker.quick_ranges , not exposed in the UI + // Whether timepicker is visible or not. + hideTimepicker: bool | *false // v1: timepicker.hidden + // Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". + weekStart?: "saturday" | "monday" | "sunday" + // The month that the fiscal year starts on. 0 = January, 11 = December + fiscalYearStartMonth: int | *0 + // Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values. + nowDelay?: string // v1: timepicker.nowDelay +} + +RepeatMode: "variable" // other repeat modes will be added in the future: label, frame + +RepeatOptions: { + mode: RepeatMode + value: string + direction?: "h" | "v" + maxPerRow?: int +} + +RowRepeatOptions: { + mode: RepeatMode + value: string +} + +TabRepeatOptions: { + mode: RepeatMode + value: string +} + +AutoGridRepeatOptions: { + mode: RepeatMode + value: string +} + +GridLayoutItemSpec: { + x: int + y: int + width: int + height: int + element: ElementReference // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference + repeat?: RepeatOptions +} + +GridLayoutItemKind: { + kind: "GridLayoutItem" + spec: GridLayoutItemSpec +} + +GridLayoutSpec: { + items: [...GridLayoutItemKind] +} + +GridLayoutKind: { + kind: "GridLayout" + spec: GridLayoutSpec +} + +RowsLayoutKind: { + kind: "RowsLayout" + spec: RowsLayoutSpec +} + +RowsLayoutSpec: { + rows: [...RowsLayoutRowKind] +} + +RowsLayoutRowKind: { + kind: "RowsLayoutRow" + spec: RowsLayoutRowSpec +} + +RowsLayoutRowSpec: { + title?: string + collapse?: bool + hideHeader?: bool + fillScreen?: bool + conditionalRendering?: ConditionalRenderingGroupKind + repeat?: RowRepeatOptions + layout: GridLayoutKind | AutoGridLayoutKind | TabsLayoutKind | RowsLayoutKind +} + +AutoGridLayoutKind: { + kind: "AutoGridLayout" + spec: AutoGridLayoutSpec +} + +AutoGridLayoutSpec: { + maxColumnCount?: number | *3 + columnWidthMode: "narrow" | *"standard" | "wide" | "custom" + columnWidth?: number + rowHeightMode: "short" | *"standard" | "tall" | "custom" + rowHeight?: number + fillScreen?: bool | *false + items: [...AutoGridLayoutItemKind] +} + +AutoGridLayoutItemKind: { + kind: "AutoGridLayoutItem" + spec: AutoGridLayoutItemSpec +} + +AutoGridLayoutItemSpec: { + element: ElementReference + repeat?: AutoGridRepeatOptions + conditionalRendering?: ConditionalRenderingGroupKind +} + +TabsLayoutKind: { + kind: "TabsLayout" + spec: TabsLayoutSpec +} + +TabsLayoutSpec: { + tabs: [...TabsLayoutTabKind] +} + +TabsLayoutTabKind: { + kind: "TabsLayoutTab" + spec: TabsLayoutTabSpec +} + +TabsLayoutTabSpec: { + title?: string + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind + conditionalRendering?: ConditionalRenderingGroupKind + repeat?: TabRepeatOptions +} + +PanelSpec: { + id: number + title: string + description: string + links: [...DataLink] + data: QueryGroupKind + vizConfig: VizConfigKind + transparent?: bool +} + +PanelKind: { + kind: "Panel" + spec: PanelSpec +} + +ElementReference: { + kind: "ElementReference" + name: string +} + +// Start FIXME: variables - in CUE PR - this are things that should be added into the cue schema +// TODO: properties such as `hide`, `skipUrlSync`, `multi` are type boolean, and in the old schema they are conditional, +// should we make them conditional in the new schema as well? or should we make them required but default to false? + +// Variable types +VariableValue: VariableValueSingle | [...VariableValueSingle] + +VariableValueSingle: string | bool | number | CustomVariableValue + +// Custom formatter variable +CustomFormatterVariable: { + name: string + type: VariableType + multi: bool + includeAll: bool +} + +// Custom variable value +CustomVariableValue: { + // The format name or function used in the expression + formatter: *null | string | VariableCustomFormatterFn +} + +// Custom formatter function +VariableCustomFormatterFn: { + value: _ + legacyVariableModel: { + name: string + type: VariableType + multi: bool + includeAll: bool + } + legacyDefaultFormatter?: VariableCustomFormatterFn +} + +// Dashboard variable type +// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. +// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). +// `constant`: Define a hidden constant. +// `datasource`: Quickly change the data source for an entire dashboard. +// `interval`: Interval variables represent time spans. +// `textbox`: Display a free text input field with an optional default value. +// `custom`: Define the variable options manually using a comma-separated list. +// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables +VariableType: "query" | "adhoc" | "groupby" | "constant" | "datasource" | "interval" | "textbox" | "custom" | + "system" | "snapshot" + +VariableKind: QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind + +// Sort variable options +// Accepted values are: +// `disabled`: No sorting +// `alphabeticalAsc`: Alphabetical ASC +// `alphabeticalDesc`: Alphabetical DESC +// `numericalAsc`: Numerical ASC +// `numericalDesc`: Numerical DESC +// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC +// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC +// `naturalAsc`: Natural ASC +// `naturalDesc`: Natural DESC +// VariableSort enum with default value +VariableSort: "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc" + +// Options to config when to refresh a variable +// `never`: Never refresh the variable +// `onDashboardLoad`: Queries the data source every time the dashboard loads. +// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes. +VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged" + +// Determine if the variable shows on dashboard +// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing). +VariableHide: *"dontHide" | "hideLabel" | "hideVariable" + +// Determine the origin of the adhoc variable filter +FilterOrigin: "dashboard" + +// FIXME: should we introduce this? --- Variable value option +VariableValueOption: { + label: string + value: VariableValueSingle + group?: string +} + +// Variable option specification +VariableOption: { + // Whether the option is selected or not + selected?: bool + // Text to be displayed for the option + text: string | [...string] + // Value of the option + value: string | [...string] +} + +// Query variable specification +QueryVariableSpec: { + name: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + label?: string + hide: VariableHide + refresh: VariableRefresh + skipUrlSync: bool | *false + description?: string + datasource?: DataSourceRef + query: DataQueryKind + regex: string | *"" + sort: VariableSort + definition?: string + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + placeholder?: string + allowCustomValue: bool | *true + staticOptions?: [...VariableOption] + staticOptionsOrder?: "before" | "after" | "sorted" +} + +// Query variable kind +QueryVariableKind: { + kind: "QueryVariable" + spec: QueryVariableSpec +} + +// Text variable specification +TextVariableSpec: { + name: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + query: string | *"" + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Text variable kind +TextVariableKind: { + kind: "TextVariable" + spec: TextVariableSpec +} + +// Constant variable specification +ConstantVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Constant variable kind +ConstantVariableKind: { + kind: "ConstantVariable" + spec: ConstantVariableSpec +} + +// Datasource variable specification +DatasourceVariableSpec: { + name: string | *"" + pluginId: string | *"" + refresh: VariableRefresh + regex: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Datasource variable kind +DatasourceVariableKind: { + kind: "DatasourceVariable" + spec: DatasourceVariableSpec +} + +// Interval variable specification +IntervalVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + auto: bool | *false + auto_min: string | *"" + auto_count: int | *0 + refresh: VariableRefresh + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Interval variable kind +IntervalVariableKind: { + kind: "IntervalVariable" + spec: IntervalVariableSpec +} + +// Custom variable specification +CustomVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Custom variable kind +CustomVariableKind: { + kind: "CustomVariable" + spec: CustomVariableSpec +} + +// GroupBy variable specification +GroupByVariableSpec: { + name: string | *"" + datasource?: DataSourceRef + defaultValue?: VariableOption + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + multi: bool | *false + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Group variable kind +GroupByVariableKind: { + kind: "GroupByVariable" + spec: GroupByVariableSpec +} + +// Adhoc variable specification +AdhocVariableSpec: { + name: string | *"" + datasource?: DataSourceRef + baseFilters: [...AdHocFilterWithLabels] | *[] + filters: [...AdHocFilterWithLabels] | *[] + defaultKeys: [...MetricFindValue] | *[] + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Define the MetricFindValue type +MetricFindValue: { + text: string + value?: string | number + group?: string + expandable?: bool +} + +// Define the AdHocFilterWithLabels type +AdHocFilterWithLabels: { + key: string + operator: string + value: string + values?: [...string] + keyLabel?: string + valueLabels?: [...string] + forceEdit?: bool + origin?: FilterOrigin + // @deprecated + condition?: string +} + +// Adhoc variable kind +AdhocVariableKind: { + kind: "AdhocVariable" + spec: AdhocVariableSpec +} + +ConditionalRenderingGroupKind: { + kind: "ConditionalRenderingGroup" + spec: ConditionalRenderingGroupSpec +} + +ConditionalRenderingGroupSpec: { + visibility: "show" | "hide" + condition: "and" | "or" + items: [...ConditionalRenderingVariableKind | ConditionalRenderingDataKind | ConditionalRenderingTimeRangeSizeKind] +} + +ConditionalRenderingVariableKind: { + kind: "ConditionalRenderingVariable" + spec: ConditionalRenderingVariableSpec +} + +ConditionalRenderingVariableSpec: { + variable: string + operator: "equals" | "notEquals" + value: string +} + +ConditionalRenderingDataKind: { + kind: "ConditionalRenderingData" + spec: ConditionalRenderingDataSpec +} + +ConditionalRenderingDataSpec: { + value: bool +} + +ConditionalRenderingTimeRangeSizeKind: { + kind: "ConditionalRenderingTimeRangeSize" + spec: ConditionalRenderingTimeRangeSizeSpec +} + +ConditionalRenderingTimeRangeSizeSpec: { + value: string +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go index a2d9a4e0250..9ddbe89502f 100644 --- a/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go @@ -763,7 +763,9 @@ type DashboardRepeatOptions struct { // NewDashboardRepeatOptions creates a new DashboardRepeatOptions object. func NewDashboardRepeatOptions() *DashboardRepeatOptions { - return &DashboardRepeatOptions{} + return &DashboardRepeatOptions{ + Mode: DashboardRepeatMode, + } } // other repeat modes will be added in the future: label, frame @@ -938,7 +940,9 @@ type DashboardRowRepeatOptions struct { // NewDashboardRowRepeatOptions creates a new DashboardRowRepeatOptions object. func NewDashboardRowRepeatOptions() *DashboardRowRepeatOptions { - return &DashboardRowRepeatOptions{} + return &DashboardRowRepeatOptions{ + Mode: DashboardRepeatMode, + } } // +k8s:openapi-gen=true @@ -1011,7 +1015,9 @@ type DashboardAutoGridRepeatOptions struct { // NewDashboardAutoGridRepeatOptions creates a new DashboardAutoGridRepeatOptions object. func NewDashboardAutoGridRepeatOptions() *DashboardAutoGridRepeatOptions { - return &DashboardAutoGridRepeatOptions{} + return &DashboardAutoGridRepeatOptions{ + Mode: DashboardRepeatMode, + } } // +k8s:openapi-gen=true @@ -1077,7 +1083,9 @@ type DashboardTabRepeatOptions struct { // NewDashboardTabRepeatOptions creates a new DashboardTabRepeatOptions object. func NewDashboardTabRepeatOptions() *DashboardTabRepeatOptions { - return &DashboardTabRepeatOptions{} + return &DashboardTabRepeatOptions{ + Mode: DashboardRepeatMode, + } } // Links with references to other dashboards or external resources @@ -1689,7 +1697,9 @@ type DashboardAdHocFilterWithLabels struct { // NewDashboardAdHocFilterWithLabels creates a new DashboardAdHocFilterWithLabels object. func NewDashboardAdHocFilterWithLabels() *DashboardAdHocFilterWithLabels { - return &DashboardAdHocFilterWithLabels{} + return &DashboardAdHocFilterWithLabels{ + Origin: DashboardFilterOrigin, + } } // Determine the origin of the adhoc variable filter diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go new file mode 100644 index 00000000000..3942a399896 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go @@ -0,0 +1,18 @@ +package v2alpha2 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +const ( + // APIGroup is the API group used by all kinds in this package + APIGroup = "dashboard.grafana.app" + // APIVersion is the API version used by all kinds in this package + APIVersion = "v2alpha2" +) + +var ( + // GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package + GroupVersion = schema.GroupVersion{ + Group: APIGroup, + Version: APIVersion, + } +) diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_codec_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_codec_gen.go new file mode 100644 index 00000000000..9c679dcafd7 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_codec_gen.go @@ -0,0 +1,28 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha2 + +import ( + "encoding/json" + "io" + + "github.com/grafana/grafana-app-sdk/resource" +) + +// DashboardJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding +type DashboardJSONCodec struct{} + +// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into` +func (*DashboardJSONCodec) Read(reader io.Reader, into resource.Object) error { + return json.NewDecoder(reader).Decode(into) +} + +// Write writes JSON-encoded bytes into `writer` marshaled from `from` +func (*DashboardJSONCodec) Write(writer io.Writer, from resource.Object) error { + return json.NewEncoder(writer).Encode(from) +} + +// Interface compliance checks +var _ resource.Codec = &DashboardJSONCodec{} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_metadata_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_metadata_gen.go new file mode 100644 index 00000000000..62e187af661 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_metadata_gen.go @@ -0,0 +1,31 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha2 + +import ( + time "time" +) + +// metadata contains embedded CommonMetadata and can be extended with custom string fields +// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here +// without external reference as using the CommonMetadata reference breaks thema codegen. +type DashboardMetadata struct { + UpdateTimestamp time.Time `json:"updateTimestamp"` + CreatedBy string `json:"createdBy"` + Uid string `json:"uid"` + CreationTimestamp time.Time `json:"creationTimestamp"` + DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` + Finalizers []string `json:"finalizers"` + ResourceVersion string `json:"resourceVersion"` + Generation int64 `json:"generation"` + UpdatedBy string `json:"updatedBy"` + Labels map[string]string `json:"labels"` +} + +// NewDashboardMetadata creates a new DashboardMetadata object. +func NewDashboardMetadata() *DashboardMetadata { + return &DashboardMetadata{ + Finalizers: []string{}, + Labels: map[string]string{}, + } +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_object_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_object_gen.go new file mode 100644 index 00000000000..641ba8ce808 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_object_gen.go @@ -0,0 +1,319 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha2 + +import ( + "fmt" + "github.com/grafana/grafana-app-sdk/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "time" +) + +// +k8s:openapi-gen=true +type Dashboard struct { + metav1.TypeMeta `json:",inline" yaml:",inline"` + metav1.ObjectMeta `json:"metadata" yaml:"metadata"` + + // Spec is the spec of the Dashboard + Spec DashboardSpec `json:"spec" yaml:"spec"` + + Status DashboardStatus `json:"status" yaml:"status"` +} + +func (o *Dashboard) GetSpec() any { + return o.Spec +} + +func (o *Dashboard) SetSpec(spec any) error { + cast, ok := spec.(DashboardSpec) + if !ok { + return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) + } + o.Spec = cast + return nil +} + +func (o *Dashboard) GetSubresources() map[string]any { + return map[string]any{ + "status": o.Status, + } +} + +func (o *Dashboard) GetSubresource(name string) (any, bool) { + switch name { + case "status": + return o.Status, true + default: + return nil, false + } +} + +func (o *Dashboard) SetSubresource(name string, value any) error { + switch name { + case "status": + cast, ok := value.(DashboardStatus) + if !ok { + return fmt.Errorf("cannot set status type %#v, not of type DashboardStatus", value) + } + o.Status = cast + return nil + default: + return fmt.Errorf("subresource '%s' does not exist", name) + } +} + +func (o *Dashboard) GetStaticMetadata() resource.StaticMetadata { + gvk := o.GroupVersionKind() + return resource.StaticMetadata{ + Name: o.ObjectMeta.Name, + Namespace: o.ObjectMeta.Namespace, + Group: gvk.Group, + Version: gvk.Version, + Kind: gvk.Kind, + } +} + +func (o *Dashboard) SetStaticMetadata(metadata resource.StaticMetadata) { + o.Name = metadata.Name + o.Namespace = metadata.Namespace + o.SetGroupVersionKind(schema.GroupVersionKind{ + Group: metadata.Group, + Version: metadata.Version, + Kind: metadata.Kind, + }) +} + +func (o *Dashboard) GetCommonMetadata() resource.CommonMetadata { + dt := o.DeletionTimestamp + var deletionTimestamp *time.Time + if dt != nil { + deletionTimestamp = &dt.Time + } + // Legacy ExtraFields support + extraFields := make(map[string]any) + if o.Annotations != nil { + extraFields["annotations"] = o.Annotations + } + if o.ManagedFields != nil { + extraFields["managedFields"] = o.ManagedFields + } + if o.OwnerReferences != nil { + extraFields["ownerReferences"] = o.OwnerReferences + } + return resource.CommonMetadata{ + UID: string(o.UID), + ResourceVersion: o.ResourceVersion, + Generation: o.Generation, + Labels: o.Labels, + CreationTimestamp: o.CreationTimestamp.Time, + DeletionTimestamp: deletionTimestamp, + Finalizers: o.Finalizers, + UpdateTimestamp: o.GetUpdateTimestamp(), + CreatedBy: o.GetCreatedBy(), + UpdatedBy: o.GetUpdatedBy(), + ExtraFields: extraFields, + } +} + +func (o *Dashboard) SetCommonMetadata(metadata resource.CommonMetadata) { + o.UID = types.UID(metadata.UID) + o.ResourceVersion = metadata.ResourceVersion + o.Generation = metadata.Generation + o.Labels = metadata.Labels + o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) + if metadata.DeletionTimestamp != nil { + dt := metav1.NewTime(*metadata.DeletionTimestamp) + o.DeletionTimestamp = &dt + } else { + o.DeletionTimestamp = nil + } + o.Finalizers = metadata.Finalizers + if o.Annotations == nil { + o.Annotations = make(map[string]string) + } + if !metadata.UpdateTimestamp.IsZero() { + o.SetUpdateTimestamp(metadata.UpdateTimestamp) + } + if metadata.CreatedBy != "" { + o.SetCreatedBy(metadata.CreatedBy) + } + if metadata.UpdatedBy != "" { + o.SetUpdatedBy(metadata.UpdatedBy) + } + // Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields + if metadata.ExtraFields != nil { + if annotations, ok := metadata.ExtraFields["annotations"]; ok { + if cast, ok := annotations.(map[string]string); ok { + o.Annotations = cast + } + } + if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { + if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { + o.ManagedFields = cast + } + } + if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { + if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { + o.OwnerReferences = cast + } + } + } +} + +func (o *Dashboard) GetCreatedBy() string { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + return o.ObjectMeta.Annotations["grafana.com/createdBy"] +} + +func (o *Dashboard) SetCreatedBy(createdBy string) { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy +} + +func (o *Dashboard) GetUpdateTimestamp() time.Time { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) + return parsed +} + +func (o *Dashboard) SetUpdateTimestamp(updateTimestamp time.Time) { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) +} + +func (o *Dashboard) GetUpdatedBy() string { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + return o.ObjectMeta.Annotations["grafana.com/updatedBy"] +} + +func (o *Dashboard) SetUpdatedBy(updatedBy string) { + if o.ObjectMeta.Annotations == nil { + o.ObjectMeta.Annotations = make(map[string]string) + } + + o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy +} + +func (o *Dashboard) Copy() resource.Object { + return resource.CopyObject(o) +} + +func (o *Dashboard) DeepCopyObject() runtime.Object { + return o.Copy() +} + +func (o *Dashboard) DeepCopy() *Dashboard { + cpy := &Dashboard{} + o.DeepCopyInto(cpy) + return cpy +} + +func (o *Dashboard) DeepCopyInto(dst *Dashboard) { + dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion + dst.TypeMeta.Kind = o.TypeMeta.Kind + o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta) + o.Spec.DeepCopyInto(&dst.Spec) + o.Status.DeepCopyInto(&dst.Status) +} + +// Interface compliance compile-time check +var _ resource.Object = &Dashboard{} + +// +k8s:openapi-gen=true +type DashboardList struct { + metav1.TypeMeta `json:",inline" yaml:",inline"` + metav1.ListMeta `json:"metadata" yaml:"metadata"` + Items []Dashboard `json:"items" yaml:"items"` +} + +func (o *DashboardList) DeepCopyObject() runtime.Object { + return o.Copy() +} + +func (o *DashboardList) Copy() resource.ListObject { + cpy := &DashboardList{ + TypeMeta: o.TypeMeta, + Items: make([]Dashboard, len(o.Items)), + } + o.ListMeta.DeepCopyInto(&cpy.ListMeta) + for i := 0; i < len(o.Items); i++ { + if item, ok := o.Items[i].Copy().(*Dashboard); ok { + cpy.Items[i] = *item + } + } + return cpy +} + +func (o *DashboardList) GetItems() []resource.Object { + items := make([]resource.Object, len(o.Items)) + for i := 0; i < len(o.Items); i++ { + items[i] = &o.Items[i] + } + return items +} + +func (o *DashboardList) SetItems(items []resource.Object) { + o.Items = make([]Dashboard, len(items)) + for i := 0; i < len(items); i++ { + o.Items[i] = *items[i].(*Dashboard) + } +} + +func (o *DashboardList) DeepCopy() *DashboardList { + cpy := &DashboardList{} + o.DeepCopyInto(cpy) + return cpy +} + +func (o *DashboardList) DeepCopyInto(dst *DashboardList) { + resource.CopyObjectInto(dst, o) +} + +// Interface compliance compile-time check +var _ resource.ListObject = &DashboardList{} + +// Copy methods for all subresource types + +// DeepCopy creates a full deep copy of Spec +func (s *DashboardSpec) DeepCopy() *DashboardSpec { + cpy := &DashboardSpec{} + s.DeepCopyInto(cpy) + return cpy +} + +// DeepCopyInto deep copies Spec into another Spec object +func (s *DashboardSpec) DeepCopyInto(dst *DashboardSpec) { + resource.CopyObjectInto(dst, s) +} + +// DeepCopy creates a full deep copy of DashboardStatus +func (s *DashboardStatus) DeepCopy() *DashboardStatus { + cpy := &DashboardStatus{} + s.DeepCopyInto(cpy) + return cpy +} + +// DeepCopyInto deep copies DashboardStatus into another DashboardStatus object +func (s *DashboardStatus) DeepCopyInto(dst *DashboardStatus) { + resource.CopyObjectInto(dst, s) +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_schema_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_schema_gen.go new file mode 100644 index 00000000000..da9ae612d71 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_schema_gen.go @@ -0,0 +1,34 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha2 + +import ( + "github.com/grafana/grafana-app-sdk/resource" +) + +// schema is unexported to prevent accidental overwrites +var ( + schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v2alpha2", &Dashboard{}, &DashboardList{}, resource.WithKind("Dashboard"), + resource.WithPlural("dashboards"), resource.WithScope(resource.NamespacedScope)) + kindDashboard = resource.Kind{ + Schema: schemaDashboard, + Codecs: map[resource.KindEncoding]resource.Codec{ + resource.KindEncodingJSON: &DashboardJSONCodec{}, + }, + } +) + +// Kind returns a resource.Kind for this Schema with a JSON codec +func DashboardKind() resource.Kind { + return kindDashboard +} + +// Schema returns a resource.SimpleSchema representation of Dashboard +func DashboardSchema() *resource.SimpleSchema { + return schemaDashboard +} + +// Interface compliance checks +var _ resource.Schema = kindDashboard diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue new file mode 100644 index 00000000000..4fdce729b2c --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue @@ -0,0 +1,968 @@ +// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY +// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue +// To sync changes, run: make generate in apps/dashboard + +package v2alpha2 + +DashboardSpec: { + annotations: [...AnnotationQueryKind] | *[] + + // Configuration of dashboard cursor sync behavior. + // "Off" for no shared crosshair or tooltip (default). + // "Crosshair" for shared crosshair. + // "Tooltip" for shared crosshair AND shared tooltip. + cursorSync: DashboardCursorSync + + // Description of dashboard. + description?: string + + // Whether a dashboard is editable or not. + editable?: bool | *true + + elements: [ElementReference.name]: Element | *{} + + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind + + // Links with references to other dashboards or external websites. + links: [...DashboardLink] | *[] + + // When set to true, the dashboard will redraw panels at an interval matching the pixel width. + // This will keep data "moving left" regardless of the query refresh rate. This setting helps + // avoid dashboards presenting stale live data. + liveNow?: bool + + // When set to true, the dashboard will load all panels in the dashboard when it's loaded. + preload: bool | *false + + // Plugins only. The version of the dashboard installed together with the plugin. + // This is used to determine if the dashboard should be updated when the plugin is updated. + revision?: uint16 + + // Tags associated with dashboard. + tags: [...string] | *[] + + timeSettings: TimeSettingsSpec + + // Title of dashboard. + title: string + + // Configured template variables. + variables: [...VariableKind] | *[] +} + +// Supported dashboard elements +Element: PanelKind | LibraryPanelKind // |* more element types in the future + +LibraryPanelKind: { + kind: "LibraryPanel" + spec: LibraryPanelKindSpec +} + +LibraryPanelKindSpec: { + // Panel ID for the library panel in the dashboard + id: number + // Title for the library panel in the dashboard + title: string + + libraryPanel: LibraryPanelRef +} + +// A library panel is a reusable panel that you can use in any dashboard. +// When you make a change to a library panel, that change propagates to all instances of where the panel is used. +// Library panels streamline reuse of panels across multiple dashboards. +LibraryPanelRef: { + // Library panel name + name: string + // Library panel uid + uid: string +} + +AnnotationPanelFilter: { + // Should the specified panels be included or excluded + exclude?: bool | *false + + // Panel IDs that should be included or excluded + ids: [...uint32] +} + +// "Off" for no shared crosshair or tooltip (default). +// "Crosshair" for shared crosshair. +// "Tooltip" for shared crosshair AND shared tooltip. +DashboardCursorSync: "Crosshair" | "Tooltip" | *"Off" + +// Links with references to other dashboards or external resources +DashboardLink: { + // Title to display with the link + title: string + // Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) + // FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType` + type: DashboardLinkType + // Icon name to be displayed with the link + icon: string + // Tooltip to display when the user hovers their mouse over it + tooltip: string + // Link URL. Only required/valid if the type is link + url?: string + // List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards + tags: [...string] | *[] + // If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards + asDropdown: bool | *false + // If true, the link will be opened in a new tab + targetBlank: bool | *false + // If true, includes current template variables values in the link as query params + includeVars: bool | *false + // If true, includes current time range in the link as query params + keepTime: bool | *false +} + +DataSourceRef: { + // The plugin type-id + type?: string + + // Specific datasource instance + uid?: string +} + +// A topic is attached to DataFrame metadata in query results. +// This specifies where the data should be used. +DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates") + +// Transformations allow to manipulate data returned by a query before the system applies a visualization. +// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, +// use the output of one transformation as the input to another transformation, etc. +DataTransformerConfig: { + // Unique identifier of transformer + id: string + // Disabled transformations are skipped + disabled?: bool + // Optional frame matcher. When missing it will be applied to all results + filter?: MatcherConfig + // Where to pull DataFrames from as input to transformation + topic?: DataTopic + // Options to be passed to the transformer + // Valid options depend on the transformer id + options: _ +} + +DataLink: { + title: string + url: string + targetBlank?: bool +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +FieldConfigSource: { + // Defaults are the options applied to all fields. + defaults: FieldConfig + // Overrides are the options applied to specific fields overriding the defaults. + overrides: [...{ + matcher: MatcherConfig + properties: [...DynamicConfigValue] + }] +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +FieldConfig: { + // The display value for this field. This supports template variables blank is auto + displayName?: string + + // This can be used by data sources that return and explicit naming structure for values and labels + // When this property is configured, this value is used rather than the default naming strategy. + displayNameFromDS?: string + + // Human readable field metadata + description?: string + + // An explicit path to the field in the datasource. When the frame meta includes a path, + // This will default to `${frame.meta.path}/${field.name} + // + // When defined, this value can be used as an identifier within the datasource scope, and + // may be used to update the results + path?: string + + // True if data source can write a value to the path. Auth/authz are supported separately + writeable?: bool + + // True if data source field supports ad-hoc filters + filterable?: bool + + // Unit a field should use. The unit you select is applied to all fields except time. + // You can use the units ID availables in Grafana or a custom unit. + // Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts + // As custom unit, you can use the following formats: + // `suffix:` for custom unit that should go after value. + // `prefix:` for custom unit that should go before value. + // `time:` For custom date time formats type for example `time:YYYY-MM-DD`. + // `si:` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. + // `count:` for a custom count unit. + // `currency:` for custom a currency unit. + unit?: string + + // Specify the number of decimals Grafana includes in the rendered value. + // If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. + // For example 1.1234 will display as 1.12 and 100.456 will display as 100. + // To display all decimals, set the unit to `String`. + decimals?: number + + // The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + min?: number + // The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + max?: number + + // Convert input values into a display string + mappings?: [...ValueMapping] + + // Map numeric values to states + thresholds?: ThresholdsConfig + + // Panel color configuration + color?: FieldColor + + // The behavior when clicking on a result + links?: [...] + + // Alternative to empty string + noValue?: string + + // custom is specified by the FieldConfig field + // in panel plugin schemas. + custom?: {...} +} + +DynamicConfigValue: { + id: string | *"" + value?: _ +} + +// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. +// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type. +MatcherConfig: { + // The matcher id. This is used to find the matcher implementation from registry. + id: string | *"" + // The matcher options. This is specific to the matcher implementation. + options?: _ +} + +Threshold: { + value: number + color: string +} + +ThresholdsMode: "absolute" | "percentage" + +ThresholdsConfig: { + mode: ThresholdsMode + steps: [...Threshold] +} + +ValueMapping: ValueMap | RangeMap | RegexMap | SpecialValueMap + +// Supported value mapping types +// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A. +MappingType: "value" | "range" | "regex" | "special" + +// Maps text values to a color or different display text and color. +// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +ValueMap: { + type: MappingType & "value" + // Map with : ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } + options: [string]: ValueMappingResult +} + +// Maps numerical ranges to a display text and color. +// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +RangeMap: { + type: MappingType & "range" + // Range to match against and the result to apply when the value is within the range + options: { + // Min value of the range. It can be null which means -Infinity + from: float64 | null + // Max value of the range. It can be null which means +Infinity + to: float64 | null + // Config to apply when the value is within the range + result: ValueMappingResult + } +} + +// Maps regular expressions to replacement text and a color. +// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +RegexMap: { + type: MappingType & "regex" + // Regular expression to match against and the result to apply when the value matches the regex + options: { + // Regular expression to match against + pattern: string + // Config to apply when the value matches the regex + result: ValueMappingResult + } +} + +// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. +// See SpecialValueMatch to see the list of special values. +// For example, you can configure a special value mapping so that null values appear as N/A. +SpecialValueMap: { + type: MappingType & "special" + options: { + // Special value to match against + match: SpecialValueMatch + // Config to apply when the value matches the special value + result: ValueMappingResult + } +} + +// Special value types supported by the `SpecialValueMap` +SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cog(kind="enum",memberNames="True|False|Null|NaN|NullAndNaN|Empty") + +// Result used as replacement with text and color when the value matches +ValueMappingResult: { + // Text to display when the value matches + text?: string + // Text to use when the value matches + color?: string + // Icon to display when the value matches. Only specific visualizations. + icon?: string + // Position in the mapping array. Only used internally. + index?: int32 +} + +// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. +// Continuous color interpolates a color using the percentage of a value relative to min and max. +// Accepted values are: +// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold +// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations +// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations +// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode +// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode +// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode +// `continuous-YlRd`: Continuous Yellow-Red palette mode +// `continuous-BlPu`: Continuous Blue-Purple palette mode +// `continuous-YlBl`: Continuous Yellow-Blue palette mode +// `continuous-blues`: Continuous Blue palette mode +// `continuous-reds`: Continuous Red palette mode +// `continuous-greens`: Continuous Green palette mode +// `continuous-purples`: Continuous Purple palette mode +// `shades`: Shades of a single color. Specify a single color, useful in an override rule. +// `fixed`: Fixed color mode. Specify a single color, useful in an override rule. +FieldColorModeId: "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades" + +// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value. +FieldColorSeriesByMode: "min" | "max" | "last" + +// Map a field to a color. +FieldColor: { + // The main color scheme mode. + mode: FieldColorModeId + // The fixed color value for fixed or shades color modes. + fixedColor?: string + // Some visualizations need to know how to assign a series color from by value color schemes. + seriesBy?: FieldColorSeriesByMode +} + +// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) +DashboardLinkType: "link" | "dashboards" + +// --- Common types --- +Kind: { + kind: string + spec: _ + metadata?: _ +} + +// --- Kinds --- +VizConfigSpec: { + pluginVersion: string + options: [string]: _ + fieldConfig: FieldConfigSource +} + +VizConfigKind: { + // The kind of a VizConfigKind is the plugin ID + kind: string + spec: VizConfigSpec +} + +AnnotationQuerySpec: { + datasource?: DataSourceRef + query?: DataQueryKind + enable: bool + hide: bool + iconColor: string + name: string + builtIn?: bool | *false + filter?: AnnotationPanelFilter + legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties +} + +AnnotationQueryKind: { + kind: "AnnotationQuery" + spec: AnnotationQuerySpec +} + +QueryOptionsSpec: { + timeFrom?: string + maxDataPoints?: int + timeShift?: string + queryCachingTTL?: int + interval?: string + cacheTimeout?: string + hideTimeOverride?: bool +} + +DataQueryKind: { + // The kind of a DataQueryKind is the datasource type + kind: string + spec: [string]: _ +} + +PanelQuerySpec: { + query: DataQueryKind + datasource?: DataSourceRef + + refId: string + hidden: bool +} + +PanelQueryKind: { + kind: "PanelQuery" + spec: PanelQuerySpec +} + +TransformationKind: { + // The kind of a TransformationKind is the transformation ID + kind: string + spec: DataTransformerConfig +} + +QueryGroupSpec: { + queries: [...PanelQueryKind] + transformations: [...TransformationKind] + queryOptions: QueryOptionsSpec +} + +QueryGroupKind: { + kind: "QueryGroup" + spec: QueryGroupSpec +} + +TimeRangeOption: { + display: string | *"Last 6 hours" + from: string | *"now-6h" + to: string | *"now" +} + +// Time configuration +// It defines the default time config for the time picker, the refresh picker for the specific dashboard. +TimeSettingsSpec: { + // Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". + timezone?: string | *"browser" + // Start time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + from: string | *"now-6h" + // End time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + to: string | *"now" + // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". + autoRefresh: string | *"" // v1: refresh + // Interval options available in the refresh picker dropdown. + autoRefreshIntervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] // v1: timepicker.refresh_intervals + // Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. + quickRanges?: [...TimeRangeOption] // v1: timepicker.quick_ranges , not exposed in the UI + // Whether timepicker is visible or not. + hideTimepicker: bool | *false // v1: timepicker.hidden + // Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". + weekStart?: "saturday" | "monday" | "sunday" + // The month that the fiscal year starts on. 0 = January, 11 = December + fiscalYearStartMonth: int | *0 + // Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values. + nowDelay?: string // v1: timepicker.nowDelay +} + +RepeatMode: "variable" // other repeat modes will be added in the future: label, frame + +RepeatOptions: { + mode: RepeatMode + value: string + direction?: "h" | "v" + maxPerRow?: int +} + +RowRepeatOptions: { + mode: RepeatMode + value: string +} + +TabRepeatOptions: { + mode: RepeatMode + value: string +} + +AutoGridRepeatOptions: { + mode: RepeatMode + value: string +} + +GridLayoutItemSpec: { + x: int + y: int + width: int + height: int + element: ElementReference // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference + repeat?: RepeatOptions +} + +GridLayoutItemKind: { + kind: "GridLayoutItem" + spec: GridLayoutItemSpec +} + +GridLayoutSpec: { + items: [...GridLayoutItemKind] +} + +GridLayoutKind: { + kind: "GridLayout" + spec: GridLayoutSpec +} + +RowsLayoutKind: { + kind: "RowsLayout" + spec: RowsLayoutSpec +} + +RowsLayoutSpec: { + rows: [...RowsLayoutRowKind] +} + +RowsLayoutRowKind: { + kind: "RowsLayoutRow" + spec: RowsLayoutRowSpec +} + +RowsLayoutRowSpec: { + title?: string + collapse?: bool + hideHeader?: bool + fillScreen?: bool + conditionalRendering?: ConditionalRenderingGroupKind + repeat?: RowRepeatOptions + layout: GridLayoutKind | AutoGridLayoutKind | TabsLayoutKind | RowsLayoutKind +} + +AutoGridLayoutKind: { + kind: "AutoGridLayout" + spec: AutoGridLayoutSpec +} + +AutoGridLayoutSpec: { + maxColumnCount?: number | *3 + columnWidthMode: "narrow" | *"standard" | "wide" | "custom" + columnWidth?: number + rowHeightMode: "short" | *"standard" | "tall" | "custom" + rowHeight?: number + fillScreen?: bool | *false + items: [...AutoGridLayoutItemKind] +} + +AutoGridLayoutItemKind: { + kind: "AutoGridLayoutItem" + spec: AutoGridLayoutItemSpec +} + +AutoGridLayoutItemSpec: { + element: ElementReference + repeat?: AutoGridRepeatOptions + conditionalRendering?: ConditionalRenderingGroupKind +} + +TabsLayoutKind: { + kind: "TabsLayout" + spec: TabsLayoutSpec +} + +TabsLayoutSpec: { + tabs: [...TabsLayoutTabKind] +} + +TabsLayoutTabKind: { + kind: "TabsLayoutTab" + spec: TabsLayoutTabSpec +} + +TabsLayoutTabSpec: { + title?: string + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind + conditionalRendering?: ConditionalRenderingGroupKind + repeat?: TabRepeatOptions +} + +PanelSpec: { + id: number + title: string + description: string + links: [...DataLink] + data: QueryGroupKind + vizConfig: VizConfigKind + transparent?: bool +} + +PanelKind: { + kind: "Panel" + spec: PanelSpec +} + +ElementReference: { + kind: "ElementReference" + name: string +} + +// Start FIXME: variables - in CUE PR - this are things that should be added into the cue schema +// TODO: properties such as `hide`, `skipUrlSync`, `multi` are type boolean, and in the old schema they are conditional, +// should we make them conditional in the new schema as well? or should we make them required but default to false? + +// Variable types +VariableValue: VariableValueSingle | [...VariableValueSingle] + +VariableValueSingle: string | bool | number | CustomVariableValue + +// Custom formatter variable +CustomFormatterVariable: { + name: string + type: VariableType + multi: bool + includeAll: bool +} + +// Custom variable value +CustomVariableValue: { + // The format name or function used in the expression + formatter: *null | string | VariableCustomFormatterFn +} + +// Custom formatter function +VariableCustomFormatterFn: { + value: _ + legacyVariableModel: { + name: string + type: VariableType + multi: bool + includeAll: bool + } + legacyDefaultFormatter?: VariableCustomFormatterFn +} + +// Dashboard variable type +// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. +// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). +// `constant`: Define a hidden constant. +// `datasource`: Quickly change the data source for an entire dashboard. +// `interval`: Interval variables represent time spans. +// `textbox`: Display a free text input field with an optional default value. +// `custom`: Define the variable options manually using a comma-separated list. +// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables +VariableType: "query" | "adhoc" | "groupby" | "constant" | "datasource" | "interval" | "textbox" | "custom" | + "system" | "snapshot" + +VariableKind: QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind + +// Sort variable options +// Accepted values are: +// `disabled`: No sorting +// `alphabeticalAsc`: Alphabetical ASC +// `alphabeticalDesc`: Alphabetical DESC +// `numericalAsc`: Numerical ASC +// `numericalDesc`: Numerical DESC +// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC +// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC +// `naturalAsc`: Natural ASC +// `naturalDesc`: Natural DESC +// VariableSort enum with default value +VariableSort: "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc" + +// Options to config when to refresh a variable +// `never`: Never refresh the variable +// `onDashboardLoad`: Queries the data source every time the dashboard loads. +// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes. +VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged" + +// Determine if the variable shows on dashboard +// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing). +VariableHide: *"dontHide" | "hideLabel" | "hideVariable" + +// Determine the origin of the adhoc variable filter +FilterOrigin: "dashboard" + +// FIXME: should we introduce this? --- Variable value option +VariableValueOption: { + label: string + value: VariableValueSingle + group?: string +} + +// Variable option specification +VariableOption: { + // Whether the option is selected or not + selected?: bool + // Text to be displayed for the option + text: string | [...string] + // Value of the option + value: string | [...string] +} + +// Query variable specification +QueryVariableSpec: { + name: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + label?: string + hide: VariableHide + refresh: VariableRefresh + skipUrlSync: bool | *false + description?: string + datasource?: DataSourceRef + query: DataQueryKind + regex: string | *"" + sort: VariableSort + definition?: string + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + placeholder?: string + allowCustomValue: bool | *true + staticOptions?: [...VariableOption] + staticOptionsOrder?: "before" | "after" | "sorted" +} + +// Query variable kind +QueryVariableKind: { + kind: "QueryVariable" + spec: QueryVariableSpec +} + +// Text variable specification +TextVariableSpec: { + name: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + query: string | *"" + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Text variable kind +TextVariableKind: { + kind: "TextVariable" + spec: TextVariableSpec +} + +// Constant variable specification +ConstantVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Constant variable kind +ConstantVariableKind: { + kind: "ConstantVariable" + spec: ConstantVariableSpec +} + +// Datasource variable specification +DatasourceVariableSpec: { + name: string | *"" + pluginId: string | *"" + refresh: VariableRefresh + regex: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Datasource variable kind +DatasourceVariableKind: { + kind: "DatasourceVariable" + spec: DatasourceVariableSpec +} + +// Interval variable specification +IntervalVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + auto: bool | *false + auto_min: string | *"" + auto_count: int | *0 + refresh: VariableRefresh + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Interval variable kind +IntervalVariableKind: { + kind: "IntervalVariable" + spec: IntervalVariableSpec +} + +// Custom variable specification +CustomVariableSpec: { + name: string | *"" + query: string | *"" + current: VariableOption + options: [...VariableOption] | *[] + multi: bool | *false + includeAll: bool | *false + allValue?: string + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Custom variable kind +CustomVariableKind: { + kind: "CustomVariable" + spec: CustomVariableSpec +} + +// GroupBy variable specification +GroupByVariableSpec: { + name: string | *"" + datasource?: DataSourceRef + defaultValue?: VariableOption + current: VariableOption | *{ + text: "" + value: "" + } + options: [...VariableOption] | *[] + multi: bool | *false + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string +} + +// Group variable kind +GroupByVariableKind: { + kind: "GroupByVariable" + spec: GroupByVariableSpec +} + +// Adhoc variable specification +AdhocVariableSpec: { + name: string | *"" + datasource?: DataSourceRef + baseFilters: [...AdHocFilterWithLabels] | *[] + filters: [...AdHocFilterWithLabels] | *[] + defaultKeys: [...MetricFindValue] | *[] + label?: string + hide: VariableHide + skipUrlSync: bool | *false + description?: string + allowCustomValue: bool | *true +} + +// Define the MetricFindValue type +MetricFindValue: { + text: string + value?: string | number + group?: string + expandable?: bool +} + +// Define the AdHocFilterWithLabels type +AdHocFilterWithLabels: { + key: string + operator: string + value: string + values?: [...string] + keyLabel?: string + valueLabels?: [...string] + forceEdit?: bool + origin?: FilterOrigin + // @deprecated + condition?: string +} + +// Adhoc variable kind +AdhocVariableKind: { + kind: "AdhocVariable" + spec: AdhocVariableSpec +} + +ConditionalRenderingGroupKind: { + kind: "ConditionalRenderingGroup" + spec: ConditionalRenderingGroupSpec +} + +ConditionalRenderingGroupSpec: { + visibility: "show" | "hide" + condition: "and" | "or" + items: [...ConditionalRenderingVariableKind | ConditionalRenderingDataKind | ConditionalRenderingTimeRangeSizeKind] +} + +ConditionalRenderingVariableKind: { + kind: "ConditionalRenderingVariable" + spec: ConditionalRenderingVariableSpec +} + +ConditionalRenderingVariableSpec: { + variable: string + operator: "equals" | "notEquals" + value: string +} + +ConditionalRenderingDataKind: { + kind: "ConditionalRenderingData" + spec: ConditionalRenderingDataSpec +} + +ConditionalRenderingDataSpec: { + value: bool +} + +ConditionalRenderingTimeRangeSizeKind: { + kind: "ConditionalRenderingTimeRangeSize" + spec: ConditionalRenderingTimeRangeSizeSpec +} + +ConditionalRenderingTimeRangeSizeSpec: { + value: string +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go new file mode 100644 index 00000000000..32b90053977 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go @@ -0,0 +1,2540 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha2 + +import ( + json "encoding/json" + errors "errors" +) + +// +k8s:openapi-gen=true +type DashboardAnnotationQueryKind struct { + Kind string `json:"kind"` + Spec DashboardAnnotationQuerySpec `json:"spec"` +} + +// NewDashboardAnnotationQueryKind creates a new DashboardAnnotationQueryKind object. +func NewDashboardAnnotationQueryKind() *DashboardAnnotationQueryKind { + return &DashboardAnnotationQueryKind{ + Kind: "AnnotationQuery", + Spec: *NewDashboardAnnotationQuerySpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardAnnotationQuerySpec struct { + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + Query *DashboardDataQueryKind `json:"query,omitempty"` + Enable bool `json:"enable"` + Hide bool `json:"hide"` + IconColor string `json:"iconColor"` + Name string `json:"name"` + BuiltIn *bool `json:"builtIn,omitempty"` + Filter *DashboardAnnotationPanelFilter `json:"filter,omitempty"` + // Catch-all field for datasource-specific properties + LegacyOptions map[string]interface{} `json:"legacyOptions,omitempty"` +} + +// NewDashboardAnnotationQuerySpec creates a new DashboardAnnotationQuerySpec object. +func NewDashboardAnnotationQuerySpec() *DashboardAnnotationQuerySpec { + return &DashboardAnnotationQuerySpec{ + BuiltIn: (func(input bool) *bool { return &input })(false), + } +} + +// +k8s:openapi-gen=true +type DashboardDataSourceRef struct { + // The plugin type-id + Type *string `json:"type,omitempty"` + // Specific datasource instance + Uid *string `json:"uid,omitempty"` +} + +// NewDashboardDataSourceRef creates a new DashboardDataSourceRef object. +func NewDashboardDataSourceRef() *DashboardDataSourceRef { + return &DashboardDataSourceRef{} +} + +// +k8s:openapi-gen=true +type DashboardDataQueryKind struct { + // The kind of a DataQueryKind is the datasource type + Kind string `json:"kind"` + Spec map[string]interface{} `json:"spec"` +} + +// NewDashboardDataQueryKind creates a new DashboardDataQueryKind object. +func NewDashboardDataQueryKind() *DashboardDataQueryKind { + return &DashboardDataQueryKind{ + Spec: map[string]interface{}{}, + } +} + +// +k8s:openapi-gen=true +type DashboardAnnotationPanelFilter struct { + // Should the specified panels be included or excluded + Exclude *bool `json:"exclude,omitempty"` + // Panel IDs that should be included or excluded + Ids []uint32 `json:"ids"` +} + +// NewDashboardAnnotationPanelFilter creates a new DashboardAnnotationPanelFilter object. +func NewDashboardAnnotationPanelFilter() *DashboardAnnotationPanelFilter { + return &DashboardAnnotationPanelFilter{ + Exclude: (func(input bool) *bool { return &input })(false), + Ids: []uint32{}, + } +} + +// "Off" for no shared crosshair or tooltip (default). +// "Crosshair" for shared crosshair. +// "Tooltip" for shared crosshair AND shared tooltip. +// +k8s:openapi-gen=true +type DashboardDashboardCursorSync string + +const ( + DashboardDashboardCursorSyncCrosshair DashboardDashboardCursorSync = "Crosshair" + DashboardDashboardCursorSyncTooltip DashboardDashboardCursorSync = "Tooltip" + DashboardDashboardCursorSyncOff DashboardDashboardCursorSync = "Off" +) + +// Supported dashboard elements +// |* more element types in the future +// +k8s:openapi-gen=true +type DashboardElement = DashboardPanelKindOrLibraryPanelKind + +// NewDashboardElement creates a new DashboardElement object. +func NewDashboardElement() *DashboardElement { + return NewDashboardPanelKindOrLibraryPanelKind() +} + +// +k8s:openapi-gen=true +type DashboardPanelKind struct { + Kind string `json:"kind"` + Spec DashboardPanelSpec `json:"spec"` +} + +// NewDashboardPanelKind creates a new DashboardPanelKind object. +func NewDashboardPanelKind() *DashboardPanelKind { + return &DashboardPanelKind{ + Kind: "Panel", + Spec: *NewDashboardPanelSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardPanelSpec struct { + Id float64 `json:"id"` + Title string `json:"title"` + Description string `json:"description"` + Links []DashboardDataLink `json:"links"` + Data DashboardQueryGroupKind `json:"data"` + VizConfig DashboardVizConfigKind `json:"vizConfig"` + Transparent *bool `json:"transparent,omitempty"` +} + +// NewDashboardPanelSpec creates a new DashboardPanelSpec object. +func NewDashboardPanelSpec() *DashboardPanelSpec { + return &DashboardPanelSpec{ + Links: []DashboardDataLink{}, + Data: *NewDashboardQueryGroupKind(), + VizConfig: *NewDashboardVizConfigKind(), + } +} + +// +k8s:openapi-gen=true +type DashboardDataLink struct { + Title string `json:"title"` + Url string `json:"url"` + TargetBlank *bool `json:"targetBlank,omitempty"` +} + +// NewDashboardDataLink creates a new DashboardDataLink object. +func NewDashboardDataLink() *DashboardDataLink { + return &DashboardDataLink{} +} + +// +k8s:openapi-gen=true +type DashboardQueryGroupKind struct { + Kind string `json:"kind"` + Spec DashboardQueryGroupSpec `json:"spec"` +} + +// NewDashboardQueryGroupKind creates a new DashboardQueryGroupKind object. +func NewDashboardQueryGroupKind() *DashboardQueryGroupKind { + return &DashboardQueryGroupKind{ + Kind: "QueryGroup", + Spec: *NewDashboardQueryGroupSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardQueryGroupSpec struct { + Queries []DashboardPanelQueryKind `json:"queries"` + Transformations []DashboardTransformationKind `json:"transformations"` + QueryOptions DashboardQueryOptionsSpec `json:"queryOptions"` +} + +// NewDashboardQueryGroupSpec creates a new DashboardQueryGroupSpec object. +func NewDashboardQueryGroupSpec() *DashboardQueryGroupSpec { + return &DashboardQueryGroupSpec{ + Queries: []DashboardPanelQueryKind{}, + Transformations: []DashboardTransformationKind{}, + QueryOptions: *NewDashboardQueryOptionsSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardPanelQueryKind struct { + Kind string `json:"kind"` + Spec DashboardPanelQuerySpec `json:"spec"` +} + +// NewDashboardPanelQueryKind creates a new DashboardPanelQueryKind object. +func NewDashboardPanelQueryKind() *DashboardPanelQueryKind { + return &DashboardPanelQueryKind{ + Kind: "PanelQuery", + Spec: *NewDashboardPanelQuerySpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardPanelQuerySpec struct { + Query DashboardDataQueryKind `json:"query"` + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + RefId string `json:"refId"` + Hidden bool `json:"hidden"` +} + +// NewDashboardPanelQuerySpec creates a new DashboardPanelQuerySpec object. +func NewDashboardPanelQuerySpec() *DashboardPanelQuerySpec { + return &DashboardPanelQuerySpec{ + Query: *NewDashboardDataQueryKind(), + } +} + +// +k8s:openapi-gen=true +type DashboardTransformationKind struct { + // The kind of a TransformationKind is the transformation ID + Kind string `json:"kind"` + Spec DashboardDataTransformerConfig `json:"spec"` +} + +// NewDashboardTransformationKind creates a new DashboardTransformationKind object. +func NewDashboardTransformationKind() *DashboardTransformationKind { + return &DashboardTransformationKind{ + Spec: *NewDashboardDataTransformerConfig(), + } +} + +// Transformations allow to manipulate data returned by a query before the system applies a visualization. +// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, +// use the output of one transformation as the input to another transformation, etc. +// +k8s:openapi-gen=true +type DashboardDataTransformerConfig struct { + // Unique identifier of transformer + Id string `json:"id"` + // Disabled transformations are skipped + Disabled *bool `json:"disabled,omitempty"` + // Optional frame matcher. When missing it will be applied to all results + Filter *DashboardMatcherConfig `json:"filter,omitempty"` + // Where to pull DataFrames from as input to transformation + Topic *DashboardDataTopic `json:"topic,omitempty"` + // Options to be passed to the transformer + // Valid options depend on the transformer id + Options interface{} `json:"options"` +} + +// NewDashboardDataTransformerConfig creates a new DashboardDataTransformerConfig object. +func NewDashboardDataTransformerConfig() *DashboardDataTransformerConfig { + return &DashboardDataTransformerConfig{} +} + +// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. +// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type. +// +k8s:openapi-gen=true +type DashboardMatcherConfig struct { + // The matcher id. This is used to find the matcher implementation from registry. + Id string `json:"id"` + // The matcher options. This is specific to the matcher implementation. + Options interface{} `json:"options,omitempty"` +} + +// NewDashboardMatcherConfig creates a new DashboardMatcherConfig object. +func NewDashboardMatcherConfig() *DashboardMatcherConfig { + return &DashboardMatcherConfig{ + Id: "", + } +} + +// A topic is attached to DataFrame metadata in query results. +// This specifies where the data should be used. +// +k8s:openapi-gen=true +type DashboardDataTopic string + +const ( + DashboardDataTopicSeries DashboardDataTopic = "series" + DashboardDataTopicAnnotations DashboardDataTopic = "annotations" + DashboardDataTopicAlertStates DashboardDataTopic = "alertStates" +) + +// +k8s:openapi-gen=true +type DashboardQueryOptionsSpec struct { + TimeFrom *string `json:"timeFrom,omitempty"` + MaxDataPoints *int64 `json:"maxDataPoints,omitempty"` + TimeShift *string `json:"timeShift,omitempty"` + QueryCachingTTL *int64 `json:"queryCachingTTL,omitempty"` + Interval *string `json:"interval,omitempty"` + CacheTimeout *string `json:"cacheTimeout,omitempty"` + HideTimeOverride *bool `json:"hideTimeOverride,omitempty"` +} + +// NewDashboardQueryOptionsSpec creates a new DashboardQueryOptionsSpec object. +func NewDashboardQueryOptionsSpec() *DashboardQueryOptionsSpec { + return &DashboardQueryOptionsSpec{} +} + +// +k8s:openapi-gen=true +type DashboardVizConfigKind struct { + // The kind of a VizConfigKind is the plugin ID + Kind string `json:"kind"` + Spec DashboardVizConfigSpec `json:"spec"` +} + +// NewDashboardVizConfigKind creates a new DashboardVizConfigKind object. +func NewDashboardVizConfigKind() *DashboardVizConfigKind { + return &DashboardVizConfigKind{ + Spec: *NewDashboardVizConfigSpec(), + } +} + +// --- Kinds --- +// +k8s:openapi-gen=true +type DashboardVizConfigSpec struct { + PluginVersion string `json:"pluginVersion"` + Options map[string]interface{} `json:"options"` + FieldConfig DashboardFieldConfigSource `json:"fieldConfig"` +} + +// NewDashboardVizConfigSpec creates a new DashboardVizConfigSpec object. +func NewDashboardVizConfigSpec() *DashboardVizConfigSpec { + return &DashboardVizConfigSpec{ + Options: map[string]interface{}{}, + FieldConfig: *NewDashboardFieldConfigSource(), + } +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +// +k8s:openapi-gen=true +type DashboardFieldConfigSource struct { + // Defaults are the options applied to all fields. + Defaults DashboardFieldConfig `json:"defaults"` + // Overrides are the options applied to specific fields overriding the defaults. + Overrides []DashboardV2alpha2FieldConfigSourceOverrides `json:"overrides"` +} + +// NewDashboardFieldConfigSource creates a new DashboardFieldConfigSource object. +func NewDashboardFieldConfigSource() *DashboardFieldConfigSource { + return &DashboardFieldConfigSource{ + Defaults: *NewDashboardFieldConfig(), + Overrides: []DashboardV2alpha2FieldConfigSourceOverrides{}, + } +} + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +// +k8s:openapi-gen=true +type DashboardFieldConfig struct { + // The display value for this field. This supports template variables blank is auto + DisplayName *string `json:"displayName,omitempty"` + // This can be used by data sources that return and explicit naming structure for values and labels + // When this property is configured, this value is used rather than the default naming strategy. + DisplayNameFromDS *string `json:"displayNameFromDS,omitempty"` + // Human readable field metadata + Description *string `json:"description,omitempty"` + // An explicit path to the field in the datasource. When the frame meta includes a path, + // This will default to `${frame.meta.path}/${field.name} + // + // When defined, this value can be used as an identifier within the datasource scope, and + // may be used to update the results + Path *string `json:"path,omitempty"` + // True if data source can write a value to the path. Auth/authz are supported separately + Writeable *bool `json:"writeable,omitempty"` + // True if data source field supports ad-hoc filters + Filterable *bool `json:"filterable,omitempty"` + // Unit a field should use. The unit you select is applied to all fields except time. + // You can use the units ID availables in Grafana or a custom unit. + // Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts + // As custom unit, you can use the following formats: + // `suffix:` for custom unit that should go after value. + // `prefix:` for custom unit that should go before value. + // `time:` For custom date time formats type for example `time:YYYY-MM-DD`. + // `si:` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. + // `count:` for a custom count unit. + // `currency:` for custom a currency unit. + Unit *string `json:"unit,omitempty"` + // Specify the number of decimals Grafana includes in the rendered value. + // If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. + // For example 1.1234 will display as 1.12 and 100.456 will display as 100. + // To display all decimals, set the unit to `String`. + Decimals *float64 `json:"decimals,omitempty"` + // The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + Min *float64 `json:"min,omitempty"` + // The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + Max *float64 `json:"max,omitempty"` + // Convert input values into a display string + Mappings []DashboardValueMapping `json:"mappings,omitempty"` + // Map numeric values to states + Thresholds *DashboardThresholdsConfig `json:"thresholds,omitempty"` + // Panel color configuration + Color *DashboardFieldColor `json:"color,omitempty"` + // The behavior when clicking on a result + Links []interface{} `json:"links,omitempty"` + // Alternative to empty string + NoValue *string `json:"noValue,omitempty"` + // custom is specified by the FieldConfig field + // in panel plugin schemas. + Custom map[string]interface{} `json:"custom,omitempty"` +} + +// NewDashboardFieldConfig creates a new DashboardFieldConfig object. +func NewDashboardFieldConfig() *DashboardFieldConfig { + return &DashboardFieldConfig{} +} + +// +k8s:openapi-gen=true +type DashboardValueMapping = DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap + +// NewDashboardValueMapping creates a new DashboardValueMapping object. +func NewDashboardValueMapping() *DashboardValueMapping { + return NewDashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap() +} + +// Maps text values to a color or different display text and color. +// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +// +k8s:openapi-gen=true +type DashboardValueMap struct { + Type DashboardMappingType `json:"type"` + // Map with : ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } + Options map[string]DashboardValueMappingResult `json:"options"` +} + +// NewDashboardValueMap creates a new DashboardValueMap object. +func NewDashboardValueMap() *DashboardValueMap { + return &DashboardValueMap{ + Type: DashboardMappingTypeValue, + Options: map[string]DashboardValueMappingResult{}, + } +} + +// Supported value mapping types +// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A. +// +k8s:openapi-gen=true +type DashboardMappingType string + +const ( + DashboardMappingTypeValue DashboardMappingType = "value" + DashboardMappingTypeRange DashboardMappingType = "range" + DashboardMappingTypeRegex DashboardMappingType = "regex" + DashboardMappingTypeSpecial DashboardMappingType = "special" +) + +// Result used as replacement with text and color when the value matches +// +k8s:openapi-gen=true +type DashboardValueMappingResult struct { + // Text to display when the value matches + Text *string `json:"text,omitempty"` + // Text to use when the value matches + Color *string `json:"color,omitempty"` + // Icon to display when the value matches. Only specific visualizations. + Icon *string `json:"icon,omitempty"` + // Position in the mapping array. Only used internally. + Index *int32 `json:"index,omitempty"` +} + +// NewDashboardValueMappingResult creates a new DashboardValueMappingResult object. +func NewDashboardValueMappingResult() *DashboardValueMappingResult { + return &DashboardValueMappingResult{} +} + +// Maps numerical ranges to a display text and color. +// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +// +k8s:openapi-gen=true +type DashboardRangeMap struct { + Type DashboardMappingType `json:"type"` + // Range to match against and the result to apply when the value is within the range + Options DashboardV2alpha2RangeMapOptions `json:"options"` +} + +// NewDashboardRangeMap creates a new DashboardRangeMap object. +func NewDashboardRangeMap() *DashboardRangeMap { + return &DashboardRangeMap{ + Type: DashboardMappingTypeRange, + Options: *NewDashboardV2alpha2RangeMapOptions(), + } +} + +// Maps regular expressions to replacement text and a color. +// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +// +k8s:openapi-gen=true +type DashboardRegexMap struct { + Type DashboardMappingType `json:"type"` + // Regular expression to match against and the result to apply when the value matches the regex + Options DashboardV2alpha2RegexMapOptions `json:"options"` +} + +// NewDashboardRegexMap creates a new DashboardRegexMap object. +func NewDashboardRegexMap() *DashboardRegexMap { + return &DashboardRegexMap{ + Type: DashboardMappingTypeRegex, + Options: *NewDashboardV2alpha2RegexMapOptions(), + } +} + +// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. +// See SpecialValueMatch to see the list of special values. +// For example, you can configure a special value mapping so that null values appear as N/A. +// +k8s:openapi-gen=true +type DashboardSpecialValueMap struct { + Type DashboardMappingType `json:"type"` + Options DashboardV2alpha2SpecialValueMapOptions `json:"options"` +} + +// NewDashboardSpecialValueMap creates a new DashboardSpecialValueMap object. +func NewDashboardSpecialValueMap() *DashboardSpecialValueMap { + return &DashboardSpecialValueMap{ + Type: DashboardMappingTypeSpecial, + Options: *NewDashboardV2alpha2SpecialValueMapOptions(), + } +} + +// Special value types supported by the `SpecialValueMap` +// +k8s:openapi-gen=true +type DashboardSpecialValueMatch string + +const ( + DashboardSpecialValueMatchTrue DashboardSpecialValueMatch = "true" + DashboardSpecialValueMatchFalse DashboardSpecialValueMatch = "false" + DashboardSpecialValueMatchNull DashboardSpecialValueMatch = "null" + DashboardSpecialValueMatchNaN DashboardSpecialValueMatch = "nan" + DashboardSpecialValueMatchNullAndNaN DashboardSpecialValueMatch = "null+nan" + DashboardSpecialValueMatchEmpty DashboardSpecialValueMatch = "empty" +) + +// +k8s:openapi-gen=true +type DashboardThresholdsConfig struct { + Mode DashboardThresholdsMode `json:"mode"` + Steps []DashboardThreshold `json:"steps"` +} + +// NewDashboardThresholdsConfig creates a new DashboardThresholdsConfig object. +func NewDashboardThresholdsConfig() *DashboardThresholdsConfig { + return &DashboardThresholdsConfig{ + Steps: []DashboardThreshold{}, + } +} + +// +k8s:openapi-gen=true +type DashboardThresholdsMode string + +const ( + DashboardThresholdsModeAbsolute DashboardThresholdsMode = "absolute" + DashboardThresholdsModePercentage DashboardThresholdsMode = "percentage" +) + +// +k8s:openapi-gen=true +type DashboardThreshold struct { + Value float64 `json:"value"` + Color string `json:"color"` +} + +// NewDashboardThreshold creates a new DashboardThreshold object. +func NewDashboardThreshold() *DashboardThreshold { + return &DashboardThreshold{} +} + +// Map a field to a color. +// +k8s:openapi-gen=true +type DashboardFieldColor struct { + // The main color scheme mode. + Mode DashboardFieldColorModeId `json:"mode"` + // The fixed color value for fixed or shades color modes. + FixedColor *string `json:"fixedColor,omitempty"` + // Some visualizations need to know how to assign a series color from by value color schemes. + SeriesBy *DashboardFieldColorSeriesByMode `json:"seriesBy,omitempty"` +} + +// NewDashboardFieldColor creates a new DashboardFieldColor object. +func NewDashboardFieldColor() *DashboardFieldColor { + return &DashboardFieldColor{} +} + +// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. +// Continuous color interpolates a color using the percentage of a value relative to min and max. +// Accepted values are: +// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold +// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations +// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations +// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode +// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode +// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode +// `continuous-YlRd`: Continuous Yellow-Red palette mode +// `continuous-BlPu`: Continuous Blue-Purple palette mode +// `continuous-YlBl`: Continuous Yellow-Blue palette mode +// `continuous-blues`: Continuous Blue palette mode +// `continuous-reds`: Continuous Red palette mode +// `continuous-greens`: Continuous Green palette mode +// `continuous-purples`: Continuous Purple palette mode +// `shades`: Shades of a single color. Specify a single color, useful in an override rule. +// `fixed`: Fixed color mode. Specify a single color, useful in an override rule. +// +k8s:openapi-gen=true +type DashboardFieldColorModeId string + +const ( + DashboardFieldColorModeIdThresholds DashboardFieldColorModeId = "thresholds" + DashboardFieldColorModeIdPaletteClassic DashboardFieldColorModeId = "palette-classic" + DashboardFieldColorModeIdPaletteClassicByName DashboardFieldColorModeId = "palette-classic-by-name" + DashboardFieldColorModeIdContinuousGrYlRd DashboardFieldColorModeId = "continuous-GrYlRd" + DashboardFieldColorModeIdContinuousRdYlGr DashboardFieldColorModeId = "continuous-RdYlGr" + DashboardFieldColorModeIdContinuousBlYlRd DashboardFieldColorModeId = "continuous-BlYlRd" + DashboardFieldColorModeIdContinuousYlRd DashboardFieldColorModeId = "continuous-YlRd" + DashboardFieldColorModeIdContinuousBlPu DashboardFieldColorModeId = "continuous-BlPu" + DashboardFieldColorModeIdContinuousYlBl DashboardFieldColorModeId = "continuous-YlBl" + DashboardFieldColorModeIdContinuousBlues DashboardFieldColorModeId = "continuous-blues" + DashboardFieldColorModeIdContinuousReds DashboardFieldColorModeId = "continuous-reds" + DashboardFieldColorModeIdContinuousGreens DashboardFieldColorModeId = "continuous-greens" + DashboardFieldColorModeIdContinuousPurples DashboardFieldColorModeId = "continuous-purples" + DashboardFieldColorModeIdFixed DashboardFieldColorModeId = "fixed" + DashboardFieldColorModeIdShades DashboardFieldColorModeId = "shades" +) + +// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value. +// +k8s:openapi-gen=true +type DashboardFieldColorSeriesByMode string + +const ( + DashboardFieldColorSeriesByModeMin DashboardFieldColorSeriesByMode = "min" + DashboardFieldColorSeriesByModeMax DashboardFieldColorSeriesByMode = "max" + DashboardFieldColorSeriesByModeLast DashboardFieldColorSeriesByMode = "last" +) + +// +k8s:openapi-gen=true +type DashboardDynamicConfigValue struct { + Id string `json:"id"` + Value interface{} `json:"value,omitempty"` +} + +// NewDashboardDynamicConfigValue creates a new DashboardDynamicConfigValue object. +func NewDashboardDynamicConfigValue() *DashboardDynamicConfigValue { + return &DashboardDynamicConfigValue{ + Id: "", + } +} + +// +k8s:openapi-gen=true +type DashboardLibraryPanelKind struct { + Kind string `json:"kind"` + Spec DashboardLibraryPanelKindSpec `json:"spec"` +} + +// NewDashboardLibraryPanelKind creates a new DashboardLibraryPanelKind object. +func NewDashboardLibraryPanelKind() *DashboardLibraryPanelKind { + return &DashboardLibraryPanelKind{ + Kind: "LibraryPanel", + Spec: *NewDashboardLibraryPanelKindSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardLibraryPanelKindSpec struct { + // Panel ID for the library panel in the dashboard + Id float64 `json:"id"` + // Title for the library panel in the dashboard + Title string `json:"title"` + LibraryPanel DashboardLibraryPanelRef `json:"libraryPanel"` +} + +// NewDashboardLibraryPanelKindSpec creates a new DashboardLibraryPanelKindSpec object. +func NewDashboardLibraryPanelKindSpec() *DashboardLibraryPanelKindSpec { + return &DashboardLibraryPanelKindSpec{ + LibraryPanel: *NewDashboardLibraryPanelRef(), + } +} + +// A library panel is a reusable panel that you can use in any dashboard. +// When you make a change to a library panel, that change propagates to all instances of where the panel is used. +// Library panels streamline reuse of panels across multiple dashboards. +// +k8s:openapi-gen=true +type DashboardLibraryPanelRef struct { + // Library panel name + Name string `json:"name"` + // Library panel uid + Uid string `json:"uid"` +} + +// NewDashboardLibraryPanelRef creates a new DashboardLibraryPanelRef object. +func NewDashboardLibraryPanelRef() *DashboardLibraryPanelRef { + return &DashboardLibraryPanelRef{} +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKind struct { + Kind string `json:"kind"` + Spec DashboardGridLayoutSpec `json:"spec"` +} + +// NewDashboardGridLayoutKind creates a new DashboardGridLayoutKind object. +func NewDashboardGridLayoutKind() *DashboardGridLayoutKind { + return &DashboardGridLayoutKind{ + Kind: "GridLayout", + Spec: *NewDashboardGridLayoutSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutSpec struct { + Items []DashboardGridLayoutItemKind `json:"items"` +} + +// NewDashboardGridLayoutSpec creates a new DashboardGridLayoutSpec object. +func NewDashboardGridLayoutSpec() *DashboardGridLayoutSpec { + return &DashboardGridLayoutSpec{ + Items: []DashboardGridLayoutItemKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutItemKind struct { + Kind string `json:"kind"` + Spec DashboardGridLayoutItemSpec `json:"spec"` +} + +// NewDashboardGridLayoutItemKind creates a new DashboardGridLayoutItemKind object. +func NewDashboardGridLayoutItemKind() *DashboardGridLayoutItemKind { + return &DashboardGridLayoutItemKind{ + Kind: "GridLayoutItem", + Spec: *NewDashboardGridLayoutItemSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutItemSpec struct { + X int64 `json:"x"` + Y int64 `json:"y"` + Width int64 `json:"width"` + Height int64 `json:"height"` + // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference + Element DashboardElementReference `json:"element"` + Repeat *DashboardRepeatOptions `json:"repeat,omitempty"` +} + +// NewDashboardGridLayoutItemSpec creates a new DashboardGridLayoutItemSpec object. +func NewDashboardGridLayoutItemSpec() *DashboardGridLayoutItemSpec { + return &DashboardGridLayoutItemSpec{ + Element: *NewDashboardElementReference(), + } +} + +// +k8s:openapi-gen=true +type DashboardElementReference struct { + Kind string `json:"kind"` + Name string `json:"name"` +} + +// NewDashboardElementReference creates a new DashboardElementReference object. +func NewDashboardElementReference() *DashboardElementReference { + return &DashboardElementReference{ + Kind: "ElementReference", + } +} + +// +k8s:openapi-gen=true +type DashboardRepeatOptions struct { + Mode string `json:"mode"` + Value string `json:"value"` + Direction *DashboardRepeatOptionsDirection `json:"direction,omitempty"` + MaxPerRow *int64 `json:"maxPerRow,omitempty"` +} + +// NewDashboardRepeatOptions creates a new DashboardRepeatOptions object. +func NewDashboardRepeatOptions() *DashboardRepeatOptions { + return &DashboardRepeatOptions{ + Mode: DashboardRepeatMode, + } +} + +// other repeat modes will be added in the future: label, frame +// +k8s:openapi-gen=true +const DashboardRepeatMode = "variable" + +// +k8s:openapi-gen=true +type DashboardRowsLayoutKind struct { + Kind string `json:"kind"` + Spec DashboardRowsLayoutSpec `json:"spec"` +} + +// NewDashboardRowsLayoutKind creates a new DashboardRowsLayoutKind object. +func NewDashboardRowsLayoutKind() *DashboardRowsLayoutKind { + return &DashboardRowsLayoutKind{ + Kind: "RowsLayout", + Spec: *NewDashboardRowsLayoutSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardRowsLayoutSpec struct { + Rows []DashboardRowsLayoutRowKind `json:"rows"` +} + +// NewDashboardRowsLayoutSpec creates a new DashboardRowsLayoutSpec object. +func NewDashboardRowsLayoutSpec() *DashboardRowsLayoutSpec { + return &DashboardRowsLayoutSpec{ + Rows: []DashboardRowsLayoutRowKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardRowsLayoutRowKind struct { + Kind string `json:"kind"` + Spec DashboardRowsLayoutRowSpec `json:"spec"` +} + +// NewDashboardRowsLayoutRowKind creates a new DashboardRowsLayoutRowKind object. +func NewDashboardRowsLayoutRowKind() *DashboardRowsLayoutRowKind { + return &DashboardRowsLayoutRowKind{ + Kind: "RowsLayoutRow", + Spec: *NewDashboardRowsLayoutRowSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardRowsLayoutRowSpec struct { + Title *string `json:"title,omitempty"` + Collapse *bool `json:"collapse,omitempty"` + HideHeader *bool `json:"hideHeader,omitempty"` + FillScreen *bool `json:"fillScreen,omitempty"` + ConditionalRendering *DashboardConditionalRenderingGroupKind `json:"conditionalRendering,omitempty"` + Repeat *DashboardRowRepeatOptions `json:"repeat,omitempty"` + Layout DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind `json:"layout"` +} + +// NewDashboardRowsLayoutRowSpec creates a new DashboardRowsLayoutRowSpec object. +func NewDashboardRowsLayoutRowSpec() *DashboardRowsLayoutRowSpec { + return &DashboardRowsLayoutRowSpec{ + Layout: *NewDashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind(), + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingGroupKind struct { + Kind string `json:"kind"` + Spec DashboardConditionalRenderingGroupSpec `json:"spec"` +} + +// NewDashboardConditionalRenderingGroupKind creates a new DashboardConditionalRenderingGroupKind object. +func NewDashboardConditionalRenderingGroupKind() *DashboardConditionalRenderingGroupKind { + return &DashboardConditionalRenderingGroupKind{ + Kind: "ConditionalRenderingGroup", + Spec: *NewDashboardConditionalRenderingGroupSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingGroupSpec struct { + Visibility DashboardConditionalRenderingGroupSpecVisibility `json:"visibility"` + Condition DashboardConditionalRenderingGroupSpecCondition `json:"condition"` + Items []DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind `json:"items"` +} + +// NewDashboardConditionalRenderingGroupSpec creates a new DashboardConditionalRenderingGroupSpec object. +func NewDashboardConditionalRenderingGroupSpec() *DashboardConditionalRenderingGroupSpec { + return &DashboardConditionalRenderingGroupSpec{ + Items: []DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingVariableKind struct { + Kind string `json:"kind"` + Spec DashboardConditionalRenderingVariableSpec `json:"spec"` +} + +// NewDashboardConditionalRenderingVariableKind creates a new DashboardConditionalRenderingVariableKind object. +func NewDashboardConditionalRenderingVariableKind() *DashboardConditionalRenderingVariableKind { + return &DashboardConditionalRenderingVariableKind{ + Kind: "ConditionalRenderingVariable", + Spec: *NewDashboardConditionalRenderingVariableSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingVariableSpec struct { + Variable string `json:"variable"` + Operator DashboardConditionalRenderingVariableSpecOperator `json:"operator"` + Value string `json:"value"` +} + +// NewDashboardConditionalRenderingVariableSpec creates a new DashboardConditionalRenderingVariableSpec object. +func NewDashboardConditionalRenderingVariableSpec() *DashboardConditionalRenderingVariableSpec { + return &DashboardConditionalRenderingVariableSpec{} +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingDataKind struct { + Kind string `json:"kind"` + Spec DashboardConditionalRenderingDataSpec `json:"spec"` +} + +// NewDashboardConditionalRenderingDataKind creates a new DashboardConditionalRenderingDataKind object. +func NewDashboardConditionalRenderingDataKind() *DashboardConditionalRenderingDataKind { + return &DashboardConditionalRenderingDataKind{ + Kind: "ConditionalRenderingData", + Spec: *NewDashboardConditionalRenderingDataSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingDataSpec struct { + Value bool `json:"value"` +} + +// NewDashboardConditionalRenderingDataSpec creates a new DashboardConditionalRenderingDataSpec object. +func NewDashboardConditionalRenderingDataSpec() *DashboardConditionalRenderingDataSpec { + return &DashboardConditionalRenderingDataSpec{} +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingTimeRangeSizeKind struct { + Kind string `json:"kind"` + Spec DashboardConditionalRenderingTimeRangeSizeSpec `json:"spec"` +} + +// NewDashboardConditionalRenderingTimeRangeSizeKind creates a new DashboardConditionalRenderingTimeRangeSizeKind object. +func NewDashboardConditionalRenderingTimeRangeSizeKind() *DashboardConditionalRenderingTimeRangeSizeKind { + return &DashboardConditionalRenderingTimeRangeSizeKind{ + Kind: "ConditionalRenderingTimeRangeSize", + Spec: *NewDashboardConditionalRenderingTimeRangeSizeSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingTimeRangeSizeSpec struct { + Value string `json:"value"` +} + +// NewDashboardConditionalRenderingTimeRangeSizeSpec creates a new DashboardConditionalRenderingTimeRangeSizeSpec object. +func NewDashboardConditionalRenderingTimeRangeSizeSpec() *DashboardConditionalRenderingTimeRangeSizeSpec { + return &DashboardConditionalRenderingTimeRangeSizeSpec{} +} + +// +k8s:openapi-gen=true +type DashboardRowRepeatOptions struct { + Mode string `json:"mode"` + Value string `json:"value"` +} + +// NewDashboardRowRepeatOptions creates a new DashboardRowRepeatOptions object. +func NewDashboardRowRepeatOptions() *DashboardRowRepeatOptions { + return &DashboardRowRepeatOptions{ + Mode: DashboardRepeatMode, + } +} + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutKind struct { + Kind string `json:"kind"` + Spec DashboardAutoGridLayoutSpec `json:"spec"` +} + +// NewDashboardAutoGridLayoutKind creates a new DashboardAutoGridLayoutKind object. +func NewDashboardAutoGridLayoutKind() *DashboardAutoGridLayoutKind { + return &DashboardAutoGridLayoutKind{ + Kind: "AutoGridLayout", + Spec: *NewDashboardAutoGridLayoutSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutSpec struct { + MaxColumnCount *float64 `json:"maxColumnCount,omitempty"` + ColumnWidthMode DashboardAutoGridLayoutSpecColumnWidthMode `json:"columnWidthMode"` + ColumnWidth *float64 `json:"columnWidth,omitempty"` + RowHeightMode DashboardAutoGridLayoutSpecRowHeightMode `json:"rowHeightMode"` + RowHeight *float64 `json:"rowHeight,omitempty"` + FillScreen *bool `json:"fillScreen,omitempty"` + Items []DashboardAutoGridLayoutItemKind `json:"items"` +} + +// NewDashboardAutoGridLayoutSpec creates a new DashboardAutoGridLayoutSpec object. +func NewDashboardAutoGridLayoutSpec() *DashboardAutoGridLayoutSpec { + return &DashboardAutoGridLayoutSpec{ + MaxColumnCount: (func(input float64) *float64 { return &input })(3), + FillScreen: (func(input bool) *bool { return &input })(false), + Items: []DashboardAutoGridLayoutItemKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutItemKind struct { + Kind string `json:"kind"` + Spec DashboardAutoGridLayoutItemSpec `json:"spec"` +} + +// NewDashboardAutoGridLayoutItemKind creates a new DashboardAutoGridLayoutItemKind object. +func NewDashboardAutoGridLayoutItemKind() *DashboardAutoGridLayoutItemKind { + return &DashboardAutoGridLayoutItemKind{ + Kind: "AutoGridLayoutItem", + Spec: *NewDashboardAutoGridLayoutItemSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutItemSpec struct { + Element DashboardElementReference `json:"element"` + Repeat *DashboardAutoGridRepeatOptions `json:"repeat,omitempty"` + ConditionalRendering *DashboardConditionalRenderingGroupKind `json:"conditionalRendering,omitempty"` +} + +// NewDashboardAutoGridLayoutItemSpec creates a new DashboardAutoGridLayoutItemSpec object. +func NewDashboardAutoGridLayoutItemSpec() *DashboardAutoGridLayoutItemSpec { + return &DashboardAutoGridLayoutItemSpec{ + Element: *NewDashboardElementReference(), + } +} + +// +k8s:openapi-gen=true +type DashboardAutoGridRepeatOptions struct { + Mode string `json:"mode"` + Value string `json:"value"` +} + +// NewDashboardAutoGridRepeatOptions creates a new DashboardAutoGridRepeatOptions object. +func NewDashboardAutoGridRepeatOptions() *DashboardAutoGridRepeatOptions { + return &DashboardAutoGridRepeatOptions{ + Mode: DashboardRepeatMode, + } +} + +// +k8s:openapi-gen=true +type DashboardTabsLayoutKind struct { + Kind string `json:"kind"` + Spec DashboardTabsLayoutSpec `json:"spec"` +} + +// NewDashboardTabsLayoutKind creates a new DashboardTabsLayoutKind object. +func NewDashboardTabsLayoutKind() *DashboardTabsLayoutKind { + return &DashboardTabsLayoutKind{ + Kind: "TabsLayout", + Spec: *NewDashboardTabsLayoutSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardTabsLayoutSpec struct { + Tabs []DashboardTabsLayoutTabKind `json:"tabs"` +} + +// NewDashboardTabsLayoutSpec creates a new DashboardTabsLayoutSpec object. +func NewDashboardTabsLayoutSpec() *DashboardTabsLayoutSpec { + return &DashboardTabsLayoutSpec{ + Tabs: []DashboardTabsLayoutTabKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardTabsLayoutTabKind struct { + Kind string `json:"kind"` + Spec DashboardTabsLayoutTabSpec `json:"spec"` +} + +// NewDashboardTabsLayoutTabKind creates a new DashboardTabsLayoutTabKind object. +func NewDashboardTabsLayoutTabKind() *DashboardTabsLayoutTabKind { + return &DashboardTabsLayoutTabKind{ + Kind: "TabsLayoutTab", + Spec: *NewDashboardTabsLayoutTabSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardTabsLayoutTabSpec struct { + Title *string `json:"title,omitempty"` + Layout DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind `json:"layout"` + ConditionalRendering *DashboardConditionalRenderingGroupKind `json:"conditionalRendering,omitempty"` + Repeat *DashboardTabRepeatOptions `json:"repeat,omitempty"` +} + +// NewDashboardTabsLayoutTabSpec creates a new DashboardTabsLayoutTabSpec object. +func NewDashboardTabsLayoutTabSpec() *DashboardTabsLayoutTabSpec { + return &DashboardTabsLayoutTabSpec{ + Layout: *NewDashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind(), + } +} + +// +k8s:openapi-gen=true +type DashboardTabRepeatOptions struct { + Mode string `json:"mode"` + Value string `json:"value"` +} + +// NewDashboardTabRepeatOptions creates a new DashboardTabRepeatOptions object. +func NewDashboardTabRepeatOptions() *DashboardTabRepeatOptions { + return &DashboardTabRepeatOptions{ + Mode: DashboardRepeatMode, + } +} + +// Links with references to other dashboards or external resources +// +k8s:openapi-gen=true +type DashboardDashboardLink struct { + // Title to display with the link + Title string `json:"title"` + // Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) + // FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType` + Type DashboardDashboardLinkType `json:"type"` + // Icon name to be displayed with the link + Icon string `json:"icon"` + // Tooltip to display when the user hovers their mouse over it + Tooltip string `json:"tooltip"` + // Link URL. Only required/valid if the type is link + Url *string `json:"url,omitempty"` + // List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards + Tags []string `json:"tags"` + // If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards + AsDropdown bool `json:"asDropdown"` + // If true, the link will be opened in a new tab + TargetBlank bool `json:"targetBlank"` + // If true, includes current template variables values in the link as query params + IncludeVars bool `json:"includeVars"` + // If true, includes current time range in the link as query params + KeepTime bool `json:"keepTime"` +} + +// NewDashboardDashboardLink creates a new DashboardDashboardLink object. +func NewDashboardDashboardLink() *DashboardDashboardLink { + return &DashboardDashboardLink{ + Tags: []string{}, + AsDropdown: false, + TargetBlank: false, + IncludeVars: false, + KeepTime: false, + } +} + +// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) +// +k8s:openapi-gen=true +type DashboardDashboardLinkType string + +const ( + DashboardDashboardLinkTypeLink DashboardDashboardLinkType = "link" + DashboardDashboardLinkTypeDashboards DashboardDashboardLinkType = "dashboards" +) + +// Time configuration +// It defines the default time config for the time picker, the refresh picker for the specific dashboard. +// +k8s:openapi-gen=true +type DashboardTimeSettingsSpec struct { + // Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". + Timezone *string `json:"timezone,omitempty"` + // Start time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + From string `json:"from"` + // End time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + To string `json:"to"` + // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". + // v1: refresh + AutoRefresh string `json:"autoRefresh"` + // Interval options available in the refresh picker dropdown. + // v1: timepicker.refresh_intervals + AutoRefreshIntervals []string `json:"autoRefreshIntervals"` + // Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. + // v1: timepicker.quick_ranges , not exposed in the UI + QuickRanges []DashboardTimeRangeOption `json:"quickRanges,omitempty"` + // Whether timepicker is visible or not. + // v1: timepicker.hidden + HideTimepicker bool `json:"hideTimepicker"` + // Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". + WeekStart *DashboardTimeSettingsSpecWeekStart `json:"weekStart,omitempty"` + // The month that the fiscal year starts on. 0 = January, 11 = December + FiscalYearStartMonth int64 `json:"fiscalYearStartMonth"` + // Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values. + // v1: timepicker.nowDelay + NowDelay *string `json:"nowDelay,omitempty"` +} + +// NewDashboardTimeSettingsSpec creates a new DashboardTimeSettingsSpec object. +func NewDashboardTimeSettingsSpec() *DashboardTimeSettingsSpec { + return &DashboardTimeSettingsSpec{ + Timezone: (func(input string) *string { return &input })("browser"), + From: "now-6h", + To: "now", + AutoRefresh: "", + AutoRefreshIntervals: []string{"5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"}, + HideTimepicker: false, + FiscalYearStartMonth: 0, + } +} + +// +k8s:openapi-gen=true +type DashboardTimeRangeOption struct { + Display string `json:"display"` + From string `json:"from"` + To string `json:"to"` +} + +// NewDashboardTimeRangeOption creates a new DashboardTimeRangeOption object. +func NewDashboardTimeRangeOption() *DashboardTimeRangeOption { + return &DashboardTimeRangeOption{ + Display: "Last 6 hours", + From: "now-6h", + To: "now", + } +} + +// +k8s:openapi-gen=true +type DashboardVariableKind = DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind + +// NewDashboardVariableKind creates a new DashboardVariableKind object. +func NewDashboardVariableKind() *DashboardVariableKind { + return NewDashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind() +} + +// Query variable kind +// +k8s:openapi-gen=true +type DashboardQueryVariableKind struct { + Kind string `json:"kind"` + Spec DashboardQueryVariableSpec `json:"spec"` +} + +// NewDashboardQueryVariableKind creates a new DashboardQueryVariableKind object. +func NewDashboardQueryVariableKind() *DashboardQueryVariableKind { + return &DashboardQueryVariableKind{ + Kind: "QueryVariable", + Spec: *NewDashboardQueryVariableSpec(), + } +} + +// Query variable specification +// +k8s:openapi-gen=true +type DashboardQueryVariableSpec struct { + Name string `json:"name"` + Current DashboardVariableOption `json:"current"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + Refresh DashboardVariableRefresh `json:"refresh"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + Query DashboardDataQueryKind `json:"query"` + Regex string `json:"regex"` + Sort DashboardVariableSort `json:"sort"` + Definition *string `json:"definition,omitempty"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Placeholder *string `json:"placeholder,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` + StaticOptions []DashboardVariableOption `json:"staticOptions,omitempty"` + StaticOptionsOrder *DashboardQueryVariableSpecStaticOptionsOrder `json:"staticOptionsOrder,omitempty"` +} + +// NewDashboardQueryVariableSpec creates a new DashboardQueryVariableSpec object. +func NewDashboardQueryVariableSpec() *DashboardQueryVariableSpec { + return &DashboardQueryVariableSpec{ + Name: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Hide: DashboardVariableHideDontHide, + Refresh: DashboardVariableRefreshNever, + SkipUrlSync: false, + Query: *NewDashboardDataQueryKind(), + Regex: "", + Options: []DashboardVariableOption{}, + Multi: false, + IncludeAll: false, + AllowCustomValue: true, + } +} + +// Variable option specification +// +k8s:openapi-gen=true +type DashboardVariableOption struct { + // Whether the option is selected or not + Selected *bool `json:"selected,omitempty"` + // Text to be displayed for the option + Text DashboardStringOrArrayOfString `json:"text"` + // Value of the option + Value DashboardStringOrArrayOfString `json:"value"` +} + +// NewDashboardVariableOption creates a new DashboardVariableOption object. +func NewDashboardVariableOption() *DashboardVariableOption { + return &DashboardVariableOption{ + Text: *NewDashboardStringOrArrayOfString(), + Value: *NewDashboardStringOrArrayOfString(), + } +} + +// Determine if the variable shows on dashboard +// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing). +// +k8s:openapi-gen=true +type DashboardVariableHide string + +const ( + DashboardVariableHideDontHide DashboardVariableHide = "dontHide" + DashboardVariableHideHideLabel DashboardVariableHide = "hideLabel" + DashboardVariableHideHideVariable DashboardVariableHide = "hideVariable" +) + +// Options to config when to refresh a variable +// `never`: Never refresh the variable +// `onDashboardLoad`: Queries the data source every time the dashboard loads. +// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes. +// +k8s:openapi-gen=true +type DashboardVariableRefresh string + +const ( + DashboardVariableRefreshNever DashboardVariableRefresh = "never" + DashboardVariableRefreshOnDashboardLoad DashboardVariableRefresh = "onDashboardLoad" + DashboardVariableRefreshOnTimeRangeChanged DashboardVariableRefresh = "onTimeRangeChanged" +) + +// Sort variable options +// Accepted values are: +// `disabled`: No sorting +// `alphabeticalAsc`: Alphabetical ASC +// `alphabeticalDesc`: Alphabetical DESC +// `numericalAsc`: Numerical ASC +// `numericalDesc`: Numerical DESC +// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC +// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC +// `naturalAsc`: Natural ASC +// `naturalDesc`: Natural DESC +// VariableSort enum with default value +// +k8s:openapi-gen=true +type DashboardVariableSort string + +const ( + DashboardVariableSortDisabled DashboardVariableSort = "disabled" + DashboardVariableSortAlphabeticalAsc DashboardVariableSort = "alphabeticalAsc" + DashboardVariableSortAlphabeticalDesc DashboardVariableSort = "alphabeticalDesc" + DashboardVariableSortNumericalAsc DashboardVariableSort = "numericalAsc" + DashboardVariableSortNumericalDesc DashboardVariableSort = "numericalDesc" + DashboardVariableSortAlphabeticalCaseInsensitiveAsc DashboardVariableSort = "alphabeticalCaseInsensitiveAsc" + DashboardVariableSortAlphabeticalCaseInsensitiveDesc DashboardVariableSort = "alphabeticalCaseInsensitiveDesc" + DashboardVariableSortNaturalAsc DashboardVariableSort = "naturalAsc" + DashboardVariableSortNaturalDesc DashboardVariableSort = "naturalDesc" +) + +// Text variable kind +// +k8s:openapi-gen=true +type DashboardTextVariableKind struct { + Kind string `json:"kind"` + Spec DashboardTextVariableSpec `json:"spec"` +} + +// NewDashboardTextVariableKind creates a new DashboardTextVariableKind object. +func NewDashboardTextVariableKind() *DashboardTextVariableKind { + return &DashboardTextVariableKind{ + Kind: "TextVariable", + Spec: *NewDashboardTextVariableSpec(), + } +} + +// Text variable specification +// +k8s:openapi-gen=true +type DashboardTextVariableSpec struct { + Name string `json:"name"` + Current DashboardVariableOption `json:"current"` + Query string `json:"query"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` +} + +// NewDashboardTextVariableSpec creates a new DashboardTextVariableSpec object. +func NewDashboardTextVariableSpec() *DashboardTextVariableSpec { + return &DashboardTextVariableSpec{ + Name: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Query: "", + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// Constant variable kind +// +k8s:openapi-gen=true +type DashboardConstantVariableKind struct { + Kind string `json:"kind"` + Spec DashboardConstantVariableSpec `json:"spec"` +} + +// NewDashboardConstantVariableKind creates a new DashboardConstantVariableKind object. +func NewDashboardConstantVariableKind() *DashboardConstantVariableKind { + return &DashboardConstantVariableKind{ + Kind: "ConstantVariable", + Spec: *NewDashboardConstantVariableSpec(), + } +} + +// Constant variable specification +// +k8s:openapi-gen=true +type DashboardConstantVariableSpec struct { + Name string `json:"name"` + Query string `json:"query"` + Current DashboardVariableOption `json:"current"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` +} + +// NewDashboardConstantVariableSpec creates a new DashboardConstantVariableSpec object. +func NewDashboardConstantVariableSpec() *DashboardConstantVariableSpec { + return &DashboardConstantVariableSpec{ + Name: "", + Query: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// Datasource variable kind +// +k8s:openapi-gen=true +type DashboardDatasourceVariableKind struct { + Kind string `json:"kind"` + Spec DashboardDatasourceVariableSpec `json:"spec"` +} + +// NewDashboardDatasourceVariableKind creates a new DashboardDatasourceVariableKind object. +func NewDashboardDatasourceVariableKind() *DashboardDatasourceVariableKind { + return &DashboardDatasourceVariableKind{ + Kind: "DatasourceVariable", + Spec: *NewDashboardDatasourceVariableSpec(), + } +} + +// Datasource variable specification +// +k8s:openapi-gen=true +type DashboardDatasourceVariableSpec struct { + Name string `json:"name"` + PluginId string `json:"pluginId"` + Refresh DashboardVariableRefresh `json:"refresh"` + Regex string `json:"regex"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` +} + +// NewDashboardDatasourceVariableSpec creates a new DashboardDatasourceVariableSpec object. +func NewDashboardDatasourceVariableSpec() *DashboardDatasourceVariableSpec { + return &DashboardDatasourceVariableSpec{ + Name: "", + PluginId: "", + Refresh: DashboardVariableRefreshNever, + Regex: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Options: []DashboardVariableOption{}, + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, + } +} + +// Interval variable kind +// +k8s:openapi-gen=true +type DashboardIntervalVariableKind struct { + Kind string `json:"kind"` + Spec DashboardIntervalVariableSpec `json:"spec"` +} + +// NewDashboardIntervalVariableKind creates a new DashboardIntervalVariableKind object. +func NewDashboardIntervalVariableKind() *DashboardIntervalVariableKind { + return &DashboardIntervalVariableKind{ + Kind: "IntervalVariable", + Spec: *NewDashboardIntervalVariableSpec(), + } +} + +// Interval variable specification +// +k8s:openapi-gen=true +type DashboardIntervalVariableSpec struct { + Name string `json:"name"` + Query string `json:"query"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Auto bool `json:"auto"` + AutoMin string `json:"auto_min"` + AutoCount int64 `json:"auto_count"` + Refresh DashboardVariableRefresh `json:"refresh"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` +} + +// NewDashboardIntervalVariableSpec creates a new DashboardIntervalVariableSpec object. +func NewDashboardIntervalVariableSpec() *DashboardIntervalVariableSpec { + return &DashboardIntervalVariableSpec{ + Name: "", + Query: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Options: []DashboardVariableOption{}, + Auto: false, + AutoMin: "", + AutoCount: 0, + Refresh: DashboardVariableRefreshNever, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// Custom variable kind +// +k8s:openapi-gen=true +type DashboardCustomVariableKind struct { + Kind string `json:"kind"` + Spec DashboardCustomVariableSpec `json:"spec"` +} + +// NewDashboardCustomVariableKind creates a new DashboardCustomVariableKind object. +func NewDashboardCustomVariableKind() *DashboardCustomVariableKind { + return &DashboardCustomVariableKind{ + Kind: "CustomVariable", + Spec: *NewDashboardCustomVariableSpec(), + } +} + +// Custom variable specification +// +k8s:openapi-gen=true +type DashboardCustomVariableSpec struct { + Name string `json:"name"` + Query string `json:"query"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + IncludeAll bool `json:"includeAll"` + AllValue *string `json:"allValue,omitempty"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` +} + +// NewDashboardCustomVariableSpec creates a new DashboardCustomVariableSpec object. +func NewDashboardCustomVariableSpec() *DashboardCustomVariableSpec { + return &DashboardCustomVariableSpec{ + Name: "", + Query: "", + Current: *NewDashboardVariableOption(), + Options: []DashboardVariableOption{}, + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, + } +} + +// Group variable kind +// +k8s:openapi-gen=true +type DashboardGroupByVariableKind struct { + Kind string `json:"kind"` + Spec DashboardGroupByVariableSpec `json:"spec"` +} + +// NewDashboardGroupByVariableKind creates a new DashboardGroupByVariableKind object. +func NewDashboardGroupByVariableKind() *DashboardGroupByVariableKind { + return &DashboardGroupByVariableKind{ + Kind: "GroupByVariable", + Spec: *NewDashboardGroupByVariableSpec(), + } +} + +// GroupBy variable specification +// +k8s:openapi-gen=true +type DashboardGroupByVariableSpec struct { + Name string `json:"name"` + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + DefaultValue *DashboardVariableOption `json:"defaultValue,omitempty"` + Current DashboardVariableOption `json:"current"` + Options []DashboardVariableOption `json:"options"` + Multi bool `json:"multi"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` +} + +// NewDashboardGroupByVariableSpec creates a new DashboardGroupByVariableSpec object. +func NewDashboardGroupByVariableSpec() *DashboardGroupByVariableSpec { + return &DashboardGroupByVariableSpec{ + Name: "", + Current: DashboardVariableOption{ + Text: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + Value: DashboardStringOrArrayOfString{ + String: (func(input string) *string { return &input })(""), + }, + }, + Options: []DashboardVariableOption{}, + Multi: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// Adhoc variable kind +// +k8s:openapi-gen=true +type DashboardAdhocVariableKind struct { + Kind string `json:"kind"` + Spec DashboardAdhocVariableSpec `json:"spec"` +} + +// NewDashboardAdhocVariableKind creates a new DashboardAdhocVariableKind object. +func NewDashboardAdhocVariableKind() *DashboardAdhocVariableKind { + return &DashboardAdhocVariableKind{ + Kind: "AdhocVariable", + Spec: *NewDashboardAdhocVariableSpec(), + } +} + +// Adhoc variable specification +// +k8s:openapi-gen=true +type DashboardAdhocVariableSpec struct { + Name string `json:"name"` + Datasource *DashboardDataSourceRef `json:"datasource,omitempty"` + BaseFilters []DashboardAdHocFilterWithLabels `json:"baseFilters"` + Filters []DashboardAdHocFilterWithLabels `json:"filters"` + DefaultKeys []DashboardMetricFindValue `json:"defaultKeys"` + Label *string `json:"label,omitempty"` + Hide DashboardVariableHide `json:"hide"` + SkipUrlSync bool `json:"skipUrlSync"` + Description *string `json:"description,omitempty"` + AllowCustomValue bool `json:"allowCustomValue"` +} + +// NewDashboardAdhocVariableSpec creates a new DashboardAdhocVariableSpec object. +func NewDashboardAdhocVariableSpec() *DashboardAdhocVariableSpec { + return &DashboardAdhocVariableSpec{ + Name: "", + BaseFilters: []DashboardAdHocFilterWithLabels{}, + Filters: []DashboardAdHocFilterWithLabels{}, + DefaultKeys: []DashboardMetricFindValue{}, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + AllowCustomValue: true, + } +} + +// Define the AdHocFilterWithLabels type +// +k8s:openapi-gen=true +type DashboardAdHocFilterWithLabels struct { + Key string `json:"key"` + Operator string `json:"operator"` + Value string `json:"value"` + Values []string `json:"values,omitempty"` + KeyLabel *string `json:"keyLabel,omitempty"` + ValueLabels []string `json:"valueLabels,omitempty"` + ForceEdit *bool `json:"forceEdit,omitempty"` + Origin string `json:"origin,omitempty"` + // @deprecated + Condition *string `json:"condition,omitempty"` +} + +// NewDashboardAdHocFilterWithLabels creates a new DashboardAdHocFilterWithLabels object. +func NewDashboardAdHocFilterWithLabels() *DashboardAdHocFilterWithLabels { + return &DashboardAdHocFilterWithLabels{ + Origin: DashboardFilterOrigin, + } +} + +// Determine the origin of the adhoc variable filter +// +k8s:openapi-gen=true +const DashboardFilterOrigin = "dashboard" + +// Define the MetricFindValue type +// +k8s:openapi-gen=true +type DashboardMetricFindValue struct { + Text string `json:"text"` + Value *DashboardStringOrFloat64 `json:"value,omitempty"` + Group *string `json:"group,omitempty"` + Expandable *bool `json:"expandable,omitempty"` +} + +// NewDashboardMetricFindValue creates a new DashboardMetricFindValue object. +func NewDashboardMetricFindValue() *DashboardMetricFindValue { + return &DashboardMetricFindValue{} +} + +// +k8s:openapi-gen=true +type DashboardSpec struct { + Annotations []DashboardAnnotationQueryKind `json:"annotations"` + // Configuration of dashboard cursor sync behavior. + // "Off" for no shared crosshair or tooltip (default). + // "Crosshair" for shared crosshair. + // "Tooltip" for shared crosshair AND shared tooltip. + CursorSync DashboardDashboardCursorSync `json:"cursorSync"` + // Description of dashboard. + Description *string `json:"description,omitempty"` + // Whether a dashboard is editable or not. + Editable *bool `json:"editable,omitempty"` + Elements map[string]DashboardElement `json:"elements"` + Layout DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind `json:"layout"` + // Links with references to other dashboards or external websites. + Links []DashboardDashboardLink `json:"links"` + // When set to true, the dashboard will redraw panels at an interval matching the pixel width. + // This will keep data "moving left" regardless of the query refresh rate. This setting helps + // avoid dashboards presenting stale live data. + LiveNow *bool `json:"liveNow,omitempty"` + // When set to true, the dashboard will load all panels in the dashboard when it's loaded. + Preload bool `json:"preload"` + // Plugins only. The version of the dashboard installed together with the plugin. + // This is used to determine if the dashboard should be updated when the plugin is updated. + Revision *uint16 `json:"revision,omitempty"` + // Tags associated with dashboard. + Tags []string `json:"tags"` + TimeSettings DashboardTimeSettingsSpec `json:"timeSettings"` + // Title of dashboard. + Title string `json:"title"` + // Configured template variables. + Variables []DashboardVariableKind `json:"variables"` +} + +// NewDashboardSpec creates a new DashboardSpec object. +func NewDashboardSpec() *DashboardSpec { + return &DashboardSpec{ + Annotations: []DashboardAnnotationQueryKind{}, + CursorSync: DashboardDashboardCursorSyncOff, + Editable: (func(input bool) *bool { return &input })(true), + Elements: map[string]DashboardElement{}, + Layout: *NewDashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind(), + Links: []DashboardDashboardLink{}, + Preload: false, + Tags: []string{}, + TimeSettings: *NewDashboardTimeSettingsSpec(), + Variables: []DashboardVariableKind{}, + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha2FieldConfigSourceOverrides struct { + Matcher DashboardMatcherConfig `json:"matcher"` + Properties []DashboardDynamicConfigValue `json:"properties"` +} + +// NewDashboardV2alpha2FieldConfigSourceOverrides creates a new DashboardV2alpha2FieldConfigSourceOverrides object. +func NewDashboardV2alpha2FieldConfigSourceOverrides() *DashboardV2alpha2FieldConfigSourceOverrides { + return &DashboardV2alpha2FieldConfigSourceOverrides{ + Matcher: *NewDashboardMatcherConfig(), + Properties: []DashboardDynamicConfigValue{}, + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha2RangeMapOptions struct { + // Min value of the range. It can be null which means -Infinity + From *float64 `json:"from"` + // Max value of the range. It can be null which means +Infinity + To *float64 `json:"to"` + // Config to apply when the value is within the range + Result DashboardValueMappingResult `json:"result"` +} + +// NewDashboardV2alpha2RangeMapOptions creates a new DashboardV2alpha2RangeMapOptions object. +func NewDashboardV2alpha2RangeMapOptions() *DashboardV2alpha2RangeMapOptions { + return &DashboardV2alpha2RangeMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha2RegexMapOptions struct { + // Regular expression to match against + Pattern string `json:"pattern"` + // Config to apply when the value matches the regex + Result DashboardValueMappingResult `json:"result"` +} + +// NewDashboardV2alpha2RegexMapOptions creates a new DashboardV2alpha2RegexMapOptions object. +func NewDashboardV2alpha2RegexMapOptions() *DashboardV2alpha2RegexMapOptions { + return &DashboardV2alpha2RegexMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha2SpecialValueMapOptions struct { + // Special value to match against + Match DashboardSpecialValueMatch `json:"match"` + // Config to apply when the value matches the special value + Result DashboardValueMappingResult `json:"result"` +} + +// NewDashboardV2alpha2SpecialValueMapOptions creates a new DashboardV2alpha2SpecialValueMapOptions object. +func NewDashboardV2alpha2SpecialValueMapOptions() *DashboardV2alpha2SpecialValueMapOptions { + return &DashboardV2alpha2SpecialValueMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardRepeatOptionsDirection string + +const ( + DashboardRepeatOptionsDirectionH DashboardRepeatOptionsDirection = "h" + DashboardRepeatOptionsDirectionV DashboardRepeatOptionsDirection = "v" +) + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingGroupSpecVisibility string + +const ( + DashboardConditionalRenderingGroupSpecVisibilityShow DashboardConditionalRenderingGroupSpecVisibility = "show" + DashboardConditionalRenderingGroupSpecVisibilityHide DashboardConditionalRenderingGroupSpecVisibility = "hide" +) + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingGroupSpecCondition string + +const ( + DashboardConditionalRenderingGroupSpecConditionAnd DashboardConditionalRenderingGroupSpecCondition = "and" + DashboardConditionalRenderingGroupSpecConditionOr DashboardConditionalRenderingGroupSpecCondition = "or" +) + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingVariableSpecOperator string + +const ( + DashboardConditionalRenderingVariableSpecOperatorEquals DashboardConditionalRenderingVariableSpecOperator = "equals" + DashboardConditionalRenderingVariableSpecOperatorNotEquals DashboardConditionalRenderingVariableSpecOperator = "notEquals" +) + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutSpecColumnWidthMode string + +const ( + DashboardAutoGridLayoutSpecColumnWidthModeNarrow DashboardAutoGridLayoutSpecColumnWidthMode = "narrow" + DashboardAutoGridLayoutSpecColumnWidthModeStandard DashboardAutoGridLayoutSpecColumnWidthMode = "standard" + DashboardAutoGridLayoutSpecColumnWidthModeWide DashboardAutoGridLayoutSpecColumnWidthMode = "wide" + DashboardAutoGridLayoutSpecColumnWidthModeCustom DashboardAutoGridLayoutSpecColumnWidthMode = "custom" +) + +// +k8s:openapi-gen=true +type DashboardAutoGridLayoutSpecRowHeightMode string + +const ( + DashboardAutoGridLayoutSpecRowHeightModeShort DashboardAutoGridLayoutSpecRowHeightMode = "short" + DashboardAutoGridLayoutSpecRowHeightModeStandard DashboardAutoGridLayoutSpecRowHeightMode = "standard" + DashboardAutoGridLayoutSpecRowHeightModeTall DashboardAutoGridLayoutSpecRowHeightMode = "tall" + DashboardAutoGridLayoutSpecRowHeightModeCustom DashboardAutoGridLayoutSpecRowHeightMode = "custom" +) + +// +k8s:openapi-gen=true +type DashboardTimeSettingsSpecWeekStart string + +const ( + DashboardTimeSettingsSpecWeekStartSaturday DashboardTimeSettingsSpecWeekStart = "saturday" + DashboardTimeSettingsSpecWeekStartMonday DashboardTimeSettingsSpecWeekStart = "monday" + DashboardTimeSettingsSpecWeekStartSunday DashboardTimeSettingsSpecWeekStart = "sunday" +) + +// +k8s:openapi-gen=true +type DashboardQueryVariableSpecStaticOptionsOrder string + +const ( + DashboardQueryVariableSpecStaticOptionsOrderBefore DashboardQueryVariableSpecStaticOptionsOrder = "before" + DashboardQueryVariableSpecStaticOptionsOrderAfter DashboardQueryVariableSpecStaticOptionsOrder = "after" + DashboardQueryVariableSpecStaticOptionsOrderSorted DashboardQueryVariableSpecStaticOptionsOrder = "sorted" +) + +// +k8s:openapi-gen=true +type DashboardPanelKindOrLibraryPanelKind struct { + PanelKind *DashboardPanelKind `json:"PanelKind,omitempty"` + LibraryPanelKind *DashboardLibraryPanelKind `json:"LibraryPanelKind,omitempty"` +} + +// NewDashboardPanelKindOrLibraryPanelKind creates a new DashboardPanelKindOrLibraryPanelKind object. +func NewDashboardPanelKindOrLibraryPanelKind() *DashboardPanelKindOrLibraryPanelKind { + return &DashboardPanelKindOrLibraryPanelKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardPanelKindOrLibraryPanelKind` as JSON. +func (resource DashboardPanelKindOrLibraryPanelKind) MarshalJSON() ([]byte, error) { + if resource.PanelKind != nil { + return json.Marshal(resource.PanelKind) + } + if resource.LibraryPanelKind != nil { + return json.Marshal(resource.LibraryPanelKind) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardPanelKindOrLibraryPanelKind` from JSON. +func (resource *DashboardPanelKindOrLibraryPanelKind) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["kind"] + if !found { + return nil + } + + switch discriminator { + case "LibraryPanel": + var dashboardLibraryPanelKind DashboardLibraryPanelKind + if err := json.Unmarshal(raw, &dashboardLibraryPanelKind); err != nil { + return err + } + + resource.LibraryPanelKind = &dashboardLibraryPanelKind + return nil + case "Panel": + var dashboardPanelKind DashboardPanelKind + if err := json.Unmarshal(raw, &dashboardPanelKind); err != nil { + return err + } + + resource.PanelKind = &dashboardPanelKind + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap struct { + ValueMap *DashboardValueMap `json:"ValueMap,omitempty"` + RangeMap *DashboardRangeMap `json:"RangeMap,omitempty"` + RegexMap *DashboardRegexMap `json:"RegexMap,omitempty"` + SpecialValueMap *DashboardSpecialValueMap `json:"SpecialValueMap,omitempty"` +} + +// NewDashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap creates a new DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap object. +func NewDashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap() *DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap { + return &DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap` as JSON. +func (resource DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap) MarshalJSON() ([]byte, error) { + if resource.ValueMap != nil { + return json.Marshal(resource.ValueMap) + } + if resource.RangeMap != nil { + return json.Marshal(resource.RangeMap) + } + if resource.RegexMap != nil { + return json.Marshal(resource.RegexMap) + } + if resource.SpecialValueMap != nil { + return json.Marshal(resource.SpecialValueMap) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap` from JSON. +func (resource *DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["type"] + if !found { + return nil + } + + switch discriminator { + case "range": + var dashboardRangeMap DashboardRangeMap + if err := json.Unmarshal(raw, &dashboardRangeMap); err != nil { + return err + } + + resource.RangeMap = &dashboardRangeMap + return nil + case "regex": + var dashboardRegexMap DashboardRegexMap + if err := json.Unmarshal(raw, &dashboardRegexMap); err != nil { + return err + } + + resource.RegexMap = &dashboardRegexMap + return nil + case "special": + var dashboardSpecialValueMap DashboardSpecialValueMap + if err := json.Unmarshal(raw, &dashboardSpecialValueMap); err != nil { + return err + } + + resource.SpecialValueMap = &dashboardSpecialValueMap + return nil + case "value": + var dashboardValueMap DashboardValueMap + if err := json.Unmarshal(raw, &dashboardValueMap); err != nil { + return err + } + + resource.ValueMap = &dashboardValueMap + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind struct { + GridLayoutKind *DashboardGridLayoutKind `json:"GridLayoutKind,omitempty"` + AutoGridLayoutKind *DashboardAutoGridLayoutKind `json:"AutoGridLayoutKind,omitempty"` + TabsLayoutKind *DashboardTabsLayoutKind `json:"TabsLayoutKind,omitempty"` + RowsLayoutKind *DashboardRowsLayoutKind `json:"RowsLayoutKind,omitempty"` +} + +// NewDashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind creates a new DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind object. +func NewDashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind() *DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind { + return &DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind` as JSON. +func (resource DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutKind != nil { + return json.Marshal(resource.GridLayoutKind) + } + if resource.AutoGridLayoutKind != nil { + return json.Marshal(resource.AutoGridLayoutKind) + } + if resource.TabsLayoutKind != nil { + return json.Marshal(resource.TabsLayoutKind) + } + if resource.RowsLayoutKind != nil { + return json.Marshal(resource.RowsLayoutKind) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind` from JSON. +func (resource *DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["kind"] + if !found { + return nil + } + + switch discriminator { + case "AutoGridLayout": + var dashboardAutoGridLayoutKind DashboardAutoGridLayoutKind + if err := json.Unmarshal(raw, &dashboardAutoGridLayoutKind); err != nil { + return err + } + + resource.AutoGridLayoutKind = &dashboardAutoGridLayoutKind + return nil + case "GridLayout": + var dashboardGridLayoutKind DashboardGridLayoutKind + if err := json.Unmarshal(raw, &dashboardGridLayoutKind); err != nil { + return err + } + + resource.GridLayoutKind = &dashboardGridLayoutKind + return nil + case "RowsLayout": + var dashboardRowsLayoutKind DashboardRowsLayoutKind + if err := json.Unmarshal(raw, &dashboardRowsLayoutKind); err != nil { + return err + } + + resource.RowsLayoutKind = &dashboardRowsLayoutKind + return nil + case "TabsLayout": + var dashboardTabsLayoutKind DashboardTabsLayoutKind + if err := json.Unmarshal(raw, &dashboardTabsLayoutKind); err != nil { + return err + } + + resource.TabsLayoutKind = &dashboardTabsLayoutKind + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind struct { + ConditionalRenderingVariableKind *DashboardConditionalRenderingVariableKind `json:"ConditionalRenderingVariableKind,omitempty"` + ConditionalRenderingDataKind *DashboardConditionalRenderingDataKind `json:"ConditionalRenderingDataKind,omitempty"` + ConditionalRenderingTimeRangeSizeKind *DashboardConditionalRenderingTimeRangeSizeKind `json:"ConditionalRenderingTimeRangeSizeKind,omitempty"` +} + +// NewDashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind creates a new DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind object. +func NewDashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind() *DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind { + return &DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind` as JSON. +func (resource DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind) MarshalJSON() ([]byte, error) { + if resource.ConditionalRenderingVariableKind != nil { + return json.Marshal(resource.ConditionalRenderingVariableKind) + } + if resource.ConditionalRenderingDataKind != nil { + return json.Marshal(resource.ConditionalRenderingDataKind) + } + if resource.ConditionalRenderingTimeRangeSizeKind != nil { + return json.Marshal(resource.ConditionalRenderingTimeRangeSizeKind) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind` from JSON. +func (resource *DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["kind"] + if !found { + return nil + } + + switch discriminator { + case "ConditionalRenderingData": + var dashboardConditionalRenderingDataKind DashboardConditionalRenderingDataKind + if err := json.Unmarshal(raw, &dashboardConditionalRenderingDataKind); err != nil { + return err + } + + resource.ConditionalRenderingDataKind = &dashboardConditionalRenderingDataKind + return nil + case "ConditionalRenderingTimeRangeSize": + var dashboardConditionalRenderingTimeRangeSizeKind DashboardConditionalRenderingTimeRangeSizeKind + if err := json.Unmarshal(raw, &dashboardConditionalRenderingTimeRangeSizeKind); err != nil { + return err + } + + resource.ConditionalRenderingTimeRangeSizeKind = &dashboardConditionalRenderingTimeRangeSizeKind + return nil + case "ConditionalRenderingVariable": + var dashboardConditionalRenderingVariableKind DashboardConditionalRenderingVariableKind + if err := json.Unmarshal(raw, &dashboardConditionalRenderingVariableKind); err != nil { + return err + } + + resource.ConditionalRenderingVariableKind = &dashboardConditionalRenderingVariableKind + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind struct { + GridLayoutKind *DashboardGridLayoutKind `json:"GridLayoutKind,omitempty"` + RowsLayoutKind *DashboardRowsLayoutKind `json:"RowsLayoutKind,omitempty"` + AutoGridLayoutKind *DashboardAutoGridLayoutKind `json:"AutoGridLayoutKind,omitempty"` + TabsLayoutKind *DashboardTabsLayoutKind `json:"TabsLayoutKind,omitempty"` +} + +// NewDashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind creates a new DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind object. +func NewDashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind() *DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind { + return &DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind` as JSON. +func (resource DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutKind != nil { + return json.Marshal(resource.GridLayoutKind) + } + if resource.RowsLayoutKind != nil { + return json.Marshal(resource.RowsLayoutKind) + } + if resource.AutoGridLayoutKind != nil { + return json.Marshal(resource.AutoGridLayoutKind) + } + if resource.TabsLayoutKind != nil { + return json.Marshal(resource.TabsLayoutKind) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind` from JSON. +func (resource *DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["kind"] + if !found { + return nil + } + + switch discriminator { + case "AutoGridLayout": + var dashboardAutoGridLayoutKind DashboardAutoGridLayoutKind + if err := json.Unmarshal(raw, &dashboardAutoGridLayoutKind); err != nil { + return err + } + + resource.AutoGridLayoutKind = &dashboardAutoGridLayoutKind + return nil + case "GridLayout": + var dashboardGridLayoutKind DashboardGridLayoutKind + if err := json.Unmarshal(raw, &dashboardGridLayoutKind); err != nil { + return err + } + + resource.GridLayoutKind = &dashboardGridLayoutKind + return nil + case "RowsLayout": + var dashboardRowsLayoutKind DashboardRowsLayoutKind + if err := json.Unmarshal(raw, &dashboardRowsLayoutKind); err != nil { + return err + } + + resource.RowsLayoutKind = &dashboardRowsLayoutKind + return nil + case "TabsLayout": + var dashboardTabsLayoutKind DashboardTabsLayoutKind + if err := json.Unmarshal(raw, &dashboardTabsLayoutKind); err != nil { + return err + } + + resource.TabsLayoutKind = &dashboardTabsLayoutKind + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind struct { + QueryVariableKind *DashboardQueryVariableKind `json:"QueryVariableKind,omitempty"` + TextVariableKind *DashboardTextVariableKind `json:"TextVariableKind,omitempty"` + ConstantVariableKind *DashboardConstantVariableKind `json:"ConstantVariableKind,omitempty"` + DatasourceVariableKind *DashboardDatasourceVariableKind `json:"DatasourceVariableKind,omitempty"` + IntervalVariableKind *DashboardIntervalVariableKind `json:"IntervalVariableKind,omitempty"` + CustomVariableKind *DashboardCustomVariableKind `json:"CustomVariableKind,omitempty"` + GroupByVariableKind *DashboardGroupByVariableKind `json:"GroupByVariableKind,omitempty"` + AdhocVariableKind *DashboardAdhocVariableKind `json:"AdhocVariableKind,omitempty"` +} + +// NewDashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind creates a new DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind object. +func NewDashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind() *DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind { + return &DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind` as JSON. +func (resource DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind) MarshalJSON() ([]byte, error) { + if resource.QueryVariableKind != nil { + return json.Marshal(resource.QueryVariableKind) + } + if resource.TextVariableKind != nil { + return json.Marshal(resource.TextVariableKind) + } + if resource.ConstantVariableKind != nil { + return json.Marshal(resource.ConstantVariableKind) + } + if resource.DatasourceVariableKind != nil { + return json.Marshal(resource.DatasourceVariableKind) + } + if resource.IntervalVariableKind != nil { + return json.Marshal(resource.IntervalVariableKind) + } + if resource.CustomVariableKind != nil { + return json.Marshal(resource.CustomVariableKind) + } + if resource.GroupByVariableKind != nil { + return json.Marshal(resource.GroupByVariableKind) + } + if resource.AdhocVariableKind != nil { + return json.Marshal(resource.AdhocVariableKind) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind` from JSON. +func (resource *DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + // FIXME: this is wasteful, we need to find a more efficient way to unmarshal this. + parsedAsMap := make(map[string]interface{}) + if err := json.Unmarshal(raw, &parsedAsMap); err != nil { + return err + } + + discriminator, found := parsedAsMap["kind"] + if !found { + return nil + } + + switch discriminator { + case "AdhocVariable": + var dashboardAdhocVariableKind DashboardAdhocVariableKind + if err := json.Unmarshal(raw, &dashboardAdhocVariableKind); err != nil { + return err + } + + resource.AdhocVariableKind = &dashboardAdhocVariableKind + return nil + case "ConstantVariable": + var dashboardConstantVariableKind DashboardConstantVariableKind + if err := json.Unmarshal(raw, &dashboardConstantVariableKind); err != nil { + return err + } + + resource.ConstantVariableKind = &dashboardConstantVariableKind + return nil + case "CustomVariable": + var dashboardCustomVariableKind DashboardCustomVariableKind + if err := json.Unmarshal(raw, &dashboardCustomVariableKind); err != nil { + return err + } + + resource.CustomVariableKind = &dashboardCustomVariableKind + return nil + case "DatasourceVariable": + var dashboardDatasourceVariableKind DashboardDatasourceVariableKind + if err := json.Unmarshal(raw, &dashboardDatasourceVariableKind); err != nil { + return err + } + + resource.DatasourceVariableKind = &dashboardDatasourceVariableKind + return nil + case "GroupByVariable": + var dashboardGroupByVariableKind DashboardGroupByVariableKind + if err := json.Unmarshal(raw, &dashboardGroupByVariableKind); err != nil { + return err + } + + resource.GroupByVariableKind = &dashboardGroupByVariableKind + return nil + case "IntervalVariable": + var dashboardIntervalVariableKind DashboardIntervalVariableKind + if err := json.Unmarshal(raw, &dashboardIntervalVariableKind); err != nil { + return err + } + + resource.IntervalVariableKind = &dashboardIntervalVariableKind + return nil + case "QueryVariable": + var dashboardQueryVariableKind DashboardQueryVariableKind + if err := json.Unmarshal(raw, &dashboardQueryVariableKind); err != nil { + return err + } + + resource.QueryVariableKind = &dashboardQueryVariableKind + return nil + case "TextVariable": + var dashboardTextVariableKind DashboardTextVariableKind + if err := json.Unmarshal(raw, &dashboardTextVariableKind); err != nil { + return err + } + + resource.TextVariableKind = &dashboardTextVariableKind + return nil + } + + return nil +} + +// +k8s:openapi-gen=true +type DashboardStringOrArrayOfString struct { + String *string `json:"String,omitempty"` + ArrayOfString []string `json:"ArrayOfString,omitempty"` +} + +// NewDashboardStringOrArrayOfString creates a new DashboardStringOrArrayOfString object. +func NewDashboardStringOrArrayOfString() *DashboardStringOrArrayOfString { + return &DashboardStringOrArrayOfString{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardStringOrArrayOfString` as JSON. +func (resource DashboardStringOrArrayOfString) MarshalJSON() ([]byte, error) { + if resource.String != nil { + return json.Marshal(resource.String) + } + + if resource.ArrayOfString != nil { + return json.Marshal(resource.ArrayOfString) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardStringOrArrayOfString` from JSON. +func (resource *DashboardStringOrArrayOfString) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + var errList []error + + // String + var String string + if err := json.Unmarshal(raw, &String); err != nil { + errList = append(errList, err) + resource.String = nil + } else { + resource.String = &String + return nil + } + + // ArrayOfString + var ArrayOfString []string + if err := json.Unmarshal(raw, &ArrayOfString); err != nil { + errList = append(errList, err) + resource.ArrayOfString = nil + } else { + resource.ArrayOfString = ArrayOfString + return nil + } + + return errors.Join(errList...) +} + +// +k8s:openapi-gen=true +type DashboardStringOrFloat64 struct { + String *string `json:"String,omitempty"` + Float64 *float64 `json:"Float64,omitempty"` +} + +// NewDashboardStringOrFloat64 creates a new DashboardStringOrFloat64 object. +func NewDashboardStringOrFloat64() *DashboardStringOrFloat64 { + return &DashboardStringOrFloat64{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardStringOrFloat64` as JSON. +func (resource DashboardStringOrFloat64) MarshalJSON() ([]byte, error) { + if resource.String != nil { + return json.Marshal(resource.String) + } + + if resource.Float64 != nil { + return json.Marshal(resource.Float64) + } + + return []byte("null"), nil +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardStringOrFloat64` from JSON. +func (resource *DashboardStringOrFloat64) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + var errList []error + + // String + var String string + if err := json.Unmarshal(raw, &String); err != nil { + errList = append(errList, err) + resource.String = nil + } else { + resource.String = &String + return nil + } + + // Float64 + var Float64 float64 + if err := json.Unmarshal(raw, &Float64); err != nil { + errList = append(errList, err) + resource.Float64 = nil + } else { + resource.Float64 = &Float64 + return nil + } + + return errors.Join(errList...) +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_status_gen.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_status_gen.go new file mode 100644 index 00000000000..322f9f072ec --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_status_gen.go @@ -0,0 +1,34 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha2 + +// ConversionStatus is the status of the conversion of the dashboard. +// +k8s:openapi-gen=true +type DashboardConversionStatus struct { + // Whether from another version has failed. + // If true, means that the dashboard is not valid, + // and the caller should instead fetch the stored version. + Failed bool `json:"failed"` + // The version which was stored when the dashboard was created / updated. + // Fetching this version should always succeed. + StoredVersion string `json:"storedVersion"` + // The error message from the conversion. + // Empty if the conversion has not failed. + Error string `json:"error"` +} + +// NewDashboardConversionStatus creates a new DashboardConversionStatus object. +func NewDashboardConversionStatus() *DashboardConversionStatus { + return &DashboardConversionStatus{} +} + +// +k8s:openapi-gen=true +type DashboardStatus struct { + // Optional conversion status. + Conversion *DashboardConversionStatus `json:"conversion,omitempty"` +} + +// NewDashboardStatus creates a new DashboardStatus object. +func NewDashboardStatus() *DashboardStatus { + return &DashboardStatus{} +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go new file mode 100644 index 00000000000..95dba55d4cd --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go @@ -0,0 +1,10 @@ +// +k8s:openapi-gen=true +// +k8s:defaulter-gen=TypeMeta +// +k8s:conversion-gen=github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard +// +groupName=dashboard.grafana.app + +// NOTE (@radiohead): we do not use package-wide deepcopy generation +// because grafana-app-sdk already provides deepcopy functions. +// Kinds which are not generated by the SDK are explicitly opted in to deepcopy generation. + +package v2alpha2 // import "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go new file mode 100644 index 00000000000..0a68d910fb1 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go @@ -0,0 +1,103 @@ +package v2alpha2 + +import ( + "fmt" + "time" + + "github.com/grafana/grafana/pkg/apimachinery/utils" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + GROUP = "dashboard.grafana.app" + VERSION = "v2alpha2" + APIVERSION = GROUP + "/" + VERSION +) + +var DashboardResourceInfo = utils.NewResourceInfo(GROUP, VERSION, + "dashboards", "dashboard", "Dashboard", + func() runtime.Object { return &Dashboard{} }, + func() runtime.Object { return &DashboardList{} }, + utils.TableColumns{ + Definition: []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name"}, + {Name: "Title", Type: "string", Format: "string", Description: "The dashboard name"}, + {Name: "Created At", Type: "date"}, + }, + Reader: func(obj any) ([]interface{}, error) { + dash, ok := obj.(*Dashboard) + if ok { + if dash != nil { + return []interface{}{ + dash.Name, + dash.Spec.Title, + dash.CreationTimestamp.UTC().Format(time.RFC3339), + }, nil + } + } + return nil, fmt.Errorf("expected dashboard") + }, + }, +) + +var LibraryPanelResourceInfo = utils.NewResourceInfo(GROUP, VERSION, + "librarypanels", "librarypanel", "LibraryPanel", + func() runtime.Object { return &LibraryPanel{} }, + func() runtime.Object { return &LibraryPanelList{} }, + utils.TableColumns{ + Definition: []metav1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name"}, + {Name: "Title", Type: "string", Description: "The dashboard name"}, + {Name: "Type", Type: "string", Description: "the panel type"}, + {Name: "Created At", Type: "date"}, + }, + Reader: func(obj any) ([]interface{}, error) { + panel, ok := obj.(*LibraryPanel) + if ok { + if panel != nil { + return []interface{}{ + panel.Name, + panel.Spec.Title, + panel.Spec.Type, + panel.CreationTimestamp.UTC().Format(time.RFC3339), + }, nil + } + } + return nil, fmt.Errorf("expected library panel") + }, + }, +) + +var ( + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme + schemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION} +) + +func init() { + localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(schemeGroupVersion, + &Dashboard{}, + &DashboardList{}, + &DashboardWithAccessInfo{}, + &DashboardVersionList{}, + &VersionsQueryOptions{}, + &LibraryPanel{}, + &LibraryPanelList{}, + &metav1.PartialObjectMetadata{}, + &metav1.PartialObjectMetadataList{}, + ) + metav1.AddToGroupVersion(scheme, schemeGroupVersion) + return nil +} + +func addDefaultingFuncs(scheme *runtime.Scheme) error { + return RegisterDefaults(scheme) +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go new file mode 100644 index 00000000000..b40a86fe94e --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go @@ -0,0 +1,149 @@ +package v2alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + data "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1" + common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" +) + +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type DashboardVersionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []DashboardVersionInfo `json:"items"` +} + +// +k8s:deepcopy-gen=true +type DashboardVersionInfo struct { + // The internal ID for this version (will be replaced with resourceVersion) + Version int `json:"version"` + + // If the dashboard came from a previous version, it is set here + ParentVersion int `json:"parentVersion,omitempty"` + + // The creation timestamp for this version + Created int64 `json:"created"` + + // The user who created this version + CreatedBy string `json:"createdBy,omitempty"` + + // Message passed while saving the version + Message string `json:"message,omitempty"` +} + +// +k8s:deepcopy-gen=true +// +k8s:conversion-gen:explicit-from=net/url.Values +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type VersionsQueryOptions struct { + metav1.TypeMeta `json:",inline"` + + // Path is the URL path + // +optional + Path string `json:"path,omitempty"` + + // +optional + Version int64 `json:"version,omitempty"` +} + +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type LibraryPanel struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Panel properties + Spec LibraryPanelSpec `json:"spec"` + + // Status will show errors + Status *LibraryPanelStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type LibraryPanelList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []LibraryPanel `json:"items"` +} + +// +k8s:deepcopy-gen=true +type LibraryPanelSpec struct { + // The panel type + Type string `json:"type"` + + // The panel type + PluginVersion string `json:"pluginVersion,omitempty"` + + // The panel title + Title string `json:"title,omitempty"` + + // Library panel description + Description string `json:"description,omitempty"` + + // The options schema depends on the panel type + Options common.Unstructured `json:"options"` + + // The fieldConfig schema depends on the panel type + FieldConfig common.Unstructured `json:"fieldConfig"` + + // The default datasource type + Datasource *data.DataSourceRef `json:"datasource,omitempty"` + + // The datasource queries + // +listType=set + Targets []data.DataQuery `json:"targets,omitempty"` +} + +// +k8s:deepcopy-gen=true +type LibraryPanelStatus struct { + // Translation warnings (mostly things that were in SQL columns but not found in the saved body) + Warnings []string `json:"warnings,omitempty"` + + // The properties previously stored in SQL that are not included in this model + Missing common.Unstructured `json:"missing,omitempty"` +} + +// This is like the legacy DTO where access and metadata are all returned in a single call +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type DashboardWithAccessInfo struct { + Dashboard `json:",inline"` + + Access DashboardAccess `json:"access"` +} + +// Information about how the requesting user can use a given dashboard +// +k8s:deepcopy-gen=true +type DashboardAccess struct { + // Metadata fields + Slug string `json:"slug,omitempty"` + Url string `json:"url,omitempty"` + + // The permissions part + CanSave bool `json:"canSave"` + CanEdit bool `json:"canEdit"` + CanAdmin bool `json:"canAdmin"` + CanStar bool `json:"canStar"` + CanDelete bool `json:"canDelete"` + AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions"` +} + +// +k8s:deepcopy-gen=true +type AnnotationPermission struct { + Dashboard AnnotationActions `json:"dashboard"` + Organization AnnotationActions `json:"organization"` +} + +// +k8s:deepcopy-gen=true +type AnnotationActions struct { + CanAdd bool `json:"canAdd"` + CanEdit bool `json:"canEdit"` + CanDelete bool `json:"canDelete"` +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go new file mode 100644 index 00000000000..9b01c53a3e1 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go @@ -0,0 +1,84 @@ +package v2alpha2 + +import ( + _ "embed" + json "encoding/json" + fmt "fmt" + "strings" + "sync" + + "k8s.io/apimachinery/pkg/util/validation/field" + + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + "cuelang.org/go/cue/errors" + cuejson "cuelang.org/go/encoding/json" +) + +func ValidateDashboardSpec(obj *Dashboard) field.ErrorList { + data, err := json.Marshal(obj.Spec) + if err != nil { + return field.ErrorList{ + field.Invalid(field.NewPath("spec"), field.OmitValueType{}, err.Error()), + } + } + + if err := cuejson.Validate(data, getCueSchema()); err != nil { + errs := field.ErrorList{} + + for _, e := range errors.Errors(err) { + if + // We don't want to return confusing "empty disjunction" errors, + // because the users don't necessarily understand what to do with them. + // For empty disjunctions, CUE will also return more specific errors, + // so we can safely ignore the generic ones. + strings.Contains(e.Error(), "disjunction") || + // We don't want to return errors about unknown fields either. + strings.Contains(e.Error(), "field not allowed") { + continue + } + + if strings.Contains(e.Error(), "mismatched types null and list") { + // Go populates empty slices as nil, which the cue validator does not like + continue + } + + // We want to manually format the error message, + // because e.Error() contains the full CUE path. + format, args := e.Msg() + + errs = append(errs, field.Invalid( + field.NewPath(formatErrorPath(e.Path())), + field.OmitValueType{}, + fmt.Sprintf(format, args...), + )) + } + + return errs + } + + return nil +} + +func formatErrorPath(path []string) string { + return strings.Join(path, ".") +} + +var ( + compiledSchema cue.Value + getSchemaOnce sync.Once +) + +//go:embed dashboard_spec.cue +var schemaSource string + +func getCueSchema() cue.Value { + getSchemaOnce.Do(func() { + cueCtx := cuecontext.New() + compiledSchema = cueCtx.CompileString(schemaSource).LookupPath( + cue.ParsePath("DashboardSpec"), + ) + }) + + return compiledSchema +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.conversion.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.conversion.go new file mode 100644 index 00000000000..3159ff2e0f7 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.conversion.go @@ -0,0 +1,175 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// SPDX-License-Identifier: AGPL-3.0-only + +// Code generated by conversion-gen. DO NOT EDIT. + +package v2alpha2 + +import ( + url "net/url" + unsafe "unsafe" + + dashboard "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*AnnotationActions)(nil), (*dashboard.AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(a.(*AnnotationActions), b.(*dashboard.AnnotationActions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationActions)(nil), (*AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(a.(*dashboard.AnnotationActions), b.(*AnnotationActions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*AnnotationPermission)(nil), (*dashboard.AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(a.(*AnnotationPermission), b.(*dashboard.AnnotationPermission), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationPermission)(nil), (*AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(a.(*dashboard.AnnotationPermission), b.(*AnnotationPermission), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*DashboardAccess)(nil), (*dashboard.DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(a.(*DashboardAccess), b.(*dashboard.DashboardAccess), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*dashboard.DashboardAccess)(nil), (*DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(a.(*dashboard.DashboardAccess), b.(*DashboardAccess), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*VersionsQueryOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_url_Values_To_v2alpha2_VersionsQueryOptions(a.(*url.Values), b.(*VersionsQueryOptions), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error { + out.CanAdd = in.CanAdd + out.CanEdit = in.CanEdit + out.CanDelete = in.CanDelete + return nil +} + +// Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions is an autogenerated conversion function. +func Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error { + return autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in, out, s) +} + +func autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error { + out.CanAdd = in.CanAdd + out.CanEdit = in.CanEdit + out.CanDelete = in.CanDelete + return nil +} + +// Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions is an autogenerated conversion function. +func Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error { + return autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in, out, s) +} + +func autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error { + if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil { + return err + } + if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Organization, &out.Organization, s); err != nil { + return err + } + return nil +} + +// Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission is an autogenerated conversion function. +func Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error { + return autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in, out, s) +} + +func autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error { + if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil { + return err + } + if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Organization, &out.Organization, s); err != nil { + return err + } + return nil +} + +// Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission is an autogenerated conversion function. +func Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error { + return autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in, out, s) +} + +func autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error { + out.Slug = in.Slug + out.Url = in.Url + out.CanSave = in.CanSave + out.CanEdit = in.CanEdit + out.CanAdmin = in.CanAdmin + out.CanStar = in.CanStar + out.CanDelete = in.CanDelete + out.AnnotationsPermissions = (*dashboard.AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions)) + return nil +} + +// Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess is an autogenerated conversion function. +func Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error { + return autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in, out, s) +} + +func autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error { + out.Slug = in.Slug + out.Url = in.Url + out.CanSave = in.CanSave + out.CanEdit = in.CanEdit + out.CanAdmin = in.CanAdmin + out.CanStar = in.CanStar + out.CanDelete = in.CanDelete + out.AnnotationsPermissions = (*AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions)) + return nil +} + +// Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess is an autogenerated conversion function. +func Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error { + return autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in, out, s) +} + +func autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error { + // WARNING: Field TypeMeta does not have json tag, skipping. + + if values, ok := map[string][]string(*in)["path"]; ok && len(values) > 0 { + if err := runtime.Convert_Slice_string_To_string(&values, &out.Path, s); err != nil { + return err + } + } else { + out.Path = "" + } + if values, ok := map[string][]string(*in)["version"]; ok && len(values) > 0 { + if err := runtime.Convert_Slice_string_To_int64(&values, &out.Version, s); err != nil { + return err + } + } else { + out.Version = 0 + } + return nil +} + +// Convert_url_Values_To_v2alpha2_VersionsQueryOptions is an autogenerated conversion function. +func Convert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error { + return autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in, out, s) +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.deepcopy.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.deepcopy.go new file mode 100644 index 00000000000..9a8a05f7f22 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.deepcopy.go @@ -0,0 +1,283 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// SPDX-License-Identifier: AGPL-3.0-only + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v2alpha2 + +import ( + v0alpha1 "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AnnotationActions) DeepCopyInto(out *AnnotationActions) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnnotationActions. +func (in *AnnotationActions) DeepCopy() *AnnotationActions { + if in == nil { + return nil + } + out := new(AnnotationActions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AnnotationPermission) DeepCopyInto(out *AnnotationPermission) { + *out = *in + out.Dashboard = in.Dashboard + out.Organization = in.Organization + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnnotationPermission. +func (in *AnnotationPermission) DeepCopy() *AnnotationPermission { + if in == nil { + return nil + } + out := new(AnnotationPermission) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardAccess) DeepCopyInto(out *DashboardAccess) { + *out = *in + if in.AnnotationsPermissions != nil { + in, out := &in.AnnotationsPermissions, &out.AnnotationsPermissions + *out = new(AnnotationPermission) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardAccess. +func (in *DashboardAccess) DeepCopy() *DashboardAccess { + if in == nil { + return nil + } + out := new(DashboardAccess) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardVersionInfo) DeepCopyInto(out *DashboardVersionInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardVersionInfo. +func (in *DashboardVersionInfo) DeepCopy() *DashboardVersionInfo { + if in == nil { + return nil + } + out := new(DashboardVersionInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardVersionList) DeepCopyInto(out *DashboardVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DashboardVersionInfo, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardVersionList. +func (in *DashboardVersionList) DeepCopy() *DashboardVersionList { + if in == nil { + return nil + } + out := new(DashboardVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DashboardVersionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardWithAccessInfo) DeepCopyInto(out *DashboardWithAccessInfo) { + *out = *in + in.Dashboard.DeepCopyInto(&out.Dashboard) + in.Access.DeepCopyInto(&out.Access) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardWithAccessInfo. +func (in *DashboardWithAccessInfo) DeepCopy() *DashboardWithAccessInfo { + if in == nil { + return nil + } + out := new(DashboardWithAccessInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DashboardWithAccessInfo) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LibraryPanel) DeepCopyInto(out *LibraryPanel) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(LibraryPanelStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanel. +func (in *LibraryPanel) DeepCopy() *LibraryPanel { + if in == nil { + return nil + } + out := new(LibraryPanel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LibraryPanel) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LibraryPanelList) DeepCopyInto(out *LibraryPanelList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]LibraryPanel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelList. +func (in *LibraryPanelList) DeepCopy() *LibraryPanelList { + if in == nil { + return nil + } + out := new(LibraryPanelList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *LibraryPanelList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LibraryPanelSpec) DeepCopyInto(out *LibraryPanelSpec) { + *out = *in + in.Options.DeepCopyInto(&out.Options) + in.FieldConfig.DeepCopyInto(&out.FieldConfig) + if in.Datasource != nil { + in, out := &in.Datasource, &out.Datasource + *out = new(v0alpha1.DataSourceRef) + **out = **in + } + if in.Targets != nil { + in, out := &in.Targets, &out.Targets + *out = make([]v0alpha1.DataQuery, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelSpec. +func (in *LibraryPanelSpec) DeepCopy() *LibraryPanelSpec { + if in == nil { + return nil + } + out := new(LibraryPanelSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LibraryPanelStatus) DeepCopyInto(out *LibraryPanelStatus) { + *out = *in + if in.Warnings != nil { + in, out := &in.Warnings, &out.Warnings + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Missing.DeepCopyInto(&out.Missing) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelStatus. +func (in *LibraryPanelStatus) DeepCopy() *LibraryPanelStatus { + if in == nil { + return nil + } + out := new(LibraryPanelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VersionsQueryOptions) DeepCopyInto(out *VersionsQueryOptions) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionsQueryOptions. +func (in *VersionsQueryOptions) DeepCopy() *VersionsQueryOptions { + if in == nil { + return nil + } + out := new(VersionsQueryOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VersionsQueryOptions) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.defaults.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.defaults.go new file mode 100644 index 00000000000..efead5bdea7 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.defaults.go @@ -0,0 +1,19 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// SPDX-License-Identifier: AGPL-3.0-only + +// Code generated by defaulter-gen. DO NOT EDIT. + +package v2alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go new file mode 100644 index 00000000000..7ed5e3983d4 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go @@ -0,0 +1,5094 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// SPDX-License-Identifier: AGPL-3.0-only + +// Code generated by openapi-gen. DO NOT EDIT. + +package v2alpha2 + +import ( + common "k8s.io/kube-openapi/pkg/common" + spec "k8s.io/kube-openapi/pkg/validation/spec" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationActions": schema_pkg_apis_dashboard_v2alpha2_AnnotationActions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationPermission": schema_pkg_apis_dashboard_v2alpha2_AnnotationPermission(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.Dashboard": schema_pkg_apis_dashboard_v2alpha2_Dashboard(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAccess": schema_pkg_apis_dashboard_v2alpha2_DashboardAccess(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdHocFilterWithLabels": schema_pkg_apis_dashboard_v2alpha2_DashboardAdHocFilterWithLabels(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardAdhocVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardAdhocVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationPanelFilter": schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationPanelFilter(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQueryKind": schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationQueryKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQuerySpec": schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationQuerySpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemKind": schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutItemKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutItemSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridRepeatOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridRepeatOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingDataKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingDataSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingGroupKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingGroupSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingTimeRangeSizeKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingTimeRangeSizeSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardConstantVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardConstantVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConversionStatus": schema_pkg_apis_dashboard_v2alpha2_DashboardConversionStatus(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardCustomVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardCustomVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDashboardLink": schema_pkg_apis_dashboard_v2alpha2_DashboardDashboardLink(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataLink": schema_pkg_apis_dashboard_v2alpha2_DashboardDataLink(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind": schema_pkg_apis_dashboard_v2alpha2_DashboardDataQueryKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef": schema_pkg_apis_dashboard_v2alpha2_DashboardDataSourceRef(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataTransformerConfig": schema_pkg_apis_dashboard_v2alpha2_DashboardDataTransformerConfig(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardDatasourceVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardDatasourceVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDynamicConfigValue": schema_pkg_apis_dashboard_v2alpha2_DashboardDynamicConfigValue(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardElementReference": schema_pkg_apis_dashboard_v2alpha2_DashboardElementReference(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldColor": schema_pkg_apis_dashboard_v2alpha2_DashboardFieldColor(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfig": schema_pkg_apis_dashboard_v2alpha2_DashboardFieldConfig(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfigSource": schema_pkg_apis_dashboard_v2alpha2_DashboardFieldConfigSource(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemKind": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutItemKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutItemSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardGroupByVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardGroupByVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardIntervalVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardIntervalVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardJSONCodec": schema_pkg_apis_dashboard_v2alpha2_DashboardJSONCodec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKind": schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKindSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelKindSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelRef": schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelRef(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardList": schema_pkg_apis_dashboard_v2alpha2_DashboardList(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMatcherConfig": schema_pkg_apis_dashboard_v2alpha2_DashboardMatcherConfig(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMetadata": schema_pkg_apis_dashboard_v2alpha2_DashboardMetadata(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMetricFindValue": schema_pkg_apis_dashboard_v2alpha2_DashboardMetricFindValue(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKind": schema_pkg_apis_dashboard_v2alpha2_DashboardPanelKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKindOrLibraryPanelKind": schema_pkg_apis_dashboard_v2alpha2_DashboardPanelKindOrLibraryPanelKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQueryKind": schema_pkg_apis_dashboard_v2alpha2_DashboardPanelQueryKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQuerySpec": schema_pkg_apis_dashboard_v2alpha2_DashboardPanelQuerySpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardPanelSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupKind": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryGroupKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryGroupSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryOptionsSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryOptionsSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRangeMap": schema_pkg_apis_dashboard_v2alpha2_DashboardRangeMap(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRegexMap": schema_pkg_apis_dashboard_v2alpha2_DashboardRegexMap(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRepeatOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardRepeatOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowRepeatOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardRowRepeatOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowKind": schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutRowKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutRowSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpecialValueMap": schema_pkg_apis_dashboard_v2alpha2_DashboardSpecialValueMap(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStatus": schema_pkg_apis_dashboard_v2alpha2_DashboardStatus(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrArrayOfString": schema_pkg_apis_dashboard_v2alpha2_DashboardStringOrArrayOfString(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrFloat64": schema_pkg_apis_dashboard_v2alpha2_DashboardStringOrFloat64(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabRepeatOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardTabRepeatOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutKind": schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabKind": schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutTabKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutTabSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableKind": schema_pkg_apis_dashboard_v2alpha2_DashboardTextVariableKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardTextVariableSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThreshold": schema_pkg_apis_dashboard_v2alpha2_DashboardThreshold(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThresholdsConfig": schema_pkg_apis_dashboard_v2alpha2_DashboardThresholdsConfig(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeRangeOption": schema_pkg_apis_dashboard_v2alpha2_DashboardTimeRangeOption(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeSettingsSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardTimeSettingsSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTransformationKind": schema_pkg_apis_dashboard_v2alpha2_DashboardTransformationKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2FieldConfigSourceOverrides": schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2FieldConfigSourceOverrides(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RangeMapOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2RangeMapOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RegexMapOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2RegexMapOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2SpecialValueMapOptions": schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2SpecialValueMapOptions(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMap": schema_pkg_apis_dashboard_v2alpha2_DashboardValueMap(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap": schema_pkg_apis_dashboard_v2alpha2_DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult": schema_pkg_apis_dashboard_v2alpha2_DashboardValueMappingResult(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption": schema_pkg_apis_dashboard_v2alpha2_DashboardVariableOption(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVersionInfo": schema_pkg_apis_dashboard_v2alpha2_DashboardVersionInfo(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVersionList": schema_pkg_apis_dashboard_v2alpha2_DashboardVersionList(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigKind": schema_pkg_apis_dashboard_v2alpha2_DashboardVizConfigKind(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigSpec": schema_pkg_apis_dashboard_v2alpha2_DashboardVizConfigSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v2alpha2_DashboardWithAccessInfo(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanel": schema_pkg_apis_dashboard_v2alpha2_LibraryPanel(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelList": schema_pkg_apis_dashboard_v2alpha2_LibraryPanelList(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelSpec": schema_pkg_apis_dashboard_v2alpha2_LibraryPanelSpec(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelStatus": schema_pkg_apis_dashboard_v2alpha2_LibraryPanelStatus(ref), + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.VersionsQueryOptions": schema_pkg_apis_dashboard_v2alpha2_VersionsQueryOptions(ref), + } +} + +func schema_pkg_apis_dashboard_v2alpha2_AnnotationActions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "canAdd": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canEdit": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canDelete": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"canAdd", "canEdit", "canDelete"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_AnnotationPermission(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "dashboard": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationActions"), + }, + }, + "organization": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationActions"), + }, + }, + }, + Required: []string{"dashboard", "organization"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationActions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_Dashboard(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec is the spec of the Dashboard", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStatus"), + }, + }, + }, + Required: []string{"metadata", "spec", "status"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpec", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAccess(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Information about how the requesting user can use a given dashboard", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "slug": { + SchemaProps: spec.SchemaProps{ + Description: "Metadata fields", + Type: []string{"string"}, + Format: "", + }, + }, + "url": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "canSave": { + SchemaProps: spec.SchemaProps{ + Description: "The permissions part", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canEdit": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canAdmin": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canStar": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "canDelete": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "annotationsPermissions": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationPermission"), + }, + }, + }, + Required: []string{"canSave", "canEdit", "canAdmin", "canStar", "canDelete", "annotationsPermissions"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.AnnotationPermission"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAdHocFilterWithLabels(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Define the AdHocFilterWithLabels type", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "keyLabel": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "valueLabels": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "forceEdit": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "origin": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "condition": { + SchemaProps: spec.SchemaProps{ + Description: "@deprecated", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"key", "operator", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAdhocVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adhoc variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAdhocVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Adhoc variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"), + }, + }, + "baseFilters": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdHocFilterWithLabels"), + }, + }, + }, + }, + }, + "filters": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdHocFilterWithLabels"), + }, + }, + }, + }, + }, + "defaultKeys": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMetricFindValue"), + }, + }, + }, + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name", "baseFilters", "filters", "defaultKeys", "hide", "skipUrlSync", "allowCustomValue"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdHocFilterWithLabels", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMetricFindValue"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationPanelFilter(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "exclude": { + SchemaProps: spec.SchemaProps{ + Description: "Should the specified panels be included or excluded", + Type: []string{"boolean"}, + Format: "", + }, + }, + "ids": { + SchemaProps: spec.SchemaProps{ + Description: "Panel IDs that should be included or excluded", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + }, + Required: []string{"ids"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationQueryKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQuerySpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQuerySpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAnnotationQuerySpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"), + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind"), + }, + }, + "enable": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "iconColor": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "builtIn": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "filter": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationPanelFilter"), + }, + }, + "legacyOptions": { + SchemaProps: spec.SchemaProps{ + Description: "Catch-all field for datasource-specific properties", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"enable", "hide", "iconColor", "name"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationPanelFilter", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutItemKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutItemSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "element": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardElementReference"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridRepeatOptions"), + }, + }, + "conditionalRendering": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind"), + }, + }, + }, + Required: []string{"element"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridRepeatOptions", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardElementReference"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridLayoutSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "maxColumnCount": { + SchemaProps: spec.SchemaProps{ + Type: []string{"number"}, + Format: "double", + }, + }, + "columnWidthMode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "columnWidth": { + SchemaProps: spec.SchemaProps{ + Type: []string{"number"}, + Format: "double", + }, + }, + "rowHeightMode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "rowHeight": { + SchemaProps: spec.SchemaProps{ + Type: []string{"number"}, + Format: "double", + }, + }, + "fillScreen": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"columnWidthMode", "rowHeightMode", "items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutItemKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardAutoGridRepeatOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"mode", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingDataKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingDataSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingGroupKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingGroupSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "visibility": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "condition": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"visibility", "condition", "items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingTimeRangeSizeKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingTimeRangeSizeSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ConditionalRenderingVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKind"), + }, + }, + "ConditionalRenderingDataKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataKind"), + }, + }, + "ConditionalRenderingTimeRangeSizeKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingDataKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingTimeRangeSizeKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingVariableKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConditionalRenderingVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "variable": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"variable", "operator", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConstantVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Constant variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConstantVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Constant variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "query", "current", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardConversionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ConversionStatus is the status of the conversion of the dashboard.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "failed": { + SchemaProps: spec.SchemaProps{ + Description: "Whether from another version has failed. If true, means that the dashboard is not valid, and the caller should instead fetch the stored version.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "storedVersion": { + SchemaProps: spec.SchemaProps{ + Description: "The version which was stored when the dashboard was created / updated. Fetching this version should always succeed.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Description: "The error message from the conversion. Empty if the conversion has not failed.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"failed", "storedVersion", "error"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardCustomVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Custom variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardCustomVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Custom variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "multi": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "includeAll": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "allValue": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name", "query", "current", "options", "multi", "includeAll", "hide", "skipUrlSync", "allowCustomValue"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDashboardLink(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Links with references to other dashboards or external resources", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "title": { + SchemaProps: spec.SchemaProps{ + Description: "Title to display with the link", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType`", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "icon": { + SchemaProps: spec.SchemaProps{ + Description: "Icon name to be displayed with the link", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "tooltip": { + SchemaProps: spec.SchemaProps{ + Description: "Tooltip to display when the user hovers their mouse over it", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "url": { + SchemaProps: spec.SchemaProps{ + Description: "Link URL. Only required/valid if the type is link", + Type: []string{"string"}, + Format: "", + }, + }, + "tags": { + SchemaProps: spec.SchemaProps{ + Description: "List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "asDropdown": { + SchemaProps: spec.SchemaProps{ + Description: "If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "targetBlank": { + SchemaProps: spec.SchemaProps{ + Description: "If true, the link will be opened in a new tab", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "includeVars": { + SchemaProps: spec.SchemaProps{ + Description: "If true, includes current template variables values in the link as query params", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "keepTime": { + SchemaProps: spec.SchemaProps{ + Description: "If true, includes current time range in the link as query params", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"title", "type", "icon", "tooltip", "tags", "asDropdown", "targetBlank", "includeVars", "keepTime"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDataLink(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "title": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "url": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "targetBlank": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"title", "url"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDataQueryKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "The kind of a DataQueryKind is the datasource type", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDataSourceRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "The plugin type-id", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "Specific datasource instance", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDataTransformerConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Transformations allow to manipulate data returned by a query before the system applies a visualization. Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, use the output of one transformation as the input to another transformation, etc.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "Unique identifier of transformer", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "disabled": { + SchemaProps: spec.SchemaProps{ + Description: "Disabled transformations are skipped", + Type: []string{"boolean"}, + Format: "", + }, + }, + "filter": { + SchemaProps: spec.SchemaProps{ + Description: "Optional frame matcher. When missing it will be applied to all results", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMatcherConfig"), + }, + }, + "topic": { + SchemaProps: spec.SchemaProps{ + Description: "Where to pull DataFrames from as input to transformation", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "Options to be passed to the transformer Valid options depend on the transformer id", + Type: []string{"object"}, + Format: "", + }, + }, + }, + Required: []string{"id", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMatcherConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDatasourceVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Datasource variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDatasourceVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Datasource variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "pluginId": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "refresh": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "regex": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "multi": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "includeAll": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "allValue": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name", "pluginId", "refresh", "regex", "current", "options", "multi", "includeAll", "hide", "skipUrlSync", "allowCustomValue"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardDynamicConfigValue(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + Required: []string{"id"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardElementReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"kind", "name"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardFieldColor(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Map a field to a color.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Description: "The main color scheme mode.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "fixedColor": { + SchemaProps: spec.SchemaProps{ + Description: "The fixed color value for fixed or shades color modes.", + Type: []string{"string"}, + Format: "", + }, + }, + "seriesBy": { + SchemaProps: spec.SchemaProps{ + Description: "Some visualizations need to know how to assign a series color from by value color schemes.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"mode"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardFieldConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. Each column within this structure is called a field. A field can represent a single time series or table column. Field options allow you to change how the data is displayed in your visualizations.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "displayName": { + SchemaProps: spec.SchemaProps{ + Description: "The display value for this field. This supports template variables blank is auto", + Type: []string{"string"}, + Format: "", + }, + }, + "displayNameFromDS": { + SchemaProps: spec.SchemaProps{ + Description: "This can be used by data sources that return and explicit naming structure for values and labels When this property is configured, this value is used rather than the default naming strategy.", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "Human readable field metadata", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "An explicit path to the field in the datasource. When the frame meta includes a path, This will default to `${frame.meta.path}/${field.name}\n\nWhen defined, this value can be used as an identifier within the datasource scope, and may be used to update the results", + Type: []string{"string"}, + Format: "", + }, + }, + "writeable": { + SchemaProps: spec.SchemaProps{ + Description: "True if data source can write a value to the path. Auth/authz are supported separately", + Type: []string{"boolean"}, + Format: "", + }, + }, + "filterable": { + SchemaProps: spec.SchemaProps{ + Description: "True if data source field supports ad-hoc filters", + Type: []string{"boolean"}, + Format: "", + }, + }, + "unit": { + SchemaProps: spec.SchemaProps{ + Description: "Unit a field should use. The unit you select is applied to all fields except time. You can use the units ID availables in Grafana or a custom unit. Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts As custom unit, you can use the following formats: `suffix:` for custom unit that should go after value. `prefix:` for custom unit that should go before value. `time:` For custom date time formats type for example `time:YYYY-MM-DD`. `si:` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. `count:` for a custom count unit. `currency:` for custom a currency unit.", + Type: []string{"string"}, + Format: "", + }, + }, + "decimals": { + SchemaProps: spec.SchemaProps{ + Description: "Specify the number of decimals Grafana includes in the rendered value. If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. For example 1.1234 will display as 1.12 and 100.456 will display as 100. To display all decimals, set the unit to `String`.", + Type: []string{"number"}, + Format: "double", + }, + }, + "min": { + SchemaProps: spec.SchemaProps{ + Description: "The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.", + Type: []string{"number"}, + Format: "double", + }, + }, + "max": { + SchemaProps: spec.SchemaProps{ + Description: "The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.", + Type: []string{"number"}, + Format: "double", + }, + }, + "mappings": { + SchemaProps: spec.SchemaProps{ + Description: "Convert input values into a display string", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap"), + }, + }, + }, + }, + }, + "thresholds": { + SchemaProps: spec.SchemaProps{ + Description: "Map numeric values to states", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThresholdsConfig"), + }, + }, + "color": { + SchemaProps: spec.SchemaProps{ + Description: "Panel color configuration", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldColor"), + }, + }, + "links": { + SchemaProps: spec.SchemaProps{ + Description: "The behavior when clicking on a result", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + "noValue": { + SchemaProps: spec.SchemaProps{ + Description: "Alternative to empty string", + Type: []string{"string"}, + Format: "", + }, + }, + "custom": { + SchemaProps: spec.SchemaProps{ + Description: "custom is specified by the FieldConfig field in panel plugin schemas.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldColor", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThresholdsConfig", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardFieldConfigSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. Each column within this structure is called a field. A field can represent a single time series or table column. Field options allow you to change how the data is displayed in your visualizations.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "defaults": { + SchemaProps: spec.SchemaProps{ + Description: "Defaults are the options applied to all fields.", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfig"), + }, + }, + "overrides": { + SchemaProps: spec.SchemaProps{ + Description: "Overrides are the options applied to specific fields overriding the defaults.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2FieldConfigSourceOverrides"), + }, + }, + }, + }, + }, + }, + Required: []string{"defaults", "overrides"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfig", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2FieldConfigSourceOverrides"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutItemKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutItemSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "x": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "y": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "width": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "height": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "element": { + SchemaProps: spec.SchemaProps{ + Description: "reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardElementReference"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRepeatOptions"), + }, + }, + }, + Required: []string{"x", "y", "width", "height", "element"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardElementReference", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "GridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKind"), + }, + }, + "AutoGridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutKind"), + }, + }, + "TabsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutKind"), + }, + }, + "RowsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "GridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKind"), + }, + }, + "RowsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutKind"), + }, + }, + "AutoGridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutKind"), + }, + }, + "TabsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAutoGridLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGridLayoutSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutItemKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGroupByVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Group variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardGroupByVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupBy variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"), + }, + }, + "defaultValue": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "multi": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "current", "options", "multi", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardIntervalVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Interval variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardIntervalVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Interval variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "auto": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "auto_min": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "auto_count": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "refresh": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "query", "current", "options", "auto", "auto_min", "auto_count", "refresh", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardJSONCodec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DashboardJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding", + Type: []string{"object"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKindSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKindSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelKindSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "Panel ID for the library panel in the dashboard", + Default: 0, + Type: []string{"number"}, + Format: "double", + }, + }, + "title": { + SchemaProps: spec.SchemaProps{ + Description: "Title for the library panel in the dashboard", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "libraryPanel": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelRef"), + }, + }, + }, + Required: []string{"id", "title", "libraryPanel"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardLibraryPanelRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A library panel is a reusable panel that you can use in any dashboard. When you make a change to a library panel, that change propagates to all instances of where the panel is used. Library panels streamline reuse of panels across multiple dashboards.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Library panel name", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "Library panel uid", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "uid"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.Dashboard"), + }, + }, + }, + }, + }, + }, + Required: []string{"metadata", "items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.Dashboard", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardMatcherConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "The matcher id. This is used to find the matcher implementation from registry.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "The matcher options. This is specific to the matcher implementation.", + Type: []string{"object"}, + Format: "", + }, + }, + }, + Required: []string{"id"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardMetadata(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "metadata contains embedded CommonMetadata and can be extended with custom string fields without external reference as using the CommonMetadata reference breaks thema codegen.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "updateTimestamp": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + "createdBy": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "creationTimestamp": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + "deletionTimestamp": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + "finalizers": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "generation": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "updatedBy": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "labels": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"updateTimestamp", "createdBy", "uid", "creationTimestamp", "finalizers", "resourceVersion", "generation", "updatedBy", "labels"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardMetricFindValue(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Define the MetricFindValue type", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "text": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrFloat64"), + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "expandable": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"text"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrFloat64"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardPanelKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardPanelKindOrLibraryPanelKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "PanelKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKind"), + }, + }, + "LibraryPanelKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardLibraryPanelKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardPanelQueryKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQuerySpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQuerySpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardPanelQuerySpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "query": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind"), + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"), + }, + }, + "refId": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "hidden": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"query", "refId", "hidden"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardPanelSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"number"}, + Format: "double", + }, + }, + "title": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "links": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataLink"), + }, + }, + }, + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupKind"), + }, + }, + "vizConfig": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigKind"), + }, + }, + "transparent": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"id", "title", "description", "links", "data", "vizConfig"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataLink", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryGroupKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryGroupSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryGroupSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "queries": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQueryKind"), + }, + }, + }, + }, + }, + "transformations": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTransformationKind"), + }, + }, + }, + }, + }, + "queryOptions": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryOptionsSpec"), + }, + }, + }, + Required: []string{"queries", "transformations", "queryOptions"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryOptionsSpec", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTransformationKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryOptionsSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "timeFrom": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "maxDataPoints": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int64", + }, + }, + "timeShift": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "queryCachingTTL": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int64", + }, + }, + "interval": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "cacheTimeout": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hideTimeOverride": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Query variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "QueryVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKind"), + }, + }, + "TextVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableKind"), + }, + }, + "ConstantVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableKind"), + }, + }, + "DatasourceVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableKind"), + }, + }, + "IntervalVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableKind"), + }, + }, + "CustomVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableKind"), + }, + }, + "GroupByVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableKind"), + }, + }, + "AdhocVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAdhocVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConstantVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardCustomVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDatasourceVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGroupByVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardIntervalVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardQueryVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Query variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "refresh": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef"), + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind"), + }, + }, + "regex": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "sort": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "definition": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "multi": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "includeAll": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "allValue": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "placeholder": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "allowCustomValue": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "staticOptions": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + }, + }, + }, + "staticOptionsOrder": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "current", "hide", "refresh", "skipUrlSync", "query", "regex", "sort", "options", "multi", "includeAll", "allowCustomValue"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataSourceRef", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRangeMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "Range to match against and the result to apply when the value is within the range", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RangeMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RangeMapOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRegexMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "Regular expression to match against and the result to apply when the value matches the regex", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RegexMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2RegexMapOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRepeatOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "direction": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "maxPerRow": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + Required: []string{"mode", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRowRepeatOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"mode", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutRowKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutRowSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "title": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "collapse": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "hideHeader": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "fillScreen": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "conditionalRendering": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowRepeatOptions"), + }, + }, + "layout": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind"), + }, + }, + }, + Required: []string{"layout"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardRowsLayoutSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "rows": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"rows"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRowsLayoutRowKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "annotations": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQueryKind"), + }, + }, + }, + }, + }, + "cursorSync": { + SchemaProps: spec.SchemaProps{ + Description: "Configuration of dashboard cursor sync behavior. \"Off\" for no shared crosshair or tooltip (default). \"Crosshair\" for shared crosshair. \"Tooltip\" for shared crosshair AND shared tooltip.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "Description of dashboard.", + Type: []string{"string"}, + Format: "", + }, + }, + "editable": { + SchemaProps: spec.SchemaProps{ + Description: "Whether a dashboard is editable or not.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "elements": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKindOrLibraryPanelKind"), + }, + }, + }, + }, + }, + "layout": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind"), + }, + }, + "links": { + SchemaProps: spec.SchemaProps{ + Description: "Links with references to other dashboards or external websites.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDashboardLink"), + }, + }, + }, + }, + }, + "liveNow": { + SchemaProps: spec.SchemaProps{ + Description: "When set to true, the dashboard will redraw panels at an interval matching the pixel width. This will keep data \"moving left\" regardless of the query refresh rate. This setting helps avoid dashboards presenting stale live data.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "preload": { + SchemaProps: spec.SchemaProps{ + Description: "When set to true, the dashboard will load all panels in the dashboard when it's loaded.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "revision": { + SchemaProps: spec.SchemaProps{ + Description: "Plugins only. The version of the dashboard installed together with the plugin. This is used to determine if the dashboard should be updated when the plugin is updated.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "tags": { + SchemaProps: spec.SchemaProps{ + Description: "Tags associated with dashboard.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "timeSettings": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeSettingsSpec"), + }, + }, + "title": { + SchemaProps: spec.SchemaProps{ + Description: "Title of dashboard.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "variables": { + SchemaProps: spec.SchemaProps{ + Description: "Configured template variables.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"annotations", "cursorSync", "elements", "layout", "links", "preload", "tags", "timeSettings", "title", "variables"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAnnotationQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDashboardLink", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardPanelKindOrLibraryPanelKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeSettingsSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardSpecialValueMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2SpecialValueMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardV2alpha2SpecialValueMapOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "conversion": { + SchemaProps: spec.SchemaProps{ + Description: "Optional conversion status.", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConversionStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConversionStatus"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardStringOrArrayOfString(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "String": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "ArrayOfString": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardStringOrFloat64(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "String": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "Float64": { + SchemaProps: spec.SchemaProps{ + Type: []string{"number"}, + Format: "double", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTabRepeatOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"mode", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "tabs": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"tabs"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutTabKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabsLayoutTabSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTabsLayoutTabSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "title": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "layout": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind"), + }, + }, + "conditionalRendering": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabRepeatOptions"), + }, + }, + }, + Required: []string{"layout"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardConditionalRenderingGroupKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTabRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTextVariableKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Text variable kind", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTextVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTextVariableSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Text variable specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"), + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "label": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "hide": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "skipUrlSync": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "current", "query", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardThreshold(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"number"}, + Format: "double", + }, + }, + "color": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value", "color"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardThresholdsConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "steps": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThreshold"), + }, + }, + }, + }, + }, + }, + Required: []string{"mode", "steps"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardThreshold"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTimeRangeOption(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "display": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "from": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "to": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"display", "from", "to"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTimeSettingsSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Time configuration It defines the default time config for the time picker, the refresh picker for the specific dashboard.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "timezone": { + SchemaProps: spec.SchemaProps{ + Description: "Timezone of dashboard. Accepted values are IANA TZDB zone ID or \"browser\" or \"utc\".", + Type: []string{"string"}, + Format: "", + }, + }, + "from": { + SchemaProps: spec.SchemaProps{ + Description: "Start time range for dashboard. Accepted values are relative time strings like \"now-6h\" or absolute time strings like \"2020-07-10T08:00:00.000Z\".", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "to": { + SchemaProps: spec.SchemaProps{ + Description: "End time range for dashboard. Accepted values are relative time strings like \"now-6h\" or absolute time strings like \"2020-07-10T08:00:00.000Z\".", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "autoRefresh": { + SchemaProps: spec.SchemaProps{ + Description: "Refresh rate of dashboard. Represented via interval string, e.g. \"5s\", \"1m\", \"1h\", \"1d\". v1: refresh", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "autoRefreshIntervals": { + SchemaProps: spec.SchemaProps{ + Description: "Interval options available in the refresh picker dropdown. v1: timepicker.refresh_intervals", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "quickRanges": { + SchemaProps: spec.SchemaProps{ + Description: "Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. v1: timepicker.quick_ranges , not exposed in the UI", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeRangeOption"), + }, + }, + }, + }, + }, + "hideTimepicker": { + SchemaProps: spec.SchemaProps{ + Description: "Whether timepicker is visible or not. v1: timepicker.hidden", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "weekStart": { + SchemaProps: spec.SchemaProps{ + Description: "Day when the week starts. Expressed by the name of the day in lowercase, e.g. \"monday\".", + Type: []string{"string"}, + Format: "", + }, + }, + "fiscalYearStartMonth": { + SchemaProps: spec.SchemaProps{ + Description: "The month that the fiscal year starts on. 0 = January, 11 = December", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "nowDelay": { + SchemaProps: spec.SchemaProps{ + Description: "Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values. v1: timepicker.nowDelay", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"from", "to", "autoRefresh", "autoRefreshIntervals", "hideTimepicker", "fiscalYearStartMonth"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardTimeRangeOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardTransformationKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "The kind of a TransformationKind is the transformation ID", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataTransformerConfig"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDataTransformerConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2FieldConfigSourceOverrides(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matcher": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMatcherConfig"), + }, + }, + "properties": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDynamicConfigValue"), + }, + }, + }, + }, + }, + }, + Required: []string{"matcher", "properties"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardDynamicConfigValue", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardMatcherConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2RangeMapOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "from": { + SchemaProps: spec.SchemaProps{ + Description: "Min value of the range. It can be null which means -Infinity", + Type: []string{"number"}, + Format: "double", + }, + }, + "to": { + SchemaProps: spec.SchemaProps{ + Description: "Max value of the range. It can be null which means +Infinity", + Type: []string{"number"}, + Format: "double", + }, + }, + "result": { + SchemaProps: spec.SchemaProps{ + Description: "Config to apply when the value is within the range", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"from", "to", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2RegexMapOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pattern": { + SchemaProps: spec.SchemaProps{ + Description: "Regular expression to match against", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "result": { + SchemaProps: spec.SchemaProps{ + Description: "Config to apply when the value matches the regex", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"pattern", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardV2alpha2SpecialValueMapOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "match": { + SchemaProps: spec.SchemaProps{ + Description: "Special value to match against", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "result": { + SchemaProps: spec.SchemaProps{ + Description: "Config to apply when the value matches the special value", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"match", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardValueMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "Map with : ValueMappingResult. For example: { \"10\": { text: \"Perfection!\", color: \"green\" } }", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"), + }, + }, + }, + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "ValueMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMap"), + }, + }, + "RangeMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRangeMap"), + }, + }, + "RegexMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRegexMap"), + }, + }, + "SpecialValueMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpecialValueMap"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRangeMap", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardRegexMap", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpecialValueMap", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardValueMap"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardValueMappingResult(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Result used as replacement with text and color when the value matches", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "text": { + SchemaProps: spec.SchemaProps{ + Description: "Text to display when the value matches", + Type: []string{"string"}, + Format: "", + }, + }, + "color": { + SchemaProps: spec.SchemaProps{ + Description: "Text to use when the value matches", + Type: []string{"string"}, + Format: "", + }, + }, + "icon": { + SchemaProps: spec.SchemaProps{ + Description: "Icon to display when the value matches. Only specific visualizations.", + Type: []string{"string"}, + Format: "", + }, + }, + "index": { + SchemaProps: spec.SchemaProps{ + Description: "Position in the mapping array. Only used internally.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardVariableOption(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Variable option specification", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "selected": { + SchemaProps: spec.SchemaProps{ + Description: "Whether the option is selected or not", + Type: []string{"boolean"}, + Format: "", + }, + }, + "text": { + SchemaProps: spec.SchemaProps{ + Description: "Text to be displayed for the option", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrArrayOfString"), + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value of the option", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrArrayOfString"), + }, + }, + }, + Required: []string{"text", "value"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStringOrArrayOfString"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardVersionInfo(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "version": { + SchemaProps: spec.SchemaProps{ + Description: "The internal ID for this version (will be replaced with resourceVersion)", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "parentVersion": { + SchemaProps: spec.SchemaProps{ + Description: "If the dashboard came from a previous version, it is set here", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "created": { + SchemaProps: spec.SchemaProps{ + Description: "The creation timestamp for this version", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "createdBy": { + SchemaProps: spec.SchemaProps{ + Description: "The user who created this version", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Message passed while saving the version", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"version", "created"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardVersionList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVersionInfo"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVersionInfo", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardVizConfigKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "The kind of a VizConfigKind is the plugin ID", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardVizConfigSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardVizConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "--- Kinds ---", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pluginVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + "fieldConfig": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfigSource"), + }, + }, + }, + Required: []string{"pluginVersion", "options", "fieldConfig"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardFieldConfigSource"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_DashboardWithAccessInfo(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "This is like the legacy DTO where access and metadata are all returned in a single call", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Spec is the spec of the Dashboard", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStatus"), + }, + }, + "access": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAccess"), + }, + }, + }, + Required: []string{"metadata", "spec", "status", "access"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardAccess", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardSpec", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_LibraryPanel(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Description: "Panel properties", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status will show errors", + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelStatus"), + }, + }, + }, + Required: []string{"spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelSpec", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanelStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_LibraryPanelList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanel"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2.LibraryPanel", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_LibraryPanelSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "The panel type", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "pluginVersion": { + SchemaProps: spec.SchemaProps{ + Description: "The panel type", + Type: []string{"string"}, + Format: "", + }, + }, + "title": { + SchemaProps: spec.SchemaProps{ + Description: "The panel title", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "Library panel description", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Description: "The options schema depends on the panel type", + Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + }, + }, + "fieldConfig": { + SchemaProps: spec.SchemaProps{ + Description: "The fieldConfig schema depends on the panel type", + Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Description: "The default datasource type", + Ref: ref("github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1.DataSourceRef"), + }, + }, + "targets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "set", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "The datasource queries", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1.DataQuery"), + }, + }, + }, + }, + }, + }, + Required: []string{"type", "options", "fieldConfig"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1.DataQuery", "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1.DataSourceRef", "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_LibraryPanelStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "warnings": { + SchemaProps: spec.SchemaProps{ + Description: "Translation warnings (mostly things that were in SQL columns but not found in the saved body)", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "missing": { + SchemaProps: spec.SchemaProps{ + Description: "The properties previously stored in SQL that are not included in this model", + Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha2_VersionsQueryOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "path": { + SchemaProps: spec.SchemaProps{ + Description: "Path is the URL path", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} diff --git a/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi_violation_exceptions.list b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi_violation_exceptions.list new file mode 100644 index 00000000000..1db67fbe438 --- /dev/null +++ b/apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi_violation_exceptions.list @@ -0,0 +1,67 @@ +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,ValueLabels +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,Values +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,BaseFilters +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,DefaultKeys +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,Filters +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAnnotationPanelFilter,Ids +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAutoGridLayoutSpec,Items +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingGroupSpec,Items +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardCustomVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDashboardLink,Tags +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDatasourceVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Links +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Mappings +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfigSource,Overrides +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutSpec,Items +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGroupByVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardMetadata,Finalizers +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelSpec,Links +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Queries +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Transformations +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,StaticOptions +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardRowsLayoutSpec,Rows +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Annotations +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Links +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Tags +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Variables +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTabsLayoutSpec,Tabs +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardThresholdsConfig,Steps +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,AutoRefreshIntervals +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,QuickRanges +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardV2alpha2FieldConfigSourceOverrides,Properties +API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,LibraryPanelStatus,Warnings +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingDataKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingTimeRangeSizeKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,AutoGridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,GridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,RowsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,TabsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,AutoGridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,GridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,RowsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,TabsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoCount +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoMin +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,LibraryPanelKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,PanelKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,AdhocVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,ConstantVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,CustomVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,DatasourceVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,GroupByVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,IntervalVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,QueryVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,TextVariableKind +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,String +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,Float64 +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,String +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RangeMap +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RegexMap +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,SpecialValueMap +API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,ValueMap +API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardList,ListMeta diff --git a/apps/dashboard/pkg/apis/dashboard_manifest.go b/apps/dashboard/pkg/apis/dashboard_manifest.go index 568e229d09d..59f0032ab5f 100644 --- a/apps/dashboard/pkg/apis/dashboard_manifest.go +++ b/apps/dashboard/pkg/apis/dashboard_manifest.go @@ -14,6 +14,7 @@ import ( v0alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" v1beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + v2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" ) var appManifestData = app.ManifestData{ @@ -36,6 +37,10 @@ var appManifestData = app.ManifestData{ { Name: "v2alpha1", }, + + { + Name: "v2alpha2", + }, }, }, }, @@ -53,6 +58,7 @@ var kindVersionToGoType = map[string]resource.Kind{ "Dashboard/v0alpha1": v0alpha1.DashboardKind(), "Dashboard/v1beta1": v1beta1.DashboardKind(), "Dashboard/v2alpha1": v2alpha1.DashboardKind(), + "Dashboard/v2alpha2": v2alpha2.DashboardKind(), } // ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists. diff --git a/apps/dashboard/pkg/migration/conversion/conversion.go b/apps/dashboard/pkg/migration/conversion/conversion.go index ff9f1c0365c..8fb35a45dbe 100644 --- a/apps/dashboard/pkg/migration/conversion/conversion.go +++ b/apps/dashboard/pkg/migration/conversion/conversion.go @@ -6,167 +6,77 @@ import ( dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" - dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" - "github.com/grafana/grafana/apps/dashboard/pkg/migration" - "github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" ) func RegisterConversions(s *runtime.Scheme) error { + // v0 conversions if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_V0_to_V1(a.(*dashv0.Dashboard), b.(*dashv1.Dashboard), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_V0_to_V2(a.(*dashv0.Dashboard), b.(*dashv2.Dashboard), scope) + if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V0_to_V2alpha1(a.(*dashv0.Dashboard), b.(*dashv2alpha1.Dashboard), scope) }); err != nil { return err } + if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V0_to_V2alpha2(a.(*dashv0.Dashboard), b.(*dashv2alpha2.Dashboard), scope) + }); err != nil { + return err + } + + // v1 conversions if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_V1_to_V0(a.(*dashv1.Dashboard), b.(*dashv0.Dashboard), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_V1_to_V2(a.(*dashv1.Dashboard), b.(*dashv2.Dashboard), scope) + if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V1_to_V2alpha1(a.(*dashv1.Dashboard), b.(*dashv2alpha1.Dashboard), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*dashv2.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_V2_to_V0(a.(*dashv2.Dashboard), b.(*dashv0.Dashboard), scope) + if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V1_to_V2alpha2(a.(*dashv1.Dashboard), b.(*dashv2alpha2.Dashboard), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*dashv2.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_V2_to_V1(a.(*dashv2.Dashboard), b.(*dashv1.Dashboard), scope) + + // v2alpha1 conversions + if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha1_to_V0(a.(*dashv2alpha1.Dashboard), b.(*dashv0.Dashboard), scope) }); err != nil { return err } - return nil -} - -func Convert_V0_to_V1(in *dashv0.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - out.Spec.Object = in.Spec.Object - - out.Status = dashv1.DashboardStatus{ - Conversion: &dashv1.DashboardConversionStatus{ - StoredVersion: dashv0.VERSION, - }, + if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha1_to_V1(a.(*dashv2alpha1.Dashboard), b.(*dashv1.Dashboard), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha1_to_V2alpha2(a.(*dashv2alpha1.Dashboard), b.(*dashv2alpha2.Dashboard), scope) + }); err != nil { + return err } - if err := migration.Migrate(out.Spec.Object, schemaversion.LATEST_VERSION); err != nil { - out.Status.Conversion.Failed = true - out.Status.Conversion.Error = err.Error() - } - - return nil -} - -func Convert_V0_to_V2(in *dashv0.Dashboard, out *dashv2.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - // TODO (@radiohead): implement V0 to V2 conversion - // This is the bare minimum conversion that is needed to make the dashboard servable. - - if v, ok := in.Spec.Object["title"]; ok { - if title, ok := v.(string); ok { - out.Spec.Title = title - } - } - - // We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail. - out.Spec.Layout = dashv2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{ - GridLayoutKind: &dashv2.DashboardGridLayoutKind{ - Kind: "GridLayout", - Spec: dashv2.DashboardGridLayoutSpec{}, - }, - } - - out.Status = dashv2.DashboardStatus{ - Conversion: &dashv2.DashboardConversionStatus{ - StoredVersion: dashv0.VERSION, - Failed: true, - Error: "backend conversion not yet implemented", - }, - } - - return nil -} - -func Convert_V1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - out.Spec.Object = in.Spec.Object - - out.Status = dashv0.DashboardStatus{ - Conversion: &dashv0.DashboardConversionStatus{ - StoredVersion: dashv1.VERSION, - }, - } - - return nil -} - -func Convert_V1_to_V2(in *dashv1.Dashboard, out *dashv2.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - // TODO (@radiohead): implement V1 to V2 conversion - // This is the bare minimum conversion that is needed to make the dashboard servable. - - if v, ok := in.Spec.Object["title"]; ok { - if title, ok := v.(string); ok { - out.Spec.Title = title - } - } - - // We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail. - out.Spec.Layout = dashv2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{ - GridLayoutKind: &dashv2.DashboardGridLayoutKind{ - Kind: "GridLayout", - Spec: dashv2.DashboardGridLayoutSpec{}, - }, - } - - out.Status = dashv2.DashboardStatus{ - Conversion: &dashv2.DashboardConversionStatus{ - StoredVersion: dashv1.VERSION, - Failed: true, - Error: "backend conversion not yet implemented", - }, - } - - return nil -} - -func Convert_V2_to_V0(in *dashv2.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - // TODO: implement V2 to V0 conversion - - out.Status = dashv0.DashboardStatus{ - Conversion: &dashv0.DashboardConversionStatus{ - StoredVersion: dashv2.VERSION, - Failed: true, - Error: "backend conversion not yet implemented", - }, - } - - return nil -} - -func Convert_V2_to_V1(in *dashv2.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - - // TODO: implement V2 to V1 conversion - - out.Status = dashv1.DashboardStatus{ - Conversion: &dashv1.DashboardConversionStatus{ - StoredVersion: dashv2.VERSION, - Failed: true, - Error: "backend conversion not yet implemented", - }, + // v2alpha2 conversions + if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha2_to_V0(a.(*dashv2alpha2.Dashboard), b.(*dashv0.Dashboard), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha2_to_V1(a.(*dashv2alpha2.Dashboard), b.(*dashv1.Dashboard), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_V2alpha2_to_V2alpha1(a.(*dashv2alpha2.Dashboard), b.(*dashv2alpha1.Dashboard), scope) + }); err != nil { + return err } return nil diff --git a/apps/dashboard/pkg/migration/conversion/conversion_test.go b/apps/dashboard/pkg/migration/conversion/conversion_test.go index 9e51322fee1..0efd0ab6205 100644 --- a/apps/dashboard/pkg/migration/conversion/conversion_test.go +++ b/apps/dashboard/pkg/migration/conversion/conversion_test.go @@ -11,7 +11,8 @@ import ( dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" - dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" "github.com/grafana/grafana/apps/dashboard/pkg/migration" "github.com/grafana/grafana/apps/dashboard/pkg/migration/testutil" common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" @@ -25,7 +26,8 @@ func TestConversionMatrixExist(t *testing.T) { versions := []v1.Object{ &dashv0.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV0"}}}, &dashv1.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV1"}}}, - &dashv2.Dashboard{Spec: dashv2.DashboardSpec{Title: "dashboardV2"}}, + &dashv2alpha1.Dashboard{Spec: dashv2alpha1.DashboardSpec{Title: "dashboardV2alpha1"}}, + &dashv2alpha2.Dashboard{Spec: dashv2alpha2.DashboardSpec{Title: "dashboardV2alpha2"}}, } scheme := runtime.NewScheme() diff --git a/apps/dashboard/pkg/migration/conversion/v0.go b/apps/dashboard/pkg/migration/conversion/v0.go new file mode 100644 index 00000000000..94f3d5b57f4 --- /dev/null +++ b/apps/dashboard/pkg/migration/conversion/v0.go @@ -0,0 +1,78 @@ +package conversion + +import ( + "k8s.io/apimachinery/pkg/conversion" + + dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" + dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" + "github.com/grafana/grafana/apps/dashboard/pkg/migration" + "github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion" +) + +func Convert_V0_to_V1(in *dashv0.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + out.Spec.Object = in.Spec.Object + + out.Status = dashv1.DashboardStatus{ + Conversion: &dashv1.DashboardConversionStatus{ + StoredVersion: dashv0.VERSION, + }, + } + + if err := migration.Migrate(out.Spec.Object, schemaversion.LATEST_VERSION); err != nil { + out.Status.Conversion.Failed = true + out.Status.Conversion.Error = err.Error() + } + + return nil +} + +func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO (@radiohead): implement V0 to V2 conversion + // This is the bare minimum conversion that is needed to make the dashboard servable. + + if v, ok := in.Spec.Object["title"]; ok { + if title, ok := v.(string); ok { + out.Spec.Title = title + } + } + + // We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail. + out.Spec.Layout = dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{ + GridLayoutKind: &dashv2alpha1.DashboardGridLayoutKind{ + Kind: "GridLayout", + Spec: dashv2alpha1.DashboardGridLayoutSpec{}, + }, + } + + out.Status = dashv2alpha1.DashboardStatus{ + Conversion: &dashv2alpha1.DashboardConversionStatus{ + StoredVersion: dashv0.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V0_to_V2alpha2(in *dashv0.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V0 to V2alpha2 conversion + + out.Status = dashv2alpha2.DashboardStatus{ + Conversion: &dashv2alpha2.DashboardConversionStatus{ + StoredVersion: dashv0.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} diff --git a/apps/dashboard/pkg/migration/conversion/v1.go b/apps/dashboard/pkg/migration/conversion/v1.go new file mode 100644 index 00000000000..d71d9e40caf --- /dev/null +++ b/apps/dashboard/pkg/migration/conversion/v1.go @@ -0,0 +1,71 @@ +package conversion + +import ( + "k8s.io/apimachinery/pkg/conversion" + + dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" + dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" +) + +func Convert_V1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + out.Spec.Object = in.Spec.Object + + out.Status = dashv0.DashboardStatus{ + Conversion: &dashv0.DashboardConversionStatus{ + StoredVersion: dashv1.VERSION, + }, + } + + return nil +} + +func Convert_V1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO (@radiohead): implement V1 to V2 conversion + // This is the bare minimum conversion that is needed to make the dashboard servable. + + if v, ok := in.Spec.Object["title"]; ok { + if title, ok := v.(string); ok { + out.Spec.Title = title + } + } + + // We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail. + out.Spec.Layout = dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{ + GridLayoutKind: &dashv2alpha1.DashboardGridLayoutKind{ + Kind: "GridLayout", + Spec: dashv2alpha1.DashboardGridLayoutSpec{}, + }, + } + + out.Status = dashv2alpha1.DashboardStatus{ + Conversion: &dashv2alpha1.DashboardConversionStatus{ + StoredVersion: dashv1.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V1_to_V2alpha2(in *dashv1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V1 to V2alpha2 conversion + + out.Status = dashv2alpha2.DashboardStatus{ + Conversion: &dashv2alpha2.DashboardConversionStatus{ + StoredVersion: dashv1.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} diff --git a/apps/dashboard/pkg/migration/conversion/v2.go b/apps/dashboard/pkg/migration/conversion/v2.go new file mode 100644 index 00000000000..5186f9257e2 --- /dev/null +++ b/apps/dashboard/pkg/migration/conversion/v2.go @@ -0,0 +1,105 @@ +package conversion + +import ( + "k8s.io/apimachinery/pkg/conversion" + + dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" + dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" +) + +func Convert_V2alpha1_to_V0(in *dashv2alpha1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2 to V0 conversion + + out.Status = dashv0.DashboardStatus{ + Conversion: &dashv0.DashboardConversionStatus{ + StoredVersion: dashv2alpha1.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V2alpha1_to_V1(in *dashv2alpha1.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2 to V1 conversion + + out.Status = dashv1.DashboardStatus{ + Conversion: &dashv1.DashboardConversionStatus{ + StoredVersion: dashv2alpha1.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V2alpha1_to_V2alpha2(in *dashv2alpha1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2alpha1 to V2alpha2 conversion + + out.Status = dashv2alpha2.DashboardStatus{ + Conversion: &dashv2alpha2.DashboardConversionStatus{ + StoredVersion: dashv2alpha1.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} +func Convert_V2alpha2_to_V0(in *dashv2alpha2.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2alpha2 to V0 conversion + + out.Status = dashv0.DashboardStatus{ + Conversion: &dashv0.DashboardConversionStatus{ + StoredVersion: dashv2alpha2.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V2alpha2_to_V1(in *dashv2alpha2.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2alpha2 to V1 conversion + + out.Status = dashv1.DashboardStatus{ + Conversion: &dashv1.DashboardConversionStatus{ + StoredVersion: dashv2alpha2.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} + +func Convert_V2alpha2_to_V2alpha1(in *dashv2alpha2.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + + // TODO: implement V2alpha2 to V2alpha1 conversion + + out.Status = dashv2alpha1.DashboardStatus{ + Conversion: &dashv2alpha1.DashboardConversionStatus{ + StoredVersion: dashv2alpha2.VERSION, + Failed: true, + Error: "backend conversion not yet implemented", + }, + } + + return nil +} diff --git a/packages/grafana-schema/src/schema/dashboard/v2alpha2/dashboard_object_gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha2/dashboard_object_gen.ts new file mode 100644 index 00000000000..a89d50ebd2d --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha2/dashboard_object_gen.ts @@ -0,0 +1,49 @@ +/* + * This file was generated by grafana-app-sdk. DO NOT EDIT. + */ +import { Spec } from './types.spec.gen'; +import { Status } from './types.status.gen'; + +export interface Metadata { + name: string; + namespace: string; + generateName?: string; + selfLink?: string; + uid?: string; + resourceVersion?: string; + generation?: number; + creationTimestamp?: string; + deletionTimestamp?: string; + deletionGracePeriodSeconds?: number; + labels?: Record; + annotations?: Record; + ownerReferences?: OwnerReference[]; + finalizers?: string[]; + managedFields?: ManagedFieldsEntry[]; +} + +export interface OwnerReference { + apiVersion: string; + kind: string; + name: string; + uid: string; + controller?: boolean; + blockOwnerDeletion?: boolean; +} + +export interface ManagedFieldsEntry { + manager?: string; + operation?: string; + apiVersion?: string; + time?: string; + fieldsType?: string; + subresource?: string; +} + +export interface Dashboard { + kind: string; + apiVersion: string; + metadata: Metadata; + spec: Spec; + status: Status; +} diff --git a/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.metadata.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.metadata.gen.ts new file mode 100644 index 00000000000..4377f3c1d08 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.metadata.gen.ts @@ -0,0 +1,30 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +// metadata contains embedded CommonMetadata and can be extended with custom string fields +// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here +// without external reference as using the CommonMetadata reference breaks thema codegen. +export interface Metadata { + updateTimestamp: string; + createdBy: string; + uid: string; + creationTimestamp: string; + deletionTimestamp?: string; + finalizers: string[]; + resourceVersion: string; + generation: number; + updatedBy: string; + labels: Record; +} + +export const defaultMetadata = (): Metadata => ({ + updateTimestamp: "", + createdBy: "", + uid: "", + creationTimestamp: "", + finalizers: [], + resourceVersion: "", + generation: 0, + updatedBy: "", + labels: {}, +}); + diff --git a/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.spec.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.spec.gen.ts new file mode 100644 index 00000000000..04fc5092d8a --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.spec.gen.ts @@ -0,0 +1,1404 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +export interface AnnotationQueryKind { + kind: "AnnotationQuery"; + spec: AnnotationQuerySpec; +} + +export const defaultAnnotationQueryKind = (): AnnotationQueryKind => ({ + kind: "AnnotationQuery", + spec: defaultAnnotationQuerySpec(), +}); + +export interface AnnotationQuerySpec { + datasource?: DataSourceRef; + query?: DataQueryKind; + enable: boolean; + hide: boolean; + iconColor: string; + name: string; + builtIn?: boolean; + filter?: AnnotationPanelFilter; + // Catch-all field for datasource-specific properties + legacyOptions?: Record; +} + +export const defaultAnnotationQuerySpec = (): AnnotationQuerySpec => ({ + enable: false, + hide: false, + iconColor: "", + name: "", + builtIn: false, +}); + +export interface DataSourceRef { + // The plugin type-id + type?: string; + // Specific datasource instance + uid?: string; +} + +export const defaultDataSourceRef = (): DataSourceRef => ({ +}); + +export interface DataQueryKind { + // The kind of a DataQueryKind is the datasource type + kind: string; + spec: Record; +} + +export const defaultDataQueryKind = (): DataQueryKind => ({ + kind: "", + spec: {}, +}); + +export interface AnnotationPanelFilter { + // Should the specified panels be included or excluded + exclude?: boolean; + // Panel IDs that should be included or excluded + ids: number[]; +} + +export const defaultAnnotationPanelFilter = (): AnnotationPanelFilter => ({ + exclude: false, + ids: [], +}); + +// "Off" for no shared crosshair or tooltip (default). +// "Crosshair" for shared crosshair. +// "Tooltip" for shared crosshair AND shared tooltip. +export type DashboardCursorSync = "Crosshair" | "Tooltip" | "Off"; + +export const defaultDashboardCursorSync = (): DashboardCursorSync => ("Off"); + +// Supported dashboard elements +// |* more element types in the future +export type Element = PanelKind | LibraryPanelKind; + +export const defaultElement = (): Element => (defaultPanelKind()); + +export interface PanelKind { + kind: "Panel"; + spec: PanelSpec; +} + +export const defaultPanelKind = (): PanelKind => ({ + kind: "Panel", + spec: defaultPanelSpec(), +}); + +export interface PanelSpec { + id: number; + title: string; + description: string; + links: DataLink[]; + data: QueryGroupKind; + vizConfig: VizConfigKind; + transparent?: boolean; +} + +export const defaultPanelSpec = (): PanelSpec => ({ + id: 0, + title: "", + description: "", + links: [], + data: defaultQueryGroupKind(), + vizConfig: defaultVizConfigKind(), +}); + +export interface DataLink { + title: string; + url: string; + targetBlank?: boolean; +} + +export const defaultDataLink = (): DataLink => ({ + title: "", + url: "", +}); + +export interface QueryGroupKind { + kind: "QueryGroup"; + spec: QueryGroupSpec; +} + +export const defaultQueryGroupKind = (): QueryGroupKind => ({ + kind: "QueryGroup", + spec: defaultQueryGroupSpec(), +}); + +export interface QueryGroupSpec { + queries: PanelQueryKind[]; + transformations: TransformationKind[]; + queryOptions: QueryOptionsSpec; +} + +export const defaultQueryGroupSpec = (): QueryGroupSpec => ({ + queries: [], + transformations: [], + queryOptions: defaultQueryOptionsSpec(), +}); + +export interface PanelQueryKind { + kind: "PanelQuery"; + spec: PanelQuerySpec; +} + +export const defaultPanelQueryKind = (): PanelQueryKind => ({ + kind: "PanelQuery", + spec: defaultPanelQuerySpec(), +}); + +export interface PanelQuerySpec { + query: DataQueryKind; + datasource?: DataSourceRef; + refId: string; + hidden: boolean; +} + +export const defaultPanelQuerySpec = (): PanelQuerySpec => ({ + query: defaultDataQueryKind(), + refId: "", + hidden: false, +}); + +export interface TransformationKind { + // The kind of a TransformationKind is the transformation ID + kind: string; + spec: DataTransformerConfig; +} + +export const defaultTransformationKind = (): TransformationKind => ({ + kind: "", + spec: defaultDataTransformerConfig(), +}); + +// Transformations allow to manipulate data returned by a query before the system applies a visualization. +// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries, +// use the output of one transformation as the input to another transformation, etc. +export interface DataTransformerConfig { + // Unique identifier of transformer + id: string; + // Disabled transformations are skipped + disabled?: boolean; + // Optional frame matcher. When missing it will be applied to all results + filter?: MatcherConfig; + // Where to pull DataFrames from as input to transformation + topic?: DataTopic; + // Options to be passed to the transformer + // Valid options depend on the transformer id + options: any; +} + +export const defaultDataTransformerConfig = (): DataTransformerConfig => ({ + id: "", + options: {}, +}); + +// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation. +// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type. +export interface MatcherConfig { + // The matcher id. This is used to find the matcher implementation from registry. + id: string; + // The matcher options. This is specific to the matcher implementation. + options?: any; +} + +export const defaultMatcherConfig = (): MatcherConfig => ({ + id: "", +}); + +// A topic is attached to DataFrame metadata in query results. +// This specifies where the data should be used. +export type DataTopic = "series" | "annotations" | "alertStates"; + +export const defaultDataTopic = (): DataTopic => ("series"); + +export interface QueryOptionsSpec { + timeFrom?: string; + maxDataPoints?: number; + timeShift?: string; + queryCachingTTL?: number; + interval?: string; + cacheTimeout?: string; + hideTimeOverride?: boolean; +} + +export const defaultQueryOptionsSpec = (): QueryOptionsSpec => ({ +}); + +export interface VizConfigKind { + // The kind of a VizConfigKind is the plugin ID + kind: string; + spec: VizConfigSpec; +} + +export const defaultVizConfigKind = (): VizConfigKind => ({ + kind: "", + spec: defaultVizConfigSpec(), +}); + +// --- Kinds --- +export interface VizConfigSpec { + pluginVersion: string; + options: Record; + fieldConfig: FieldConfigSource; +} + +export const defaultVizConfigSpec = (): VizConfigSpec => ({ + pluginVersion: "", + options: {}, + fieldConfig: defaultFieldConfigSource(), +}); + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +export interface FieldConfigSource { + // Defaults are the options applied to all fields. + defaults: FieldConfig; + // Overrides are the options applied to specific fields overriding the defaults. + overrides: { + matcher: MatcherConfig; + properties: DynamicConfigValue[]; + }[]; +} + +export const defaultFieldConfigSource = (): FieldConfigSource => ({ + defaults: defaultFieldConfig(), + overrides: [], +}); + +// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results. +// Each column within this structure is called a field. A field can represent a single time series or table column. +// Field options allow you to change how the data is displayed in your visualizations. +export interface FieldConfig { + // The display value for this field. This supports template variables blank is auto + displayName?: string; + // This can be used by data sources that return and explicit naming structure for values and labels + // When this property is configured, this value is used rather than the default naming strategy. + displayNameFromDS?: string; + // Human readable field metadata + description?: string; + // An explicit path to the field in the datasource. When the frame meta includes a path, + // This will default to `${frame.meta.path}/${field.name} + // + // When defined, this value can be used as an identifier within the datasource scope, and + // may be used to update the results + path?: string; + // True if data source can write a value to the path. Auth/authz are supported separately + writeable?: boolean; + // True if data source field supports ad-hoc filters + filterable?: boolean; + // Unit a field should use. The unit you select is applied to all fields except time. + // You can use the units ID availables in Grafana or a custom unit. + // Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts + // As custom unit, you can use the following formats: + // `suffix:` for custom unit that should go after value. + // `prefix:` for custom unit that should go before value. + // `time:` For custom date time formats type for example `time:YYYY-MM-DD`. + // `si:` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. + // `count:` for a custom count unit. + // `currency:` for custom a currency unit. + unit?: string; + // Specify the number of decimals Grafana includes in the rendered value. + // If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. + // For example 1.1234 will display as 1.12 and 100.456 will display as 100. + // To display all decimals, set the unit to `String`. + decimals?: number; + // The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + min?: number; + // The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. + max?: number; + // Convert input values into a display string + mappings?: ValueMapping[]; + // Map numeric values to states + thresholds?: ThresholdsConfig; + // Panel color configuration + color?: FieldColor; + // The behavior when clicking on a result + links?: any[]; + // Alternative to empty string + noValue?: string; + // custom is specified by the FieldConfig field + // in panel plugin schemas. + custom?: Record; +} + +export const defaultFieldConfig = (): FieldConfig => ({ +}); + +export type ValueMapping = ValueMap | RangeMap | RegexMap | SpecialValueMap; + +export const defaultValueMapping = (): ValueMapping => (defaultValueMap()); + +// Maps text values to a color or different display text and color. +// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +export interface ValueMap { + type: "value"; + // Map with : ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } + options: Record; +} + +export const defaultValueMap = (): ValueMap => ({ + type: "value", + options: {}, +}); + +// Supported value mapping types +// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number. +// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A. +export type MappingType = "value" | "range" | "regex" | "special"; + +export const defaultMappingType = (): MappingType => ("value"); + +// Result used as replacement with text and color when the value matches +export interface ValueMappingResult { + // Text to display when the value matches + text?: string; + // Text to use when the value matches + color?: string; + // Icon to display when the value matches. Only specific visualizations. + icon?: string; + // Position in the mapping array. Only used internally. + index?: number; +} + +export const defaultValueMappingResult = (): ValueMappingResult => ({ +}); + +// Maps numerical ranges to a display text and color. +// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number. +export interface RangeMap { + type: "range"; + // Range to match against and the result to apply when the value is within the range + options: { + // Min value of the range. It can be null which means -Infinity + from: number | null; + // Max value of the range. It can be null which means +Infinity + to: number | null; + // Config to apply when the value is within the range + result: ValueMappingResult; + }; +} + +export const defaultRangeMap = (): RangeMap => ({ + type: "range", + options: { + from: 0, + to: 0, + result: defaultValueMappingResult(), +}, +}); + +// Maps regular expressions to replacement text and a color. +// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain. +export interface RegexMap { + type: "regex"; + // Regular expression to match against and the result to apply when the value matches the regex + options: { + // Regular expression to match against + pattern: string; + // Config to apply when the value matches the regex + result: ValueMappingResult; + }; +} + +export const defaultRegexMap = (): RegexMap => ({ + type: "regex", + options: { + pattern: "", + result: defaultValueMappingResult(), +}, +}); + +// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. +// See SpecialValueMatch to see the list of special values. +// For example, you can configure a special value mapping so that null values appear as N/A. +export interface SpecialValueMap { + type: "special"; + options: { + // Special value to match against + match: SpecialValueMatch; + // Config to apply when the value matches the special value + result: ValueMappingResult; + }; +} + +export const defaultSpecialValueMap = (): SpecialValueMap => ({ + type: "special", + options: { + match: "true", + result: defaultValueMappingResult(), +}, +}); + +// Special value types supported by the `SpecialValueMap` +export type SpecialValueMatch = "true" | "false" | "null" | "nan" | "null+nan" | "empty"; + +export const defaultSpecialValueMatch = (): SpecialValueMatch => ("true"); + +export interface ThresholdsConfig { + mode: ThresholdsMode; + steps: Threshold[]; +} + +export const defaultThresholdsConfig = (): ThresholdsConfig => ({ + mode: "absolute", + steps: [], +}); + +export type ThresholdsMode = "absolute" | "percentage"; + +export const defaultThresholdsMode = (): ThresholdsMode => ("absolute"); + +export interface Threshold { + value: number; + color: string; +} + +export const defaultThreshold = (): Threshold => ({ + value: 0, + color: "", +}); + +// Map a field to a color. +export interface FieldColor { + // The main color scheme mode. + mode: FieldColorModeId; + // The fixed color value for fixed or shades color modes. + fixedColor?: string; + // Some visualizations need to know how to assign a series color from by value color schemes. + seriesBy?: FieldColorSeriesByMode; +} + +export const defaultFieldColor = (): FieldColor => ({ + mode: "thresholds", +}); + +// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. +// Continuous color interpolates a color using the percentage of a value relative to min and max. +// Accepted values are: +// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold +// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations +// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations +// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode +// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode +// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode +// `continuous-YlRd`: Continuous Yellow-Red palette mode +// `continuous-BlPu`: Continuous Blue-Purple palette mode +// `continuous-YlBl`: Continuous Yellow-Blue palette mode +// `continuous-blues`: Continuous Blue palette mode +// `continuous-reds`: Continuous Red palette mode +// `continuous-greens`: Continuous Green palette mode +// `continuous-purples`: Continuous Purple palette mode +// `shades`: Shades of a single color. Specify a single color, useful in an override rule. +// `fixed`: Fixed color mode. Specify a single color, useful in an override rule. +export type FieldColorModeId = "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades"; + +export const defaultFieldColorModeId = (): FieldColorModeId => ("thresholds"); + +// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value. +export type FieldColorSeriesByMode = "min" | "max" | "last"; + +export const defaultFieldColorSeriesByMode = (): FieldColorSeriesByMode => ("min"); + +export interface DynamicConfigValue { + id: string; + value?: any; +} + +export const defaultDynamicConfigValue = (): DynamicConfigValue => ({ + id: "", +}); + +export interface LibraryPanelKind { + kind: "LibraryPanel"; + spec: LibraryPanelKindSpec; +} + +export const defaultLibraryPanelKind = (): LibraryPanelKind => ({ + kind: "LibraryPanel", + spec: defaultLibraryPanelKindSpec(), +}); + +export interface LibraryPanelKindSpec { + // Panel ID for the library panel in the dashboard + id: number; + // Title for the library panel in the dashboard + title: string; + libraryPanel: LibraryPanelRef; +} + +export const defaultLibraryPanelKindSpec = (): LibraryPanelKindSpec => ({ + id: 0, + title: "", + libraryPanel: defaultLibraryPanelRef(), +}); + +// A library panel is a reusable panel that you can use in any dashboard. +// When you make a change to a library panel, that change propagates to all instances of where the panel is used. +// Library panels streamline reuse of panels across multiple dashboards. +export interface LibraryPanelRef { + // Library panel name + name: string; + // Library panel uid + uid: string; +} + +export const defaultLibraryPanelRef = (): LibraryPanelRef => ({ + name: "", + uid: "", +}); + +export interface GridLayoutKind { + kind: "GridLayout"; + spec: GridLayoutSpec; +} + +export const defaultGridLayoutKind = (): GridLayoutKind => ({ + kind: "GridLayout", + spec: defaultGridLayoutSpec(), +}); + +export interface GridLayoutSpec { + items: GridLayoutItemKind[]; +} + +export const defaultGridLayoutSpec = (): GridLayoutSpec => ({ + items: [], +}); + +export interface GridLayoutItemKind { + kind: "GridLayoutItem"; + spec: GridLayoutItemSpec; +} + +export const defaultGridLayoutItemKind = (): GridLayoutItemKind => ({ + kind: "GridLayoutItem", + spec: defaultGridLayoutItemSpec(), +}); + +export interface GridLayoutItemSpec { + x: number; + y: number; + width: number; + height: number; + // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference + element: ElementReference; + repeat?: RepeatOptions; +} + +export const defaultGridLayoutItemSpec = (): GridLayoutItemSpec => ({ + x: 0, + y: 0, + width: 0, + height: 0, + element: defaultElementReference(), +}); + +export interface ElementReference { + kind: "ElementReference"; + name: string; +} + +export const defaultElementReference = (): ElementReference => ({ + kind: "ElementReference", + name: "", +}); + +export interface RepeatOptions { + mode: "variable"; + value: string; + direction?: "h" | "v"; + maxPerRow?: number; +} + +export const defaultRepeatOptions = (): RepeatOptions => ({ + mode: RepeatMode, + value: "", +}); + +// other repeat modes will be added in the future: label, frame +export const RepeatMode = "variable"; + +export interface RowsLayoutKind { + kind: "RowsLayout"; + spec: RowsLayoutSpec; +} + +export const defaultRowsLayoutKind = (): RowsLayoutKind => ({ + kind: "RowsLayout", + spec: defaultRowsLayoutSpec(), +}); + +export interface RowsLayoutSpec { + rows: RowsLayoutRowKind[]; +} + +export const defaultRowsLayoutSpec = (): RowsLayoutSpec => ({ + rows: [], +}); + +export interface RowsLayoutRowKind { + kind: "RowsLayoutRow"; + spec: RowsLayoutRowSpec; +} + +export const defaultRowsLayoutRowKind = (): RowsLayoutRowKind => ({ + kind: "RowsLayoutRow", + spec: defaultRowsLayoutRowSpec(), +}); + +export interface RowsLayoutRowSpec { + title?: string; + collapse?: boolean; + hideHeader?: boolean; + fillScreen?: boolean; + conditionalRendering?: ConditionalRenderingGroupKind; + repeat?: RowRepeatOptions; + layout: GridLayoutKind | AutoGridLayoutKind | TabsLayoutKind | RowsLayoutKind; +} + +export const defaultRowsLayoutRowSpec = (): RowsLayoutRowSpec => ({ + layout: defaultGridLayoutKind(), +}); + +export interface ConditionalRenderingGroupKind { + kind: "ConditionalRenderingGroup"; + spec: ConditionalRenderingGroupSpec; +} + +export const defaultConditionalRenderingGroupKind = (): ConditionalRenderingGroupKind => ({ + kind: "ConditionalRenderingGroup", + spec: defaultConditionalRenderingGroupSpec(), +}); + +export interface ConditionalRenderingGroupSpec { + visibility: "show" | "hide"; + condition: "and" | "or"; + items: (ConditionalRenderingVariableKind | ConditionalRenderingDataKind | ConditionalRenderingTimeRangeSizeKind)[]; +} + +export const defaultConditionalRenderingGroupSpec = (): ConditionalRenderingGroupSpec => ({ + visibility: "show", + condition: "and", + items: [], +}); + +export interface ConditionalRenderingVariableKind { + kind: "ConditionalRenderingVariable"; + spec: ConditionalRenderingVariableSpec; +} + +export const defaultConditionalRenderingVariableKind = (): ConditionalRenderingVariableKind => ({ + kind: "ConditionalRenderingVariable", + spec: defaultConditionalRenderingVariableSpec(), +}); + +export interface ConditionalRenderingVariableSpec { + variable: string; + operator: "equals" | "notEquals"; + value: string; +} + +export const defaultConditionalRenderingVariableSpec = (): ConditionalRenderingVariableSpec => ({ + variable: "", + operator: "equals", + value: "", +}); + +export interface ConditionalRenderingDataKind { + kind: "ConditionalRenderingData"; + spec: ConditionalRenderingDataSpec; +} + +export const defaultConditionalRenderingDataKind = (): ConditionalRenderingDataKind => ({ + kind: "ConditionalRenderingData", + spec: defaultConditionalRenderingDataSpec(), +}); + +export interface ConditionalRenderingDataSpec { + value: boolean; +} + +export const defaultConditionalRenderingDataSpec = (): ConditionalRenderingDataSpec => ({ + value: false, +}); + +export interface ConditionalRenderingTimeRangeSizeKind { + kind: "ConditionalRenderingTimeRangeSize"; + spec: ConditionalRenderingTimeRangeSizeSpec; +} + +export const defaultConditionalRenderingTimeRangeSizeKind = (): ConditionalRenderingTimeRangeSizeKind => ({ + kind: "ConditionalRenderingTimeRangeSize", + spec: defaultConditionalRenderingTimeRangeSizeSpec(), +}); + +export interface ConditionalRenderingTimeRangeSizeSpec { + value: string; +} + +export const defaultConditionalRenderingTimeRangeSizeSpec = (): ConditionalRenderingTimeRangeSizeSpec => ({ + value: "", +}); + +export interface RowRepeatOptions { + mode: "variable"; + value: string; +} + +export const defaultRowRepeatOptions = (): RowRepeatOptions => ({ + mode: RepeatMode, + value: "", +}); + +export interface AutoGridLayoutKind { + kind: "AutoGridLayout"; + spec: AutoGridLayoutSpec; +} + +export const defaultAutoGridLayoutKind = (): AutoGridLayoutKind => ({ + kind: "AutoGridLayout", + spec: defaultAutoGridLayoutSpec(), +}); + +export interface AutoGridLayoutSpec { + maxColumnCount?: number; + columnWidthMode: "narrow" | "standard" | "wide" | "custom"; + columnWidth?: number; + rowHeightMode: "short" | "standard" | "tall" | "custom"; + rowHeight?: number; + fillScreen?: boolean; + items: AutoGridLayoutItemKind[]; +} + +export const defaultAutoGridLayoutSpec = (): AutoGridLayoutSpec => ({ + maxColumnCount: 3, + columnWidthMode: "standard", + rowHeightMode: "standard", + fillScreen: false, + items: [], +}); + +export interface AutoGridLayoutItemKind { + kind: "AutoGridLayoutItem"; + spec: AutoGridLayoutItemSpec; +} + +export const defaultAutoGridLayoutItemKind = (): AutoGridLayoutItemKind => ({ + kind: "AutoGridLayoutItem", + spec: defaultAutoGridLayoutItemSpec(), +}); + +export interface AutoGridLayoutItemSpec { + element: ElementReference; + repeat?: AutoGridRepeatOptions; + conditionalRendering?: ConditionalRenderingGroupKind; +} + +export const defaultAutoGridLayoutItemSpec = (): AutoGridLayoutItemSpec => ({ + element: defaultElementReference(), +}); + +export interface AutoGridRepeatOptions { + mode: "variable"; + value: string; +} + +export const defaultAutoGridRepeatOptions = (): AutoGridRepeatOptions => ({ + mode: RepeatMode, + value: "", +}); + +export interface TabsLayoutKind { + kind: "TabsLayout"; + spec: TabsLayoutSpec; +} + +export const defaultTabsLayoutKind = (): TabsLayoutKind => ({ + kind: "TabsLayout", + spec: defaultTabsLayoutSpec(), +}); + +export interface TabsLayoutSpec { + tabs: TabsLayoutTabKind[]; +} + +export const defaultTabsLayoutSpec = (): TabsLayoutSpec => ({ + tabs: [], +}); + +export interface TabsLayoutTabKind { + kind: "TabsLayoutTab"; + spec: TabsLayoutTabSpec; +} + +export const defaultTabsLayoutTabKind = (): TabsLayoutTabKind => ({ + kind: "TabsLayoutTab", + spec: defaultTabsLayoutTabSpec(), +}); + +export interface TabsLayoutTabSpec { + title?: string; + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind; + conditionalRendering?: ConditionalRenderingGroupKind; + repeat?: TabRepeatOptions; +} + +export const defaultTabsLayoutTabSpec = (): TabsLayoutTabSpec => ({ + layout: defaultGridLayoutKind(), +}); + +export interface TabRepeatOptions { + mode: "variable"; + value: string; +} + +export const defaultTabRepeatOptions = (): TabRepeatOptions => ({ + mode: RepeatMode, + value: "", +}); + +// Links with references to other dashboards or external resources +export interface DashboardLink { + // Title to display with the link + title: string; + // Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) + // FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType` + type: DashboardLinkType; + // Icon name to be displayed with the link + icon: string; + // Tooltip to display when the user hovers their mouse over it + tooltip: string; + // Link URL. Only required/valid if the type is link + url?: string; + // List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards + tags: string[]; + // If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards + asDropdown: boolean; + // If true, the link will be opened in a new tab + targetBlank: boolean; + // If true, includes current template variables values in the link as query params + includeVars: boolean; + // If true, includes current time range in the link as query params + keepTime: boolean; +} + +export const defaultDashboardLink = (): DashboardLink => ({ + title: "", + type: "link", + icon: "", + tooltip: "", + tags: [], + asDropdown: false, + targetBlank: false, + includeVars: false, + keepTime: false, +}); + +// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource) +export type DashboardLinkType = "link" | "dashboards"; + +export const defaultDashboardLinkType = (): DashboardLinkType => ("link"); + +// Time configuration +// It defines the default time config for the time picker, the refresh picker for the specific dashboard. +export interface TimeSettingsSpec { + // Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc". + timezone?: string; + // Start time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + from: string; + // End time range for dashboard. + // Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z". + to: string; + // Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d". + // v1: refresh + autoRefresh: string; + // Interval options available in the refresh picker dropdown. + // v1: timepicker.refresh_intervals + autoRefreshIntervals: string[]; + // Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard. + // v1: timepicker.quick_ranges , not exposed in the UI + quickRanges?: TimeRangeOption[]; + // Whether timepicker is visible or not. + // v1: timepicker.hidden + hideTimepicker: boolean; + // Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday". + weekStart?: "saturday" | "monday" | "sunday"; + // The month that the fiscal year starts on. 0 = January, 11 = December + fiscalYearStartMonth: number; + // Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values. + // v1: timepicker.nowDelay + nowDelay?: string; +} + +export const defaultTimeSettingsSpec = (): TimeSettingsSpec => ({ + timezone: "browser", + from: "now-6h", + to: "now", + autoRefresh: "", + autoRefreshIntervals: [ +"5s", +"10s", +"30s", +"1m", +"5m", +"15m", +"30m", +"1h", +"2h", +"1d", +], + hideTimepicker: false, + fiscalYearStartMonth: 0, +}); + +export interface TimeRangeOption { + display: string; + from: string; + to: string; +} + +export const defaultTimeRangeOption = (): TimeRangeOption => ({ + display: "Last 6 hours", + from: "now-6h", + to: "now", +}); + +export type VariableKind = QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind; + +export const defaultVariableKind = (): VariableKind => (defaultQueryVariableKind()); + +// Query variable kind +export interface QueryVariableKind { + kind: "QueryVariable"; + spec: QueryVariableSpec; +} + +export const defaultQueryVariableKind = (): QueryVariableKind => ({ + kind: "QueryVariable", + spec: defaultQueryVariableSpec(), +}); + +// Query variable specification +export interface QueryVariableSpec { + name: string; + current: VariableOption; + label?: string; + hide: VariableHide; + refresh: VariableRefresh; + skipUrlSync: boolean; + description?: string; + datasource?: DataSourceRef; + query: DataQueryKind; + regex: string; + sort: VariableSort; + definition?: string; + options: VariableOption[]; + multi: boolean; + includeAll: boolean; + allValue?: string; + placeholder?: string; + allowCustomValue: boolean; + staticOptions?: VariableOption[]; + staticOptionsOrder?: "before" | "after" | "sorted"; +} + +export const defaultQueryVariableSpec = (): QueryVariableSpec => ({ + name: "", + current: { text: "", value: "", }, + hide: "dontHide", + refresh: "never", + skipUrlSync: false, + query: defaultDataQueryKind(), + regex: "", + sort: "disabled", + options: [], + multi: false, + includeAll: false, + allowCustomValue: true, +}); + +// Variable option specification +export interface VariableOption { + // Whether the option is selected or not + selected?: boolean; + // Text to be displayed for the option + text: string | string[]; + // Value of the option + value: string | string[]; +} + +export const defaultVariableOption = (): VariableOption => ({ + text: "", + value: "", +}); + +// Determine if the variable shows on dashboard +// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing). +export type VariableHide = "dontHide" | "hideLabel" | "hideVariable"; + +export const defaultVariableHide = (): VariableHide => ("dontHide"); + +// Options to config when to refresh a variable +// `never`: Never refresh the variable +// `onDashboardLoad`: Queries the data source every time the dashboard loads. +// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes. +export type VariableRefresh = "never" | "onDashboardLoad" | "onTimeRangeChanged"; + +export const defaultVariableRefresh = (): VariableRefresh => ("never"); + +// Sort variable options +// Accepted values are: +// `disabled`: No sorting +// `alphabeticalAsc`: Alphabetical ASC +// `alphabeticalDesc`: Alphabetical DESC +// `numericalAsc`: Numerical ASC +// `numericalDesc`: Numerical DESC +// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC +// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC +// `naturalAsc`: Natural ASC +// `naturalDesc`: Natural DESC +// VariableSort enum with default value +export type VariableSort = "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc"; + +export const defaultVariableSort = (): VariableSort => ("disabled"); + +// Text variable kind +export interface TextVariableKind { + kind: "TextVariable"; + spec: TextVariableSpec; +} + +export const defaultTextVariableKind = (): TextVariableKind => ({ + kind: "TextVariable", + spec: defaultTextVariableSpec(), +}); + +// Text variable specification +export interface TextVariableSpec { + name: string; + current: VariableOption; + query: string; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; +} + +export const defaultTextVariableSpec = (): TextVariableSpec => ({ + name: "", + current: { text: "", value: "", }, + query: "", + hide: "dontHide", + skipUrlSync: false, +}); + +// Constant variable kind +export interface ConstantVariableKind { + kind: "ConstantVariable"; + spec: ConstantVariableSpec; +} + +export const defaultConstantVariableKind = (): ConstantVariableKind => ({ + kind: "ConstantVariable", + spec: defaultConstantVariableSpec(), +}); + +// Constant variable specification +export interface ConstantVariableSpec { + name: string; + query: string; + current: VariableOption; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; +} + +export const defaultConstantVariableSpec = (): ConstantVariableSpec => ({ + name: "", + query: "", + current: { text: "", value: "", }, + hide: "dontHide", + skipUrlSync: false, +}); + +// Datasource variable kind +export interface DatasourceVariableKind { + kind: "DatasourceVariable"; + spec: DatasourceVariableSpec; +} + +export const defaultDatasourceVariableKind = (): DatasourceVariableKind => ({ + kind: "DatasourceVariable", + spec: defaultDatasourceVariableSpec(), +}); + +// Datasource variable specification +export interface DatasourceVariableSpec { + name: string; + pluginId: string; + refresh: VariableRefresh; + regex: string; + current: VariableOption; + options: VariableOption[]; + multi: boolean; + includeAll: boolean; + allValue?: string; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; + allowCustomValue: boolean; +} + +export const defaultDatasourceVariableSpec = (): DatasourceVariableSpec => ({ + name: "", + pluginId: "", + refresh: "never", + regex: "", + current: { text: "", value: "", }, + options: [], + multi: false, + includeAll: false, + hide: "dontHide", + skipUrlSync: false, + allowCustomValue: true, +}); + +// Interval variable kind +export interface IntervalVariableKind { + kind: "IntervalVariable"; + spec: IntervalVariableSpec; +} + +export const defaultIntervalVariableKind = (): IntervalVariableKind => ({ + kind: "IntervalVariable", + spec: defaultIntervalVariableSpec(), +}); + +// Interval variable specification +export interface IntervalVariableSpec { + name: string; + query: string; + current: VariableOption; + options: VariableOption[]; + auto: boolean; + auto_min: string; + auto_count: number; + refresh: VariableRefresh; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; +} + +export const defaultIntervalVariableSpec = (): IntervalVariableSpec => ({ + name: "", + query: "", + current: { text: "", value: "", }, + options: [], + auto: false, + auto_min: "", + auto_count: 0, + refresh: "never", + hide: "dontHide", + skipUrlSync: false, +}); + +// Custom variable kind +export interface CustomVariableKind { + kind: "CustomVariable"; + spec: CustomVariableSpec; +} + +export const defaultCustomVariableKind = (): CustomVariableKind => ({ + kind: "CustomVariable", + spec: defaultCustomVariableSpec(), +}); + +// Custom variable specification +export interface CustomVariableSpec { + name: string; + query: string; + current: VariableOption; + options: VariableOption[]; + multi: boolean; + includeAll: boolean; + allValue?: string; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; + allowCustomValue: boolean; +} + +export const defaultCustomVariableSpec = (): CustomVariableSpec => ({ + name: "", + query: "", + current: defaultVariableOption(), + options: [], + multi: false, + includeAll: false, + hide: "dontHide", + skipUrlSync: false, + allowCustomValue: true, +}); + +// Group variable kind +export interface GroupByVariableKind { + kind: "GroupByVariable"; + spec: GroupByVariableSpec; +} + +export const defaultGroupByVariableKind = (): GroupByVariableKind => ({ + kind: "GroupByVariable", + spec: defaultGroupByVariableSpec(), +}); + +// GroupBy variable specification +export interface GroupByVariableSpec { + name: string; + datasource?: DataSourceRef; + defaultValue?: VariableOption; + current: VariableOption; + options: VariableOption[]; + multi: boolean; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; +} + +export const defaultGroupByVariableSpec = (): GroupByVariableSpec => ({ + name: "", + current: { text: "", value: "", }, + options: [], + multi: false, + hide: "dontHide", + skipUrlSync: false, +}); + +// Adhoc variable kind +export interface AdhocVariableKind { + kind: "AdhocVariable"; + spec: AdhocVariableSpec; +} + +export const defaultAdhocVariableKind = (): AdhocVariableKind => ({ + kind: "AdhocVariable", + spec: defaultAdhocVariableSpec(), +}); + +// Adhoc variable specification +export interface AdhocVariableSpec { + name: string; + datasource?: DataSourceRef; + baseFilters: AdHocFilterWithLabels[]; + filters: AdHocFilterWithLabels[]; + defaultKeys: MetricFindValue[]; + label?: string; + hide: VariableHide; + skipUrlSync: boolean; + description?: string; + allowCustomValue: boolean; +} + +export const defaultAdhocVariableSpec = (): AdhocVariableSpec => ({ + name: "", + baseFilters: [], + filters: [], + defaultKeys: [], + hide: "dontHide", + skipUrlSync: false, + allowCustomValue: true, +}); + +// Define the AdHocFilterWithLabels type +export interface AdHocFilterWithLabels { + key: string; + operator: string; + value: string; + values?: string[]; + keyLabel?: string; + valueLabels?: string[]; + forceEdit?: boolean; + origin?: "dashboard"; + // @deprecated + condition?: string; +} + +export const defaultAdHocFilterWithLabels = (): AdHocFilterWithLabels => ({ + key: "", + operator: "", + value: "", +}); + +// Determine the origin of the adhoc variable filter +export const FilterOrigin = "dashboard"; + +// Define the MetricFindValue type +export interface MetricFindValue { + text: string; + value?: string | number; + group?: string; + expandable?: boolean; +} + +export const defaultMetricFindValue = (): MetricFindValue => ({ + text: "", +}); + +export interface Spec { + annotations: AnnotationQueryKind[]; + // Configuration of dashboard cursor sync behavior. + // "Off" for no shared crosshair or tooltip (default). + // "Crosshair" for shared crosshair. + // "Tooltip" for shared crosshair AND shared tooltip. + cursorSync: DashboardCursorSync; + // Description of dashboard. + description?: string; + // Whether a dashboard is editable or not. + editable?: boolean; + elements: Record; + layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind; + // Links with references to other dashboards or external websites. + links: DashboardLink[]; + // When set to true, the dashboard will redraw panels at an interval matching the pixel width. + // This will keep data "moving left" regardless of the query refresh rate. This setting helps + // avoid dashboards presenting stale live data. + liveNow?: boolean; + // When set to true, the dashboard will load all panels in the dashboard when it's loaded. + preload: boolean; + // Plugins only. The version of the dashboard installed together with the plugin. + // This is used to determine if the dashboard should be updated when the plugin is updated. + revision?: number; + // Tags associated with dashboard. + tags: string[]; + timeSettings: TimeSettingsSpec; + // Title of dashboard. + title: string; + // Configured template variables. + variables: VariableKind[]; +} + +export const defaultSpec = (): Spec => ({ + annotations: [], + cursorSync: "Off", + editable: true, + elements: {}, + layout: defaultGridLayoutKind(), + links: [], + preload: false, + tags: [], + timeSettings: defaultTimeSettingsSpec(), + title: "", + variables: [], +}); + diff --git a/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.status.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.status.gen.ts new file mode 100644 index 00000000000..29494dfaf24 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha2/types.status.gen.ts @@ -0,0 +1,30 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +// ConversionStatus is the status of the conversion of the dashboard. +export interface ConversionStatus { + // Whether from another version has failed. + // If true, means that the dashboard is not valid, + // and the caller should instead fetch the stored version. + failed: boolean; + // The version which was stored when the dashboard was created / updated. + // Fetching this version should always succeed. + storedVersion: string; + // The error message from the conversion. + // Empty if the conversion has not failed. + error: string; +} + +export const defaultConversionStatus = (): ConversionStatus => ({ + failed: false, + storedVersion: "", + error: "", +}); + +export interface Status { + // Optional conversion status. + conversion?: ConversionStatus; +} + +export const defaultStatus = (): Status => ({ +}); + diff --git a/pkg/registry/apis/dashboard/register.go b/pkg/registry/apis/dashboard/register.go index 6ca9b87fbc4..f2fda01d1c9 100644 --- a/pkg/registry/apis/dashboard/register.go +++ b/pkg/registry/apis/dashboard/register.go @@ -23,7 +23,8 @@ import ( internal "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard" dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" - dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" "github.com/grafana/grafana/apps/dashboard/pkg/migration" "github.com/grafana/grafana/apps/dashboard/pkg/migration/conversion" "github.com/grafana/grafana/pkg/apimachinery/identity" @@ -158,16 +159,18 @@ func (b *DashboardsAPIBuilder) GetGroupVersions() []schema.GroupVersion { if featuremgmt.AnyEnabled(b.features, featuremgmt.FlagDashboardNewLayouts) { // If dashboards v2 is enabled, we want to use v2alpha1 as the default API version. return []schema.GroupVersion{ - dashv2.DashboardResourceInfo.GroupVersion(), + dashv2alpha1.DashboardResourceInfo.GroupVersion(), dashv0.DashboardResourceInfo.GroupVersion(), dashv1.DashboardResourceInfo.GroupVersion(), + dashv2alpha2.DashboardResourceInfo.GroupVersion(), } } return []schema.GroupVersion{ dashv1.DashboardResourceInfo.GroupVersion(), dashv0.DashboardResourceInfo.GroupVersion(), - dashv2.DashboardResourceInfo.GroupVersion(), + dashv2alpha1.DashboardResourceInfo.GroupVersion(), + dashv2alpha2.DashboardResourceInfo.GroupVersion(), } } @@ -179,7 +182,11 @@ func (b *DashboardsAPIBuilder) InstallSchema(scheme *runtime.Scheme) error { if err := dashv1.AddToScheme(scheme); err != nil { return err } - if err := dashv2.AddToScheme(scheme); err != nil { + if err := dashv2alpha1.AddToScheme(scheme); err != nil { + return err + } + + if err := dashv2alpha2.AddToScheme(scheme); err != nil { return err } @@ -391,7 +398,10 @@ func getDashboardProperties(obj runtime.Object) (string, string, error) { case *dashv1.Dashboard: title = d.Spec.GetNestedString(dashboardSpecTitle) refresh = d.Spec.GetNestedString(dashboardSpecRefreshInterval) - case *dashv2.Dashboard: + case *dashv2alpha1.Dashboard: + title = d.Spec.Title + refresh = d.Spec.TimeSettings.AutoRefresh + case *dashv2alpha2.Dashboard: title = d.Spec.Title refresh = d.Spec.TimeSettings.AutoRefresh default: @@ -456,11 +466,28 @@ func (b *DashboardsAPIBuilder) UpdateAPIGroupInfo(apiGroupInfo *genericapiserver // v2alpha1 if err := b.storageForVersion(apiGroupInfo, opts, largeObjects, - dashv2.DashboardResourceInfo, + dashv2alpha1.DashboardResourceInfo, nil, // do not register library panel func(obj runtime.Object, access *internal.DashboardAccess) (v runtime.Object, err error) { - dto := &dashv2.DashboardWithAccessInfo{} - dash, ok := obj.(*dashv2.Dashboard) + dto := &dashv2alpha1.DashboardWithAccessInfo{} + dash, ok := obj.(*dashv2alpha1.Dashboard) + if ok { + dto.Dashboard = *dash + } + if access != nil { + err = b.scheme.Convert(access, &dto.Access, nil) + } + return dto, err + }); err != nil { + return err + } + + if err := b.storageForVersion(apiGroupInfo, opts, largeObjects, + dashv2alpha2.DashboardResourceInfo, + nil, // do not register library panel + func(obj runtime.Object, access *internal.DashboardAccess) (v runtime.Object, err error) { + dto := &dashv2alpha2.DashboardWithAccessInfo{} + dash, ok := obj.(*dashv2alpha2.Dashboard) if ok { dto.Dashboard = *dash } @@ -544,7 +571,8 @@ func (b *DashboardsAPIBuilder) GetOpenAPIDefinitions() common.GetOpenAPIDefiniti return func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { defs := dashv0.GetOpenAPIDefinitions(ref) maps.Copy(defs, dashv1.GetOpenAPIDefinitions(ref)) - maps.Copy(defs, dashv2.GetOpenAPIDefinitions(ref)) + maps.Copy(defs, dashv2alpha1.GetOpenAPIDefinitions(ref)) + maps.Copy(defs, dashv2alpha2.GetOpenAPIDefinitions(ref)) return defs } } diff --git a/pkg/registry/apis/dashboard/register_test.go b/pkg/registry/apis/dashboard/register_test.go index 58ebb470cd9..2bccf5a1453 100644 --- a/pkg/registry/apis/dashboard/register_test.go +++ b/pkg/registry/apis/dashboard/register_test.go @@ -13,7 +13,8 @@ import ( dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1" dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1" - dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1" + dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2" common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" "github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/featuremgmt" @@ -176,7 +177,8 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) { expected: []schema.GroupVersion{ dashv1.DashboardResourceInfo.GroupVersion(), dashv0.DashboardResourceInfo.GroupVersion(), - dashv2.DashboardResourceInfo.GroupVersion(), + dashv2alpha1.DashboardResourceInfo.GroupVersion(), + dashv2alpha2.DashboardResourceInfo.GroupVersion(), }, }, { @@ -187,7 +189,8 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) { expected: []schema.GroupVersion{ dashv1.DashboardResourceInfo.GroupVersion(), dashv0.DashboardResourceInfo.GroupVersion(), - dashv2.DashboardResourceInfo.GroupVersion(), + dashv2alpha1.DashboardResourceInfo.GroupVersion(), + dashv2alpha2.DashboardResourceInfo.GroupVersion(), }, }, { @@ -196,9 +199,10 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) { featuremgmt.FlagDashboardNewLayouts, }, expected: []schema.GroupVersion{ - dashv2.DashboardResourceInfo.GroupVersion(), + dashv2alpha1.DashboardResourceInfo.GroupVersion(), dashv0.DashboardResourceInfo.GroupVersion(), dashv1.DashboardResourceInfo.GroupVersion(), + dashv2alpha2.DashboardResourceInfo.GroupVersion(), }, }, }