mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Schema: Create PublicDashboard core kind (#62155)
This commit is contained in:
parent
e8b8a9e276
commit
354f6d9e23
@ -0,0 +1,25 @@
|
||||
---
|
||||
keywords:
|
||||
- grafana
|
||||
- schema
|
||||
title: PublicDashboard kind
|
||||
---
|
||||
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
|
||||
|
||||
# PublicDashboard kind
|
||||
|
||||
## Maturity: merged
|
||||
## Version: 0.0
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Required | Description |
|
||||
|------------------------|---------|----------|-----------------------------------------------------------------|
|
||||
| `annotationsEnabled` | boolean | **Yes** | Flag that indicates if annotations are enabled |
|
||||
| `dashboardUid` | string | **Yes** | Dashboard unique identifier referenced by this public dashboard |
|
||||
| `isEnabled` | boolean | **Yes** | Flag that indicates if the public dashboard is enabled |
|
||||
| `timeSelectionEnabled` | boolean | **Yes** | Flag that indicates if the time range picker is enabled |
|
||||
| `uid` | string | **Yes** | Unique public dashboard identifier |
|
||||
| `accessToken` | string | No | Unique public access token |
|
||||
|
||||
|
26
kinds/publicdashboard/public_dashboard_kind.cue
Normal file
26
kinds/publicdashboard/public_dashboard_kind.cue
Normal file
@ -0,0 +1,26 @@
|
||||
package kind
|
||||
|
||||
name: "PublicDashboard"
|
||||
maturity: "merged"
|
||||
|
||||
lineage: seqs: [
|
||||
{
|
||||
schemas: [
|
||||
// 0.0
|
||||
{
|
||||
// Unique public dashboard identifier
|
||||
uid: string
|
||||
// Dashboard unique identifier referenced by this public dashboard
|
||||
dashboardUid: string
|
||||
// Unique public access token
|
||||
accessToken?: string
|
||||
// Flag that indicates if the public dashboard is enabled
|
||||
isEnabled: bool
|
||||
// Flag that indicates if annotations are enabled
|
||||
annotationsEnabled: bool
|
||||
// Flag that indicates if the time range picker is enabled
|
||||
timeSelectionEnabled: bool
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
@ -101,6 +101,9 @@ export type {
|
||||
QueryHistoryPreference
|
||||
} from './raw/preferences/x/preferences_types.gen';
|
||||
|
||||
// Raw generated types from PublicDashboard kind.
|
||||
export type { PublicDashboard } from './raw/publicdashboard/x/publicdashboard_types.gen';
|
||||
|
||||
// Raw generated types from ServiceAccount kind.
|
||||
export type {
|
||||
ServiceAccount,
|
||||
|
@ -0,0 +1,36 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// TSTypesJenny
|
||||
// LatestMajorsOrXJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
export interface PublicDashboard {
|
||||
/**
|
||||
* Unique public access token
|
||||
*/
|
||||
accessToken?: string;
|
||||
/**
|
||||
* Flag that indicates if annotations are enabled
|
||||
*/
|
||||
annotationsEnabled: boolean;
|
||||
/**
|
||||
* Dashboard unique identifier referenced by this public dashboard
|
||||
*/
|
||||
dashboardUid: string;
|
||||
/**
|
||||
* Flag that indicates if the public dashboard is enabled
|
||||
*/
|
||||
isEnabled: boolean;
|
||||
/**
|
||||
* Flag that indicates if the time range picker is enabled
|
||||
*/
|
||||
timeSelectionEnabled: boolean;
|
||||
/**
|
||||
* Unique public dashboard identifier
|
||||
*/
|
||||
uid: string;
|
||||
}
|
113
pkg/kinds/publicdashboard/publicdashboard_kind_gen.go
Normal file
113
pkg/kinds/publicdashboard/publicdashboard_kind_gen.go
Normal file
@ -0,0 +1,113 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// CoreKindJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package publicdashboard
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/kindsys"
|
||||
"github.com/grafana/thema"
|
||||
"github.com/grafana/thema/vmux"
|
||||
)
|
||||
|
||||
// rootrel is the relative path from the grafana repository root to the
|
||||
// directory containing the .cue files in which this kind is declared. Necessary
|
||||
// for runtime errors related to the declaration and/or lineage to provide
|
||||
// a real path to the correct .cue file.
|
||||
const rootrel string = "kinds/publicdashboard"
|
||||
|
||||
// TODO standard generated docs
|
||||
type Kind struct {
|
||||
lin thema.ConvergentLineage[*PublicDashboard]
|
||||
jcodec vmux.Codec
|
||||
valmux vmux.ValueMux[*PublicDashboard]
|
||||
decl kindsys.Decl[kindsys.CoreProperties]
|
||||
}
|
||||
|
||||
// type guard
|
||||
var _ kindsys.Core = &Kind{}
|
||||
|
||||
// TODO standard generated docs
|
||||
func NewKind(rt *thema.Runtime, opts ...thema.BindOption) (*Kind, error) {
|
||||
decl, err := kindsys.LoadCoreKind(rootrel, rt.Context(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
k := &Kind{
|
||||
decl: decl,
|
||||
}
|
||||
|
||||
lin, err := decl.Some().BindKindLineage(rt, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the thema.Schema that the meta says is in the current version (which
|
||||
// codegen ensures is always the latest)
|
||||
cursch := thema.SchemaP(lin, k.decl.Properties.CurrentVersion)
|
||||
tsch, err := thema.BindType[*PublicDashboard](cursch, &PublicDashboard{})
|
||||
if err != nil {
|
||||
// Should be unreachable, modulo bugs in the Thema->Go code generator
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k.jcodec = vmux.NewJSONCodec("publicdashboard.json")
|
||||
k.lin = tsch.ConvergentLineage()
|
||||
k.valmux = vmux.NewValueMux(k.lin.TypedSchema(), k.jcodec)
|
||||
return k, nil
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) Name() string {
|
||||
return "publicdashboard"
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) MachineName() string {
|
||||
return "publicdashboard"
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) Lineage() thema.Lineage {
|
||||
return k.lin
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) ConvergentLineage() thema.ConvergentLineage[*PublicDashboard] {
|
||||
return k.lin
|
||||
}
|
||||
|
||||
// JSONValueMux is a version multiplexer that maps a []byte containing JSON data
|
||||
// at any schematized dashboard version to an instance of PublicDashboard.
|
||||
//
|
||||
// Validation and translation errors emitted from this func will identify the
|
||||
// input bytes as "dashboard.json".
|
||||
//
|
||||
// This is a thin wrapper around Thema's [vmux.ValueMux].
|
||||
func (k *Kind) JSONValueMux(b []byte) (*PublicDashboard, thema.TranslationLacunas, error) {
|
||||
return k.valmux(b)
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) Maturity() kindsys.Maturity {
|
||||
return k.decl.Properties.Maturity
|
||||
}
|
||||
|
||||
// Decl returns the [kindsys.Decl] containing both CUE and Go representations of the
|
||||
// publicdashboard declaration in .cue files.
|
||||
func (k *Kind) Decl() kindsys.Decl[kindsys.CoreProperties] {
|
||||
return k.decl
|
||||
}
|
||||
|
||||
// Props returns a [kindsys.SomeKindProps], with underlying type [kindsys.CoreProperties],
|
||||
// representing the static properties declared in the publicdashboard kind.
|
||||
//
|
||||
// This method is identical to calling Decl().Props. It is provided to satisfy [kindsys.Interface].
|
||||
func (k *Kind) Props() kindsys.SomeKindProperties {
|
||||
return k.decl.Properties
|
||||
}
|
32
pkg/kinds/publicdashboard/publicdashboard_types_gen.go
Normal file
32
pkg/kinds/publicdashboard/publicdashboard_types_gen.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
// LatestJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package publicdashboard
|
||||
|
||||
// PublicDashboard defines model for PublicDashboard.
|
||||
type PublicDashboard struct {
|
||||
// Unique public access token
|
||||
AccessToken *string `json:"accessToken,omitempty"`
|
||||
|
||||
// Flag that indicates if annotations are enabled
|
||||
AnnotationsEnabled bool `json:"annotationsEnabled"`
|
||||
|
||||
// Dashboard unique identifier referenced by this public dashboard
|
||||
DashboardUid string `json:"dashboardUid"`
|
||||
|
||||
// Flag that indicates if the public dashboard is enabled
|
||||
IsEnabled bool `json:"isEnabled"`
|
||||
|
||||
// Flag that indicates if the time range picker is enabled
|
||||
TimeSelectionEnabled bool `json:"timeSelectionEnabled"`
|
||||
|
||||
// Unique public dashboard identifier
|
||||
Uid string `json:"uid"`
|
||||
}
|
@ -1281,6 +1281,32 @@
|
||||
"pluralName": "PrometheusDataSourceCfgs",
|
||||
"schemaInterface": "DataSourceCfg"
|
||||
},
|
||||
"publicdashboard": {
|
||||
"category": "core",
|
||||
"codeowners": [
|
||||
"grafana/grafana-as-code",
|
||||
"grafana/grafana-bi-squad",
|
||||
"grafana/plugins-platform-frontend",
|
||||
"grafana/user-essentials"
|
||||
],
|
||||
"currentVersion": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"grafanaMaturityCount": 0,
|
||||
"lineageIsGroup": false,
|
||||
"links": {
|
||||
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/core/publicdashboard/schema-reference",
|
||||
"go": "https://github.com/grafana/grafana/tree/main/pkg/kinds/publicdashboard",
|
||||
"schema": "https://github.com/grafana/grafana/tree/main/kinds/publicdashboard/publicdashboard_kind.cue",
|
||||
"ts": "https://github.com/grafana/grafana/tree/main/packages/grafana-schema/src/raw/publicdashboard/x/publicdashboard_types.gen.ts"
|
||||
},
|
||||
"machineName": "publicdashboard",
|
||||
"maturity": "merged",
|
||||
"name": "PublicDashboard",
|
||||
"pluralMachineName": "publicdashboards",
|
||||
"pluralName": "PublicDashboards"
|
||||
},
|
||||
"query": {
|
||||
"category": "core",
|
||||
"codeowners": [],
|
||||
@ -1818,6 +1844,7 @@
|
||||
"folder",
|
||||
"playlist",
|
||||
"preferences",
|
||||
"publicdashboard",
|
||||
"query",
|
||||
"queryhistory",
|
||||
"serviceaccount",
|
||||
@ -1825,7 +1852,7 @@
|
||||
"thumb",
|
||||
"user"
|
||||
],
|
||||
"count": 12
|
||||
"count": 13
|
||||
}
|
||||
},
|
||||
"maturity": {
|
||||
@ -1860,10 +1887,11 @@
|
||||
"alertgroupspanelcfg",
|
||||
"playlist",
|
||||
"preferences",
|
||||
"publicdashboard",
|
||||
"serviceaccount",
|
||||
"team"
|
||||
],
|
||||
"count": 5
|
||||
"count": 6
|
||||
},
|
||||
"planned": {
|
||||
"name": "planned",
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/kinds/dashboard"
|
||||
"github.com/grafana/grafana/pkg/kinds/playlist"
|
||||
"github.com/grafana/grafana/pkg/kinds/preferences"
|
||||
"github.com/grafana/grafana/pkg/kinds/publicdashboard"
|
||||
"github.com/grafana/grafana/pkg/kinds/serviceaccount"
|
||||
"github.com/grafana/grafana/pkg/kinds/team"
|
||||
"github.com/grafana/grafana/pkg/kindsys"
|
||||
@ -32,12 +33,13 @@ import (
|
||||
// Prefer All*() methods when performing operations generically across all kinds.
|
||||
// For example, a validation HTTP middleware for any kind-schematized object type.
|
||||
type Base struct {
|
||||
all []kindsys.Core
|
||||
dashboard *dashboard.Kind
|
||||
playlist *playlist.Kind
|
||||
preferences *preferences.Kind
|
||||
serviceaccount *serviceaccount.Kind
|
||||
team *team.Kind
|
||||
all []kindsys.Core
|
||||
dashboard *dashboard.Kind
|
||||
playlist *playlist.Kind
|
||||
preferences *preferences.Kind
|
||||
publicdashboard *publicdashboard.Kind
|
||||
serviceaccount *serviceaccount.Kind
|
||||
team *team.Kind
|
||||
}
|
||||
|
||||
// type guards
|
||||
@ -45,6 +47,7 @@ var (
|
||||
_ kindsys.Core = &dashboard.Kind{}
|
||||
_ kindsys.Core = &playlist.Kind{}
|
||||
_ kindsys.Core = &preferences.Kind{}
|
||||
_ kindsys.Core = &publicdashboard.Kind{}
|
||||
_ kindsys.Core = &serviceaccount.Kind{}
|
||||
_ kindsys.Core = &team.Kind{}
|
||||
)
|
||||
@ -64,6 +67,11 @@ func (b *Base) Preferences() *preferences.Kind {
|
||||
return b.preferences
|
||||
}
|
||||
|
||||
// PublicDashboard returns the [kindsys.Interface] implementation for the publicdashboard kind.
|
||||
func (b *Base) PublicDashboard() *publicdashboard.Kind {
|
||||
return b.publicdashboard
|
||||
}
|
||||
|
||||
// ServiceAccount returns the [kindsys.Interface] implementation for the serviceaccount kind.
|
||||
func (b *Base) ServiceAccount() *serviceaccount.Kind {
|
||||
return b.serviceaccount
|
||||
@ -96,6 +104,12 @@ func doNewBase(rt *thema.Runtime) *Base {
|
||||
}
|
||||
reg.all = append(reg.all, reg.preferences)
|
||||
|
||||
reg.publicdashboard, err = publicdashboard.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the publicdashboard Kind: %s", err))
|
||||
}
|
||||
reg.all = append(reg.all, reg.publicdashboard)
|
||||
|
||||
reg.serviceaccount, err = serviceaccount.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the serviceaccount Kind: %s", err))
|
||||
|
Loading…
Reference in New Issue
Block a user