grafana / cog

Code Generation with a human touch
Apache License 2.0
48 stars 2 forks source link

Add an option to disable runtime-related codegen in Go #409

Closed K-Phoen closed 5 months ago

K-Phoen commented 5 months ago

Relates to #408

github-actions[bot] commented 5 months ago

Note: in addition to the changes introduced by this PR, the diff includes unreleased changes living in main.

### 🔎 Changes to `grafana-foundation-sdk@next+cog-v0.0.x` ```patch diff --git a/go/alerting/rule_builder_gen.go b/go/alerting/rule_builder_gen.go index 26c5fa1..6e66fe8 100644 --- a/go/alerting/rule_builder_gen.go +++ b/go/alerting/rule_builder_gen.go @@ -4,6 +4,7 @@ package alerting import ( "errors" + "time" cog "github.com/grafana/grafana-foundation-sdk/go/cog" ) @@ -197,7 +198,7 @@ func (builder *RuleBuilder) Uid(uid string) *RuleBuilder { return builder } -func (builder *RuleBuilder) Updated(updated string) *RuleBuilder { +func (builder *RuleBuilder) Updated(updated time.Time) *RuleBuilder { builder.internal.Updated = &updated return builder diff --git a/go/alerting/types_gen.go b/go/alerting/types_gen.go index e12da94..0e53dc0 100644 --- a/go/alerting/types_gen.go +++ b/go/alerting/types_gen.go @@ -3,6 +3,8 @@ package alerting import ( + "time" + cogvariants "github.com/grafana/grafana-foundation-sdk/go/cog/variants" ) @@ -82,7 +84,7 @@ type Rule struct { RuleGroup string `json:"ruleGroup"` Title string `json:"title"` Uid *string `json:"uid,omitempty"` - Updated *string `json:"updated,omitempty"` + Updated *time.Time `json:"updated,omitempty"` } type NotificationSettings struct { diff --git a/go/common/types_gen.go b/go/common/types_gen.go index 4cb5641..e809b43 100644 --- a/go/common/types_gen.go +++ b/go/common/types_gen.go @@ -486,6 +486,15 @@ const ( BigValueTextModeNone BigValueTextMode = "none" ) +// TODO docs +type PercentChangeColorMode string + +const ( + PercentChangeColorModeStandard PercentChangeColorMode = "standard" + PercentChangeColorModeInverted PercentChangeColorMode = "inverted" + PercentChangeColorModeSameAsValue PercentChangeColorMode = "same_as_value" +) + // TODO -- should not be table specific! // TODO docs type FieldTextAlignment string diff --git a/go/dashboard/snapshot_builder_gen.go b/go/dashboard/snapshot_builder_gen.go index 67f670f..3bcc084 100644 --- a/go/dashboard/snapshot_builder_gen.go +++ b/go/dashboard/snapshot_builder_gen.go @@ -3,6 +3,8 @@ package dashboard import ( + "time" + cog "github.com/grafana/grafana-foundation-sdk/go/cog" ) @@ -45,7 +47,7 @@ func (builder *SnapshotBuilder) Build() (Snapshot, error) { } // Time when the snapshot was created -func (builder *SnapshotBuilder) Created(created string) *SnapshotBuilder { +func (builder *SnapshotBuilder) Created(created time.Time) *SnapshotBuilder { builder.internal.Created = created return builder @@ -108,7 +110,7 @@ func (builder *SnapshotBuilder) OrgId(orgId uint32) *SnapshotBuilder { } // last time when the snapshot was updated -func (builder *SnapshotBuilder) Updated(updated string) *SnapshotBuilder { +func (builder *SnapshotBuilder) Updated(updated time.Time) *SnapshotBuilder { builder.internal.Updated = updated return builder diff --git a/go/dashboard/types_gen.go b/go/dashboard/types_gen.go index 51549a5..5d56fb4 100644 --- a/go/dashboard/types_gen.go +++ b/go/dashboard/types_gen.go @@ -3,6 +3,8 @@ package dashboard import ( + "time" + cogvariants "github.com/grafana/grafana-foundation-sdk/go/cog/variants" ) @@ -520,7 +522,7 @@ const ( // Sensitive information stripped: queries (metric, template,annotation) and panel links. type Snapshot struct { // Time when the snapshot was created - Created string `json:"created"` + Created time.Time `json:"created"` // Time when the snapshot expires, default is never to expire Expires string `json:"expires"` // Is the snapshot saved in an external grafana instance @@ -538,7 +540,7 @@ type Snapshot struct { // org id of the snapshot OrgId uint32 `json:"orgId"` // last time when the snapshot was updated - Updated string `json:"updated"` + Updated time.Time `json:"updated"` // url of the snapshot, if snapshot was shared internally Url *string `json:"url,omitempty"` // user id of the snapshot creator diff --git a/go/expr/typeclassicconditions_builder_gen.go b/go/expr/typeclassicconditions_builder_gen.go index ef17618..f03f7c2 100644 --- a/go/expr/typeclassicconditions_builder_gen.go +++ b/go/expr/typeclassicconditions_builder_gen.go @@ -64,9 +64,11 @@ func (builder *TypeClassicConditionsBuilder) Conditions(conditions []struct { // The datasource func (builder *TypeClassicConditionsBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeClassicConditionsBuilder { builder.internal.Datasource = &datasource diff --git a/go/expr/typemath_builder_gen.go b/go/expr/typemath_builder_gen.go index df39855..8ac4487 100644 --- a/go/expr/typemath_builder_gen.go +++ b/go/expr/typemath_builder_gen.go @@ -45,9 +45,11 @@ func (builder *TypeMathBuilder) Build() (cogvariants.Dataquery, error) { // The datasource func (builder *TypeMathBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeMathBuilder { builder.internal.Datasource = &datasource diff --git a/go/expr/typereduce_builder_gen.go b/go/expr/typereduce_builder_gen.go index d9661f9..f96dd8a 100644 --- a/go/expr/typereduce_builder_gen.go +++ b/go/expr/typereduce_builder_gen.go @@ -45,9 +45,11 @@ func (builder *TypeReduceBuilder) Build() (cogvariants.Dataquery, error) { // The datasource func (builder *TypeReduceBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeReduceBuilder { builder.internal.Datasource = &datasource diff --git a/go/expr/typeresample_builder_gen.go b/go/expr/typeresample_builder_gen.go index 61054f6..6cb2009 100644 --- a/go/expr/typeresample_builder_gen.go +++ b/go/expr/typeresample_builder_gen.go @@ -45,9 +45,11 @@ func (builder *TypeResampleBuilder) Build() (cogvariants.Dataquery, error) { // The datasource func (builder *TypeResampleBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeResampleBuilder { builder.internal.Datasource = &datasource diff --git a/go/expr/types_gen.go b/go/expr/types_gen.go index 5e51491..2fd5657 100644 --- a/go/expr/types_gen.go +++ b/go/expr/types_gen.go @@ -9,9 +9,11 @@ func (resource Expr) ImplementsDataqueryVariant() {} type TypeMath struct { // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` // General math expression @@ -72,9 +74,11 @@ func (resource TypeMath) ImplementsDataqueryVariant() {} type TypeReduce struct { // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` // Reference to single query result @@ -154,9 +158,11 @@ func (resource TypeReduce) ImplementsDataqueryVariant() {} type TypeResample struct { // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` // The downsample function @@ -250,9 +256,11 @@ type TypeClassicConditions struct { } `json:"conditions"` // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` // true if query is disabled (ie should not be returned to the dashboard) @@ -325,9 +333,11 @@ type TypeThreshold struct { } `json:"conditions"` // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` // Reference to single query result @@ -388,9 +398,11 @@ func (resource TypeThreshold) ImplementsDataqueryVariant() {} type TypeSql struct { // The datasource Datasource *struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } `json:"datasource,omitempty"` Expression string `json:"expression"` diff --git a/go/expr/typesql_builder_gen.go b/go/expr/typesql_builder_gen.go index 241f0b2..2358525 100644 --- a/go/expr/typesql_builder_gen.go +++ b/go/expr/typesql_builder_gen.go @@ -45,9 +45,11 @@ func (builder *TypeSqlBuilder) Build() (cogvariants.Dataquery, error) { // The datasource func (builder *TypeSqlBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeSqlBuilder { builder.internal.Datasource = &datasource diff --git a/go/expr/typethreshold_builder_gen.go b/go/expr/typethreshold_builder_gen.go index e3b5a5f..3fcde76 100644 --- a/go/expr/typethreshold_builder_gen.go +++ b/go/expr/typethreshold_builder_gen.go @@ -64,9 +64,11 @@ func (builder *TypeThresholdBuilder) Conditions(conditions []struct { // The datasource func (builder *TypeThresholdBuilder) Datasource(datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` }) *TypeThresholdBuilder { builder.internal.Datasource = &datasource diff --git a/go/librarypanel/libraryelementdtometa_builder_gen.go b/go/librarypanel/libraryelementdtometa_builder_gen.go index 59035ef..4a6cb99 100644 --- a/go/librarypanel/libraryelementdtometa_builder_gen.go +++ b/go/librarypanel/libraryelementdtometa_builder_gen.go @@ -3,6 +3,8 @@ package librarypanel import ( + "time" + cog "github.com/grafana/grafana-foundation-sdk/go/cog" ) @@ -57,13 +59,13 @@ func (builder *LibraryElementDTOMetaBuilder) ConnectedDashboards(connectedDashbo return builder } -func (builder *LibraryElementDTOMetaBuilder) Created(created string) *LibraryElementDTOMetaBuilder { +func (builder *LibraryElementDTOMetaBuilder) Created(created time.Time) *LibraryElementDTOMetaBuilder { builder.internal.Created = created return builder } -func (builder *LibraryElementDTOMetaBuilder) Updated(updated string) *LibraryElementDTOMetaBuilder { +func (builder *LibraryElementDTOMetaBuilder) Updated(updated time.Time) *LibraryElementDTOMetaBuilder { builder.internal.Updated = updated return builder diff --git a/go/librarypanel/types_gen.go b/go/librarypanel/types_gen.go index 7a868b1..322cbae 100644 --- a/go/librarypanel/types_gen.go +++ b/go/librarypanel/types_gen.go @@ -3,6 +3,8 @@ package librarypanel import ( + "time" + cogvariants "github.com/grafana/grafana-foundation-sdk/go/cog/variants" dashboard "github.com/grafana/grafana-foundation-sdk/go/dashboard" ) @@ -99,8 +101,8 @@ type LibraryElementDTOMeta struct { FolderName string `json:"folderName"` FolderUid string `json:"folderUid"` ConnectedDashboards int64 `json:"connectedDashboards"` - Created string `json:"created"` - Updated string `json:"updated"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` CreatedBy LibraryElementDTOMetaUser `json:"createdBy"` UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"` } diff --git a/go/stat/panel_builder_gen.go b/go/stat/panel_builder_gen.go index f3223dd..eaf3847 100644 --- a/go/stat/panel_builder_gen.go +++ b/go/stat/panel_builder_gen.go @@ -460,6 +460,15 @@ func (builder *PanelBuilder) WideLayout(wideLayout bool) *PanelBuilder { return builder } +func (builder *PanelBuilder) ShowPercentChange(showPercentChange bool) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).ShowPercentChange = showPercentChange + + return builder +} + func (builder *PanelBuilder) ReduceOptions(reduceOptions cog.Builder[common.ReduceDataOptions]) *PanelBuilder { if builder.internal.Options == nil { builder.internal.Options = &Options{} @@ -488,11 +497,11 @@ func (builder *PanelBuilder) Text(text cog.Builder[common.VizTextDisplayOptions] return builder } -func (builder *PanelBuilder) ShowPercentChange(showPercentChange bool) *PanelBuilder { +func (builder *PanelBuilder) PercentChangeColorMode(percentChangeColorMode common.PercentChangeColorMode) *PanelBuilder { if builder.internal.Options == nil { builder.internal.Options = &Options{} } - builder.internal.Options.(*Options).ShowPercentChange = showPercentChange + builder.internal.Options.(*Options).PercentChangeColorMode = percentChangeColorMode return builder } @@ -516,4 +525,5 @@ func (builder *PanelBuilder) applyDefaults() { builder.TextMode("auto") builder.WideLayout(true) builder.ShowPercentChange(false) + builder.PercentChangeColorMode("standard") } diff --git a/go/stat/types_gen.go b/go/stat/types_gen.go index 9ac32b4..211581b 100644 --- a/go/stat/types_gen.go +++ b/go/stat/types_gen.go @@ -7,13 +7,14 @@ import ( ) type Options struct { - GraphMode common.BigValueGraphMode `json:"graphMode"` - ColorMode common.BigValueColorMode `json:"colorMode"` - JustifyMode common.BigValueJustifyMode `json:"justifyMode"` - TextMode common.BigValueTextMode `json:"textMode"` - WideLayout bool `json:"wideLayout"` - ReduceOptions common.ReduceDataOptions `json:"reduceOptions"` - Text *common.VizTextDisplayOptions `json:"text,omitempty"` - ShowPercentChange bool `json:"showPercentChange"` - Orientation common.VizOrientation `json:"orientation"` + GraphMode common.BigValueGraphMode `json:"graphMode"` + ColorMode common.BigValueColorMode `json:"colorMode"` + JustifyMode common.BigValueJustifyMode `json:"justifyMode"` + TextMode common.BigValueTextMode `json:"textMode"` + WideLayout bool `json:"wideLayout"` + ShowPercentChange bool `json:"showPercentChange"` + ReduceOptions common.ReduceDataOptions `json:"reduceOptions"` + Text *common.VizTextDisplayOptions `json:"text,omitempty"` + PercentChangeColorMode common.PercentChangeColorMode `json:"percentChangeColorMode"` + Orientation common.VizOrientation `json:"orientation"` } diff --git a/go/testdata/datasource_builder_gen.go b/go/testdata/datasource_builder_gen.go index a995e8c..6a1cb76 100644 --- a/go/testdata/datasource_builder_gen.go +++ b/go/testdata/datasource_builder_gen.go @@ -39,6 +39,13 @@ func (builder *DatasourceBuilder) Build() (Datasource, error) { return *builder.internal, nil } +// The apiserver version +func (builder *DatasourceBuilder) ApiVersion(apiVersion string) *DatasourceBuilder { + builder.internal.ApiVersion = &apiVersion + + return builder +} + // The datasource plugin type func (builder *DatasourceBuilder) Type(typeArg string) *DatasourceBuilder { builder.internal.Type = typeArg @@ -46,7 +53,7 @@ func (builder *DatasourceBuilder) Type(typeArg string) *DatasourceBuilder { return builder } -// Datasource UID +// Datasource UID (NOTE: name in k8s) func (builder *DatasourceBuilder) Uid(uid string) *DatasourceBuilder { builder.internal.Uid = &uid diff --git a/go/testdata/types_gen.go b/go/testdata/types_gen.go index 357dc96..0b42707 100644 --- a/go/testdata/types_gen.go +++ b/go/testdata/types_gen.go @@ -105,9 +105,11 @@ type CSVWave struct { } type Datasource struct { + // The apiserver version + ApiVersion *string `json:"apiVersion,omitempty"` // The datasource plugin type Type string `json:"type"` - // Datasource UID + // Datasource UID (NOTE: name in k8s) Uid *string `json:"uid,omitempty"` } diff --git a/jsonschema/alerting.jsonschema.json b/jsonschema/alerting.jsonschema.json index a7e2b0c..08c2bbc 100644 --- a/jsonschema/alerting.jsonschema.json +++ b/jsonschema/alerting.jsonschema.json @@ -210,7 +210,8 @@ "maxLength": 40 }, "updated": { - "type": "string" + "type": "string", + "format": "date-time" } } }, diff --git a/jsonschema/common.jsonschema.json b/jsonschema/common.jsonschema.json index bd71a75..9a0163c 100644 --- a/jsonschema/common.jsonschema.json +++ b/jsonschema/common.jsonschema.json @@ -757,6 +757,14 @@ ], "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "FieldTextAlignment": { "enum": [ "auto", diff --git a/jsonschema/dashboard.jsonschema.json b/jsonschema/dashboard.jsonschema.json index 84da7c3..9165e9b 100644 --- a/jsonschema/dashboard.jsonschema.json +++ b/jsonschema/dashboard.jsonschema.json @@ -977,6 +977,7 @@ "properties": { "created": { "type": "string", + "format": "date-time", "description": "Time when the snapshot was created" }, "expires": { @@ -1013,6 +1014,7 @@ }, "updated": { "type": "string", + "format": "date-time", "description": "last time when the snapshot was updated" }, "url": { diff --git a/jsonschema/expr.jsonschema.json b/jsonschema/expr.jsonschema.json index a307493..208039b 100644 --- a/jsonschema/expr.jsonschema.json +++ b/jsonschema/expr.jsonschema.json @@ -40,6 +40,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -47,7 +51,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -158,6 +162,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -165,7 +173,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -310,6 +318,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -317,7 +329,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -528,6 +540,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -535,7 +551,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -708,6 +724,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -715,7 +735,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -825,6 +845,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -832,7 +856,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" diff --git a/jsonschema/librarypanel.jsonschema.json b/jsonschema/librarypanel.jsonschema.json index d439ce9..fa2840b 100644 --- a/jsonschema/librarypanel.jsonschema.json +++ b/jsonschema/librarypanel.jsonschema.json @@ -203,10 +203,12 @@ "type": "integer" }, "created": { - "type": "string" + "type": "string", + "format": "date-time" }, "updated": { - "type": "string" + "type": "string", + "format": "date-time" }, "createdBy": { "$ref": "#/definitions/LibraryElementDTOMetaUser" diff --git a/jsonschema/stat.jsonschema.json b/jsonschema/stat.jsonschema.json index 0fa8b86..eca0e1c 100644 --- a/jsonschema/stat.jsonschema.json +++ b/jsonschema/stat.jsonschema.json @@ -10,8 +10,9 @@ "justifyMode", "textMode", "wideLayout", - "reduceOptions", "showPercentChange", + "reduceOptions", + "percentChangeColorMode", "orientation" ], "properties": { @@ -35,15 +36,19 @@ "type": "boolean", "default": true }, + "showPercentChange": { + "type": "boolean", + "default": false + }, "reduceOptions": { "$ref": "#/definitions/ReduceDataOptions" }, "text": { "$ref": "#/definitions/VizTextDisplayOptions" }, - "showPercentChange": { - "type": "boolean", - "default": false + "percentChangeColorMode": { + "$ref": "#/definitions/PercentChangeColorMode", + "default": "standard" }, "orientation": { "$ref": "#/definitions/VizOrientation" @@ -128,6 +133,14 @@ }, "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "VizOrientation": { "enum": [ "auto", diff --git a/jsonschema/testdata.jsonschema.json b/jsonschema/testdata.jsonschema.json index 556a7ab..decaf42 100644 --- a/jsonschema/testdata.jsonschema.json +++ b/jsonschema/testdata.jsonschema.json @@ -197,13 +197,17 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "description": "The datasource plugin type" }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } } }, diff --git a/openapi/alerting.openapi.json b/openapi/alerting.openapi.json index 0260592..0b1a7bf 100644 --- a/openapi/alerting.openapi.json +++ b/openapi/alerting.openapi.json @@ -218,7 +218,8 @@ "maxLength": 40 }, "updated": { - "type": "string" + "type": "string", + "format": "date-time" } } }, diff --git a/openapi/common.openapi.json b/openapi/common.openapi.json index e8bea4a..f03e8df 100644 --- a/openapi/common.openapi.json +++ b/openapi/common.openapi.json @@ -765,6 +765,14 @@ ], "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "FieldTextAlignment": { "enum": [ "auto", diff --git a/openapi/dashboard.openapi.json b/openapi/dashboard.openapi.json index a95f7a8..daf7a9a 100644 --- a/openapi/dashboard.openapi.json +++ b/openapi/dashboard.openapi.json @@ -984,6 +984,7 @@ "properties": { "created": { "type": "string", + "format": "date-time", "description": "Time when the snapshot was created" }, "expires": { @@ -1020,6 +1021,7 @@ }, "updated": { "type": "string", + "format": "date-time", "description": "last time when the snapshot was updated" }, "url": { diff --git a/openapi/expr.openapi.json b/openapi/expr.openapi.json index 72eedcd..5c64694 100644 --- a/openapi/expr.openapi.json +++ b/openapi/expr.openapi.json @@ -48,6 +48,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -55,7 +59,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -166,6 +170,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -173,7 +181,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -318,6 +326,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -325,7 +337,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -536,6 +548,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -543,7 +559,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -716,6 +732,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -723,7 +743,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" @@ -833,6 +853,10 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "const": "__expr__", @@ -840,7 +864,7 @@ }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } }, "description": "The datasource" diff --git a/openapi/librarypanel.openapi.json b/openapi/librarypanel.openapi.json index 15fce61..1e2f90e 100644 --- a/openapi/librarypanel.openapi.json +++ b/openapi/librarypanel.openapi.json @@ -210,10 +210,12 @@ "type": "integer" }, "created": { - "type": "string" + "type": "string", + "format": "date-time" }, "updated": { - "type": "string" + "type": "string", + "format": "date-time" }, "createdBy": { "$ref": "#/components/schemas/LibraryElementDTOMetaUser" diff --git a/openapi/stat.openapi.json b/openapi/stat.openapi.json index 46ade6a..11291c3 100644 --- a/openapi/stat.openapi.json +++ b/openapi/stat.openapi.json @@ -19,8 +19,9 @@ "justifyMode", "textMode", "wideLayout", - "reduceOptions", "showPercentChange", + "reduceOptions", + "percentChangeColorMode", "orientation" ], "properties": { @@ -44,15 +45,19 @@ "type": "boolean", "default": true }, + "showPercentChange": { + "type": "boolean", + "default": false + }, "reduceOptions": { "$ref": "#/components/schemas/ReduceDataOptions" }, "text": { "$ref": "#/components/schemas/VizTextDisplayOptions" }, - "showPercentChange": { - "type": "boolean", - "default": false + "percentChangeColorMode": { + "$ref": "#/components/schemas/PercentChangeColorMode", + "default": "standard" }, "orientation": { "$ref": "#/components/schemas/VizOrientation" @@ -137,6 +142,14 @@ }, "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "VizOrientation": { "enum": [ "auto", diff --git a/openapi/testdata.openapi.json b/openapi/testdata.openapi.json index ac9ed8e..c405c5a 100644 --- a/openapi/testdata.openapi.json +++ b/openapi/testdata.openapi.json @@ -206,13 +206,17 @@ "type" ], "properties": { + "apiVersion": { + "type": "string", + "description": "The apiserver version" + }, "type": { "type": "string", "description": "The datasource plugin type" }, "uid": { "type": "string", - "description": "Datasource UID" + "description": "Datasource UID (NOTE: name in k8s)" } } }, diff --git a/python/grafana_foundation_sdk/builders/expr.py b/python/grafana_foundation_sdk/builders/expr.py index 980d11b..e14e7f4 100644 --- a/python/grafana_foundation_sdk/builders/expr.py +++ b/python/grafana_foundation_sdk/builders/expr.py @@ -718,9 +718,18 @@ class ExprTypeMathDatasource(cogbuilder.Builder[expr.ExprTypeMathDatasource]): def build(self) -> expr.ExprTypeMathDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid @@ -816,9 +825,18 @@ class ExprTypeReduceDatasource(cogbuilder.Builder[expr.ExprTypeReduceDatasource] def build(self) -> expr.ExprTypeReduceDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid @@ -945,9 +963,18 @@ class ExprTypeResampleDatasource(cogbuilder.Builder[expr.ExprTypeResampleDatasou def build(self) -> expr.ExprTypeResampleDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid @@ -1146,9 +1173,18 @@ class ExprTypeClassicConditionsDatasource(cogbuilder.Builder[expr.ExprTypeClassi def build(self) -> expr.ExprTypeClassicConditionsDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid @@ -1319,9 +1355,18 @@ class ExprTypeThresholdDatasource(cogbuilder.Builder[expr.ExprTypeThresholdDatas def build(self) -> expr.ExprTypeThresholdDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid @@ -1417,9 +1462,18 @@ class ExprTypeSqlDatasource(cogbuilder.Builder[expr.ExprTypeSqlDatasource]): def build(self) -> expr.ExprTypeSqlDatasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid diff --git a/python/grafana_foundation_sdk/builders/stat.py b/python/grafana_foundation_sdk/builders/stat.py index cf3b22b..cfac2fb 100644 --- a/python/grafana_foundation_sdk/builders/stat.py +++ b/python/grafana_foundation_sdk/builders/stat.py @@ -498,6 +498,14 @@ class Panel(cogbuilder.Builder[dashboard.Panel]): return self + def show_percent_change(self, show_percent_change: bool) -> typing.Self: + if self._internal.options is None: + self._internal.options = stat.Options() + assert isinstance(self._internal.options, stat.Options) + self._internal.options.show_percent_change = show_percent_change + + return self + def reduce_options(self, reduce_options: cogbuilder.Builder[common.ReduceDataOptions]) -> typing.Self: if self._internal.options is None: self._internal.options = stat.Options() @@ -516,11 +524,11 @@ class Panel(cogbuilder.Builder[dashboard.Panel]): return self - def show_percent_change(self, show_percent_change: bool) -> typing.Self: + def percent_change_color_mode(self, percent_change_color_mode: common.PercentChangeColorMode) -> typing.Self: if self._internal.options is None: self._internal.options = stat.Options() assert isinstance(self._internal.options, stat.Options) - self._internal.options.show_percent_change = show_percent_change + self._internal.options.percent_change_color_mode = percent_change_color_mode return self diff --git a/python/grafana_foundation_sdk/builders/testdata.py b/python/grafana_foundation_sdk/builders/testdata.py index 4bc758f..d0e0a6c 100644 --- a/python/grafana_foundation_sdk/builders/testdata.py +++ b/python/grafana_foundation_sdk/builders/testdata.py @@ -336,6 +336,15 @@ class Datasource(cogbuilder.Builder[testdata.Datasource]): def build(self) -> testdata.Datasource: return self._internal + def api_version(self, api_version: str) -> typing.Self: + """ + The apiserver version + """ + + self._internal.api_version = api_version + + return self + def type_val(self, type_val: str) -> typing.Self: """ The datasource plugin type @@ -347,7 +356,7 @@ class Datasource(cogbuilder.Builder[testdata.Datasource]): def uid(self, uid: str) -> typing.Self: """ - Datasource UID + Datasource UID (NOTE: name in k8s) """ self._internal.uid = uid diff --git a/python/grafana_foundation_sdk/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py index 09cfc0d..38e041d 100644 --- a/python/grafana_foundation_sdk/cog/plugins.py +++ b/python/grafana_foundation_sdk/cog/plugins.py @@ -1,38 +1,38 @@ # Code generated - EDITING IS FUTILE. DO NOT EDIT. -from ..models import statetimeline -from ..models import barchart -from ..models import heatmap +from ..models import xychart +from ..models import table +from ..models import azuremonitor +from ..models import stat +from ..models import timeseries +from ..models import annotationslist +from ..models import candlestick +from ..models import debug from ..models import loki +from ..models import text from ..models import parca -from ..models import statushistory +from ..models import cloudwatch +from ..models import trend +from ..models import elasticsearch +from ..models import grafanapyroscope +from ..models import statetimeline from ..models import tempo -from ..models import news from ..models import canvas from ..models import dashboardlist -from ..models import debug -from ..models import grafanapyroscope -from ..models import stat -from ..models import elasticsearch +from ..models import datagrid +from ..models import gauge +from ..models import heatmap +from ..models import histogram from ..models import nodegraph -from ..models import trend +from ..models import news +from ..models import barchart from ..models import bargauge -from ..models import cloudwatch -from ..models import gauge +from ..models import geomap from ..models import googlecloudmonitoring from ..models import logs -from ..models import table -from ..models import annotationslist -from ..models import azuremonitor -from ..models import datagrid -from ..models import geomap -from ..models import text -from ..models import candlestick -from ..models import histogram from ..models import piechart +from ..models import statushistory from ..models import prometheus -from ..models import timeseries -from ..models import xychart from ..models import expr from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/cloudwatch.py b/python/grafana_foundation_sdk/models/cloudwatch.py index 761fcb8..fac0fa9 100644 --- a/python/grafana_foundation_sdk/models/cloudwatch.py +++ b/python/grafana_foundation_sdk/models/cloudwatch.py @@ -894,7 +894,7 @@ CloudWatchQuery: typing.TypeAlias = typing.Union['CloudWatchMetricsQuery', 'Clou def variant_config() -> cogruntime.DataqueryConfig: - decoding_map: dict[str, typing.Union[typing.Type[CloudWatchMetricsQuery], typing.Type[CloudWatchLogsQuery], typing.Type[CloudWatchAnnotationQuery]]] = {"Metrics": CloudWatchMetricsQuery, "Logs": CloudWatchLogsQuery, "Annotations": CloudWatchAnnotationQuery} + decoding_map: dict[str, typing.Union[typing.Type[CloudWatchAnnotationQuery], typing.Type[CloudWatchMetricsQuery], typing.Type[CloudWatchLogsQuery]]] = {"Annotations": CloudWatchAnnotationQuery, "Metrics": CloudWatchMetricsQuery, "Logs": CloudWatchLogsQuery} return cogruntime.DataqueryConfig( identifier="cloudwatch", from_json_hook=lambda data: decoding_map[data["queryMode"]].from_json(data), diff --git a/python/grafana_foundation_sdk/models/common.py b/python/grafana_foundation_sdk/models/common.py index 56a8688..b7df805 100644 --- a/python/grafana_foundation_sdk/models/common.py +++ b/python/grafana_foundation_sdk/models/common.py @@ -1333,6 +1333,16 @@ class BigValueTextMode(enum.StrEnum): NONE = "none" +class PercentChangeColorMode(enum.StrEnum): + """ + TODO docs + """ + + STANDARD = "standard" + INVERTED = "inverted" + SAME_AS_VALUE = "same_as_value" + + class FieldTextAlignment(enum.StrEnum): """ TODO -- should not be table specific! diff --git a/python/grafana_foundation_sdk/models/expr.py b/python/grafana_foundation_sdk/models/expr.py index 395a5a1..5dd1737 100644 --- a/python/grafana_foundation_sdk/models/expr.py +++ b/python/grafana_foundation_sdk/models/expr.py @@ -9,7 +9,7 @@ Expr: typing.TypeAlias = typing.Union['TypeMath', 'TypeReduce', 'TypeResample', def variant_config() -> cogruntime.DataqueryConfig: - decoding_map: dict[str, typing.Union[typing.Type[TypeReduce], typing.Type[TypeResample], typing.Type[TypeClassicConditions], typing.Type[TypeThreshold], typing.Type[TypeSql], typing.Type[TypeMath]]] = {"reduce": TypeReduce, "resample": TypeResample, "classic_conditions": TypeClassicConditions, "threshold": TypeThreshold, "sql": TypeSql, "math": TypeMath} + decoding_map: dict[str, typing.Union[typing.Type[TypeMath], typing.Type[TypeReduce], typing.Type[TypeResample], typing.Type[TypeClassicConditions], typing.Type[TypeThreshold], typing.Type[TypeSql]]] = {"math": TypeMath, "reduce": TypeReduce, "resample": TypeResample, "classic_conditions": TypeClassicConditions, "threshold": TypeThreshold, "sql": TypeSql} return cogruntime.DataqueryConfig( identifier="__expr__", from_json_hook=lambda data: decoding_map[data["type"]].from_json(data), @@ -663,12 +663,15 @@ class TypeMathOrTypeReduceOrTypeResampleOrTypeClassicConditionsOrTypeThresholdOr class ExprTypeMathDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -676,6 +679,8 @@ class ExprTypeMathDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -684,6 +689,8 @@ class ExprTypeMathDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] @@ -770,12 +777,15 @@ class ExprTypeMathTimeRange: class ExprTypeReduceDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -783,6 +793,8 @@ class ExprTypeReduceDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -791,6 +803,8 @@ class ExprTypeReduceDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] @@ -910,12 +924,15 @@ class ExprTypeReduceTimeRange: class ExprTypeResampleDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -923,6 +940,8 @@ class ExprTypeResampleDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -931,6 +950,8 @@ class ExprTypeResampleDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] @@ -1148,12 +1169,15 @@ class ExprTypeClassicConditionsConditions: class ExprTypeClassicConditionsDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -1161,6 +1185,8 @@ class ExprTypeClassicConditionsDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -1169,6 +1195,8 @@ class ExprTypeClassicConditionsDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] @@ -1345,12 +1373,15 @@ class ExprTypeThresholdConditions: class ExprTypeThresholdDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -1358,6 +1389,8 @@ class ExprTypeThresholdDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -1366,6 +1399,8 @@ class ExprTypeThresholdDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] @@ -1452,12 +1487,15 @@ class ExprTypeThresholdTimeRange: class ExprTypeSqlDatasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: typing.Literal["__expr__"] - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = "__expr__" self.uid = uid @@ -1465,6 +1503,8 @@ class ExprTypeSqlDatasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -1473,6 +1513,8 @@ class ExprTypeSqlDatasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "uid" in data: args["uid"] = data["uid"] diff --git a/python/grafana_foundation_sdk/models/rolebinding.py b/python/grafana_foundation_sdk/models/rolebinding.py index eafa911..e8f302c 100644 --- a/python/grafana_foundation_sdk/models/rolebinding.py +++ b/python/grafana_foundation_sdk/models/rolebinding.py @@ -25,7 +25,7 @@ class RoleBinding: args: dict[str, typing.Any] = {} if "role" in data: - decoding_map: dict[str, typing.Union[typing.Type[CustomRoleRef], typing.Type[BuiltinRoleRef]]] = {"Role": CustomRoleRef, "BuiltinRole": BuiltinRoleRef} + decoding_map: dict[str, typing.Union[typing.Type[BuiltinRoleRef], typing.Type[CustomRoleRef]]] = {"BuiltinRole": BuiltinRoleRef, "Role": CustomRoleRef} args["role"] = decoding_map[data["role"]["kind"]].from_json(data["role"]) if "subject" in data: args["subject"] = RoleBindingSubject.from_json(data["subject"]) diff --git a/python/grafana_foundation_sdk/models/stat.py b/python/grafana_foundation_sdk/models/stat.py index a713ab1..eb7a4ed 100644 --- a/python/grafana_foundation_sdk/models/stat.py +++ b/python/grafana_foundation_sdk/models/stat.py @@ -11,20 +11,22 @@ class Options: justify_mode: common.BigValueJustifyMode text_mode: common.BigValueTextMode wide_layout: bool + show_percent_change: bool reduce_options: common.ReduceDataOptions text: typing.Optional[common.VizTextDisplayOptions] - show_percent_change: bool + percent_change_color_mode: common.PercentChangeColorMode orientation: common.VizOrientation - def __init__(self, graph_mode: typing.Optional[common.BigValueGraphMode] = None, color_mode: typing.Optional[common.BigValueColorMode] = None, justify_mode: typing.Optional[common.BigValueJustifyMode] = None, text_mode: typing.Optional[common.BigValueTextMode] = None, wide_layout: bool = True, reduce_options: typing.Optional[common.ReduceDataOptions] = None, text: typing.Optional[common.VizTextDisplayOptions] = None, show_percent_change: bool = False, orientation: typing.Optional[common.VizOrientation] = None): + def __init__(self, graph_mode: typing.Optional[common.BigValueGraphMode] = None, color_mode: typing.Optional[common.BigValueColorMode] = None, justify_mode: typing.Optional[common.BigValueJustifyMode] = None, text_mode: typing.Optional[common.BigValueTextMode] = None, wide_layout: bool = True, show_percent_change: bool = False, reduce_options: typing.Optional[common.ReduceDataOptions] = None, text: typing.Optional[common.VizTextDisplayOptions] = None, percent_change_color_mode: typing.Optional[common.PercentChangeColorMode] = None, orientation: typing.Optional[common.VizOrientation] = None): self.graph_mode = graph_mode if graph_mode is not None else common.BigValueGraphMode.AREA self.color_mode = color_mode if color_mode is not None else common.BigValueColorMode.VALUE self.justify_mode = justify_mode if justify_mode is not None else common.BigValueJustifyMode.AUTO self.text_mode = text_mode if text_mode is not None else common.BigValueTextMode.AUTO self.wide_layout = wide_layout + self.show_percent_change = show_percent_change self.reduce_options = reduce_options if reduce_options is not None else common.ReduceDataOptions() self.text = text - self.show_percent_change = show_percent_change + self.percent_change_color_mode = percent_change_color_mode if percent_change_color_mode is not None else common.PercentChangeColorMode.STANDARD self.orientation = orientation if orientation is not None else common.VizOrientation.AUTO def to_json(self) -> dict[str, object]: @@ -34,8 +36,9 @@ class Options: "justifyMode": self.justify_mode, "textMode": self.text_mode, "wideLayout": self.wide_layout, - "reduceOptions": self.reduce_options, "showPercentChange": self.show_percent_change, + "reduceOptions": self.reduce_options, + "percentChangeColorMode": self.percent_change_color_mode, "orientation": self.orientation, } if self.text is not None: @@ -56,12 +59,14 @@ class Options: args["text_mode"] = data["textMode"] if "wideLayout" in data: args["wide_layout"] = data["wideLayout"] + if "showPercentChange" in data: + args["show_percent_change"] = data["showPercentChange"] if "reduceOptions" in data: args["reduce_options"] = common.ReduceDataOptions.from_json(data["reduceOptions"]) if "text" in data: args["text"] = common.VizTextDisplayOptions.from_json(data["text"]) - if "showPercentChange" in data: - args["show_percent_change"] = data["showPercentChange"] + if "percentChangeColorMode" in data: + args["percent_change_color_mode"] = data["percentChangeColorMode"] if "orientation" in data: args["orientation"] = data["orientation"] diff --git a/python/grafana_foundation_sdk/models/testdata.py b/python/grafana_foundation_sdk/models/testdata.py index 46620d3..1446318 100644 --- a/python/grafana_foundation_sdk/models/testdata.py +++ b/python/grafana_foundation_sdk/models/testdata.py @@ -341,12 +341,15 @@ class CSVWave: class Datasource: + # The apiserver version + api_version: typing.Optional[str] # The datasource plugin type type_val: str - # Datasource UID + # Datasource UID (NOTE: name in k8s) uid: typing.Optional[str] - def __init__(self, type_val: str = "", uid: typing.Optional[str] = None): + def __init__(self, api_version: typing.Optional[str] = None, type_val: str = "", uid: typing.Optional[str] = None): + self.api_version = api_version self.type_val = type_val self.uid = uid @@ -354,6 +357,8 @@ class Datasource: payload: dict[str, object] = { "type": self.type_val, } + if self.api_version is not None: + payload["apiVersion"] = self.api_version if self.uid is not None: payload["uid"] = self.uid return payload @@ -362,6 +367,8 @@ class Datasource: def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: args: dict[str, typing.Any] = {} + if "apiVersion" in data: + args["api_version"] = data["apiVersion"] if "type" in data: args["type_val"] = data["type"] if "uid" in data: diff --git a/python/pyproject.toml b/python/pyproject.toml index 25bd68c..c50c536 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ keywords = [ "traces", "metrics" ] -version = "1716541717!next" +version = "1716800663!next" dependencies = [] requires-python = ">=3.11" classifiers = [ diff --git a/typescript/package.json b/typescript/package.json index d462099..f29e01f 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@grafana/grafana-foundation-sdk", - "version": "next-cogv0.0.x.1716541717", + "version": "next-cogv0.0.x.1716800663", "description": "A set of tools, types and libraries for building and manipulating Grafana objects.", "keywords": [ "observability", diff --git a/typescript/src/common/types.gen.ts b/typescript/src/common/types.gen.ts index 5bfe0d4..b687b58 100644 --- a/typescript/src/common/types.gen.ts +++ b/typescript/src/common/types.gen.ts @@ -583,6 +583,15 @@ export enum BigValueTextMode { export const defaultBigValueTextMode = (): BigValueTextMode => (BigValueTextMode.Auto); +// TODO docs +export enum PercentChangeColorMode { + Standard = "standard", + Inverted = "inverted", + SameAsValue = "same_as_value", +} + +export const defaultPercentChangeColorMode = (): PercentChangeColorMode => (PercentChangeColorMode.Standard); + // TODO -- should not be table specific! // TODO docs export enum FieldTextAlignment { diff --git a/typescript/src/expr/typeClassicConditionsBuilder.gen.ts b/typescript/src/expr/typeClassicConditionsBuilder.gen.ts index 04d6638..64e7647 100644 --- a/typescript/src/expr/typeClassicConditionsBuilder.gen.ts +++ b/typescript/src/expr/typeClassicConditionsBuilder.gen.ts @@ -37,9 +37,11 @@ export class TypeClassicConditionsBuilder implements cog.Builder // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/typeMathBuilder.gen.ts b/typescript/src/expr/typeMathBuilder.gen.ts index 42330bb..17d6693 100644 --- a/typescript/src/expr/typeMathBuilder.gen.ts +++ b/typescript/src/expr/typeMathBuilder.gen.ts @@ -17,9 +17,11 @@ export class TypeMathBuilder implements cog.Builder { // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/typeReduceBuilder.gen.ts b/typescript/src/expr/typeReduceBuilder.gen.ts index 89e581b..a6b5be9 100644 --- a/typescript/src/expr/typeReduceBuilder.gen.ts +++ b/typescript/src/expr/typeReduceBuilder.gen.ts @@ -17,9 +17,11 @@ export class TypeReduceBuilder implements cog.Builder { // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/typeResampleBuilder.gen.ts b/typescript/src/expr/typeResampleBuilder.gen.ts index ae57065..660e999 100644 --- a/typescript/src/expr/typeResampleBuilder.gen.ts +++ b/typescript/src/expr/typeResampleBuilder.gen.ts @@ -17,9 +17,11 @@ export class TypeResampleBuilder implements cog.Builder { // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/typeSqlBuilder.gen.ts b/typescript/src/expr/typeSqlBuilder.gen.ts index 49b1027..622e556 100644 --- a/typescript/src/expr/typeSqlBuilder.gen.ts +++ b/typescript/src/expr/typeSqlBuilder.gen.ts @@ -17,9 +17,11 @@ export class TypeSqlBuilder implements cog.Builder { // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/typeThresholdBuilder.gen.ts b/typescript/src/expr/typeThresholdBuilder.gen.ts index eccfc14..9f1bc80 100644 --- a/typescript/src/expr/typeThresholdBuilder.gen.ts +++ b/typescript/src/expr/typeThresholdBuilder.gen.ts @@ -35,9 +35,11 @@ export class TypeThresholdBuilder implements cog.Builder { // The datasource datasource(datasource: { + // The apiserver version + apiVersion?: string; // The datasource plugin type type: "__expr__"; - // Datasource UID + // Datasource UID (NOTE: name in k8s) uid?: string; }): this { this.internal.datasource = datasource; diff --git a/typescript/src/expr/types.gen.ts b/typescript/src/expr/types.gen.ts index daf73c3..aec97b8 100644 --- a/typescript/src/expr/types.gen.ts +++ b/typescript/src/expr/types.gen.ts @@ -7,9 +7,11 @@ export const defaultExpr = (): expr => (defaultTypeMath()); export interface TypeMath { // The datasou...*[Comment body truncated]*