From ea89a68028805fa1ec7d0d810a22b1d6d20bf8f2 Mon Sep 17 00:00:00 2001 From: Igor Suleymanov Date: Tue, 11 Mar 2025 13:00:37 +0200 Subject: [PATCH] K8s/Dashboards: Generate Dashboards k8s APIs using Grafana App SDK (#99966) * Generate Dashboard kinds with `grafana-app-sdk` Signed-off-by: Igor Suleymanov * Hack together a fix for invalid TS codegen for v0 & v1 Signed-off-by: Igor Suleymanov * Address Go linter issues Signed-off-by: Igor Suleymanov * Address TS linter issues Signed-off-by: Igor Suleymanov * Add new app to CODEOWNERS Signed-off-by: Igor Suleymanov * Fix a couple of issues detected by tests Signed-off-by: Igor Suleymanov * Update OpenAPI definitions and test files Signed-off-by: Igor Suleymanov * Remove title from Dashboard v1alpha1 spec Signed-off-by: Igor Suleymanov * Remove unused CUE schemas Signed-off-by: Igor Suleymanov * remove unrelated files * allow any in the generated betterer * Add a comment explaining why we don't use deepcopy-gen Signed-off-by: Igor Suleymanov * Default to v2alpha1 if dashboards v2 FF is enabled Signed-off-by: Igor Suleymanov --------- Signed-off-by: Igor Suleymanov Co-authored-by: Ryan McKinley --- .betterer.results | 6 + .github/CODEOWNERS | 1 + .prettierignore | 3 + apps/dashboard/Makefile | 18 + apps/dashboard/kinds/cue.mod/module.cue | 4 + apps/dashboard/kinds/dashboard.cue | 68 + apps/dashboard/kinds/manifest.cue | 9 + .../kinds/v0alpha1/dashboard_spec.cue | 6 + .../kinds/v1alpha1/dashboard_spec.cue | 6 + .../kinds/v2alpha1/dashboard_spec.cue | 923 ++++ apps/dashboard/tshack/v0alpha1_spec_gen.ts | 7 + apps/dashboard/tshack/v1alpha1_spec_gen.ts | 7 + .../v0alpha1/dashboard_object_gen.ts | 49 + .../dashboard/v0alpha1/types.metadata.gen.ts | 30 + .../dashboard/v0alpha1/types.spec.gen.ts | 7 + .../dashboard/v0alpha1/types.status.gen.ts | 30 + .../v1alpha1/dashboard_object_gen.ts | 49 + .../dashboard/v1alpha1/types.metadata.gen.ts | 30 + .../dashboard/v1alpha1/types.spec.gen.ts | 7 + .../dashboard/v1alpha1/types.status.gen.ts | 30 + .../v2alpha1/dashboard_object_gen.ts | 49 + .../dashboard/v2alpha1/types.metadata.gen.ts | 30 + .../dashboard/v2alpha1/types.spec.gen.ts | 1316 +++++ .../dashboard/v2alpha1/types.status.gen.ts | 30 + .../migration/conversion/conversion.go | 92 +- pkg/apis/dashboard/v0alpha1/constants.go | 18 + .../dashboard/v0alpha1/dashboard_codec_gen.go | 28 + .../v0alpha1/dashboard_metadata_gen.go | 28 + .../v0alpha1/dashboard_object_gen.go | 269 ++ .../v0alpha1/dashboard_schema_gen.go | 34 + pkg/apis/dashboard/v0alpha1/dashboard_spec.go | 13 + .../dashboard/v0alpha1/dashboard_spec_gen.go | 3 + .../v0alpha1/dashboard_status_gen.go | 34 + pkg/apis/dashboard/v0alpha1/deepcopy.go | 41 + pkg/apis/dashboard/v0alpha1/doc.go | 5 +- pkg/apis/dashboard/v0alpha1/search.go | 7 + pkg/apis/dashboard/v0alpha1/types.go | 46 +- .../v0alpha1/zz_generated.deepcopy.go | 102 - .../v0alpha1/zz_generated.openapi.go | 258 +- ...enerated.openapi_violation_exceptions.list | 3 +- pkg/apis/dashboard/v1alpha1/constants.go | 18 + .../dashboard/v1alpha1/dashboard_codec_gen.go | 28 + .../v1alpha1/dashboard_metadata_gen.go | 28 + .../v1alpha1/dashboard_object_gen.go | 269 ++ .../v1alpha1/dashboard_schema_gen.go | 34 + pkg/apis/dashboard/v1alpha1/dashboard_spec.go | 11 + .../dashboard/v1alpha1/dashboard_spec_gen.go | 3 + .../v1alpha1/dashboard_status_gen.go | 34 + pkg/apis/dashboard/v1alpha1/deepcopy.go | 41 + pkg/apis/dashboard/v1alpha1/doc.go | 5 +- pkg/apis/dashboard/v1alpha1/types.go | 45 +- .../v1alpha1/zz_generated.deepcopy.go | 102 - .../v1alpha1/zz_generated.openapi.go | 241 +- ...enerated.openapi_violation_exceptions.list | 3 +- pkg/apis/dashboard/v2alpha1/constants.go | 18 + .../dashboard/v2alpha1/dashboard_codec_gen.go | 28 + .../v2alpha1/dashboard_metadata_gen.go | 28 + .../v2alpha1/dashboard_object_gen.go | 269 ++ .../v2alpha1/dashboard_schema_gen.go | 34 + .../dashboard/v2alpha1/dashboard_spec_gen.go | 2373 +++++++++ .../v2alpha1/dashboard_status_gen.go | 34 + pkg/apis/dashboard/v2alpha1/deepcopy.go | 63 + pkg/apis/dashboard/v2alpha1/doc.go | 5 +- pkg/apis/dashboard/v2alpha1/register.go | 14 +- pkg/apis/dashboard/v2alpha1/types.go | 45 +- .../v2alpha1/zz_generated.deepcopy.go | 102 - .../v2alpha1/zz_generated.openapi.go | 4230 ++++++++++++++++- ...enerated.openapi_violation_exceptions.list | 65 +- pkg/apis/dashboard_manifest.go | 53 + pkg/registry/apis/dashboard/large.go | 20 +- pkg/registry/apis/dashboard/mutate.go | 5 +- pkg/registry/apis/dashboard/register.go | 10 + pkg/registry/apis/dashboard/register_test.go | 94 + pkg/storage/unified/apistore/go.mod | 1 + pkg/storage/unified/apistore/go.sum | 2 + pkg/storage/unified/resource/go.mod | 2 +- pkg/storage/unified/resource/go.sum | 2 + .../dashboard/testdata/dashboard-test-v2.yaml | 4 + .../dashboard.grafana.app-v0alpha1.json | 68 +- public/api-merged.json | 2 + public/openapi3.json | 2 + 81 files changed, 11452 insertions(+), 679 deletions(-) create mode 100644 apps/dashboard/Makefile create mode 100644 apps/dashboard/kinds/cue.mod/module.cue create mode 100644 apps/dashboard/kinds/dashboard.cue create mode 100644 apps/dashboard/kinds/manifest.cue create mode 100644 apps/dashboard/kinds/v0alpha1/dashboard_spec.cue create mode 100644 apps/dashboard/kinds/v1alpha1/dashboard_spec.cue create mode 100644 apps/dashboard/kinds/v2alpha1/dashboard_spec.cue create mode 100644 apps/dashboard/tshack/v0alpha1_spec_gen.ts create mode 100644 apps/dashboard/tshack/v1alpha1_spec_gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v0alpha1/dashboard_object_gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v0alpha1/types.metadata.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v0alpha1/types.spec.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v0alpha1/types.status.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v1alpha1/dashboard_object_gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v1alpha1/types.metadata.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v1alpha1/types.spec.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v1alpha1/types.status.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha1/dashboard_object_gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha1/types.metadata.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts create mode 100644 packages/grafana-schema/src/schema/dashboard/v2alpha1/types.status.gen.ts create mode 100644 pkg/apis/dashboard/v0alpha1/constants.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_codec_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_metadata_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_object_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_schema_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_spec.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_spec_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/dashboard_status_gen.go create mode 100644 pkg/apis/dashboard/v0alpha1/deepcopy.go create mode 100644 pkg/apis/dashboard/v1alpha1/constants.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_codec_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_metadata_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_object_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_schema_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_spec.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_spec_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/dashboard_status_gen.go create mode 100644 pkg/apis/dashboard/v1alpha1/deepcopy.go create mode 100644 pkg/apis/dashboard/v2alpha1/constants.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_codec_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_metadata_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_object_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_schema_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/dashboard_status_gen.go create mode 100644 pkg/apis/dashboard/v2alpha1/deepcopy.go create mode 100644 pkg/apis/dashboard_manifest.go diff --git a/.betterer.results b/.betterer.results index c0486d07719..b03dac144aa 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5,6 +5,12 @@ // exports[`better eslint`] = { value: `{ + "apps/dashboard/tshack/v0alpha1_spec_gen.ts:5381": [ + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + ], + "apps/dashboard/tshack/v1alpha1_spec_gen.ts:5381": [ + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + ], "e2e/old-arch/utils/support/types.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 65f706f256e..7ff10207c35 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -71,6 +71,7 @@ /pkg/registry/apis/provisioning @grafana/grafana-git-ui-sync-team /apps/alerting/ @grafana/alerting-backend +/apps/dashboard/ @grafana/grafana-app-platform-squad @grafana/dashboards-squad /apps/playlist/ @grafana/grafana-app-platform-squad /apps/investigations/ @fcjack @matryer @svennergr /apps/advisor/ @grafana/plugins-platform-backend diff --git a/.prettierignore b/.prettierignore index 8bf9dc13276..23d9231bc49 100644 --- a/.prettierignore +++ b/.prettierignore @@ -19,6 +19,9 @@ vendor # TS generate from cue by cuetsy **/*.gen.ts +# TS generated by grafana-app-sdk +**/*_gen.ts + # Auto-generated theme files theme.light.generated.json theme.dark.generated.json diff --git a/apps/dashboard/Makefile b/apps/dashboard/Makefile new file mode 100644 index 00000000000..d95e25e1abd --- /dev/null +++ b/apps/dashboard/Makefile @@ -0,0 +1,18 @@ +.PHONY: generate +generate: + @grafana-app-sdk generate \ + --source=./kinds/ \ + --gogenpath=../../pkg/apis \ + --tsgenpath=../../packages/grafana-schema/src/schema \ + --grouping=group \ + --defencoding=none \ + --genoperatorstate=false \ + --noschemasinmanifest + + # This is a workaround for SDK codegen not producing correct output for v0alpha1 + @rm ../../packages/grafana-schema/src/schema/dashboard/v0alpha1/types.spec.gen.ts + @cp ./tshack/v0alpha1_spec_gen.ts ../../packages/grafana-schema/src/schema/dashboard/v0alpha1/types.spec.gen.ts + + # Same for v1alpha1 + @rm ../../packages/grafana-schema/src/schema/dashboard/v1alpha1/types.spec.gen.ts + @cp ./tshack/v1alpha1_spec_gen.ts ../../packages/grafana-schema/src/schema/dashboard/v1alpha1/types.spec.gen.ts diff --git a/apps/dashboard/kinds/cue.mod/module.cue b/apps/dashboard/kinds/cue.mod/module.cue new file mode 100644 index 00000000000..a3b88f8aa81 --- /dev/null +++ b/apps/dashboard/kinds/cue.mod/module.cue @@ -0,0 +1,4 @@ +module: "github.com/grafana/grafana/sdkkinds/dashboard" +language: { + version: "v0.9.0" +} diff --git a/apps/dashboard/kinds/dashboard.cue b/apps/dashboard/kinds/dashboard.cue new file mode 100644 index 00000000000..da09322e0e8 --- /dev/null +++ b/apps/dashboard/kinds/dashboard.cue @@ -0,0 +1,68 @@ +package kinds + +import ( + "github.com/grafana/grafana/sdkkinds/dashboard/v0alpha1" + "github.com/grafana/grafana/sdkkinds/dashboard/v1alpha1" + "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1" +) + +// Status is the shared status of all dashboard versions. +DashboardStatus: { + // Optional conversion status. + conversion?: ConversionStatus +} + +// ConversionStatus is the status of the conversion of the dashboard. +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: bool + + // 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 +} + +dashboard: { + kind: "Dashboard" + pluralName: "Dashboards" + current: "v0alpha1" + + codegen: { + ts: { + enabled: true + config: { + enumsAsUnionTypes: true + } + } + go: { + enabled: true + } + } + + versions: { + "v0alpha1": { + schema: { + spec: v0alpha1.DashboardSpec + status: DashboardStatus + } + } + "v1alpha1": { + schema: { + spec: v1alpha1.DashboardSpec + status: DashboardStatus + } + } + "v2alpha1": { + schema: { + spec: v2alpha1.DashboardSpec + status: DashboardStatus + } + } + } +} diff --git a/apps/dashboard/kinds/manifest.cue b/apps/dashboard/kinds/manifest.cue new file mode 100644 index 00000000000..1ec0fb4f21c --- /dev/null +++ b/apps/dashboard/kinds/manifest.cue @@ -0,0 +1,9 @@ +package kinds + +manifest: { + appName: "dashboard" + groupOverride: "dashboard.grafana.app" + kinds: [ + dashboard, + ] +} diff --git a/apps/dashboard/kinds/v0alpha1/dashboard_spec.cue b/apps/dashboard/kinds/v0alpha1/dashboard_spec.cue new file mode 100644 index 00000000000..a59f79e97e9 --- /dev/null +++ b/apps/dashboard/kinds/v0alpha1/dashboard_spec.cue @@ -0,0 +1,6 @@ +package v0alpha1 + +// TODO: this outputs nothing. +// For now, we use unstructured for the spec, +// but it cannot be produced by the SDK codegen. +DashboardSpec: [string]: _ diff --git a/apps/dashboard/kinds/v1alpha1/dashboard_spec.cue b/apps/dashboard/kinds/v1alpha1/dashboard_spec.cue new file mode 100644 index 00000000000..709fb40fd02 --- /dev/null +++ b/apps/dashboard/kinds/v1alpha1/dashboard_spec.cue @@ -0,0 +1,6 @@ +package v1alpha1 + +// TODO: this outputs nothing. +// For now, we use unstructured for the spec, +// but it cannot be produced by the SDK codegen. +DashboardSpec: [string]: _ diff --git a/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue b/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue new file mode 100644 index 00000000000..a1216596268 --- /dev/null +++ b/apps/dashboard/kinds/v2alpha1/dashboard_spec.cue @@ -0,0 +1,923 @@ +package v2alpha1 + +DashboardSpec: { + // Title of dashboard. + 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 | ResponsiveGridLayoutKind | 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 + + // 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: [...uint8] +} + +// "Off" for no shared crosshair or tooltip (default). +// "Crosshair" for shared crosshair. +// "Tooltip" for shared crosshair AND shared tooltip. +DashboardCursorSync: "Off" | "Crosshair" | "Tooltip" + +// 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" @cog(kind="enum",memberNames="ValueToText|RangeToText|RegexToText|SpecialValue") + +// 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: { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "value" + type: "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: { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "range" + 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: 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: { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "regex" + 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 + } +} + +// 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: { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "special" + type: "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 +} + +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 // 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 + // 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 +} + +ResponsiveGridRepeatOptions: { + 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 +} + +GridLayoutRowKind: { + kind: "GridLayoutRow" + spec: GridLayoutRowSpec +} + +GridLayoutRowSpec: { + y: int + collapsed: bool + title: string + elements: [...GridLayoutItemKind] // Grid items in the row will have their Y value be relative to the rows Y value. This means a panel positioned at Y: 0 in a row with Y: 10 will be positioned at Y: 11 (row header has a heigh of 1) in the dashboard. + repeat?: RowRepeatOptions +} + +GridLayoutSpec: { + items: [...GridLayoutItemKind | GridLayoutRowKind] +} + +GridLayoutKind: { + kind: "GridLayout" + spec: GridLayoutSpec +} + +RowsLayoutKind: { + kind: "RowsLayout" + spec: RowsLayoutSpec +} + +RowsLayoutSpec: { + rows: [...RowsLayoutRowKind] +} + +RowsLayoutRowKind: { + kind: "RowsLayoutRow" + spec: RowsLayoutRowSpec +} + +RowsLayoutRowSpec: { + title?: string + collapsed: bool + repeat?: RowRepeatOptions + layout: GridLayoutKind | ResponsiveGridLayoutKind | TabsLayoutKind +} + +ResponsiveGridLayoutKind: { + kind: "ResponsiveGridLayout" + spec: ResponsiveGridLayoutSpec +} + +ResponsiveGridLayoutSpec: { + row: string + col: string + items: [...ResponsiveGridLayoutItemKind] +} + +ResponsiveGridLayoutItemKind: { + kind: "ResponsiveGridLayoutItem" + spec: ResponsiveGridLayoutItemSpec +} + +ResponsiveGridLayoutItemSpec: { + element: ElementReference + repeat?: ResponsiveGridRepeatOptions +} + +TabsLayoutKind: { + kind: "TabsLayout" + spec: TabsLayoutSpec +} + +TabsLayoutSpec: { + tabs: [...TabsLayoutTabKind] +} + +TabsLayoutTabKind: { + kind: "TabsLayoutTab" + spec: TabsLayoutTabSpec +} + +TabsLayoutTabSpec: { + title?: string + layout: GridLayoutKind | RowsLayoutKind | ResponsiveGridLayoutKind +} + +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" + +// 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 +} + +// 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 +} + +// 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 +} + +// Custom variable kind +CustomVariableKind: { + kind: "CustomVariable" + spec: CustomVariableSpec +} + +// GroupBy variable specification +GroupByVariableSpec: { + name: string | *"" + datasource?: DataSourceRef + 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 +} + +// 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 + // @deprecated + condition?: string +} + +// Adhoc variable kind +AdhocVariableKind: { + kind: "AdhocVariable" + spec: AdhocVariableSpec +} diff --git a/apps/dashboard/tshack/v0alpha1_spec_gen.ts b/apps/dashboard/tshack/v0alpha1_spec_gen.ts new file mode 100644 index 00000000000..3de7e52c72e --- /dev/null +++ b/apps/dashboard/tshack/v0alpha1_spec_gen.ts @@ -0,0 +1,7 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +export interface Spec { + [key: string]: any; +} + +export const defaultSpec = (): Spec => ({}); diff --git a/apps/dashboard/tshack/v1alpha1_spec_gen.ts b/apps/dashboard/tshack/v1alpha1_spec_gen.ts new file mode 100644 index 00000000000..3de7e52c72e --- /dev/null +++ b/apps/dashboard/tshack/v1alpha1_spec_gen.ts @@ -0,0 +1,7 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +export interface Spec { + [key: string]: any; +} + +export const defaultSpec = (): Spec => ({}); diff --git a/packages/grafana-schema/src/schema/dashboard/v0alpha1/dashboard_object_gen.ts b/packages/grafana-schema/src/schema/dashboard/v0alpha1/dashboard_object_gen.ts new file mode 100644 index 00000000000..a89d50ebd2d --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v0alpha1/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/v0alpha1/types.metadata.gen.ts b/packages/grafana-schema/src/schema/dashboard/v0alpha1/types.metadata.gen.ts new file mode 100644 index 00000000000..4377f3c1d08 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v0alpha1/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/v0alpha1/types.spec.gen.ts b/packages/grafana-schema/src/schema/dashboard/v0alpha1/types.spec.gen.ts new file mode 100644 index 00000000000..3de7e52c72e --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v0alpha1/types.spec.gen.ts @@ -0,0 +1,7 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +export interface Spec { + [key: string]: any; +} + +export const defaultSpec = (): Spec => ({}); diff --git a/packages/grafana-schema/src/schema/dashboard/v0alpha1/types.status.gen.ts b/packages/grafana-schema/src/schema/dashboard/v0alpha1/types.status.gen.ts new file mode 100644 index 00000000000..29494dfaf24 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v0alpha1/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/packages/grafana-schema/src/schema/dashboard/v1alpha1/dashboard_object_gen.ts b/packages/grafana-schema/src/schema/dashboard/v1alpha1/dashboard_object_gen.ts new file mode 100644 index 00000000000..a89d50ebd2d --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v1alpha1/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/v1alpha1/types.metadata.gen.ts b/packages/grafana-schema/src/schema/dashboard/v1alpha1/types.metadata.gen.ts new file mode 100644 index 00000000000..4377f3c1d08 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v1alpha1/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/v1alpha1/types.spec.gen.ts b/packages/grafana-schema/src/schema/dashboard/v1alpha1/types.spec.gen.ts new file mode 100644 index 00000000000..3de7e52c72e --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v1alpha1/types.spec.gen.ts @@ -0,0 +1,7 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +export interface Spec { + [key: string]: any; +} + +export const defaultSpec = (): Spec => ({}); diff --git a/packages/grafana-schema/src/schema/dashboard/v1alpha1/types.status.gen.ts b/packages/grafana-schema/src/schema/dashboard/v1alpha1/types.status.gen.ts new file mode 100644 index 00000000000..29494dfaf24 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v1alpha1/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/packages/grafana-schema/src/schema/dashboard/v2alpha1/dashboard_object_gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha1/dashboard_object_gen.ts new file mode 100644 index 00000000000..a89d50ebd2d --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha1/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/v2alpha1/types.metadata.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.metadata.gen.ts new file mode 100644 index 00000000000..4377f3c1d08 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha1/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/v2alpha1/types.spec.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts new file mode 100644 index 00000000000..477ec4e63ad --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.spec.gen.ts @@ -0,0 +1,1316 @@ +// 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; +} + +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 = "Off" | "Crosshair" | "Tooltip"; + +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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "value" + type: "value"; + // Map with : ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } } + options: Record; +} + +export const defaultValueMap = (): ValueMap => ({ + type: "value", + options: {}, +}); + +// 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "range" + 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "regex" + 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "special" + 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 | GridLayoutRowKind)[]; +} + +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 GridLayoutRowKind { + kind: "GridLayoutRow"; + spec: GridLayoutRowSpec; +} + +export const defaultGridLayoutRowKind = (): GridLayoutRowKind => ({ + kind: "GridLayoutRow", + spec: defaultGridLayoutRowSpec(), +}); + +export interface GridLayoutRowSpec { + y: number; + collapsed: boolean; + title: string; + // Grid items in the row will have their Y value be relative to the rows Y value. This means a panel positioned at Y: 0 in a row with Y: 10 will be positioned at Y: 11 (row header has a heigh of 1) in the dashboard. + elements: GridLayoutItemKind[]; + repeat?: RowRepeatOptions; +} + +export const defaultGridLayoutRowSpec = (): GridLayoutRowSpec => ({ + y: 0, + collapsed: false, + title: "", + elements: [], +}); + +export interface RowRepeatOptions { + mode: "variable"; + value: string; +} + +export const defaultRowRepeatOptions = (): RowRepeatOptions => ({ + mode: RepeatMode, + value: "", +}); + +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; + collapsed: boolean; + repeat?: RowRepeatOptions; + layout: GridLayoutKind | ResponsiveGridLayoutKind | TabsLayoutKind; +} + +export const defaultRowsLayoutRowSpec = (): RowsLayoutRowSpec => ({ + collapsed: false, + layout: defaultGridLayoutKind(), +}); + +export interface ResponsiveGridLayoutKind { + kind: "ResponsiveGridLayout"; + spec: ResponsiveGridLayoutSpec; +} + +export const defaultResponsiveGridLayoutKind = (): ResponsiveGridLayoutKind => ({ + kind: "ResponsiveGridLayout", + spec: defaultResponsiveGridLayoutSpec(), +}); + +export interface ResponsiveGridLayoutSpec { + row: string; + col: string; + items: ResponsiveGridLayoutItemKind[]; +} + +export const defaultResponsiveGridLayoutSpec = (): ResponsiveGridLayoutSpec => ({ + row: "", + col: "", + items: [], +}); + +export interface ResponsiveGridLayoutItemKind { + kind: "ResponsiveGridLayoutItem"; + spec: ResponsiveGridLayoutItemSpec; +} + +export const defaultResponsiveGridLayoutItemKind = (): ResponsiveGridLayoutItemKind => ({ + kind: "ResponsiveGridLayoutItem", + spec: defaultResponsiveGridLayoutItemSpec(), +}); + +export interface ResponsiveGridLayoutItemSpec { + element: ElementReference; + repeat?: ResponsiveGridRepeatOptions; +} + +export const defaultResponsiveGridLayoutItemSpec = (): ResponsiveGridLayoutItemSpec => ({ + element: defaultElementReference(), +}); + +export interface ResponsiveGridRepeatOptions { + mode: "variable"; + value: string; +} + +export const defaultResponsiveGridRepeatOptions = (): ResponsiveGridRepeatOptions => ({ + 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 | ResponsiveGridLayoutKind; +} + +export const defaultTabsLayoutTabSpec = (): TabsLayoutTabSpec => ({ + layout: defaultGridLayoutKind(), +}); + +// 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; +} + +export const defaultQueryVariableSpec = (): QueryVariableSpec => ({ + name: "", + current: { text: "", value: "", }, + hide: "dontHide", + refresh: "never", + skipUrlSync: false, + query: defaultDataQueryKind(), + regex: "", + sort: "disabled", + options: [], + multi: false, + includeAll: false, +}); + +// 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; +} + +export const defaultDatasourceVariableSpec = (): DatasourceVariableSpec => ({ + name: "", + pluginId: "", + refresh: "never", + regex: "", + current: { text: "", value: "", }, + options: [], + multi: false, + includeAll: false, + hide: "dontHide", + skipUrlSync: false, +}); + +// 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; +} + +export const defaultCustomVariableSpec = (): CustomVariableSpec => ({ + name: "", + query: "", + current: defaultVariableOption(), + options: [], + multi: false, + includeAll: false, + hide: "dontHide", + skipUrlSync: false, +}); + +// 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; + 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; +} + +export const defaultAdhocVariableSpec = (): AdhocVariableSpec => ({ + name: "", + baseFilters: [], + filters: [], + defaultKeys: [], + hide: "dontHide", + skipUrlSync: false, +}); + +// Define the AdHocFilterWithLabels type +export interface AdHocFilterWithLabels { + key: string; + operator: string; + value: string; + values?: string[]; + keyLabel?: string; + valueLabels?: string[]; + forceEdit?: boolean; + // @deprecated + condition?: string; +} + +export const defaultAdHocFilterWithLabels = (): AdHocFilterWithLabels => ({ + key: "", + operator: "", + value: "", +}); + +// Define the MetricFindValue type +export interface MetricFindValue { + text: string; + value?: string | number; + group?: string; + expandable?: boolean; +} + +export const defaultMetricFindValue = (): MetricFindValue => ({ + text: "", +}); + +export interface Spec { + // Title of dashboard. + 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 | ResponsiveGridLayoutKind | 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/v2alpha1/types.status.gen.ts b/packages/grafana-schema/src/schema/dashboard/v2alpha1/types.status.gen.ts new file mode 100644 index 00000000000..29494dfaf24 --- /dev/null +++ b/packages/grafana-schema/src/schema/dashboard/v2alpha1/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/apis/dashboard/migration/conversion/conversion.go b/pkg/apis/dashboard/migration/conversion/conversion.go index f14162ff817..830353ce1f2 100644 --- a/pkg/apis/dashboard/migration/conversion/conversion.go +++ b/pkg/apis/dashboard/migration/conversion/conversion.go @@ -47,79 +47,127 @@ func RegisterConversions(s *runtime.Scheme) error { func Convert_V0_to_V1(in *dashboardV0.Dashboard, out *dashboardV1.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV1.DashboardStatus{ - ConversionStatus: &dashboardV1.ConversionStatus{ + + out.Spec.Object = in.Spec.Object + + out.Status = dashboardV1.DashboardStatus{ + Conversion: &dashboardV1.DashboardConversionStatus{ StoredVersion: dashboardV0.VERSION, }, } - err := migration.Migrate(out.Spec.Object, schemaversion.LATEST_VERSION) - if err != nil { - out.Status.ConversionStatus.Failed = true - out.Status.ConversionStatus.Error = err.Error() + + 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 *dashboardV0.Dashboard, out *dashboardV2.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV2.DashboardStatus{ - ConversionStatus: &dashboardV2.ConversionStatus{ + + // 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 = dashboardV2.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind{ + GridLayoutKind: &dashboardV2.DashboardGridLayoutKind{ + Kind: "GridLayout", + Spec: dashboardV2.DashboardGridLayoutSpec{}, + }, + } + + out.Status = dashboardV2.DashboardStatus{ + Conversion: &dashboardV2.DashboardConversionStatus{ StoredVersion: dashboardV0.VERSION, Failed: true, Error: "backend conversion not yet implemented", }, } + return nil } func Convert_V1_to_V0(in *dashboardV1.Dashboard, out *dashboardV0.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV0.DashboardStatus{ - ConversionStatus: &dashboardV0.ConversionStatus{ + + out.Spec.Object = in.Spec.Object + + out.Status = dashboardV0.DashboardStatus{ + Conversion: &dashboardV0.DashboardConversionStatus{ StoredVersion: dashboardV1.VERSION, }, } + return nil } func Convert_V1_to_V2(in *dashboardV1.Dashboard, out *dashboardV2.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV2.DashboardStatus{ - ConversionStatus: &dashboardV2.ConversionStatus{ + + // 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 = dashboardV2.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind{ + GridLayoutKind: &dashboardV2.DashboardGridLayoutKind{ + Kind: "GridLayout", + Spec: dashboardV2.DashboardGridLayoutSpec{}, + }, + } + + out.Status = dashboardV2.DashboardStatus{ + Conversion: &dashboardV2.DashboardConversionStatus{ StoredVersion: dashboardV1.VERSION, Failed: true, Error: "backend conversion not yet implemented", }, } + return nil } func Convert_V2_to_V0(in *dashboardV2.Dashboard, out *dashboardV0.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV0.DashboardStatus{ - ConversionStatus: &dashboardV0.ConversionStatus{ + + // TODO: implement V2 to V0 conversion + + out.Status = dashboardV0.DashboardStatus{ + Conversion: &dashboardV0.DashboardConversionStatus{ StoredVersion: dashboardV2.VERSION, Failed: true, Error: "backend conversion not yet implemented", }, } + return nil } func Convert_V2_to_V1(in *dashboardV2.Dashboard, out *dashboardV1.Dashboard, scope conversion.Scope) error { out.ObjectMeta = in.ObjectMeta - out.Spec = in.Spec - out.Status = &dashboardV1.DashboardStatus{ - ConversionStatus: &dashboardV1.ConversionStatus{ + + // TODO: implement V2 to V1 conversion + + out.Status = dashboardV1.DashboardStatus{ + Conversion: &dashboardV1.DashboardConversionStatus{ StoredVersion: dashboardV2.VERSION, Failed: true, Error: "backend conversion not yet implemented", }, } + return nil } diff --git a/pkg/apis/dashboard/v0alpha1/constants.go b/pkg/apis/dashboard/v0alpha1/constants.go new file mode 100644 index 00000000000..90cb8b29db7 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/constants.go @@ -0,0 +1,18 @@ +package v0alpha1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +const ( + // Group is the API group used by all kinds in this package + Group = "dashboard.grafana.app" + // Version is the API version used by all kinds in this package + Version = "v0alpha1" +) + +var ( + // GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package + GroupVersion = schema.GroupVersion{ + Group: Group, + Version: Version, + } +) diff --git a/pkg/apis/dashboard/v0alpha1/dashboard_codec_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_codec_gen.go new file mode 100644 index 00000000000..6186cb824b5 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_codec_gen.go @@ -0,0 +1,28 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v0alpha1 + +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/pkg/apis/dashboard/v0alpha1/dashboard_metadata_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_metadata_gen.go new file mode 100644 index 00000000000..6e22219dbf4 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_metadata_gen.go @@ -0,0 +1,28 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v0alpha1 + +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{} +} diff --git a/pkg/apis/dashboard/v0alpha1/dashboard_object_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_object_gen.go new file mode 100644 index 00000000000..ab406988c90 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_object_gen.go @@ -0,0 +1,269 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v0alpha1 + +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() +} + +// 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) + } +} + +// Interface compliance compile-time check +var _ resource.ListObject = &DashboardList{} diff --git a/pkg/apis/dashboard/v0alpha1/dashboard_schema_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_schema_gen.go new file mode 100644 index 00000000000..5b2da44ec05 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_schema_gen.go @@ -0,0 +1,34 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v0alpha1 + +import ( + "github.com/grafana/grafana-app-sdk/resource" +) + +// schema is unexported to prevent accidental overwrites +var ( + schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v0alpha1", &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/pkg/apis/dashboard/v0alpha1/dashboard_spec.go b/pkg/apis/dashboard/v0alpha1/dashboard_spec.go new file mode 100644 index 00000000000..ec3bf1aeb1f --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_spec.go @@ -0,0 +1,13 @@ +package v0alpha1 + +import ( + common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" +) + +// +k8s:openapi-gen=true +type DashboardSpec = common.Unstructured + +// NewDashboardSpec creates a new Spec object. +func NewDashboardSpec() *DashboardSpec { + return &DashboardSpec{} +} diff --git a/pkg/apis/dashboard/v0alpha1/dashboard_spec_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_spec_gen.go new file mode 100644 index 00000000000..90130b85cf3 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_spec_gen.go @@ -0,0 +1,3 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v0alpha1 diff --git a/pkg/apis/dashboard/v0alpha1/dashboard_status_gen.go b/pkg/apis/dashboard/v0alpha1/dashboard_status_gen.go new file mode 100644 index 00000000000..70fbb4e9263 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/dashboard_status_gen.go @@ -0,0 +1,34 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v0alpha1 + +// 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/pkg/apis/dashboard/v0alpha1/deepcopy.go b/pkg/apis/dashboard/v0alpha1/deepcopy.go new file mode 100644 index 00000000000..ffdea428a67 --- /dev/null +++ b/pkg/apis/dashboard/v0alpha1/deepcopy.go @@ -0,0 +1,41 @@ +package v0alpha1 + +// TODO: these should be automatically generated by the SDK. + +func (in *Dashboard) DeepCopyInto(out *Dashboard) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +func (in *Dashboard) DeepCopy() *Dashboard { + if in == nil { + return nil + } + out := new(Dashboard) + in.DeepCopyInto(out) + return out +} + +func (in *DashboardList) DeepCopyInto(out *DashboardList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Dashboard, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +func (in *DashboardList) DeepCopy() *DashboardList { + if in == nil { + return nil + } + out := new(DashboardList) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/dashboard/v0alpha1/doc.go b/pkg/apis/dashboard/v0alpha1/doc.go index 5716d920d2a..748fa7fffd2 100644 --- a/pkg/apis/dashboard/v0alpha1/doc.go +++ b/pkg/apis/dashboard/v0alpha1/doc.go @@ -1,7 +1,10 @@ -// +k8s:deepcopy-gen=package // +k8s:openapi-gen=true // +k8s:defaulter-gen=TypeMeta // +k8s:conversion-gen=github.com/grafana/grafana/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 v0alpha1 // import "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1" diff --git a/pkg/apis/dashboard/v0alpha1/search.go b/pkg/apis/dashboard/v0alpha1/search.go index 96afdc447ff..5d768dbfc11 100644 --- a/pkg/apis/dashboard/v0alpha1/search.go +++ b/pkg/apis/dashboard/v0alpha1/search.go @@ -6,6 +6,7 @@ import ( 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 SearchResults struct { metav1.TypeMeta `json:",inline"` @@ -32,11 +33,13 @@ type SearchResults struct { Facets map[string]FacetResult `json:"facets,omitempty"` } +// +k8s:deepcopy-gen=true type SortBy struct { Field string `json:"field"` Descending bool `json:"desc,omitempty"` } +// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type SortableFields struct { metav1.TypeMeta `json:",inline"` @@ -45,12 +48,14 @@ type SortableFields struct { Fields []SortableField `json:"fields"` } +// +k8s:deepcopy-gen=true type SortableField struct { Field string `json:"string,omitempty"` Display string `json:"display,omitempty"` Type string `json:"type,omitempty"` // string or number } +// +k8s:deepcopy-gen=true type DashboardHit struct { // Dashboard or folder Resource string `json:"resource"` // dashboards | folders @@ -70,6 +75,7 @@ type DashboardHit struct { Explain *common.Unstructured `json:"explain,omitempty"` } +// +k8s:deepcopy-gen=true type FacetResult struct { Field string `json:"field,omitempty"` // The distinct terms @@ -80,6 +86,7 @@ type FacetResult struct { Terms []TermFacet `json:"terms,omitempty"` } +// +k8s:deepcopy-gen=true type TermFacet struct { Term string `json:"term,omitempty"` Count int64 `json:"count,omitempty"` diff --git a/pkg/apis/dashboard/v0alpha1/types.go b/pkg/apis/dashboard/v0alpha1/types.go index af6f62f2e95..ff4e38841d3 100644 --- a/pkg/apis/dashboard/v0alpha1/types.go +++ b/pkg/apis/dashboard/v0alpha1/types.go @@ -7,40 +7,7 @@ import ( common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" ) -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type Dashboard 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"` - - // The dashboard body (unstructured for now) - Spec common.Unstructured `json:"spec"` - - // Optional dashboard status - Status *DashboardStatus `json:"status,omitempty"` -} - -type DashboardStatus struct { - ConversionStatus *ConversionStatus `json:"conversion,omitempty"` -} - -type ConversionStatus struct { - Failed bool `json:"failed,omitempty"` - StoredVersion string `json:"storedVersion,omitempty"` - Error string `json:"error,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type DashboardList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - Items []Dashboard `json:"items,omitempty"` -} - +// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type DashboardVersionList struct { metav1.TypeMeta `json:",inline"` @@ -50,6 +17,7 @@ type DashboardVersionList struct { Items []DashboardVersionInfo `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type DashboardVersionInfo struct { // The internal ID for this version (will be replaced with resourceVersion) Version int `json:"version"` @@ -67,6 +35,7 @@ type DashboardVersionInfo struct { 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 { @@ -80,6 +49,7 @@ type VersionsQueryOptions struct { 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"` @@ -95,6 +65,7 @@ type LibraryPanel struct { 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"` @@ -104,6 +75,7 @@ type LibraryPanelList struct { Items []LibraryPanel `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type LibraryPanelSpec struct { // The panel type Type string `json:"type"` @@ -131,6 +103,7 @@ type LibraryPanelSpec struct { 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"` @@ -140,6 +113,7 @@ type LibraryPanelStatus struct { } // 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"` @@ -147,7 +121,7 @@ type DashboardWithAccessInfo struct { 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"` @@ -162,11 +136,13 @@ type DashboardAccess struct { 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"` diff --git a/pkg/apis/dashboard/v0alpha1/zz_generated.deepcopy.go b/pkg/apis/dashboard/v0alpha1/zz_generated.deepcopy.go index 82e62ccdae6..8d851c4f6c2 100644 --- a/pkg/apis/dashboard/v0alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/dashboard/v0alpha1/zz_generated.deepcopy.go @@ -46,54 +46,6 @@ func (in *AnnotationPermission) DeepCopy() *AnnotationPermission { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConversionStatus) DeepCopyInto(out *ConversionStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConversionStatus. -func (in *ConversionStatus) DeepCopy() *ConversionStatus { - if in == nil { - return nil - } - out := new(ConversionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Dashboard) DeepCopyInto(out *Dashboard) { - *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(DashboardStatus) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dashboard. -func (in *Dashboard) DeepCopy() *Dashboard { - if in == nil { - return nil - } - out := new(Dashboard) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Dashboard) 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 *DashboardAccess) DeepCopyInto(out *DashboardAccess) { *out = *in @@ -144,60 +96,6 @@ func (in *DashboardHit) DeepCopy() *DashboardHit { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DashboardList) DeepCopyInto(out *DashboardList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Dashboard, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardList. -func (in *DashboardList) DeepCopy() *DashboardList { - if in == nil { - return nil - } - out := new(DashboardList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DashboardList) 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 *DashboardStatus) DeepCopyInto(out *DashboardStatus) { - *out = *in - if in.ConversionStatus != nil { - in, out := &in.ConversionStatus, &out.ConversionStatus - *out = new(ConversionStatus) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardStatus. -func (in *DashboardStatus) DeepCopy() *DashboardStatus { - if in == nil { - return nil - } - out := new(DashboardStatus) - 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 diff --git a/pkg/apis/dashboard/v0alpha1/zz_generated.openapi.go b/pkg/apis/dashboard/v0alpha1/zz_generated.openapi.go index 23197ec669b..6249102860d 100644 --- a/pkg/apis/dashboard/v0alpha1/zz_generated.openapi.go +++ b/pkg/apis/dashboard/v0alpha1/zz_generated.openapi.go @@ -8,34 +8,38 @@ package v0alpha1 import ( + commonv0alpha1 "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" 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/pkg/apis/dashboard/v0alpha1.AnnotationActions": schema_pkg_apis_dashboard_v0alpha1_AnnotationActions(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v0alpha1_AnnotationPermission(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.ConversionStatus": schema_pkg_apis_dashboard_v0alpha1_ConversionStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.Dashboard": schema_pkg_apis_dashboard_v0alpha1_Dashboard(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardAccess": schema_pkg_apis_dashboard_v0alpha1_DashboardAccess(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardHit": schema_pkg_apis_dashboard_v0alpha1_DashboardHit(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardList": schema_pkg_apis_dashboard_v0alpha1_DashboardList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus": schema_pkg_apis_dashboard_v0alpha1_DashboardStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v0alpha1_DashboardVersionInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v0alpha1_DashboardVersionList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v0alpha1_DashboardWithAccessInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.FacetResult": schema_pkg_apis_dashboard_v0alpha1_FacetResult(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanel": schema_pkg_apis_dashboard_v0alpha1_LibraryPanel(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelSpec(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SearchResults": schema_pkg_apis_dashboard_v0alpha1_SearchResults(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortBy": schema_pkg_apis_dashboard_v0alpha1_SortBy(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortableField": schema_pkg_apis_dashboard_v0alpha1_SortableField(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortableFields": schema_pkg_apis_dashboard_v0alpha1_SortableFields(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.TermFacet": schema_pkg_apis_dashboard_v0alpha1_TermFacet(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v0alpha1_VersionsQueryOptions(ref), + "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured": commonv0alpha1.Unstructured{}.OpenAPIDefinition(), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.AnnotationActions": schema_pkg_apis_dashboard_v0alpha1_AnnotationActions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v0alpha1_AnnotationPermission(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.Dashboard": schema_pkg_apis_dashboard_v0alpha1_Dashboard(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardAccess": schema_pkg_apis_dashboard_v0alpha1_DashboardAccess(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardConversionStatus": schema_pkg_apis_dashboard_v0alpha1_DashboardConversionStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardHit": schema_pkg_apis_dashboard_v0alpha1_DashboardHit(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardJSONCodec": schema_pkg_apis_dashboard_v0alpha1_DashboardJSONCodec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardList": schema_pkg_apis_dashboard_v0alpha1_DashboardList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardMetadata": schema_pkg_apis_dashboard_v0alpha1_DashboardMetadata(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus": schema_pkg_apis_dashboard_v0alpha1_DashboardStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v0alpha1_DashboardVersionInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v0alpha1_DashboardVersionList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v0alpha1_DashboardWithAccessInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.FacetResult": schema_pkg_apis_dashboard_v0alpha1_FacetResult(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanel": schema_pkg_apis_dashboard_v0alpha1_LibraryPanel(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v0alpha1_LibraryPanelStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SearchResults": schema_pkg_apis_dashboard_v0alpha1_SearchResults(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortBy": schema_pkg_apis_dashboard_v0alpha1_SortBy(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortableField": schema_pkg_apis_dashboard_v0alpha1_SortableField(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.SortableFields": schema_pkg_apis_dashboard_v0alpha1_SortableFields(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.TermFacet": schema_pkg_apis_dashboard_v0alpha1_TermFacet(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v0alpha1_VersionsQueryOptions(ref), } } @@ -100,36 +104,6 @@ func schema_pkg_apis_dashboard_v0alpha1_AnnotationPermission(ref common.Referenc } } -func schema_pkg_apis_dashboard_v0alpha1_ConversionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "failed": { - SchemaProps: spec.SchemaProps{ - Type: []string{"boolean"}, - Format: "", - }, - }, - "storedVersion": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "error": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - } -} - func schema_pkg_apis_dashboard_v0alpha1_Dashboard(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -152,25 +126,24 @@ func schema_pkg_apis_dashboard_v0alpha1_Dashboard(ref common.ReferenceCallback) }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", + Description: "Spec is the spec of the Dashboard", Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus"), }, }, }, - Required: []string{"spec"}, + Required: []string{"metadata", "spec", "status"}, }, }, Dependencies: []string{ @@ -182,8 +155,7 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardAccess(ref common.ReferenceCall return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "Information about how the requesting user can use a given dashboard", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ "slug": { SchemaProps: spec.SchemaProps{ @@ -248,6 +220,44 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardAccess(ref common.ReferenceCall } } +func schema_pkg_apis_dashboard_v0alpha1_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_v0alpha1_DashboardHit(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -328,6 +338,17 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardHit(ref common.ReferenceCallbac } } +func schema_pkg_apis_dashboard_v0alpha1_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_v0alpha1_DashboardList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -368,6 +389,7 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardList(ref common.ReferenceCallba }, }, }, + Required: []string{"metadata", "items"}, }, }, Dependencies: []string{ @@ -375,6 +397,102 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardList(ref common.ReferenceCallba } } +func schema_pkg_apis_dashboard_v0alpha1_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_v0alpha1_DashboardStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -383,14 +501,15 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardStatus(ref common.ReferenceCall Properties: map[string]spec.Schema{ "conversion": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.ConversionStatus"), + Description: "Optional conversion status.", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardConversionStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.ConversionStatus"}, + "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardConversionStatus"}, } } @@ -514,21 +633,20 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardWithAccessInfo(ref common.Refer }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", + Description: "Spec is the spec of the Dashboard", Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1.DashboardStatus"), }, }, "access": { @@ -538,7 +656,7 @@ func schema_pkg_apis_dashboard_v0alpha1_DashboardWithAccessInfo(ref common.Refer }, }, }, - Required: []string{"spec", "access"}, + Required: []string{"metadata", "spec", "status", "access"}, }, }, Dependencies: []string{ diff --git a/pkg/apis/dashboard/v0alpha1/zz_generated.openapi_violation_exceptions.list b/pkg/apis/dashboard/v0alpha1/zz_generated.openapi_violation_exceptions.list index afee90908cc..7061b042725 100644 --- a/pkg/apis/dashboard/v0alpha1/zz_generated.openapi_violation_exceptions.list +++ b/pkg/apis/dashboard/v0alpha1/zz_generated.openapi_violation_exceptions.list @@ -1,8 +1,9 @@ API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,DashboardHit,Tags +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,DashboardMetadata,Finalizers API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,FacetResult,Terms API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,LibraryPanelStatus,Warnings API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,SearchResults,Hits API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,SortableFields,Fields -API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,DashboardStatus,ConversionStatus +API rule violation: names_match,github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1,Unstructured,Object API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,SortBy,Descending API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1,SortableField,Field diff --git a/pkg/apis/dashboard/v1alpha1/constants.go b/pkg/apis/dashboard/v1alpha1/constants.go new file mode 100644 index 00000000000..b3732986f0b --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/constants.go @@ -0,0 +1,18 @@ +package v1alpha1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +const ( + // Group is the API group used by all kinds in this package + Group = "dashboard.grafana.app" + // Version is the API version used by all kinds in this package + Version = "v1alpha1" +) + +var ( + // GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package + GroupVersion = schema.GroupVersion{ + Group: Group, + Version: Version, + } +) diff --git a/pkg/apis/dashboard/v1alpha1/dashboard_codec_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_codec_gen.go new file mode 100644 index 00000000000..24ee7ecd7bd --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_codec_gen.go @@ -0,0 +1,28 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v1alpha1 + +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/pkg/apis/dashboard/v1alpha1/dashboard_metadata_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_metadata_gen.go new file mode 100644 index 00000000000..16ead71d265 --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_metadata_gen.go @@ -0,0 +1,28 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v1alpha1 + +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{} +} diff --git a/pkg/apis/dashboard/v1alpha1/dashboard_object_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_object_gen.go new file mode 100644 index 00000000000..cdf11cabbd0 --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_object_gen.go @@ -0,0 +1,269 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v1alpha1 + +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() +} + +// 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) + } +} + +// Interface compliance compile-time check +var _ resource.ListObject = &DashboardList{} diff --git a/pkg/apis/dashboard/v1alpha1/dashboard_schema_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_schema_gen.go new file mode 100644 index 00000000000..1c09a83e2bd --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_schema_gen.go @@ -0,0 +1,34 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v1alpha1 + +import ( + "github.com/grafana/grafana-app-sdk/resource" +) + +// schema is unexported to prevent accidental overwrites +var ( + schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v1alpha1", &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/pkg/apis/dashboard/v1alpha1/dashboard_spec.go b/pkg/apis/dashboard/v1alpha1/dashboard_spec.go new file mode 100644 index 00000000000..0b341e6e55e --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_spec.go @@ -0,0 +1,11 @@ +package v1alpha1 + +import common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" + +// +k8s:openapi-gen=true +type DashboardSpec = common.Unstructured + +// NewDashboardSpec creates a new Spec object. +func NewDashboardSpec() *DashboardSpec { + return &DashboardSpec{} +} diff --git a/pkg/apis/dashboard/v1alpha1/dashboard_spec_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_spec_gen.go new file mode 100644 index 00000000000..4f48fee9aae --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_spec_gen.go @@ -0,0 +1,3 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v1alpha1 diff --git a/pkg/apis/dashboard/v1alpha1/dashboard_status_gen.go b/pkg/apis/dashboard/v1alpha1/dashboard_status_gen.go new file mode 100644 index 00000000000..556d5ddba53 --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/dashboard_status_gen.go @@ -0,0 +1,34 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v1alpha1 + +// 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/pkg/apis/dashboard/v1alpha1/deepcopy.go b/pkg/apis/dashboard/v1alpha1/deepcopy.go new file mode 100644 index 00000000000..1e05aa647f2 --- /dev/null +++ b/pkg/apis/dashboard/v1alpha1/deepcopy.go @@ -0,0 +1,41 @@ +package v1alpha1 + +// TODO: these should be automatically generated by the SDK. + +func (in *Dashboard) DeepCopyInto(out *Dashboard) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +func (in *Dashboard) DeepCopy() *Dashboard { + if in == nil { + return nil + } + out := new(Dashboard) + in.DeepCopyInto(out) + return out +} + +func (in *DashboardList) DeepCopyInto(out *DashboardList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Dashboard, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +func (in *DashboardList) DeepCopy() *DashboardList { + if in == nil { + return nil + } + out := new(DashboardList) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/dashboard/v1alpha1/doc.go b/pkg/apis/dashboard/v1alpha1/doc.go index 288a406db14..f10d157ec41 100644 --- a/pkg/apis/dashboard/v1alpha1/doc.go +++ b/pkg/apis/dashboard/v1alpha1/doc.go @@ -1,7 +1,10 @@ -// +k8s:deepcopy-gen=package // +k8s:openapi-gen=true // +k8s:defaulter-gen=TypeMeta // +k8s:conversion-gen=github.com/grafana/grafana/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 v1alpha1 // import "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1" diff --git a/pkg/apis/dashboard/v1alpha1/types.go b/pkg/apis/dashboard/v1alpha1/types.go index 0a5144508a1..43844655505 100644 --- a/pkg/apis/dashboard/v1alpha1/types.go +++ b/pkg/apis/dashboard/v1alpha1/types.go @@ -7,40 +7,7 @@ import ( common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" ) -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type Dashboard 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"` - - // The dashboard body (unstructured for now) - Spec common.Unstructured `json:"spec"` - - // Optional dashboard status - Status *DashboardStatus `json:"status,omitempty"` -} - -type DashboardStatus struct { - ConversionStatus *ConversionStatus `json:"conversion,omitempty"` -} - -type ConversionStatus struct { - Failed bool `json:"failed,omitempty"` - StoredVersion string `json:"storedVersion,omitempty"` - Error string `json:"error,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type DashboardList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - Items []Dashboard `json:"items,omitempty"` -} - +// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type DashboardVersionList struct { metav1.TypeMeta `json:",inline"` @@ -50,6 +17,7 @@ type DashboardVersionList struct { Items []DashboardVersionInfo `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type DashboardVersionInfo struct { // The internal ID for this version (will be replaced with resourceVersion) Version int `json:"version"` @@ -67,6 +35,7 @@ type DashboardVersionInfo struct { 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 { @@ -80,6 +49,7 @@ type VersionsQueryOptions struct { 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"` @@ -95,6 +65,7 @@ type LibraryPanel struct { 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"` @@ -104,6 +75,7 @@ type LibraryPanelList struct { Items []LibraryPanel `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type LibraryPanelSpec struct { // The panel type Type string `json:"type"` @@ -131,6 +103,7 @@ type LibraryPanelSpec struct { 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"` @@ -140,6 +113,7 @@ type LibraryPanelStatus struct { } // 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"` @@ -148,6 +122,7 @@ type DashboardWithAccessInfo struct { } // 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"` @@ -162,11 +137,13 @@ type DashboardAccess struct { 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"` diff --git a/pkg/apis/dashboard/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/dashboard/v1alpha1/zz_generated.deepcopy.go index c94be011e07..8e38161cc58 100644 --- a/pkg/apis/dashboard/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/dashboard/v1alpha1/zz_generated.deepcopy.go @@ -46,54 +46,6 @@ func (in *AnnotationPermission) DeepCopy() *AnnotationPermission { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConversionStatus) DeepCopyInto(out *ConversionStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConversionStatus. -func (in *ConversionStatus) DeepCopy() *ConversionStatus { - if in == nil { - return nil - } - out := new(ConversionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Dashboard) DeepCopyInto(out *Dashboard) { - *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(DashboardStatus) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dashboard. -func (in *Dashboard) DeepCopy() *Dashboard { - if in == nil { - return nil - } - out := new(Dashboard) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Dashboard) 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 *DashboardAccess) DeepCopyInto(out *DashboardAccess) { *out = *in @@ -115,60 +67,6 @@ func (in *DashboardAccess) DeepCopy() *DashboardAccess { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DashboardList) DeepCopyInto(out *DashboardList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Dashboard, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardList. -func (in *DashboardList) DeepCopy() *DashboardList { - if in == nil { - return nil - } - out := new(DashboardList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DashboardList) 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 *DashboardStatus) DeepCopyInto(out *DashboardStatus) { - *out = *in - if in.ConversionStatus != nil { - in, out := &in.ConversionStatus, &out.ConversionStatus - *out = new(ConversionStatus) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardStatus. -func (in *DashboardStatus) DeepCopy() *DashboardStatus { - if in == nil { - return nil - } - out := new(DashboardStatus) - 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 diff --git a/pkg/apis/dashboard/v1alpha1/zz_generated.openapi.go b/pkg/apis/dashboard/v1alpha1/zz_generated.openapi.go index e6f99cd895c..f9de16ee169 100644 --- a/pkg/apis/dashboard/v1alpha1/zz_generated.openapi.go +++ b/pkg/apis/dashboard/v1alpha1/zz_generated.openapi.go @@ -8,27 +8,31 @@ package v1alpha1 import ( + v0alpha1 "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" 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/pkg/apis/dashboard/v1alpha1.AnnotationActions": schema_pkg_apis_dashboard_v1alpha1_AnnotationActions(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v1alpha1_AnnotationPermission(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.ConversionStatus": schema_pkg_apis_dashboard_v1alpha1_ConversionStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.Dashboard": schema_pkg_apis_dashboard_v1alpha1_Dashboard(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardAccess": schema_pkg_apis_dashboard_v1alpha1_DashboardAccess(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardList": schema_pkg_apis_dashboard_v1alpha1_DashboardList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus": schema_pkg_apis_dashboard_v1alpha1_DashboardStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v1alpha1_DashboardVersionInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v1alpha1_DashboardVersionList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v1alpha1_DashboardWithAccessInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanel": schema_pkg_apis_dashboard_v1alpha1_LibraryPanel(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelSpec(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v1alpha1_VersionsQueryOptions(ref), + "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured": v0alpha1.Unstructured{}.OpenAPIDefinition(), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.AnnotationActions": schema_pkg_apis_dashboard_v1alpha1_AnnotationActions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v1alpha1_AnnotationPermission(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.Dashboard": schema_pkg_apis_dashboard_v1alpha1_Dashboard(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardAccess": schema_pkg_apis_dashboard_v1alpha1_DashboardAccess(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardConversionStatus": schema_pkg_apis_dashboard_v1alpha1_DashboardConversionStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardJSONCodec": schema_pkg_apis_dashboard_v1alpha1_DashboardJSONCodec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardList": schema_pkg_apis_dashboard_v1alpha1_DashboardList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardMetadata": schema_pkg_apis_dashboard_v1alpha1_DashboardMetadata(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus": schema_pkg_apis_dashboard_v1alpha1_DashboardStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v1alpha1_DashboardVersionInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v1alpha1_DashboardVersionList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v1alpha1_DashboardWithAccessInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanel": schema_pkg_apis_dashboard_v1alpha1_LibraryPanel(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v1alpha1_LibraryPanelStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v1alpha1_VersionsQueryOptions(ref), } } @@ -93,36 +97,6 @@ func schema_pkg_apis_dashboard_v1alpha1_AnnotationPermission(ref common.Referenc } } -func schema_pkg_apis_dashboard_v1alpha1_ConversionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "failed": { - SchemaProps: spec.SchemaProps{ - Type: []string{"boolean"}, - Format: "", - }, - }, - "storedVersion": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "error": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - } -} - func schema_pkg_apis_dashboard_v1alpha1_Dashboard(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -145,25 +119,24 @@ func schema_pkg_apis_dashboard_v1alpha1_Dashboard(ref common.ReferenceCallback) }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", + Description: "Spec is the spec of the Dashboard", Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus"), }, }, }, - Required: []string{"spec"}, + Required: []string{"metadata", "spec", "status"}, }, }, Dependencies: []string{ @@ -241,6 +214,55 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardAccess(ref common.ReferenceCall } } +func schema_pkg_apis_dashboard_v1alpha1_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_v1alpha1_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_v1alpha1_DashboardList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -281,6 +303,7 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardList(ref common.ReferenceCallba }, }, }, + Required: []string{"metadata", "items"}, }, }, Dependencies: []string{ @@ -288,6 +311,102 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardList(ref common.ReferenceCallba } } +func schema_pkg_apis_dashboard_v1alpha1_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_v1alpha1_DashboardStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -296,14 +415,15 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardStatus(ref common.ReferenceCall Properties: map[string]spec.Schema{ "conversion": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.ConversionStatus"), + Description: "Optional conversion status.", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardConversionStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.ConversionStatus"}, + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardConversionStatus"}, } } @@ -427,21 +547,20 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardWithAccessInfo(ref common.Refer }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", + Description: "Spec is the spec of the Dashboard", Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1.DashboardStatus"), }, }, "access": { @@ -451,7 +570,7 @@ func schema_pkg_apis_dashboard_v1alpha1_DashboardWithAccessInfo(ref common.Refer }, }, }, - Required: []string{"spec", "access"}, + Required: []string{"metadata", "spec", "status", "access"}, }, }, Dependencies: []string{ diff --git a/pkg/apis/dashboard/v1alpha1/zz_generated.openapi_violation_exceptions.list b/pkg/apis/dashboard/v1alpha1/zz_generated.openapi_violation_exceptions.list index bbfa46dae2b..a34c29a7192 100644 --- a/pkg/apis/dashboard/v1alpha1/zz_generated.openapi_violation_exceptions.list +++ b/pkg/apis/dashboard/v1alpha1/zz_generated.openapi_violation_exceptions.list @@ -1,2 +1,3 @@ +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1,DashboardMetadata,Finalizers API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1,LibraryPanelStatus,Warnings -API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1,DashboardStatus,ConversionStatus +API rule violation: names_match,github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1,Unstructured,Object diff --git a/pkg/apis/dashboard/v2alpha1/constants.go b/pkg/apis/dashboard/v2alpha1/constants.go new file mode 100644 index 00000000000..84b030c8994 --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/constants.go @@ -0,0 +1,18 @@ +package v2alpha1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +const ( + // Group is the API group used by all kinds in this package + Group = "dashboard.grafana.app" + // Version is the API version used by all kinds in this package + Version = "v2alpha1" +) + +var ( + // GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package + GroupVersion = schema.GroupVersion{ + Group: Group, + Version: Version, + } +) diff --git a/pkg/apis/dashboard/v2alpha1/dashboard_codec_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_codec_gen.go new file mode 100644 index 00000000000..a1892865692 --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_codec_gen.go @@ -0,0 +1,28 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha1 + +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/pkg/apis/dashboard/v2alpha1/dashboard_metadata_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_metadata_gen.go new file mode 100644 index 00000000000..f4e92178780 --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_metadata_gen.go @@ -0,0 +1,28 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha1 + +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{} +} diff --git a/pkg/apis/dashboard/v2alpha1/dashboard_object_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_object_gen.go new file mode 100644 index 00000000000..504dc5a25f1 --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_object_gen.go @@ -0,0 +1,269 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha1 + +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() +} + +// 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) + } +} + +// Interface compliance compile-time check +var _ resource.ListObject = &DashboardList{} diff --git a/pkg/apis/dashboard/v2alpha1/dashboard_schema_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_schema_gen.go new file mode 100644 index 00000000000..136698cf70f --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_schema_gen.go @@ -0,0 +1,34 @@ +// +// Code generated by grafana-app-sdk. DO NOT EDIT. +// + +package v2alpha1 + +import ( + "github.com/grafana/grafana-app-sdk/resource" +) + +// schema is unexported to prevent accidental overwrites +var ( + schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v2alpha1", &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/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go new file mode 100644 index 00000000000..ade7b3398b0 --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_spec_gen.go @@ -0,0 +1,2373 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha1 + +import ( + json "encoding/json" + errors "errors" + fmt "fmt" +) + +// +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"` +} + +// 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{} +} + +// +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 []uint8 `json:"ids"` +} + +// NewDashboardAnnotationPanelFilter creates a new DashboardAnnotationPanelFilter object. +func NewDashboardAnnotationPanelFilter() *DashboardAnnotationPanelFilter { + return &DashboardAnnotationPanelFilter{ + Exclude: (func(input bool) *bool { return &input })(false), + } +} + +// "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 ( + DashboardDashboardCursorSyncOff DashboardDashboardCursorSync = "Off" + DashboardDashboardCursorSyncCrosshair DashboardDashboardCursorSync = "Crosshair" + DashboardDashboardCursorSyncTooltip DashboardDashboardCursorSync = "Tooltip" +) + +// 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{ + 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{ + 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{ + 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 []DashboardV2alpha1FieldConfigSourceOverrides `json:"overrides"` +} + +// NewDashboardFieldConfigSource creates a new DashboardFieldConfigSource object. +func NewDashboardFieldConfigSource() *DashboardFieldConfigSource { + return &DashboardFieldConfigSource{ + Defaults: *NewDashboardFieldConfig(), + } +} + +// 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "value" + Type string `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: "value", + } +} + +// 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "range" + Type string `json:"type"` + // Range to match against and the result to apply when the value is within the range + Options DashboardV2alpha1RangeMapOptions `json:"options"` +} + +// NewDashboardRangeMap creates a new DashboardRangeMap object. +func NewDashboardRangeMap() *DashboardRangeMap { + return &DashboardRangeMap{ + Type: "range", + Options: *NewDashboardV2alpha1RangeMapOptions(), + } +} + +// 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "regex" + Type string `json:"type"` + // Regular expression to match against and the result to apply when the value matches the regex + Options DashboardV2alpha1RegexMapOptions `json:"options"` +} + +// NewDashboardRegexMap creates a new DashboardRegexMap object. +func NewDashboardRegexMap() *DashboardRegexMap { + return &DashboardRegexMap{ + Type: "regex", + Options: *NewDashboardV2alpha1RegexMapOptions(), + } +} + +// 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 { + // TODO (@radiohead): Something broke in cog / app SDK codegen + // And this is no longer producing valid TS / Go output + // type: MappingType & "special" + Type string `json:"type"` + Options DashboardV2alpha1SpecialValueMapOptions `json:"options"` +} + +// NewDashboardSpecialValueMap creates a new DashboardSpecialValueMap object. +func NewDashboardSpecialValueMap() *DashboardSpecialValueMap { + return &DashboardSpecialValueMap{ + Type: "special", + Options: *NewDashboardV2alpha1SpecialValueMapOptions(), + } +} + +// 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{} +} + +// +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 []DashboardGridLayoutItemKindOrGridLayoutRowKind `json:"items"` +} + +// NewDashboardGridLayoutSpec creates a new DashboardGridLayoutSpec object. +func NewDashboardGridLayoutSpec() *DashboardGridLayoutSpec { + return &DashboardGridLayoutSpec{} +} + +// +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{} +} + +// other repeat modes will be added in the future: label, frame +// +k8s:openapi-gen=true +const DashboardRepeatMode = "variable" + +// +k8s:openapi-gen=true +type DashboardGridLayoutRowKind struct { + Kind string `json:"kind"` + Spec DashboardGridLayoutRowSpec `json:"spec"` +} + +// NewDashboardGridLayoutRowKind creates a new DashboardGridLayoutRowKind object. +func NewDashboardGridLayoutRowKind() *DashboardGridLayoutRowKind { + return &DashboardGridLayoutRowKind{ + Kind: "GridLayoutRow", + Spec: *NewDashboardGridLayoutRowSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutRowSpec struct { + Y int64 `json:"y"` + Collapsed bool `json:"collapsed"` + Title string `json:"title"` + // Grid items in the row will have their Y value be relative to the rows Y value. This means a panel positioned at Y: 0 in a row with Y: 10 will be positioned at Y: 11 (row header has a heigh of 1) in the dashboard. + Elements []DashboardGridLayoutItemKind `json:"elements"` + Repeat *DashboardRowRepeatOptions `json:"repeat,omitempty"` +} + +// NewDashboardGridLayoutRowSpec creates a new DashboardGridLayoutRowSpec object. +func NewDashboardGridLayoutRowSpec() *DashboardGridLayoutRowSpec { + return &DashboardGridLayoutRowSpec{} +} + +// +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{} +} + +// +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{} +} + +// +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"` + Collapsed bool `json:"collapsed"` + Repeat *DashboardRowRepeatOptions `json:"repeat,omitempty"` + Layout DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind `json:"layout"` +} + +// NewDashboardRowsLayoutRowSpec creates a new DashboardRowsLayoutRowSpec object. +func NewDashboardRowsLayoutRowSpec() *DashboardRowsLayoutRowSpec { + return &DashboardRowsLayoutRowSpec{ + Layout: *NewDashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(), + } +} + +// +k8s:openapi-gen=true +type DashboardResponsiveGridLayoutKind struct { + Kind string `json:"kind"` + Spec DashboardResponsiveGridLayoutSpec `json:"spec"` +} + +// NewDashboardResponsiveGridLayoutKind creates a new DashboardResponsiveGridLayoutKind object. +func NewDashboardResponsiveGridLayoutKind() *DashboardResponsiveGridLayoutKind { + return &DashboardResponsiveGridLayoutKind{ + Kind: "ResponsiveGridLayout", + Spec: *NewDashboardResponsiveGridLayoutSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardResponsiveGridLayoutSpec struct { + Row string `json:"row"` + Col string `json:"col"` + Items []DashboardResponsiveGridLayoutItemKind `json:"items"` +} + +// NewDashboardResponsiveGridLayoutSpec creates a new DashboardResponsiveGridLayoutSpec object. +func NewDashboardResponsiveGridLayoutSpec() *DashboardResponsiveGridLayoutSpec { + return &DashboardResponsiveGridLayoutSpec{} +} + +// +k8s:openapi-gen=true +type DashboardResponsiveGridLayoutItemKind struct { + Kind string `json:"kind"` + Spec DashboardResponsiveGridLayoutItemSpec `json:"spec"` +} + +// NewDashboardResponsiveGridLayoutItemKind creates a new DashboardResponsiveGridLayoutItemKind object. +func NewDashboardResponsiveGridLayoutItemKind() *DashboardResponsiveGridLayoutItemKind { + return &DashboardResponsiveGridLayoutItemKind{ + Kind: "ResponsiveGridLayoutItem", + Spec: *NewDashboardResponsiveGridLayoutItemSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardResponsiveGridLayoutItemSpec struct { + Element DashboardElementReference `json:"element"` + Repeat *DashboardResponsiveGridRepeatOptions `json:"repeat,omitempty"` +} + +// NewDashboardResponsiveGridLayoutItemSpec creates a new DashboardResponsiveGridLayoutItemSpec object. +func NewDashboardResponsiveGridLayoutItemSpec() *DashboardResponsiveGridLayoutItemSpec { + return &DashboardResponsiveGridLayoutItemSpec{ + Element: *NewDashboardElementReference(), + } +} + +// +k8s:openapi-gen=true +type DashboardResponsiveGridRepeatOptions struct { + Mode string `json:"mode"` + Value string `json:"value"` +} + +// NewDashboardResponsiveGridRepeatOptions creates a new DashboardResponsiveGridRepeatOptions object. +func NewDashboardResponsiveGridRepeatOptions() *DashboardResponsiveGridRepeatOptions { + return &DashboardResponsiveGridRepeatOptions{} +} + +// +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{} +} + +// +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 DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind `json:"layout"` +} + +// NewDashboardTabsLayoutTabSpec creates a new DashboardTabsLayoutTabSpec object. +func NewDashboardTabsLayoutTabSpec() *DashboardTabsLayoutTabSpec { + return &DashboardTabsLayoutTabSpec{ + Layout: *NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind(), + } +} + +// 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{ + 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", + AutoRefreshIntervals: []string{"5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"}, + } +} + +// +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"` +} + +// 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: "", + Multi: false, + IncludeAll: false, + } +} + +// 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"` +} + +// 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 })(""), + }, + }, + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// 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 })(""), + }, + }, + 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"` +} + +// NewDashboardCustomVariableSpec creates a new DashboardCustomVariableSpec object. +func NewDashboardCustomVariableSpec() *DashboardCustomVariableSpec { + return &DashboardCustomVariableSpec{ + Name: "", + Query: "", + Current: *NewDashboardVariableOption(), + Multi: false, + IncludeAll: false, + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// 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"` + 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 })(""), + }, + }, + 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"` +} + +// NewDashboardAdhocVariableSpec creates a new DashboardAdhocVariableSpec object. +func NewDashboardAdhocVariableSpec() *DashboardAdhocVariableSpec { + return &DashboardAdhocVariableSpec{ + Name: "", + Hide: DashboardVariableHideDontHide, + SkipUrlSync: false, + } +} + +// 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"` + // @deprecated + Condition *string `json:"condition,omitempty"` +} + +// NewDashboardAdHocFilterWithLabels creates a new DashboardAdHocFilterWithLabels object. +func NewDashboardAdHocFilterWithLabels() *DashboardAdHocFilterWithLabels { + return &DashboardAdHocFilterWithLabels{} +} + +// 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 { + // Title of dashboard. + 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 DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind `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{ + Editable: (func(input bool) *bool { return &input })(true), + Layout: *NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(), + TimeSettings: *NewDashboardTimeSettingsSpec(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha1FieldConfigSourceOverrides struct { + Matcher DashboardMatcherConfig `json:"matcher"` + Properties []DashboardDynamicConfigValue `json:"properties"` +} + +// NewDashboardV2alpha1FieldConfigSourceOverrides creates a new DashboardV2alpha1FieldConfigSourceOverrides object. +func NewDashboardV2alpha1FieldConfigSourceOverrides() *DashboardV2alpha1FieldConfigSourceOverrides { + return &DashboardV2alpha1FieldConfigSourceOverrides{ + Matcher: *NewDashboardMatcherConfig(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha1RangeMapOptions 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"` +} + +// NewDashboardV2alpha1RangeMapOptions creates a new DashboardV2alpha1RangeMapOptions object. +func NewDashboardV2alpha1RangeMapOptions() *DashboardV2alpha1RangeMapOptions { + return &DashboardV2alpha1RangeMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha1RegexMapOptions struct { + // Regular expression to match against + Pattern string `json:"pattern"` + // Config to apply when the value matches the regex + Result DashboardValueMappingResult `json:"result"` +} + +// NewDashboardV2alpha1RegexMapOptions creates a new DashboardV2alpha1RegexMapOptions object. +func NewDashboardV2alpha1RegexMapOptions() *DashboardV2alpha1RegexMapOptions { + return &DashboardV2alpha1RegexMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardV2alpha1SpecialValueMapOptions struct { + // Special value to match against + Match DashboardSpecialValueMatch `json:"match"` + // Config to apply when the value matches the special value + Result DashboardValueMappingResult `json:"result"` +} + +// NewDashboardV2alpha1SpecialValueMapOptions creates a new DashboardV2alpha1SpecialValueMapOptions object. +func NewDashboardV2alpha1SpecialValueMapOptions() *DashboardV2alpha1SpecialValueMapOptions { + return &DashboardV2alpha1SpecialValueMapOptions{ + Result: *NewDashboardValueMappingResult(), + } +} + +// +k8s:openapi-gen=true +type DashboardRepeatOptionsDirection string + +const ( + DashboardRepeatOptionsDirectionH DashboardRepeatOptionsDirection = "h" + DashboardRepeatOptionsDirectionV DashboardRepeatOptionsDirection = "v" +) + +// +k8s:openapi-gen=true +type DashboardTimeSettingsSpecWeekStart string + +const ( + DashboardTimeSettingsSpecWeekStartSaturday DashboardTimeSettingsSpecWeekStart = "saturday" + DashboardTimeSettingsSpecWeekStartMonday DashboardTimeSettingsSpecWeekStart = "monday" + DashboardTimeSettingsSpecWeekStartSunday DashboardTimeSettingsSpecWeekStart = "sunday" +) + +// +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 nil, fmt.Errorf("no value for disjunction of refs") +} + +// 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 errors.New("discriminator field 'kind' not found in payload") + } + + 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 fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} + +// +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 nil, fmt.Errorf("no value for disjunction of refs") +} + +// 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 errors.New("discriminator field 'type' not found in payload") + } + + 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 fmt.Errorf("could not unmarshal resource with `type = %v`", discriminator) +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutItemKindOrGridLayoutRowKind struct { + GridLayoutItemKind *DashboardGridLayoutItemKind `json:"GridLayoutItemKind,omitempty"` + GridLayoutRowKind *DashboardGridLayoutRowKind `json:"GridLayoutRowKind,omitempty"` +} + +// NewDashboardGridLayoutItemKindOrGridLayoutRowKind creates a new DashboardGridLayoutItemKindOrGridLayoutRowKind object. +func NewDashboardGridLayoutItemKindOrGridLayoutRowKind() *DashboardGridLayoutItemKindOrGridLayoutRowKind { + return &DashboardGridLayoutItemKindOrGridLayoutRowKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutItemKindOrGridLayoutRowKind` as JSON. +func (resource DashboardGridLayoutItemKindOrGridLayoutRowKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutItemKind != nil { + return json.Marshal(resource.GridLayoutItemKind) + } + if resource.GridLayoutRowKind != nil { + return json.Marshal(resource.GridLayoutRowKind) + } + + return nil, fmt.Errorf("no value for disjunction of refs") +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutItemKindOrGridLayoutRowKind` from JSON. +func (resource *DashboardGridLayoutItemKindOrGridLayoutRowKind) 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 errors.New("discriminator field 'kind' not found in payload") + } + + switch discriminator { + case "GridLayoutItem": + var dashboardGridLayoutItemKind DashboardGridLayoutItemKind + if err := json.Unmarshal(raw, &dashboardGridLayoutItemKind); err != nil { + return err + } + + resource.GridLayoutItemKind = &dashboardGridLayoutItemKind + return nil + case "GridLayoutRow": + var dashboardGridLayoutRowKind DashboardGridLayoutRowKind + if err := json.Unmarshal(raw, &dashboardGridLayoutRowKind); err != nil { + return err + } + + resource.GridLayoutRowKind = &dashboardGridLayoutRowKind + return nil + } + + return fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind struct { + GridLayoutKind *DashboardGridLayoutKind `json:"GridLayoutKind,omitempty"` + ResponsiveGridLayoutKind *DashboardResponsiveGridLayoutKind `json:"ResponsiveGridLayoutKind,omitempty"` + TabsLayoutKind *DashboardTabsLayoutKind `json:"TabsLayoutKind,omitempty"` +} + +// NewDashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind creates a new DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind object. +func NewDashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind() *DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind { + return &DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind` as JSON. +func (resource DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutKind != nil { + return json.Marshal(resource.GridLayoutKind) + } + if resource.ResponsiveGridLayoutKind != nil { + return json.Marshal(resource.ResponsiveGridLayoutKind) + } + if resource.TabsLayoutKind != nil { + return json.Marshal(resource.TabsLayoutKind) + } + + return nil, fmt.Errorf("no value for disjunction of refs") +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind` from JSON. +func (resource *DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind) 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 errors.New("discriminator field 'kind' not found in payload") + } + + switch discriminator { + case "GridLayout": + var dashboardGridLayoutKind DashboardGridLayoutKind + if err := json.Unmarshal(raw, &dashboardGridLayoutKind); err != nil { + return err + } + + resource.GridLayoutKind = &dashboardGridLayoutKind + return nil + case "ResponsiveGridLayout": + var dashboardResponsiveGridLayoutKind DashboardResponsiveGridLayoutKind + if err := json.Unmarshal(raw, &dashboardResponsiveGridLayoutKind); err != nil { + return err + } + + resource.ResponsiveGridLayoutKind = &dashboardResponsiveGridLayoutKind + return nil + case "TabsLayout": + var dashboardTabsLayoutKind DashboardTabsLayoutKind + if err := json.Unmarshal(raw, &dashboardTabsLayoutKind); err != nil { + return err + } + + resource.TabsLayoutKind = &dashboardTabsLayoutKind + return nil + } + + return fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind struct { + GridLayoutKind *DashboardGridLayoutKind `json:"GridLayoutKind,omitempty"` + RowsLayoutKind *DashboardRowsLayoutKind `json:"RowsLayoutKind,omitempty"` + ResponsiveGridLayoutKind *DashboardResponsiveGridLayoutKind `json:"ResponsiveGridLayoutKind,omitempty"` +} + +// NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind creates a new DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind object. +func NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind() *DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind { + return &DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind` as JSON. +func (resource DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutKind != nil { + return json.Marshal(resource.GridLayoutKind) + } + if resource.RowsLayoutKind != nil { + return json.Marshal(resource.RowsLayoutKind) + } + if resource.ResponsiveGridLayoutKind != nil { + return json.Marshal(resource.ResponsiveGridLayoutKind) + } + + return nil, fmt.Errorf("no value for disjunction of refs") +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind` from JSON. +func (resource *DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind) 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 errors.New("discriminator field 'kind' not found in payload") + } + + switch discriminator { + case "GridLayout": + var dashboardGridLayoutKind DashboardGridLayoutKind + if err := json.Unmarshal(raw, &dashboardGridLayoutKind); err != nil { + return err + } + + resource.GridLayoutKind = &dashboardGridLayoutKind + return nil + case "ResponsiveGridLayout": + var dashboardResponsiveGridLayoutKind DashboardResponsiveGridLayoutKind + if err := json.Unmarshal(raw, &dashboardResponsiveGridLayoutKind); err != nil { + return err + } + + resource.ResponsiveGridLayoutKind = &dashboardResponsiveGridLayoutKind + return nil + case "RowsLayout": + var dashboardRowsLayoutKind DashboardRowsLayoutKind + if err := json.Unmarshal(raw, &dashboardRowsLayoutKind); err != nil { + return err + } + + resource.RowsLayoutKind = &dashboardRowsLayoutKind + return nil + } + + return fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} + +// +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 nil, fmt.Errorf("no value for disjunction of refs") +} + +// 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 errors.New("discriminator field 'kind' not found in payload") + } + + 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 fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} + +// +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 nil, fmt.Errorf("no value for disjunction of scalars") +} + +// 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 nil, fmt.Errorf("no value for disjunction of scalars") +} + +// 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...) +} + +// +k8s:openapi-gen=true +type DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind struct { + GridLayoutKind *DashboardGridLayoutKind `json:"GridLayoutKind,omitempty"` + RowsLayoutKind *DashboardRowsLayoutKind `json:"RowsLayoutKind,omitempty"` + ResponsiveGridLayoutKind *DashboardResponsiveGridLayoutKind `json:"ResponsiveGridLayoutKind,omitempty"` + TabsLayoutKind *DashboardTabsLayoutKind `json:"TabsLayoutKind,omitempty"` +} + +// NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind creates a new DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind object. +func NewDashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind() *DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind { + return &DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind{} +} + +// MarshalJSON implements a custom JSON marshalling logic to encode `DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind` as JSON. +func (resource DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind) MarshalJSON() ([]byte, error) { + if resource.GridLayoutKind != nil { + return json.Marshal(resource.GridLayoutKind) + } + if resource.RowsLayoutKind != nil { + return json.Marshal(resource.RowsLayoutKind) + } + if resource.ResponsiveGridLayoutKind != nil { + return json.Marshal(resource.ResponsiveGridLayoutKind) + } + if resource.TabsLayoutKind != nil { + return json.Marshal(resource.TabsLayoutKind) + } + + return nil, fmt.Errorf("no value for disjunction of refs") +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind` from JSON. +func (resource *DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind) 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 errors.New("discriminator field 'kind' not found in payload") + } + + switch discriminator { + case "GridLayout": + var dashboardGridLayoutKind DashboardGridLayoutKind + if err := json.Unmarshal(raw, &dashboardGridLayoutKind); err != nil { + return err + } + + resource.GridLayoutKind = &dashboardGridLayoutKind + return nil + case "ResponsiveGridLayout": + var dashboardResponsiveGridLayoutKind DashboardResponsiveGridLayoutKind + if err := json.Unmarshal(raw, &dashboardResponsiveGridLayoutKind); err != nil { + return err + } + + resource.ResponsiveGridLayoutKind = &dashboardResponsiveGridLayoutKind + 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 fmt.Errorf("could not unmarshal resource with `kind = %v`", discriminator) +} diff --git a/pkg/apis/dashboard/v2alpha1/dashboard_status_gen.go b/pkg/apis/dashboard/v2alpha1/dashboard_status_gen.go new file mode 100644 index 00000000000..5bd84ac30cc --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/dashboard_status_gen.go @@ -0,0 +1,34 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package v2alpha1 + +// 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/pkg/apis/dashboard/v2alpha1/deepcopy.go b/pkg/apis/dashboard/v2alpha1/deepcopy.go new file mode 100644 index 00000000000..621d7232a8e --- /dev/null +++ b/pkg/apis/dashboard/v2alpha1/deepcopy.go @@ -0,0 +1,63 @@ +package v2alpha1 + +import "reflect" + +// TODO: these should be automatically generated by the SDK. + +func (in *Dashboard) DeepCopyInto(out *Dashboard) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +func (in *Dashboard) DeepCopy() *Dashboard { + if in == nil { + return nil + } + out := new(Dashboard) + in.DeepCopyInto(out) + return out +} + +func (in *DashboardList) DeepCopyInto(out *DashboardList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Dashboard, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +func (in *DashboardList) DeepCopy() *DashboardList { + if in == nil { + return nil + } + out := new(DashboardList) + in.DeepCopyInto(out) + return out +} + +// TODO: we currently don't generate these methods for spec / status types. +// We probably should do that in the SDK. + +func (in *DashboardSpec) DeepCopyInto(out *DashboardSpec) { + // TODO (@radiohead): since we don't generate this, + // I've added a manual reflection-based implementation for now. + val := reflect.ValueOf(in).Elem() + cpy := reflect.New(val.Type()) + cpy.Elem().Set(val) +} + +func (in *DashboardSpec) DeepCopy() *DashboardSpec { + if in == nil { + return nil + } + out := new(DashboardSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/dashboard/v2alpha1/doc.go b/pkg/apis/dashboard/v2alpha1/doc.go index eac83f16cf9..8866425fdce 100644 --- a/pkg/apis/dashboard/v2alpha1/doc.go +++ b/pkg/apis/dashboard/v2alpha1/doc.go @@ -1,7 +1,10 @@ -// +k8s:deepcopy-gen=package // +k8s:openapi-gen=true // +k8s:defaulter-gen=TypeMeta // +k8s:conversion-gen=github.com/grafana/grafana/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 v2alpha1 // import "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1" diff --git a/pkg/apis/dashboard/v2alpha1/register.go b/pkg/apis/dashboard/v2alpha1/register.go index 8ee9e149d7a..31aa15a72dd 100644 --- a/pkg/apis/dashboard/v2alpha1/register.go +++ b/pkg/apis/dashboard/v2alpha1/register.go @@ -32,7 +32,7 @@ var DashboardResourceInfo = utils.NewResourceInfo(GROUP, VERSION, if dash != nil { return []interface{}{ dash.Name, - dash.Spec.GetNestedString("title"), + dash.Spec.Title, dash.CreationTimestamp.UTC().Format(time.RFC3339), }, nil } @@ -54,14 +54,14 @@ var LibraryPanelResourceInfo = utils.NewResourceInfo(GROUP, VERSION, {Name: "Created At", Type: "date"}, }, Reader: func(obj any) ([]interface{}, error) { - dash, ok := obj.(*LibraryPanel) + panel, ok := obj.(*LibraryPanel) if ok { - if dash != nil { + if panel != nil { return []interface{}{ - dash.Name, - dash.Spec.Title, - dash.Spec.Type, - dash.CreationTimestamp.UTC().Format(time.RFC3339), + panel.Name, + panel.Spec.Title, + panel.Spec.Type, + panel.CreationTimestamp.UTC().Format(time.RFC3339), }, nil } } diff --git a/pkg/apis/dashboard/v2alpha1/types.go b/pkg/apis/dashboard/v2alpha1/types.go index dd25b2e683b..7cc9d29d149 100644 --- a/pkg/apis/dashboard/v2alpha1/types.go +++ b/pkg/apis/dashboard/v2alpha1/types.go @@ -7,40 +7,7 @@ import ( common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" ) -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type Dashboard 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"` - - // The dashboard body (unstructured for now) - Spec common.Unstructured `json:"spec"` - - // Optional dashboard status - Status *DashboardStatus `json:"status,omitempty"` -} - -type DashboardStatus struct { - ConversionStatus *ConversionStatus `json:"conversion,omitempty"` -} - -type ConversionStatus struct { - Failed bool `json:"failed,omitempty"` - StoredVersion string `json:"storedVersion,omitempty"` - Error string `json:"error,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type DashboardList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - Items []Dashboard `json:"items,omitempty"` -} - +// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type DashboardVersionList struct { metav1.TypeMeta `json:",inline"` @@ -50,6 +17,7 @@ type DashboardVersionList struct { Items []DashboardVersionInfo `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type DashboardVersionInfo struct { // The internal ID for this version (will be replaced with resourceVersion) Version int `json:"version"` @@ -67,6 +35,7 @@ type DashboardVersionInfo struct { 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 { @@ -80,6 +49,7 @@ type VersionsQueryOptions struct { 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"` @@ -95,6 +65,7 @@ type LibraryPanel struct { 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"` @@ -104,6 +75,7 @@ type LibraryPanelList struct { Items []LibraryPanel `json:"items,omitempty"` } +// +k8s:deepcopy-gen=true type LibraryPanelSpec struct { // The panel type Type string `json:"type"` @@ -131,6 +103,7 @@ type LibraryPanelSpec struct { 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"` @@ -140,6 +113,7 @@ type LibraryPanelStatus struct { } // 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"` @@ -148,6 +122,7 @@ type DashboardWithAccessInfo struct { } // 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"` @@ -162,11 +137,13 @@ type DashboardAccess struct { 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"` diff --git a/pkg/apis/dashboard/v2alpha1/zz_generated.deepcopy.go b/pkg/apis/dashboard/v2alpha1/zz_generated.deepcopy.go index 36e22f8aeda..6ce617a1d0b 100644 --- a/pkg/apis/dashboard/v2alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/dashboard/v2alpha1/zz_generated.deepcopy.go @@ -46,54 +46,6 @@ func (in *AnnotationPermission) DeepCopy() *AnnotationPermission { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConversionStatus) DeepCopyInto(out *ConversionStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConversionStatus. -func (in *ConversionStatus) DeepCopy() *ConversionStatus { - if in == nil { - return nil - } - out := new(ConversionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Dashboard) DeepCopyInto(out *Dashboard) { - *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(DashboardStatus) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dashboard. -func (in *Dashboard) DeepCopy() *Dashboard { - if in == nil { - return nil - } - out := new(Dashboard) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Dashboard) 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 *DashboardAccess) DeepCopyInto(out *DashboardAccess) { *out = *in @@ -115,60 +67,6 @@ func (in *DashboardAccess) DeepCopy() *DashboardAccess { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DashboardList) DeepCopyInto(out *DashboardList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Dashboard, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardList. -func (in *DashboardList) DeepCopy() *DashboardList { - if in == nil { - return nil - } - out := new(DashboardList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DashboardList) 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 *DashboardStatus) DeepCopyInto(out *DashboardStatus) { - *out = *in - if in.ConversionStatus != nil { - in, out := &in.ConversionStatus, &out.ConversionStatus - *out = new(ConversionStatus) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardStatus. -func (in *DashboardStatus) DeepCopy() *DashboardStatus { - if in == nil { - return nil - } - out := new(DashboardStatus) - 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 diff --git a/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go b/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go index bb6364a92ce..1025adcda86 100644 --- a/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go +++ b/pkg/apis/dashboard/v2alpha1/zz_generated.openapi.go @@ -14,21 +14,113 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.AnnotationActions": schema_pkg_apis_dashboard_v2alpha1_AnnotationActions(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v2alpha1_AnnotationPermission(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.ConversionStatus": schema_pkg_apis_dashboard_v2alpha1_ConversionStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.Dashboard": schema_pkg_apis_dashboard_v2alpha1_Dashboard(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAccess": schema_pkg_apis_dashboard_v2alpha1_DashboardAccess(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardList": schema_pkg_apis_dashboard_v2alpha1_DashboardList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus": schema_pkg_apis_dashboard_v2alpha1_DashboardStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v2alpha1_DashboardVersionInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v2alpha1_DashboardVersionList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v2alpha1_DashboardWithAccessInfo(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanel": schema_pkg_apis_dashboard_v2alpha1_LibraryPanel(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelList(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelSpec(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelStatus(ref), - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v2alpha1_VersionsQueryOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.AnnotationActions": schema_pkg_apis_dashboard_v2alpha1_AnnotationActions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.AnnotationPermission": schema_pkg_apis_dashboard_v2alpha1_AnnotationPermission(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.Dashboard": schema_pkg_apis_dashboard_v2alpha1_Dashboard(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAccess": schema_pkg_apis_dashboard_v2alpha1_DashboardAccess(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdHocFilterWithLabels": schema_pkg_apis_dashboard_v2alpha1_DashboardAdHocFilterWithLabels(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardAdhocVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardAdhocVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationPanelFilter": schema_pkg_apis_dashboard_v2alpha1_DashboardAnnotationPanelFilter(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationQueryKind": schema_pkg_apis_dashboard_v2alpha1_DashboardAnnotationQueryKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationQuerySpec": schema_pkg_apis_dashboard_v2alpha1_DashboardAnnotationQuerySpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardConstantVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardConstantVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConversionStatus": schema_pkg_apis_dashboard_v2alpha1_DashboardConversionStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardCustomVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardCustomVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDashboardLink": schema_pkg_apis_dashboard_v2alpha1_DashboardDashboardLink(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataLink": schema_pkg_apis_dashboard_v2alpha1_DashboardDataLink(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind": schema_pkg_apis_dashboard_v2alpha1_DashboardDataQueryKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef": schema_pkg_apis_dashboard_v2alpha1_DashboardDataSourceRef(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataTransformerConfig": schema_pkg_apis_dashboard_v2alpha1_DashboardDataTransformerConfig(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardDatasourceVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardDatasourceVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDynamicConfigValue": schema_pkg_apis_dashboard_v2alpha1_DashboardDynamicConfigValue(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardElementReference": schema_pkg_apis_dashboard_v2alpha1_DashboardElementReference(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardFieldColor": schema_pkg_apis_dashboard_v2alpha1_DashboardFieldColor(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardFieldConfig": schema_pkg_apis_dashboard_v2alpha1_DashboardFieldConfig(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardFieldConfigSource": schema_pkg_apis_dashboard_v2alpha1_DashboardFieldConfigSource(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutItemKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKindOrGridLayoutRowKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutItemKindOrGridLayoutRowKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutItemSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutRowKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutRowSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardGroupByVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardGroupByVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardIntervalVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardIntervalVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardJSONCodec": schema_pkg_apis_dashboard_v2alpha1_DashboardJSONCodec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKind": schema_pkg_apis_dashboard_v2alpha1_DashboardLibraryPanelKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKindSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardLibraryPanelKindSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelRef": schema_pkg_apis_dashboard_v2alpha1_DashboardLibraryPanelRef(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardList": schema_pkg_apis_dashboard_v2alpha1_DashboardList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardMatcherConfig": schema_pkg_apis_dashboard_v2alpha1_DashboardMatcherConfig(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardMetadata": schema_pkg_apis_dashboard_v2alpha1_DashboardMetadata(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardMetricFindValue": schema_pkg_apis_dashboard_v2alpha1_DashboardMetricFindValue(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelKind": schema_pkg_apis_dashboard_v2alpha1_DashboardPanelKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelKindOrLibraryPanelKind": schema_pkg_apis_dashboard_v2alpha1_DashboardPanelKindOrLibraryPanelKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelQueryKind": schema_pkg_apis_dashboard_v2alpha1_DashboardPanelQueryKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelQuerySpec": schema_pkg_apis_dashboard_v2alpha1_DashboardPanelQuerySpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardPanelSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupKind": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryGroupKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryGroupSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryOptionsSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryOptionsSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRangeMap": schema_pkg_apis_dashboard_v2alpha1_DashboardRangeMap(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRegexMap": schema_pkg_apis_dashboard_v2alpha1_DashboardRegexMap(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRepeatOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardRepeatOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemKind": schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutItemKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutItemSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridRepeatOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridRepeatOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowRepeatOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardRowRepeatOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardRowsLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowKind": schema_pkg_apis_dashboard_v2alpha1_DashboardRowsLayoutRowKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardRowsLayoutRowSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardRowsLayoutSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpecialValueMap": schema_pkg_apis_dashboard_v2alpha1_DashboardSpecialValueMap(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus": schema_pkg_apis_dashboard_v2alpha1_DashboardStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStringOrArrayOfString": schema_pkg_apis_dashboard_v2alpha1_DashboardStringOrArrayOfString(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStringOrFloat64": schema_pkg_apis_dashboard_v2alpha1_DashboardStringOrFloat64(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutKind": schema_pkg_apis_dashboard_v2alpha1_DashboardTabsLayoutKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardTabsLayoutSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabKind": schema_pkg_apis_dashboard_v2alpha1_DashboardTabsLayoutTabKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardTabsLayoutTabSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTextVariableKind": schema_pkg_apis_dashboard_v2alpha1_DashboardTextVariableKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTextVariableSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardTextVariableSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardThreshold": schema_pkg_apis_dashboard_v2alpha1_DashboardThreshold(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardThresholdsConfig": schema_pkg_apis_dashboard_v2alpha1_DashboardThresholdsConfig(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTimeRangeOption": schema_pkg_apis_dashboard_v2alpha1_DashboardTimeRangeOption(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTimeSettingsSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardTimeSettingsSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTransformationKind": schema_pkg_apis_dashboard_v2alpha1_DashboardTransformationKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1FieldConfigSourceOverrides": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1FieldConfigSourceOverrides(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RangeMapOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RangeMapOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RegexMapOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RegexMapOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1SpecialValueMapOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1SpecialValueMapOptions(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMap": schema_pkg_apis_dashboard_v2alpha1_DashboardValueMap(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap": schema_pkg_apis_dashboard_v2alpha1_DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult": schema_pkg_apis_dashboard_v2alpha1_DashboardValueMappingResult(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVariableOption": schema_pkg_apis_dashboard_v2alpha1_DashboardVariableOption(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVersionInfo": schema_pkg_apis_dashboard_v2alpha1_DashboardVersionInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVersionList": schema_pkg_apis_dashboard_v2alpha1_DashboardVersionList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVizConfigKind": schema_pkg_apis_dashboard_v2alpha1_DashboardVizConfigKind(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVizConfigSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardVizConfigSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardWithAccessInfo": schema_pkg_apis_dashboard_v2alpha1_DashboardWithAccessInfo(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanel": schema_pkg_apis_dashboard_v2alpha1_LibraryPanel(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelList": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelList(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelSpec": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelSpec(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.LibraryPanelStatus": schema_pkg_apis_dashboard_v2alpha1_LibraryPanelStatus(ref), + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.VersionsQueryOptions": schema_pkg_apis_dashboard_v2alpha1_VersionsQueryOptions(ref), } } @@ -93,36 +185,6 @@ func schema_pkg_apis_dashboard_v2alpha1_AnnotationPermission(ref common.Referenc } } -func schema_pkg_apis_dashboard_v2alpha1_ConversionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "failed": { - SchemaProps: spec.SchemaProps{ - Type: []string{"boolean"}, - Format: "", - }, - }, - "storedVersion": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "error": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - } -} - func schema_pkg_apis_dashboard_v2alpha1_Dashboard(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -145,29 +207,29 @@ func schema_pkg_apis_dashboard_v2alpha1_Dashboard(ref common.ReferenceCallback) }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", - Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + Description: "Spec is the spec of the Dashboard", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus"), }, }, }, - Required: []string{"spec"}, + Required: []string{"metadata", "spec", "status"}, }, }, Dependencies: []string{ - "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpec", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -241,6 +303,1929 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardAccess(ref common.ReferenceCall } } +func schema_pkg_apis_dashboard_v2alpha1_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: "", + }, + }, + "condition": { + SchemaProps: spec.SchemaProps{ + Description: "@deprecated", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"key", "operator", "value"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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: "", + }, + }, + }, + Required: []string{"name", "baseFilters", "filters", "defaultKeys", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdHocFilterWithLabels", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardMetricFindValue"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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: "byte", + }, + }, + }, + }, + }, + }, + Required: []string{"ids"}, + }, + }, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardAnnotationQuerySpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationQuerySpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"), + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardAnnotationPanelFilter"), + }, + }, + }, + Required: []string{"enable", "hide", "iconColor", "name"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationPanelFilter", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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: "", + }, + }, + }, + Required: []string{"name", "query", "current", "options", "multi", "includeAll", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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_v2alpha1_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_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardMatcherConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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: "", + }, + }, + }, + Required: []string{"name", "pluginId", "refresh", "regex", "current", "options", "multi", "includeAll", "hide", "skipUrlSync"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap"), + }, + }, + }, + }, + }, + "thresholds": { + SchemaProps: spec.SchemaProps{ + Description: "Map numeric values to states", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardThresholdsConfig"), + }, + }, + "color": { + SchemaProps: spec.SchemaProps{ + Description: "Panel color configuration", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardFieldColor", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardThresholdsConfig", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1FieldConfigSourceOverrides"), + }, + }, + }, + }, + }, + }, + Required: []string{"defaults", "overrides"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardFieldConfig", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1FieldConfigSourceOverrides"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutItemKindOrGridLayoutRowKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "GridLayoutItemKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKind"), + }, + }, + "GridLayoutRowKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardElementReference"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRepeatOptions"), + }, + }, + }, + Required: []string{"x", "y", "width", "height", "element"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardElementReference", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind"), + }, + }, + "ResponsiveGridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind"), + }, + }, + "TabsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind(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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind"), + }, + }, + "RowsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutKind"), + }, + }, + "ResponsiveGridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind(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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind"), + }, + }, + "RowsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutKind"), + }, + }, + "ResponsiveGridLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind"), + }, + }, + "TabsLayoutKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutRowKind(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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutRowSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardGridLayoutRowSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "y": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "collapsed": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "title": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "elements": { + SchemaProps: spec.SchemaProps{ + Description: "Grid items in the row will have their Y value be relative to the rows Y value. This means a panel positioned at Y: 0 in a row with Y: 10 will be positioned at Y: 11 (row header has a heigh of 1) in the dashboard.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKind"), + }, + }, + }, + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowRepeatOptions"), + }, + }, + }, + Required: []string{"y", "collapsed", "title", "elements"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKindOrGridLayoutRowKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutItemKindOrGridLayoutRowKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"), + }, + }, + "current": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKindSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKindSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelRef"), + }, + }, + }, + Required: []string{"id", "title", "libraryPanel"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_DashboardList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -281,6 +2266,7 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardList(ref common.ReferenceCallba }, }, }, + Required: []string{"metadata", "items"}, }, }, Dependencies: []string{ @@ -288,6 +2274,1280 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardList(ref common.ReferenceCallba } } +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardStringOrFloat64"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardPanelSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardPanelKind"), + }, + }, + "LibraryPanelKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardLibraryPanelKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardPanelQuerySpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelQuerySpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"), + }, + }, + "datasource": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDataLink"), + }, + }, + }, + }, + }, + "data": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupKind"), + }, + }, + "vizConfig": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVizConfigKind"), + }, + }, + "transparent": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"id", "title", "description", "links", "data", "vizConfig"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataLink", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVizConfigKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryGroupSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardTransformationKind"), + }, + }, + }, + }, + }, + "queryOptions": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryOptionsSpec"), + }, + }, + }, + Required: []string{"queries", "transformations", "queryOptions"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelQueryKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryOptionsSpec", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTransformationKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKind"), + }, + }, + "TextVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTextVariableKind"), + }, + }, + "ConstantVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableKind"), + }, + }, + "DatasourceVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableKind"), + }, + }, + "IntervalVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableKind"), + }, + }, + "CustomVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableKind"), + }, + }, + "GroupByVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableKind"), + }, + }, + "AdhocVariableKind": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableKind"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAdhocVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConstantVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardCustomVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDatasourceVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGroupByVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardIntervalVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTextVariableKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"), + }, + }, + "query": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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: "", + }, + }, + }, + Required: []string{"name", "current", "hide", "refresh", "skipUrlSync", "query", "regex", "sort", "options", "multi", "includeAll"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Description: "And this is no longer producing valid TS / Go output type: MappingType & \"range\"", + 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/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RangeMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RangeMapOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Description: "And this is no longer producing valid TS / Go output type: MappingType & \"regex\"", + 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/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RegexMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RegexMapOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_DashboardResponsiveGridLayoutItemKind(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/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutItemSpec(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/pkg/apis/dashboard/v2alpha1.DashboardElementReference"), + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridRepeatOptions"), + }, + }, + }, + Required: []string{"element"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardElementReference", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutKind(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/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridLayoutSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "row": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "col": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + 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/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"row", "col", "items"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardResponsiveGridLayoutItemKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardResponsiveGridRepeatOptions(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_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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: "", + }, + }, + "collapsed": { + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "repeat": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowRepeatOptions"), + }, + }, + "layout": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind"), + }, + }, + }, + Required: []string{"collapsed", "layout"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowRepeatOptions"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"rows"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRowsLayoutRowKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Description: "Title of dashboard.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardPanelKindOrLibraryPanelKind"), + }, + }, + }, + }, + }, + "layout": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind"), + }, + }, + "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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"annotations", "cursorSync", "elements", "layout", "links", "preload", "tags", "timeSettings", "title", "variables"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAnnotationQueryKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDashboardLink", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardPanelKindOrLibraryPanelKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTimeSettingsSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Description: "And this is no longer producing valid TS / Go output type: MappingType & \"special\"", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "options": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1SpecialValueMapOptions"), + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1SpecialValueMapOptions"}, + } +} + func schema_pkg_apis_dashboard_v2alpha1_DashboardStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -296,14 +3556,782 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardStatus(ref common.ReferenceCall Properties: map[string]spec.Schema{ "conversion": { SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.ConversionStatus"), + Description: "Optional conversion status.", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConversionStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.ConversionStatus"}, + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardConversionStatus"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabKind"), + }, + }, + }, + }, + }, + }, + Required: []string{"tabs"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTabsLayoutTabSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind"), + }, + }, + }, + Required: []string{"layout"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardTextVariableSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardTextVariableSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardThreshold"), + }, + }, + }, + }, + }, + }, + Required: []string{"mode", "steps"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardThreshold"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardTimeRangeOption"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardDataTransformerConfig"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDataTransformerConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1FieldConfigSourceOverrides(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/pkg/apis/dashboard/v2alpha1.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/pkg/apis/dashboard/v2alpha1.DashboardDynamicConfigValue"), + }, + }, + }, + }, + }, + }, + Required: []string{"matcher", "properties"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardDynamicConfigValue", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardMatcherConfig"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RangeMapOptions(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/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"from", "to", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RegexMapOptions(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/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"pattern", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1SpecialValueMapOptions(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/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"), + }, + }, + }, + Required: []string{"match", "result"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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{ + Description: "And this is no longer producing valid TS / Go output type: MappingType & \"value\"", + 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/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"), + }, + }, + }, + }, + }, + }, + Required: []string{"type", "options"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMappingResult"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardValueMap"), + }, + }, + "RangeMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRangeMap"), + }, + }, + "RegexMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRegexMap"), + }, + }, + "SpecialValueMap": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpecialValueMap"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRangeMap", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardRegexMap", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpecialValueMap", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardValueMap"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardStringOrArrayOfString"), + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value of the option", + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStringOrArrayOfString"), + }, + }, + }, + Required: []string{"text", "value"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStringOrArrayOfString"}, } } @@ -404,6 +4432,78 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardVersionList(ref common.Referenc } } +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardVizConfigSpec"), + }, + }, + }, + Required: []string{"kind", "spec"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardVizConfigSpec"}, + } +} + +func schema_pkg_apis_dashboard_v2alpha1_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/pkg/apis/dashboard/v2alpha1.DashboardFieldConfigSource"), + }, + }, + }, + Required: []string{"pluginVersion", "options", "fieldConfig"}, + }, + }, + Dependencies: []string{ + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardFieldConfigSource"}, + } +} + func schema_pkg_apis_dashboard_v2alpha1_DashboardWithAccessInfo(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -427,21 +4527,21 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardWithAccessInfo(ref common.Refer }, "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"), + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, "spec": { SchemaProps: spec.SchemaProps{ - Description: "The dashboard body (unstructured for now)", - Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + Description: "Spec is the spec of the Dashboard", + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ - Description: "Optional dashboard status", - Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus"), + Default: map[string]interface{}{}, + Ref: ref("github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus"), }, }, "access": { @@ -451,11 +4551,11 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardWithAccessInfo(ref common.Refer }, }, }, - Required: []string{"spec", "access"}, + Required: []string{"metadata", "spec", "status", "access"}, }, }, Dependencies: []string{ - "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAccess", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardAccess", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardSpec", "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1.DashboardStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } diff --git a/pkg/apis/dashboard/v2alpha1/zz_generated.openapi_violation_exceptions.list b/pkg/apis/dashboard/v2alpha1/zz_generated.openapi_violation_exceptions.list index 0683c758ce4..4914dd6343d 100644 --- a/pkg/apis/dashboard/v2alpha1/zz_generated.openapi_violation_exceptions.list +++ b/pkg/apis/dashboard/v2alpha1/zz_generated.openapi_violation_exceptions.list @@ -1,2 +1,65 @@ +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardAdHocFilterWithLabels,ValueLabels +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardAdHocFilterWithLabels,Values +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardAdhocVariableSpec,BaseFilters +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardAdhocVariableSpec,DefaultKeys +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardAdhocVariableSpec,Filters +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardCustomVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardDashboardLink,Tags +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardDatasourceVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardFieldConfig,Links +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardFieldConfig,Mappings +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardFieldConfigSource,Overrides +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutRowSpec,Elements +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutSpec,Items +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGroupByVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardIntervalVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardMetadata,Finalizers +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardPanelSpec,Links +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryGroupSpec,Queries +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryGroupSpec,Transformations +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableSpec,Options +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardResponsiveGridLayoutSpec,Items +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardRowsLayoutSpec,Rows +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardSpec,Annotations +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardSpec,Links +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardSpec,Tags +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardSpec,Variables +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStringOrArrayOfString,ArrayOfString +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardTabsLayoutSpec,Tabs +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardThresholdsConfig,Steps +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardTimeSettingsSpec,AutoRefreshIntervals +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardTimeSettingsSpec,QuickRanges +API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardV2alpha1FieldConfigSourceOverrides,Properties API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,LibraryPanelStatus,Warnings -API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStatus,ConversionStatus +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutItemKindOrGridLayoutRowKind,GridLayoutItemKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutItemKindOrGridLayoutRowKind,GridLayoutRowKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,GridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,ResponsiveGridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,TabsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind,GridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind,ResponsiveGridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKind,RowsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,GridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,ResponsiveGridLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,RowsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardGridLayoutKindOrRowsLayoutKindOrResponsiveGridLayoutKindOrTabsLayoutKind,TabsLayoutKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardIntervalVariableSpec,AutoCount +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardIntervalVariableSpec,AutoMin +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardPanelKindOrLibraryPanelKind,LibraryPanelKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardPanelKindOrLibraryPanelKind,PanelKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,AdhocVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,ConstantVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,CustomVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,DatasourceVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,GroupByVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,IntervalVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,QueryVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,TextVariableKind +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStringOrArrayOfString,ArrayOfString +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStringOrArrayOfString,String +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStringOrFloat64,Float64 +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardStringOrFloat64,String +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RangeMap +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RegexMap +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,SpecialValueMap +API rule violation: names_match,github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,ValueMap diff --git a/pkg/apis/dashboard_manifest.go b/pkg/apis/dashboard_manifest.go new file mode 100644 index 00000000000..bc68fa86ca6 --- /dev/null +++ b/pkg/apis/dashboard_manifest.go @@ -0,0 +1,53 @@ +// +// This file is generated by grafana-app-sdk +// DO NOT EDIT +// + +package apis + +import ( + "encoding/json" + + "github.com/grafana/grafana-app-sdk/app" +) + +var () + +var appManifestData = app.ManifestData{ + AppName: "dashboard", + Group: "dashboard.grafana.app", + Kinds: []app.ManifestKind{ + { + Kind: "Dashboard", + Scope: "Namespaced", + Conversion: false, + Versions: []app.ManifestKindVersion{ + { + Name: "v0alpha1", + }, + + { + Name: "v1alpha1", + }, + + { + Name: "v2alpha1", + }, + }, + }, + }, +} + +func jsonToMap(j string) map[string]any { + m := make(map[string]any) + json.Unmarshal([]byte(j), &j) + return m +} + +func LocalManifest() app.Manifest { + return app.NewEmbeddedManifest(appManifestData) +} + +func RemoteManifest() app.Manifest { + return app.NewAPIServerManifest("dashboard") +} diff --git a/pkg/registry/apis/dashboard/large.go b/pkg/registry/apis/dashboard/large.go index 6594145f88d..5464d479dd6 100644 --- a/pkg/registry/apis/dashboard/large.go +++ b/pkg/registry/apis/dashboard/large.go @@ -1,6 +1,7 @@ package dashboard import ( + "encoding/json" "fmt" "k8s.io/apimachinery/pkg/runtime" @@ -35,7 +36,11 @@ func NewDashboardLargeObjectSupport(scheme *runtime.Scheme) *apistore.BasicLarge case *dashboardV1.Dashboard: reduceUnstructredSpec(&dash.Spec) case *dashboardV2.Dashboard: - reduceUnstructredSpec(&dash.Spec) + dash.Spec = dashboardV2.DashboardSpec{ + Title: dash.Spec.Title, + Description: dash.Spec.Description, + Tags: dash.Spec.Tags, + } default: return fmt.Errorf("unsupported dashboard type %T", obj) } @@ -45,23 +50,16 @@ func NewDashboardLargeObjectSupport(scheme *runtime.Scheme) *apistore.BasicLarge }, RebuildSpec: func(obj runtime.Object, blob []byte) error { - body := commonV0.Unstructured{} - err := body.UnmarshalJSON(blob) - if err != nil { - return err - } - switch dash := obj.(type) { case *dashboardV0.Dashboard: - dash.Spec = body + return dash.Spec.UnmarshalJSON(blob) case *dashboardV1.Dashboard: - dash.Spec = body + return dash.Spec.UnmarshalJSON(blob) case *dashboardV2.Dashboard: - dash.Spec = body + return json.Unmarshal(blob, &dash.Spec) default: return fmt.Errorf("unsupported dashboard type %T", obj) } - return nil }, } } diff --git a/pkg/registry/apis/dashboard/mutate.go b/pkg/registry/apis/dashboard/mutate.go index c000204744b..560dcfbedba 100644 --- a/pkg/registry/apis/dashboard/mutate.go +++ b/pkg/registry/apis/dashboard/mutate.go @@ -38,10 +38,7 @@ func (b *DashboardsAPIBuilder) Mutate(ctx context.Context, a admission.Attribute internalID = int64(id) } case *dashboardV2.Dashboard: - if id, ok := v.Spec.Object["id"].(float64); ok { - delete(v.Spec.Object, "id") - internalID = int64(id) - } + // Noop for V2 default: return fmt.Errorf("mutation error: expected to dashboard, got %T", obj) } diff --git a/pkg/registry/apis/dashboard/register.go b/pkg/registry/apis/dashboard/register.go index cedda8820ff..9c750e605a9 100644 --- a/pkg/registry/apis/dashboard/register.go +++ b/pkg/registry/apis/dashboard/register.go @@ -109,6 +109,16 @@ func RegisterAPIService( } func (b *DashboardsAPIBuilder) GetGroupVersions() []schema.GroupVersion { + if featuremgmt.AnyEnabled(b.features, featuremgmt.FlagUseV2DashboardsAPI) { + // If dashboards v2 is enabled, we want to use v2alpha1 as the default API version. + return []schema.GroupVersion{ + dashboardv2alpha1.DashboardResourceInfo.GroupVersion(), + dashboardv0alpha1.DashboardResourceInfo.GroupVersion(), + dashboardv1alpha1.DashboardResourceInfo.GroupVersion(), + } + } + + // TODO (@radiohead): should we switch to v1alpha1 by default? return []schema.GroupVersion{ dashboardv0alpha1.DashboardResourceInfo.GroupVersion(), dashboardv1alpha1.DashboardResourceInfo.GroupVersion(), diff --git a/pkg/registry/apis/dashboard/register_test.go b/pkg/registry/apis/dashboard/register_test.go index d218c0727c6..80b1dd28665 100644 --- a/pkg/registry/apis/dashboard/register_test.go +++ b/pkg/registry/apis/dashboard/register_test.go @@ -7,11 +7,15 @@ import ( common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1" + "github.com/grafana/grafana/pkg/apis/dashboard/v1alpha1" + "github.com/grafana/grafana/pkg/apis/dashboard/v2alpha1" "github.com/grafana/grafana/pkg/services/dashboards" + "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/user" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apiserver/pkg/admission" ) @@ -158,3 +162,93 @@ func TestDashboardAPIBuilder_Validate(t *testing.T) { }) } } + +func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) { + tests := []struct { + name string + enabledFeatures []string + expected []schema.GroupVersion + }{ + { + name: "should return v0alpha1 by default", + enabledFeatures: []string{}, + expected: []schema.GroupVersion{ + v0alpha1.DashboardResourceInfo.GroupVersion(), + v1alpha1.DashboardResourceInfo.GroupVersion(), + v2alpha1.DashboardResourceInfo.GroupVersion(), + }, + }, + { + name: "should return v0alpha1 as the default if some other feature is enabled", + enabledFeatures: []string{ + featuremgmt.FlagKubernetesDashboards, + }, + expected: []schema.GroupVersion{ + v0alpha1.DashboardResourceInfo.GroupVersion(), + v1alpha1.DashboardResourceInfo.GroupVersion(), + v2alpha1.DashboardResourceInfo.GroupVersion(), + }, + }, + { + name: "should return v2alpha1 as the default if dashboards v2 is enabled", + enabledFeatures: []string{ + featuremgmt.FlagUseV2DashboardsAPI, + }, + expected: []schema.GroupVersion{ + v2alpha1.DashboardResourceInfo.GroupVersion(), + v0alpha1.DashboardResourceInfo.GroupVersion(), + v1alpha1.DashboardResourceInfo.GroupVersion(), + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + builder := &DashboardsAPIBuilder{ + features: newMockFeatureToggles(t, tt.enabledFeatures...), + } + + require.Equal(t, tt.expected, builder.GetGroupVersions()) + }) + } +} + +type mockFeatureToggles struct { + // We need to make a copy in `GetEnabled` anyway, + // so no need to store the original map as map[string]bool. + enabledFeatures map[string]struct{} +} + +func newMockFeatureToggles(t *testing.T, enabledFeatures ...string) featuremgmt.FeatureToggles { + t.Helper() + + res := &mockFeatureToggles{ + enabledFeatures: make(map[string]struct{}, len(enabledFeatures)), + } + + for _, f := range enabledFeatures { + res.enabledFeatures[f] = struct{}{} + } + + return res +} + +func (m *mockFeatureToggles) IsEnabledGlobally(feature string) bool { + _, ok := m.enabledFeatures[feature] + return ok +} + +func (m *mockFeatureToggles) IsEnabled(ctx context.Context, feature string) bool { + _, ok := m.enabledFeatures[feature] + return ok +} + +func (m *mockFeatureToggles) GetEnabled(ctx context.Context) map[string]bool { + res := make(map[string]bool, len(m.enabledFeatures)) + + for f := range m.enabledFeatures { + res[f] = true + } + + return res +} diff --git a/pkg/storage/unified/apistore/go.mod b/pkg/storage/unified/apistore/go.mod index 68d9aceafbc..6c377348ee0 100644 --- a/pkg/storage/unified/apistore/go.mod +++ b/pkg/storage/unified/apistore/go.mod @@ -207,6 +207,7 @@ require ( github.com/grafana/authlib v0.0.0-20250305132846-37f49eb947fa // indirect github.com/grafana/dataplane/sdata v0.0.9 // indirect github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040 // indirect + github.com/grafana/grafana-app-sdk v0.31.0 // indirect github.com/grafana/grafana-app-sdk/logging v0.30.0 // indirect github.com/grafana/grafana-aws-sdk v0.31.5 // indirect github.com/grafana/grafana-azure-sdk-go/v2 v2.1.6 // indirect diff --git a/pkg/storage/unified/apistore/go.sum b/pkg/storage/unified/apistore/go.sum index 2a54e8f0a54..1b5e473ad53 100644 --- a/pkg/storage/unified/apistore/go.sum +++ b/pkg/storage/unified/apistore/go.sum @@ -1265,6 +1265,8 @@ github.com/grafana/dataplane/sdata v0.0.9 h1:AGL1LZnCUG4MnQtnWpBPbQ8ZpptaZs14w6k github.com/grafana/dataplane/sdata v0.0.9/go.mod h1:Jvs5ddpGmn6vcxT7tCTWAZ1mgi4sbcdFt9utQx5uMAU= github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040 h1:IR+UNYHqaU31t8/TArJk8K/GlDwOyxMpGNkWCXeZ28g= github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/grafana-app-sdk v0.31.0 h1:/mFCcx+YqG8cWAi9hePDJQxIdtXDClDIDRgZwHkksFk= +github.com/grafana/grafana-app-sdk v0.31.0/go.mod h1:Xw00NL7qpRLo5r3Gn48Bl1Xn2n4eUDI5pYf/wMufKWs= github.com/grafana/grafana-app-sdk/logging v0.30.0 h1:K/P/bm7Cp7Di4tqIJ3EQz2+842JozQGRaz62r95ApME= github.com/grafana/grafana-app-sdk/logging v0.30.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM= github.com/grafana/grafana-aws-sdk v0.31.5 h1:4HpMQx7n4Qqoi7Bgu8KHQ2QKT9fYYdHilX/Gh3FZKBE= diff --git a/pkg/storage/unified/resource/go.mod b/pkg/storage/unified/resource/go.mod index 0a5d4a68146..bc891b4aa28 100644 --- a/pkg/storage/unified/resource/go.mod +++ b/pkg/storage/unified/resource/go.mod @@ -133,6 +133,7 @@ require ( github.com/gorilla/mux v1.8.1 // indirect github.com/grafana/alerting v0.0.0-20250310104713-16b885f1c79e // indirect github.com/grafana/dataplane/sdata v0.0.9 // indirect + github.com/grafana/grafana-app-sdk v0.31.0 // indirect github.com/grafana/grafana-app-sdk/logging v0.30.0 // indirect github.com/grafana/grafana-aws-sdk v0.31.5 // indirect github.com/grafana/grafana-azure-sdk-go/v2 v2.1.6 // indirect @@ -214,7 +215,6 @@ require ( github.com/tjhop/slog-gokit v0.1.3 // indirect github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/ugorji/go/codec v1.2.11 // indirect github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 // indirect github.com/unknwon/com v1.0.1 // indirect github.com/unknwon/log v0.0.0-20200308114134-929b1006e34a // indirect diff --git a/pkg/storage/unified/resource/go.sum b/pkg/storage/unified/resource/go.sum index aef2f25aee9..b7a7baddf76 100644 --- a/pkg/storage/unified/resource/go.sum +++ b/pkg/storage/unified/resource/go.sum @@ -1160,6 +1160,8 @@ github.com/grafana/dataplane/sdata v0.0.9 h1:AGL1LZnCUG4MnQtnWpBPbQ8ZpptaZs14w6k github.com/grafana/dataplane/sdata v0.0.9/go.mod h1:Jvs5ddpGmn6vcxT7tCTWAZ1mgi4sbcdFt9utQx5uMAU= github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040 h1:IR+UNYHqaU31t8/TArJk8K/GlDwOyxMpGNkWCXeZ28g= github.com/grafana/dskit v0.0.0-20241105154643-a6b453a88040/go.mod h1:SPLNCARd4xdjCkue0O6hvuoveuS1dGJjDnfxYe405YQ= +github.com/grafana/grafana-app-sdk v0.31.0 h1:/mFCcx+YqG8cWAi9hePDJQxIdtXDClDIDRgZwHkksFk= +github.com/grafana/grafana-app-sdk v0.31.0/go.mod h1:Xw00NL7qpRLo5r3Gn48Bl1Xn2n4eUDI5pYf/wMufKWs= github.com/grafana/grafana-app-sdk/logging v0.30.0 h1:K/P/bm7Cp7Di4tqIJ3EQz2+842JozQGRaz62r95ApME= github.com/grafana/grafana-app-sdk/logging v0.30.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM= github.com/grafana/grafana-aws-sdk v0.31.5 h1:4HpMQx7n4Qqoi7Bgu8KHQ2QKT9fYYdHilX/Gh3FZKBE= diff --git a/pkg/tests/apis/dashboard/testdata/dashboard-test-v2.yaml b/pkg/tests/apis/dashboard/testdata/dashboard-test-v2.yaml index 1f9efaa0579..540b9dcc919 100644 --- a/pkg/tests/apis/dashboard/testdata/dashboard-test-v2.yaml +++ b/pkg/tests/apis/dashboard/testdata/dashboard-test-v2.yaml @@ -4,3 +4,7 @@ metadata: name: test-v2 spec: title: Test dashboard. Created at v2 + layout: + kind: GridLayout + spec: + items: [] diff --git a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json index b0f2258cb24..eec30bc3008 100644 --- a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json @@ -1490,24 +1490,12 @@ } } }, - "com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.ConversionStatus": { - "type": "object", - "properties": { - "error": { - "type": "string" - }, - "failed": { - "type": "boolean" - }, - "storedVersion": { - "type": "string" - } - } - }, "com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.Dashboard": { "type": "object", "required": [ - "spec" + "metadata", + "spec", + "status" ], "properties": { "apiVersion": { @@ -1519,7 +1507,6 @@ "type": "string" }, "metadata": { - "description": "Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", "default": {}, "allOf": [ { @@ -1528,7 +1515,7 @@ ] }, "spec": { - "description": "The dashboard body (unstructured for now)", + "description": "Spec is the spec of the Dashboard", "allOf": [ { "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured" @@ -1536,7 +1523,7 @@ ] }, "status": { - "description": "Optional dashboard status", + "default": {}, "allOf": [ { "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardStatus" @@ -1553,7 +1540,6 @@ ] }, "com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardAccess": { - "description": "Information about how the requesting user can use a given dashboard", "type": "object", "required": [ "canSave", @@ -1597,8 +1583,38 @@ } } }, + "com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardConversionStatus": { + "description": "ConversionStatus is the status of the conversion of the dashboard.", + "type": "object", + "required": [ + "failed", + "storedVersion", + "error" + ], + "properties": { + "error": { + "description": "The error message from the conversion. Empty if the conversion has not failed.", + "type": "string", + "default": "" + }, + "failed": { + "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.", + "type": "boolean", + "default": false + }, + "storedVersion": { + "description": "The version which was stored when the dashboard was created / updated. Fetching this version should always succeed.", + "type": "string", + "default": "" + } + } + }, "com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardList": { "type": "object", + "required": [ + "metadata", + "items" + ], "properties": { "apiVersion": { "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", @@ -1640,7 +1656,12 @@ "type": "object", "properties": { "conversion": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.ConversionStatus" + "description": "Optional conversion status.", + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardConversionStatus" + } + ] } } }, @@ -1648,7 +1669,9 @@ "description": "This is like the legacy DTO where access and metadata are all returned in a single call", "type": "object", "required": [ + "metadata", "spec", + "status", "access" ], "properties": { @@ -1669,7 +1692,6 @@ "type": "string" }, "metadata": { - "description": "Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", "default": {}, "allOf": [ { @@ -1678,7 +1700,7 @@ ] }, "spec": { - "description": "The dashboard body (unstructured for now)", + "description": "Spec is the spec of the Dashboard", "allOf": [ { "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured" @@ -1686,7 +1708,7 @@ ] }, "status": { - "description": "Optional dashboard status", + "default": {}, "allOf": [ { "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.dashboard.v0alpha1.DashboardStatus" diff --git a/public/api-merged.json b/public/api-merged.json index 130059510ae..873200a1fb7 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -13055,6 +13055,7 @@ } }, "AnnotationActions": { + "description": "+k8s:deepcopy-gen=true", "type": "object", "properties": { "canAdd": { @@ -13129,6 +13130,7 @@ } }, "AnnotationPermission": { + "description": "+k8s:deepcopy-gen=true", "type": "object", "properties": { "dashboard": { diff --git a/public/openapi3.json b/public/openapi3.json index d791ee2bb10..9d4c63135c3 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -3118,6 +3118,7 @@ "type": "object" }, "AnnotationActions": { + "description": "+k8s:deepcopy-gen=true", "properties": { "canAdd": { "type": "boolean" @@ -3192,6 +3193,7 @@ "type": "object" }, "AnnotationPermission": { + "description": "+k8s:deepcopy-gen=true", "properties": { "dashboard": { "$ref": "#/components/schemas/AnnotationActions"