grafana / cog

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

JSON unmarshalling in PHP #479

Closed K-Phoen closed 4 months ago

K-Phoen commented 4 months ago

After some fighting, "fromArray" functions are now generated to unmarshal objects from JSON. Both phpstan and psalm seem happy-ish with the code currently generated.

Contributes to #470

github-actions[bot] commented 4 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/azuremonitor/azurelogsquery_builder_gen.go b/go/azuremonitor/azurelogsquery_builder_gen.go index 076f120..48a2d9a 100644 --- a/go/azuremonitor/azurelogsquery_builder_gen.go +++ b/go/azuremonitor/azurelogsquery_builder_gen.go @@ -75,6 +75,13 @@ func (builder *AzureLogsQueryBuilder) TimeColumn(timeColumn string) *AzureLogsQu return builder } +// If set to true the query will be run as a basic logs query +func (builder *AzureLogsQueryBuilder) BasicLogsQuery(basicLogsQuery bool) *AzureLogsQueryBuilder { + builder.internal.BasicLogsQuery = &basicLogsQuery + + return builder +} + // Workspace ID. This was removed in Grafana 8, but remains for backwards compat. func (builder *AzureLogsQueryBuilder) Workspace(workspace string) *AzureLogsQueryBuilder { builder.internal.Workspace = &workspace diff --git a/go/azuremonitor/azuremonitorquery_builder_gen.go b/go/azuremonitor/azuremonitorquery_builder_gen.go index 6affba5..5a912ac 100644 --- a/go/azuremonitor/azuremonitorquery_builder_gen.go +++ b/go/azuremonitor/azuremonitorquery_builder_gen.go @@ -152,6 +152,12 @@ func (builder *AzureMonitorQueryBuilder) Resource(resource string) *AzureMonitor return builder } +func (builder *AzureMonitorQueryBuilder) Region(region string) *AzureMonitorQueryBuilder { + builder.internal.Region = ®ion + + return builder +} + // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema @@ -162,10 +168,9 @@ func (builder *AzureMonitorQueryBuilder) Datasource(datasource any) *AzureMonito return builder } -// Azure Monitor query type. -// queryType: #AzureQueryType -func (builder *AzureMonitorQueryBuilder) Region(region string) *AzureMonitorQueryBuilder { - builder.internal.Region = ®ion +// Used only for exemplar queries from Prometheus +func (builder *AzureMonitorQueryBuilder) Query(query string) *AzureMonitorQueryBuilder { + builder.internal.Query = &query return builder } diff --git a/go/azuremonitor/types_gen.go b/go/azuremonitor/types_gen.go index 0e98f37..d795d9b 100644 --- a/go/azuremonitor/types_gen.go +++ b/go/azuremonitor/types_gen.go @@ -38,14 +38,14 @@ type AzureMonitorQuery struct { ResourceGroup *string `json:"resourceGroup,omitempty"` Namespace *string `json:"namespace,omitempty"` Resource *string `json:"resource,omitempty"` + Region *string `json:"region,omitempty"` // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema // TODO this shouldn't be unknown but DataSourceRef | null Datasource any `json:"datasource,omitempty"` - // Azure Monitor query type. - // queryType: #AzureQueryType - Region *string `json:"region,omitempty"` + // Used only for exemplar queries from Prometheus + Query *string `json:"query,omitempty"` } func (resource AzureMonitorQuery) ImplementsDataqueryVariant() {} @@ -81,6 +81,7 @@ const ( AzureQueryTypeWorkspacesQuery AzureQueryType = "Azure Workspaces" AzureQueryTypeLocationsQuery AzureQueryType = "Azure Regions" AzureQueryTypeGrafanaTemplateVariableFn AzureQueryType = "Grafana Template Variable Function" + AzureQueryTypeTraceExemplar AzureQueryType = "traceql" ) type AzureMetricQuery struct { @@ -136,6 +137,8 @@ type AzureLogsQuery struct { DashboardTime *bool `json:"dashboardTime,omitempty"` // If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated TimeColumn *string `json:"timeColumn,omitempty"` + // If set to true the query will be run as a basic logs query + BasicLogsQuery *bool `json:"basicLogsQuery,omitempty"` // Workspace ID. This was removed in Grafana 8, but remains for backwards compat. Workspace *string `json:"workspace,omitempty"` // @deprecated Use resources instead diff --git a/go/common/tableautocelloptions_builder_gen.go b/go/common/tableautocelloptions_builder_gen.go new file mode 100644 index 0000000..4177c9f --- /dev/null +++ b/go/common/tableautocelloptions_builder_gen.go @@ -0,0 +1,51 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package common + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TableAutoCellOptions] = (*TableAutoCellOptionsBuilder)(nil) + +// Auto mode table cell options +type TableAutoCellOptionsBuilder struct { + internal *TableAutoCellOptions + errors map[string]cog.BuildErrors +} + +func NewTableAutoCellOptionsBuilder() *TableAutoCellOptionsBuilder { + resource := &TableAutoCellOptions{} + builder := &TableAutoCellOptionsBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + builder.internal.Type = "auto" + + return builder +} + +func (builder *TableAutoCellOptionsBuilder) Build() (TableAutoCellOptions, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TableAutoCellOptions", err)...) + } + + if len(errs) != 0 { + return TableAutoCellOptions{}, errs + } + + return *builder.internal, nil +} + +func (builder *TableAutoCellOptionsBuilder) WrapText(wrapText bool) *TableAutoCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + +func (builder *TableAutoCellOptionsBuilder) applyDefaults() { +} diff --git a/go/common/tablecoloredbackgroundcelloptions_builder_gen.go b/go/common/tablecoloredbackgroundcelloptions_builder_gen.go index fd519e9..57fe80b 100644 --- a/go/common/tablecoloredbackgroundcelloptions_builder_gen.go +++ b/go/common/tablecoloredbackgroundcelloptions_builder_gen.go @@ -53,5 +53,11 @@ func (builder *TableColoredBackgroundCellOptionsBuilder) ApplyToRow(applyToRow b return builder } +func (builder *TableColoredBackgroundCellOptionsBuilder) WrapText(wrapText bool) *TableColoredBackgroundCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + func (builder *TableColoredBackgroundCellOptionsBuilder) applyDefaults() { } diff --git a/go/common/tablecolortextcelloptions_builder_gen.go b/go/common/tablecolortextcelloptions_builder_gen.go new file mode 100644 index 0000000..22edbc8 --- /dev/null +++ b/go/common/tablecolortextcelloptions_builder_gen.go @@ -0,0 +1,51 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package common + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TableColorTextCellOptions] = (*TableColorTextCellOptionsBuilder)(nil) + +// Colored text cell options +type TableColorTextCellOptionsBuilder struct { + internal *TableColorTextCellOptions + errors map[string]cog.BuildErrors +} + +func NewTableColorTextCellOptionsBuilder() *TableColorTextCellOptionsBuilder { + resource := &TableColorTextCellOptions{} + builder := &TableColorTextCellOptionsBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + builder.internal.Type = "color-text" + + return builder +} + +func (builder *TableColorTextCellOptionsBuilder) Build() (TableColorTextCellOptions, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TableColorTextCellOptions", err)...) + } + + if len(errs) != 0 { + return TableColorTextCellOptions{}, errs + } + + return *builder.internal, nil +} + +func (builder *TableColorTextCellOptionsBuilder) WrapText(wrapText bool) *TableColorTextCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + +func (builder *TableColorTextCellOptionsBuilder) applyDefaults() { +} diff --git a/go/common/types_gen.go b/go/common/types_gen.go index 6389be0..2a884e4 100644 --- a/go/common/types_gen.go +++ b/go/common/types_gen.go @@ -492,6 +492,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 @@ -688,12 +697,14 @@ type TableFooterOptions struct { // Auto mode table cell options type TableAutoCellOptions struct { - Type string `json:"type"` + Type string `json:"type"` + WrapText *bool `json:"wrapText,omitempty"` } // Colored text cell options type TableColorTextCellOptions struct { - Type string `json:"type"` + Type string `json:"type"` + WrapText *bool `json:"wrapText,omitempty"` } // Json view cell options @@ -764,15 +775,17 @@ type TableColoredBackgroundCellOptions struct { Type string `json:"type"` Mode *TableCellBackgroundDisplayMode `json:"mode,omitempty"` ApplyToRow *bool `json:"applyToRow,omitempty"` + WrapText *bool `json:"wrapText,omitempty"` } // Height of a table cell type TableCellHeight string const ( - TableCellHeightSm TableCellHeight = "sm" - TableCellHeightMd TableCellHeight = "md" - TableCellHeightLg TableCellHeight = "lg" + TableCellHeightSm TableCellHeight = "sm" + TableCellHeightMd TableCellHeight = "md" + TableCellHeightLg TableCellHeight = "lg" + TableCellHeightAuto TableCellHeight = "auto" ) // Table cell options. Each cell has a display mode diff --git a/go/heatmap/panel_builder_gen.go b/go/heatmap/panel_builder_gen.go index 9c62343..045788c 100644 --- a/go/heatmap/panel_builder_gen.go +++ b/go/heatmap/panel_builder_gen.go @@ -626,6 +626,16 @@ func (builder *PanelBuilder) ExemplarsColor(color string) *PanelBuilder { return builder } +// Controls which axis to allow selection on +func (builder *PanelBuilder) SelectionMode(selectionMode HeatmapSelectionMode) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).SelectionMode = &selectionMode + + return builder +} + func (builder *PanelBuilder) ScaleDistribution(scaleDistribution cog.Builder[common.ScaleDistributionConfig]) *PanelBuilder { if builder.internal.FieldConfig == nil { builder.internal.FieldConfig = &dashboard.FieldConfigSource{} @@ -678,4 +688,5 @@ func (builder *PanelBuilder) applyDefaults() { builder.ShowValue("auto") builder.CellGap(1) builder.ExemplarsColor("rgba(255,0,255,0.7)") + builder.SelectionMode("x") } diff --git a/go/heatmap/types_gen.go b/go/heatmap/types_gen.go index 7938615..583f986 100644 --- a/go/heatmap/types_gen.go +++ b/go/heatmap/types_gen.go @@ -25,6 +25,15 @@ const ( HeatmapColorScaleExponential HeatmapColorScale = "exponential" ) +// Controls which axis to allow selection on +type HeatmapSelectionMode string + +const ( + HeatmapSelectionModeX HeatmapSelectionMode = "x" + HeatmapSelectionModeY HeatmapSelectionMode = "y" + HeatmapSelectionModeXy HeatmapSelectionMode = "xy" +) + // Controls various color options type HeatmapColorOptions struct { // Sets the color mode @@ -152,6 +161,8 @@ type Options struct { Tooltip HeatmapTooltip `json:"tooltip"` // Controls exemplar options Exemplars ExemplarConfig `json:"exemplars"` + // Controls which axis to allow selection on + SelectionMode *HeatmapSelectionMode `json:"selectionMode,omitempty"` } type FieldConfig struct { diff --git a/go/logs/panel_builder_gen.go b/go/logs/panel_builder_gen.go index 0992db9..996aea5 100644 --- a/go/logs/panel_builder_gen.go +++ b/go/logs/panel_builder_gen.go @@ -496,6 +496,52 @@ func (builder *PanelBuilder) DedupStrategy(dedupStrategy common.LogsDedupStrateg return builder } +// TODO: figure out how to define callbacks +func (builder *PanelBuilder) OnClickFilterLabel(onClickFilterLabel any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickFilterLabel = &onClickFilterLabel + + return builder +} + +func (builder *PanelBuilder) OnClickFilterOutLabel(onClickFilterOutLabel any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickFilterOutLabel = &onClickFilterOutLabel + + return builder +} + +func (builder *PanelBuilder) IsFilterLabelActive(isFilterLabelActive any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).IsFilterLabelActive = &isFilterLabelActive + + return builder +} + +func (builder *PanelBuilder) OnClickFilterString(onClickFilterString any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickFilterString = &onClickFilterString + + return builder +} + +func (builder *PanelBuilder) OnClickFilterOutString(onClickFilterOutString any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickFilterOutString = &onClickFilterOutString + + return builder +} + func (builder *PanelBuilder) applyDefaults() { builder.Transparent(false) builder.Height(9) diff --git a/go/logs/types_gen.go b/go/logs/types_gen.go index ff9d3d3..d56ac58 100644 --- a/go/logs/types_gen.go +++ b/go/logs/types_gen.go @@ -19,6 +19,12 @@ type Options struct { EnableLogDetails bool `json:"enableLogDetails"` SortOrder common.LogsSortOrder `json:"sortOrder"` DedupStrategy common.LogsDedupStrategy `json:"dedupStrategy"` + // TODO: figure out how to define callbacks + OnClickFilterLabel any `json:"onClickFilterLabel,omitempty"` + OnClickFilterOutLabel any `json:"onClickFilterOutLabel,omitempty"` + IsFilterLabelActive any `json:"isFilterLabelActive,omitempty"` + OnClickFilterString any `json:"onClickFilterString,omitempty"` + OnClickFilterOutString any `json:"onClickFilterOutString,omitempty"` } func VariantConfig() cogvariants.PanelcfgConfig { 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 dacf902..5f75c28 100644 --- a/go/stat/types_gen.go +++ b/go/stat/types_gen.go @@ -10,15 +10,16 @@ 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"` } func VariantConfig() cogvariants.PanelcfgConfig { diff --git a/go/tempo/tempoquery_builder_gen.go b/go/tempo/tempoquery_builder_gen.go index 95b85a8..6b37308 100644 --- a/go/tempo/tempoquery_builder_gen.go +++ b/go/tempo/tempoquery_builder_gen.go @@ -165,6 +165,13 @@ func (builder *TempoQueryBuilder) GroupBy(groupBy []cog.Builder[TraceqlFilter]) return builder } +// The type of the table that is used to display the search results +func (builder *TempoQueryBuilder) TableType(tableType SearchTableType) *TempoQueryBuilder { + builder.internal.TableType = &tableType + + return builder +} + // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema @@ -175,9 +182,9 @@ func (builder *TempoQueryBuilder) Datasource(datasource any) *TempoQueryBuilder return builder } -// The type of the table that is used to display the search results -func (builder *TempoQueryBuilder) TableType(tableType SearchTableType) *TempoQueryBuilder { - builder.internal.TableType = &tableType +// For metric queries, the step size to use +func (builder *TempoQueryBuilder) Step(step string) *TempoQueryBuilder { + builder.internal.Step = &step return builder } diff --git a/go/tempo/types_gen.go b/go/tempo/types_gen.go index 0025151..0778771 100644 --- a/go/tempo/types_gen.go +++ b/go/tempo/types_gen.go @@ -43,13 +43,15 @@ type TempoQuery struct { Filters []TraceqlFilter `json:"filters"` // Filters that are used to query the metrics summary GroupBy []TraceqlFilter `json:"groupBy,omitempty"` + // The type of the table that is used to display the search results + TableType *SearchTableType `json:"tableType,omitempty"` // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema // TODO this shouldn't be unknown but DataSourceRef | null Datasource any `json:"datasource,omitempty"` - // The type of the table that is used to display the search results - TableType *SearchTableType `json:"tableType,omitempty"` + // For metric queries, the step size to use + Step *string `json:"step,omitempty"` } func (resource TempoQuery) ImplementsDataqueryVariant() {} diff --git a/jsonschema/azuremonitor.jsonschema.json b/jsonschema/azuremonitor.jsonschema.json index d2d343e..983c6d1 100644 --- a/jsonschema/azuremonitor.jsonschema.json +++ b/jsonschema/azuremonitor.jsonschema.json @@ -61,14 +61,17 @@ "resource": { "type": "string" }, + "region": { + "type": "string" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "region": { + "query": { "type": "string", - "description": "Azure Monitor query type.\nqueryType: #AzureQueryType" + "description": "Used only for exemplar queries from Prometheus" } } }, @@ -85,7 +88,8 @@ "Azure Metric Names", "Azure Workspaces", "Azure Regions", - "Grafana Template Variable Function" + "Grafana Template Variable Function", + "traceql" ], "description": "Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated" }, @@ -203,6 +207,10 @@ "type": "string", "description": "If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated" }, + "basicLogsQuery": { + "type": "boolean", + "description": "If set to true the query will be run as a basic logs query" + }, "workspace": { "type": "string", "description": "Workspace ID. This was removed in Grafana 8, but remains for backwards compat." diff --git a/jsonschema/common.jsonschema.json b/jsonschema/common.jsonschema.json index bd71a75..e5c63ca 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", @@ -1115,6 +1123,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -1129,6 +1140,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" @@ -1339,6 +1353,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -1347,7 +1364,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -1555,17 +1573,7 @@ "description": "Field options for each field within a table (e.g 10, \"The String\", 64.20, etc.)\nGenerally defines alignment, filtering capabilties, display options, etc." }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/definitions/TimeZoneUtc" - }, - { - "$ref": "#/definitions/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" } } diff --git a/jsonschema/dashboard.jsonschema.json b/jsonschema/dashboard.jsonschema.json index 35d128c..e220ac1 100644 --- a/jsonschema/dashboard.jsonschema.json +++ b/jsonschema/dashboard.jsonschema.json @@ -101,7 +101,7 @@ "schemaVersion": { "type": "integer", "description": "Version of the JSON schema, incremented each time a Grafana update brings\nchanges to said schema.", - "default": 36 + "default": 39 }, "version": { "type": "integer", diff --git a/jsonschema/heatmap.jsonschema.json b/jsonschema/heatmap.jsonschema.json index a0e8d5e..ee7a168 100644 --- a/jsonschema/heatmap.jsonschema.json +++ b/jsonschema/heatmap.jsonschema.json @@ -15,6 +15,14 @@ ], "description": "Controls the color scale of the heatmap" }, + "HeatmapSelectionMode": { + "enum": [ + "x", + "y", + "xy" + ], + "description": "Controls which axis to allow selection on" + }, "HeatmapColorOptions": { "type": "object", "additionalProperties": false, @@ -308,6 +316,11 @@ "default": { "color": "rgba(255,0,255,0.7)" } + }, + "selectionMode": { + "$ref": "#/definitions/HeatmapSelectionMode", + "description": "Controls which axis to allow selection on", + "default": "x" } } }, diff --git a/jsonschema/logs.jsonschema.json b/jsonschema/logs.jsonschema.json index b711c79..bcf9764 100644 --- a/jsonschema/logs.jsonschema.json +++ b/jsonschema/logs.jsonschema.json @@ -42,6 +42,27 @@ }, "dedupStrategy": { "$ref": "#/definitions/LogsDedupStrategy" + }, + "onClickFilterLabel": { + "type": "object", + "additionalProperties": {}, + "description": "TODO: figure out how to define callbacks" + }, + "onClickFilterOutLabel": { + "type": "object", + "additionalProperties": {} + }, + "isFilterLabelActive": { + "type": "object", + "additionalProperties": {} + }, + "onClickFilterString": { + "type": "object", + "additionalProperties": {} + }, + "onClickFilterOutString": { + "type": "object", + "additionalProperties": {} } } }, 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/statetimeline.jsonschema.json b/jsonschema/statetimeline.jsonschema.json index e665a83..7547899 100644 --- a/jsonschema/statetimeline.jsonschema.json +++ b/jsonschema/statetimeline.jsonschema.json @@ -143,17 +143,7 @@ "description": "TODO docs" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/definitions/TimeZoneUtc" - }, - { - "$ref": "#/definitions/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "TimelineValueAlignment": { @@ -215,16 +205,6 @@ "none" ], "description": "TODO docs" - }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" } } } \ No newline at end of file diff --git a/jsonschema/statushistory.jsonschema.json b/jsonschema/statushistory.jsonschema.json index 8ddd3b8..c72f94c 100644 --- a/jsonschema/statushistory.jsonschema.json +++ b/jsonschema/statushistory.jsonschema.json @@ -140,17 +140,7 @@ "description": "TODO docs" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/definitions/TimeZoneUtc" - }, - { - "$ref": "#/definitions/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "HideSeriesConfig": { @@ -204,16 +194,6 @@ "none" ], "description": "TODO docs" - }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" } } } \ No newline at end of file diff --git a/jsonschema/table.jsonschema.json b/jsonschema/table.jsonschema.json index 09387da..4ac0b57 100644 --- a/jsonschema/table.jsonschema.json +++ b/jsonschema/table.jsonschema.json @@ -105,7 +105,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -218,6 +219,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -386,6 +390,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -400,6 +407,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" diff --git a/jsonschema/tempo.jsonschema.json b/jsonschema/tempo.jsonschema.json index 6aec577..de1fabf 100644 --- a/jsonschema/tempo.jsonschema.json +++ b/jsonschema/tempo.jsonschema.json @@ -84,14 +84,18 @@ }, "description": "Filters that are used to query the metrics summary" }, + "tableType": { + "$ref": "#/definitions/SearchTableType", + "description": "The type of the table that is used to display the search results" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "tableType": { - "$ref": "#/definitions/SearchTableType", - "description": "The type of the table that is used to display the search results" + "step": { + "type": "string", + "description": "For metric queries, the step size to use" } } }, diff --git a/jsonschema/timeseries.jsonschema.json b/jsonschema/timeseries.jsonschema.json index 8fdde5f..f455e01 100644 --- a/jsonschema/timeseries.jsonschema.json +++ b/jsonschema/timeseries.jsonschema.json @@ -35,17 +35,7 @@ "$ref": "#/definitions/GraphFieldConfig" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/definitions/TimeZoneUtc" - }, - { - "$ref": "#/definitions/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "VizLegendOptions": { @@ -243,16 +233,6 @@ }, "description": "TODO docs" }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" - }, "LegendDisplayMode": { "enum": [ "list", diff --git a/openapi/azuremonitor.openapi.json b/openapi/azuremonitor.openapi.json index 89bfca5..571ef1a 100644 --- a/openapi/azuremonitor.openapi.json +++ b/openapi/azuremonitor.openapi.json @@ -70,14 +70,17 @@ "resource": { "type": "string" }, + "region": { + "type": "string" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "region": { + "query": { "type": "string", - "description": "Azure Monitor query type.\nqueryType: #AzureQueryType" + "description": "Used only for exemplar queries from Prometheus" } } }, @@ -94,7 +97,8 @@ "Azure Metric Names", "Azure Workspaces", "Azure Regions", - "Grafana Template Variable Function" + "Grafana Template Variable Function", + "traceql" ], "description": "Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated" }, @@ -212,6 +216,10 @@ "type": "string", "description": "If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated" }, + "basicLogsQuery": { + "type": "boolean", + "description": "If set to true the query will be run as a basic logs query" + }, "workspace": { "type": "string", "description": "Workspace ID. This was removed in Grafana 8, but remains for backwards compat." diff --git a/openapi/common.openapi.json b/openapi/common.openapi.json index e8bea4a..91f58f0 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", @@ -1123,6 +1131,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -1137,6 +1148,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" @@ -1347,6 +1361,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -1355,7 +1372,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -1563,17 +1581,7 @@ "description": "Field options for each field within a table (e.g 10, \"The String\", 64.20, etc.)\nGenerally defines alignment, filtering capabilties, display options, etc." }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/components/schemas/TimeZoneUtc" - }, - { - "$ref": "#/components/schemas/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" } } diff --git a/openapi/dashboard.openapi.json b/openapi/dashboard.openapi.json index bcc296c..3a9a83f 100644 --- a/openapi/dashboard.openapi.json +++ b/openapi/dashboard.openapi.json @@ -108,7 +108,7 @@ "schemaVersion": { "type": "integer", "description": "Version of the JSON schema, incremented each time a Grafana update brings\nchanges to said schema.", - "default": 36 + "default": 39 }, "version": { "type": "integer", diff --git a/openapi/heatmap.openapi.json b/openapi/heatmap.openapi.json index 80cb0b9..b6d4cb4 100644 --- a/openapi/heatmap.openapi.json +++ b/openapi/heatmap.openapi.json @@ -24,6 +24,14 @@ ], "description": "Controls the color scale of the heatmap" }, + "HeatmapSelectionMode": { + "enum": [ + "x", + "y", + "xy" + ], + "description": "Controls which axis to allow selection on" + }, "HeatmapColorOptions": { "type": "object", "additionalProperties": false, @@ -317,6 +325,11 @@ "default": { "color": "rgba(255,0,255,0.7)" } + }, + "selectionMode": { + "$ref": "#/components/schemas/HeatmapSelectionMode", + "description": "Controls which axis to allow selection on", + "default": "x" } } }, diff --git a/openapi/logs.openapi.json b/openapi/logs.openapi.json index b729f0d..bc26d8e 100644 --- a/openapi/logs.openapi.json +++ b/openapi/logs.openapi.json @@ -51,6 +51,27 @@ }, "dedupStrategy": { "$ref": "#/components/schemas/LogsDedupStrategy" + }, + "onClickFilterLabel": { + "type": "object", + "additionalProperties": {}, + "description": "TODO: figure out how to define callbacks" + }, + "onClickFilterOutLabel": { + "type": "object", + "additionalProperties": {} + }, + "isFilterLabelActive": { + "type": "object", + "additionalProperties": {} + }, + "onClickFilterString": { + "type": "object", + "additionalProperties": {} + }, + "onClickFilterOutString": { + "type": "object", + "additionalProperties": {} } } }, 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/statetimeline.openapi.json b/openapi/statetimeline.openapi.json index 694e7e0..2b91df9 100644 --- a/openapi/statetimeline.openapi.json +++ b/openapi/statetimeline.openapi.json @@ -152,17 +152,7 @@ "description": "TODO docs" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/components/schemas/TimeZoneUtc" - }, - { - "$ref": "#/components/schemas/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "TimelineValueAlignment": { @@ -224,16 +214,6 @@ "none" ], "description": "TODO docs" - }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" } } } diff --git a/openapi/statushistory.openapi.json b/openapi/statushistory.openapi.json index 5c6f6a7..bb0fc77 100644 --- a/openapi/statushistory.openapi.json +++ b/openapi/statushistory.openapi.json @@ -149,17 +149,7 @@ "description": "TODO docs" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/components/schemas/TimeZoneUtc" - }, - { - "$ref": "#/components/schemas/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "HideSeriesConfig": { @@ -213,16 +203,6 @@ "none" ], "description": "TODO docs" - }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" } } } diff --git a/openapi/table.openapi.json b/openapi/table.openapi.json index 930cc90..d42ed0e 100644 --- a/openapi/table.openapi.json +++ b/openapi/table.openapi.json @@ -114,7 +114,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -227,6 +228,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -395,6 +399,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -409,6 +416,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" diff --git a/openapi/tempo.openapi.json b/openapi/tempo.openapi.json index 8ed46a7..21d05aa 100644 --- a/openapi/tempo.openapi.json +++ b/openapi/tempo.openapi.json @@ -93,14 +93,18 @@ }, "description": "Filters that are used to query the metrics summary" }, + "tableType": { + "$ref": "#/components/schemas/SearchTableType", + "description": "The type of the table that is used to display the search results" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "tableType": { - "$ref": "#/components/schemas/SearchTableType", - "description": "The type of the table that is used to display the search results" + "step": { + "type": "string", + "description": "For metric queries, the step size to use" } } }, diff --git a/openapi/timeseries.openapi.json b/openapi/timeseries.openapi.json index 98e441d..79f89c0 100644 --- a/openapi/timeseries.openapi.json +++ b/openapi/timeseries.openapi.json @@ -44,17 +44,7 @@ "$ref": "#/components/schemas/GraphFieldConfig" }, "TimeZone": { - "anyOf": [ - { - "$ref": "#/components/schemas/TimeZoneUtc" - }, - { - "$ref": "#/components/schemas/TimeZoneBrowser" - }, - { - "type": "string" - } - ], + "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, "VizLegendOptions": { @@ -252,16 +242,6 @@ }, "description": "TODO docs" }, - "TimeZoneUtc": { - "type": "string", - "const": "utc", - "description": "Use UTC/GMT timezone" - }, - "TimeZoneBrowser": { - "type": "string", - "const": "browser", - "description": "Use the timezone defined by end user web browser" - }, "LegendDisplayMode": { "enum": [ "list", diff --git a/python/grafana_foundation_sdk/builders/alerting.py b/python/grafana_foundation_sdk/builders/alerting.py index 4b1ea99..166e2f9 100644 --- a/python/grafana_foundation_sdk/builders/alerting.py +++ b/python/grafana_foundation_sdk/builders/alerting.py @@ -9,7 +9,7 @@ from ..cog import variants as cogvariants class Query(cogbuilder.Builder[alerting.Query]): _internal: alerting.Query - def __init__(self, ref_id: typing.Optional[str]): + def __init__(self, ref_id: str): self._internal = alerting.Query() self._internal.ref_id = ref_id @@ -46,7 +46,7 @@ class Query(cogbuilder.Builder[alerting.Query]): class RuleGroup(cogbuilder.Builder[alerting.RuleGroup]): _internal: alerting.RuleGroup - def __init__(self, title: typing.Optional[str]): + def __init__(self, title: str): self._internal = alerting.RuleGroup() self._internal.title = title diff --git a/python/grafana_foundation_sdk/builders/azuremonitor.py b/python/grafana_foundation_sdk/builders/azuremonitor.py index ba68ef2..a9e2529 100644 --- a/python/grafana_foundation_sdk/builders/azuremonitor.py +++ b/python/grafana_foundation_sdk/builders/azuremonitor.py @@ -130,6 +130,11 @@ class AzureMonitorQuery(cogbuilder.Builder[azuremonitor.AzureMonitorQuery]): return self + def region(self, region: str) -> typing.Self: + self._internal.region = region + + return self + def datasource(self, datasource: object) -> typing.Self: """ For mixed data sources the selected datasource is on the query level. @@ -142,13 +147,12 @@ class AzureMonitorQuery(cogbuilder.Builder[azuremonitor.AzureMonitorQuery]): return self - def region(self, region: str) -> typing.Self: + def query(self, query: str) -> typing.Self: """ - Azure Monitor query type. - queryType: #AzureQueryType + Used only for exemplar queries from Prometheus """ - self._internal.region = region + self._internal.query = query return self @@ -387,6 +391,15 @@ class AzureLogsQuery(cogbuilder.Builder[azuremonitor.AzureLogsQuery]): return self + def basic_logs_query(self, basic_logs_query: bool) -> typing.Self: + """ + If set to true the query will be run as a basic logs query + """ + + self._internal.basic_logs_query = basic_logs_query + + return self + def workspace(self, workspace: str) -> typing.Self: """ Workspace ID. This was removed in Grafana 8, but remains for backwards compat. diff --git a/python/grafana_foundation_sdk/builders/common.py b/python/grafana_foundation_sdk/builders/common.py index 2c145b1..ad060e0 100644 --- a/python/grafana_foundation_sdk/builders/common.py +++ b/python/grafana_foundation_sdk/builders/common.py @@ -1283,6 +1283,46 @@ class TableFooterOptions(cogbuilder.Builder[common.TableFooterOptions]): return self +class TableAutoCellOptions(cogbuilder.Builder[common.TableAutoCellOptions]): + """ + Auto mode table cell options + """ + + _internal: common.TableAutoCellOptions + + def __init__(self): + self._internal = common.TableAutoCellOptions() + self._internal.type_val = "auto" + + def build(self) -> common.TableAutoCellOptions: + return self._internal + + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + + +class TableColorTextCellOptions(cogbuilder.Builder[common.TableColorTextCellOptions]): + """ + Colored text cell options + """ + + _internal: common.TableColorTextCellOptions + + def __init__(self): + self._internal = common.TableColorTextCellOptions() + self._internal.type_val = "color-text" + + def build(self) -> common.TableColorTextCellOptions: + return self._internal + + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + + class TableBarGaugeCellOptions(cogbuilder.Builder[common.TableBarGaugeCellOptions]): """ Gauge cell options @@ -1523,6 +1563,11 @@ class TableColoredBackgroundCellOptions(cogbuilder.Builder[common.TableColoredBa return self + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + class DataSourceRef(cogbuilder.Builder[common.DataSourceRef]): _internal: common.DataSourceRef diff --git a/python/grafana_foundation_sdk/builders/dashboard.py b/python/grafana_foundation_sdk/builders/dashboard.py index d93cb42..72f976d 100644 --- a/python/grafana_foundation_sdk/builders/dashboard.py +++ b/python/grafana_foundation_sdk/builders/dashboard.py @@ -12,7 +12,7 @@ class Dashboard(cogbuilder.Builder[dashboard.Dashboard]): __current_x: int = 0 __last_panel_height: int = 0 - def __init__(self, title: typing.Optional[str]): + def __init__(self, title: str): self._internal = dashboard.Dashboard() self._internal.title = title @@ -1452,7 +1452,7 @@ class Row(cogbuilder.Builder[dashboard.RowPanel]): _internal: dashboard.RowPanel - def __init__(self, title: typing.Optional[str]): + def __init__(self, title: str): self._internal = dashboard.RowPanel() self._internal.type_val = "row" self._internal.title = title diff --git a/python/grafana_foundation_sdk/builders/heatmap.py b/python/grafana_foundation_sdk/builders/heatmap.py index fc6d8af..9546e30 100644 --- a/python/grafana_foundation_sdk/builders/heatmap.py +++ b/python/grafana_foundation_sdk/builders/heatmap.py @@ -717,6 +717,18 @@ class Panel(cogbuilder.Builder[dashboard.Panel]): return self + def selection_mode(self, selection_mode: heatmap.HeatmapSelectionMode) -> typing.Self: + """ + Controls which axis to allow selection on + """ + + if self._internal.options is None: + self._internal.options = heatmap.Options() + assert isinstance(self._internal.options, heatmap.Options) + self._internal.options.selection_mode = selection_mode + + return self + def scale_distribution(self, scale_distribution: cogbuilder.Builder[common.ScaleDistributionConfig]) -> typing.Self: if self._internal.field_config is None: self._internal.field_config = dashboard.FieldConfigSource() diff --git a/python/grafana_foundation_sdk/builders/logs.py b/python/grafana_foundation_sdk/builders/logs.py index 5bed101..6192da7 100644 --- a/python/grafana_foundation_sdk/builders/logs.py +++ b/python/grafana_foundation_sdk/builders/logs.py @@ -529,4 +529,48 @@ class Panel(cogbuilder.Builder[dashboard.Panel]): self._internal.options.dedup_strategy = dedup_strategy return self + + def on_click_filter_label(self, on_click_filter_label: object) -> typing.Self: + """ + TODO: figure out how to define callbacks + """ + + if self._internal.options is None: + self._internal.options = logs.Options() + assert isinstance(self._internal.options, logs.Options) + self._internal.options.on_click_filter_label = on_click_filter_label + + return self + + def on_click_filter_out_label(self, on_click_filter_out_label: object) -> typing.Self: + if self._internal.options is None: + self._internal.options = logs.Options() + assert isinstance(self._internal.options, logs.Options) + self._internal.options.on_click_filter_out_label = on_click_filter_out_label + + return self + + def is_filter_label_active(self, is_filter_label_active: object) -> typing.Self: + if self._internal.options is None: + self._internal.options = logs.Options() + assert isinstance(self._internal.options, logs.Options) + self._internal.options.is_filter_label_active = is_filter_label_active + + return self + + def on_click_filter_string(self, on_click_filter_string: object) -> typing.Self: + if self._internal.options is None: + self._internal.options = logs.Options() + assert isinstance(self._internal.options, logs.Options) + self._internal.options.on_click_filter_string = on_click_filter_string + + return self + + def on_click_filter_out_string(self, on_click_filter_out_string: object) -> typing.Self: + if self._internal.options is None: + self._internal.options = logs.Options() + assert isinstance(self._internal.options, logs.Options) + self._internal.options.on_click_filter_out_string = on_click_filter_out_string + + return self \ No newline at end of file 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/tempo.py b/python/grafana_foundation_sdk/builders/tempo.py index 6bad910..97f6b3d 100644 --- a/python/grafana_foundation_sdk/builders/tempo.py +++ b/python/grafana_foundation_sdk/builders/tempo.py @@ -150,6 +150,15 @@ class TempoQuery(cogbuilder.Builder[tempo.TempoQuery]): return self + def table_type(self, table_type: tempo.SearchTableType) -> typing.Self: + """ + The type of the table that is used to display the search results + """ + + self._internal.table_type = table_type + + return self + def datasource(self, datasource: object) -> typing.Self: """ For mixed data sources the selected datasource is on the query level. @@ -162,12 +171,12 @@ class TempoQuery(cogbuilder.Builder[tempo.TempoQuery]): return self - def table_type(self, table_type: tempo.SearchTableType) -> typing.Self: + def step(self, step: str) -> typing.Self: """ - The type of the table that is used to display the search results + For metric queries, the step size to use """ - self._internal.table_type = table_type + self._internal.step = step return self diff --git a/python/grafana_foundation_sdk/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py index 09e1e42..628ddc6 100644 --- a/python/grafana_foundation_sdk/cog/plugins.py +++ b/python/grafana_foundation_sdk/cog/plugins.py @@ -1,39 +1,39 @@ # Code generated - EDITING IS FUTILE. DO NOT EDIT. -from ..models import parca +from ..models import bargauge +from ..models import nodegraph +from ..models import table +from ..models import tempo +from ..models import barchart +from ..models import logs +from ..models import stat from ..models import expr -from ..models import azuremonitor -from ..models import canvas +from ..models import dashboardlist from ..models import debug from ..models import grafanapyroscope -from ..models import nodegraph -from ..models import barchart -from ..models import googlecloudmonitoring +from ..models import heatmap from ..models import news -from ..models import piechart +from ..models import statetimeline +from ..models import trend +from ..models import prometheus +from ..models import canvas from ..models import datagrid +from ..models import histogram +from ..models import piechart +from ..models import text +from ..models import timeseries from ..models import elasticsearch +from ..models import gauge +from ..models import loki +from ..models import azuremonitor +from ..models import cloudwatch from ..models import statushistory -from ..models import text +from ..models import xychart from ..models import annotationslist -from ..models import stat -from ..models import statetimeline -from ..models import trend -from ..models import bargauge from ..models import candlestick -from ..models import gauge from ..models import geomap -from ..models import timeseries -from ..models import xychart -from ..models import cloudwatch -from ..models import heatmap -from ..models import histogram -from ..models import prometheus -from ..models import table -from ..models import tempo -from ..models import loki -from ..models import dashboardlist -from ..models import logs +from ..models import googlecloudmonitoring +from ..models import parca from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/azuremonitor.py b/python/grafana_foundation_sdk/models/azuremonitor.py index 0769860..caec76d 100644 --- a/python/grafana_foundation_sdk/models/azuremonitor.py +++ b/python/grafana_foundation_sdk/models/azuremonitor.py @@ -34,16 +34,16 @@ class AzureMonitorQuery(cogvariants.Dataquery): resource_group: typing.Optional[str] namespace: typing.Optional[str] resource: typing.Optional[str] + region: typing.Optional[str] # For mixed data sources the selected datasource is on the query level. # For non mixed scenarios this is undefined. # TODO find a better way to do this ^ that's friendly to schema # TODO this shouldn't be unknown but DataSourceRef | null datasource: typing.Optional[object] - # Azure Monitor query type. - # queryType: #AzureQueryType - region: typing.Optional[str] + # Used only for exemplar queries from Prometheus + query: typing.Optional[str] - def __init__(self, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, subscription: typing.Optional[str] = None, subscriptions: typing.Optional[list[str]] = None, azure_monitor: typing.Optional['AzureMetricQuery'] = None, azure_log_analytics: typing.Optional['AzureLogsQuery'] = None, azure_resource_graph: typing.Optional['AzureResourceGraphQuery'] = None, azure_traces: typing.Optional['AzureTracesQuery'] = None, grafana_template_variable_fn: typing.Optional['GrafanaTemplateVariableQuery'] = None, resource_group: typing.Optional[str] = None, namespace: typing.Optional[str] = None, resource: typing.Optional[str] = None, datasource: typing.Optional[object] = None, region: typing.Optional[str] = None): + def __init__(self, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, subscription: typing.Optional[str] = None, subscriptions: typing.Optional[list[str]] = None, azure_monitor: typing.Optional['AzureMetricQuery'] = None, azure_log_analytics: typing.Optional['AzureLogsQuery'] = None, azure_resource_graph: typing.Optional['AzureResourceGraphQuery'] = None, azure_traces: typing.Optional['AzureTracesQuery'] = None, grafana_template_variable_fn: typing.Optional['GrafanaTemplateVariableQuery'] = None, resource_group: typing.Optional[str] = None, namespace: typing.Optional[str] = None, resource: typing.Optional[str] = None, region: typing.Optional[str] = None, datasource: typing.Optional[object] = None, query: typing.Optional[str] = None): self.ref_id = ref_id self.hide = hide self.query_type = query_type @@ -57,8 +57,9 @@ class AzureMonitorQuery(cogvariants.Dataquery): self.resource_group = resource_group self.namespace = namespace self.resource = resource - self.datasource = datasource self.region = region + self.datasource = datasource + self.query = query def to_json(self) -> dict[str, object]: payload: dict[str, object] = { @@ -88,10 +89,12 @@ class AzureMonitorQuery(cogvariants.Dataquery): payload["namespace"] = self.namespace if self.resource is not None: payload["resource"] = self.resource - if self.datasource is not None: - payload["datasource"] = self.datasource if self.region is not None: payload["region"] = self.region + if self.datasource is not None: + payload["datasource"] = self.datasource + if self.query is not None: + payload["query"] = self.query return payload @classmethod @@ -124,10 +127,12 @@ class AzureMonitorQuery(cogvariants.Dataquery): args["namespace"] = data["namespace"] if "resource" in data: args["resource"] = data["resource"] + if "region" in data: + args["region"] = data["region"] if "datasource" in data: args["datasource"] = data["datasource"] - if "region" in data: - args["region"] = data["region"] + if "query" in data: + args["query"] = data["query"] return cls(**args) @@ -156,6 +161,7 @@ class AzureQueryType(enum.StrEnum): ...*[Comment body truncated]*