grafana / cog

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

Cleanup txtar utils to decouple them from inputs being tested #428

Closed K-Phoen closed 5 months ago

K-Phoen commented 5 months ago

A bit of cleaning, to remove duplicated code and unnecessary couplings in txtar test utils.

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/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/types_gen.go b/go/azuremonitor/types_gen.go index 0e98f37..0e789fb 100644 --- a/go/azuremonitor/types_gen.go +++ b/go/azuremonitor/types_gen.go @@ -136,6 +136,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/types_gen.go b/go/common/types_gen.go index 6389be0..515fd60 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 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/jsonschema/azuremonitor.jsonschema.json b/jsonschema/azuremonitor.jsonschema.json index d2d343e..3aa1d09 100644 --- a/jsonschema/azuremonitor.jsonschema.json +++ b/jsonschema/azuremonitor.jsonschema.json @@ -203,6 +203,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..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 1e50241..28d29c3 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/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/openapi/azuremonitor.openapi.json b/openapi/azuremonitor.openapi.json index 89bfca5..82454e4 100644 --- a/openapi/azuremonitor.openapi.json +++ b/openapi/azuremonitor.openapi.json @@ -212,6 +212,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..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 5f10555..a7ec373 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/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/python/grafana_foundation_sdk/builders/azuremonitor.py b/python/grafana_foundation_sdk/builders/azuremonitor.py index ba68ef2..7c26cae 100644 --- a/python/grafana_foundation_sdk/builders/azuremonitor.py +++ b/python/grafana_foundation_sdk/builders/azuremonitor.py @@ -387,6 +387,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/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/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py index 4ca4b32..8f16c38 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 azuremonitor -from ..models import gauge -from ..models import logs +from ..models import debug +from ..models import googlecloudmonitoring from ..models import nodegraph -from ..models import table -from ..models import candlestick -from ..models import dashboardlist -from ..models import heatmap from ..models import prometheus -from ..models import elasticsearch -from ..models import grafanapyroscope -from ..models import loki -from ..models import trend -from ..models import xychart -from ..models import debug -from ..models import piechart -from ..models import bargauge +from ..models import expr +from ..models import annotationslist from ..models import canvas +from ..models import gauge +from ..models import heatmap +from ..models import parca +from ..models import dashboardlist from ..models import datagrid -from ..models import googlecloudmonitoring -from ..models import annotationslist -from ..models import cloudwatch from ..models import histogram -from ..models import tempo -from ..models import text -from ..models import geomap +from ..models import azuremonitor +from ..models import cloudwatch from ..models import news -from ..models import statetimeline +from ..models import stat from ..models import statushistory +from ..models import tempo +from ..models import trend from ..models import barchart -from ..models import parca -from ..models import stat +from ..models import bargauge +from ..models import logs +from ..models import piechart +from ..models import table +from ..models import text +from ..models import candlestick +from ..models import elasticsearch +from ..models import grafanapyroscope from ..models import timeseries -from ..models import expr +from ..models import xychart +from ..models import geomap +from ..models import loki +from ..models import statetimeline 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..93942e6 100644 --- a/python/grafana_foundation_sdk/models/azuremonitor.py +++ b/python/grafana_foundation_sdk/models/azuremonitor.py @@ -318,6 +318,8 @@ class AzureLogsQuery: dashboard_time: typing.Optional[bool] # 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 time_column: typing.Optional[str] + # If set to true the query will be run as a basic logs query + basic_logs_query: typing.Optional[bool] # Workspace ID. This was removed in Grafana 8, but remains for backwards compat. workspace: typing.Optional[str] # @deprecated Use resources instead @@ -325,12 +327,13 @@ class AzureLogsQuery: # @deprecated Use dashboardTime instead intersect_time: typing.Optional[bool] - def __init__(self, query: typing.Optional[str] = None, result_format: typing.Optional['ResultFormat'] = None, resources: typing.Optional[list[str]] = None, dashboard_time: typing.Optional[bool] = None, time_column: typing.Optional[str] = None, workspace: typing.Optional[str] = None, resource: typing.Optional[str] = None, intersect_time: typing.Optional[bool] = None): + def __init__(self, query: typing.Optional[str] = None, result_format: typing.Optional['ResultFormat'] = None, resources: typing.Optional[list[str]] = None, dashboard_time: typing.Optional[bool] = None, time_column: typing.Optional[str] = None, basic_logs_query: typing.Optional[bool] = None, workspace: typing.Optional[str] = None, resource: typing.Optional[str] = None, intersect_time: typing.Optional[bool] = None): self.query = query self.result_format = result_format self.resources = resources self.dashboard_time = dashboard_time self.time_column = time_column + self.basic_logs_query = basic_logs_query self.workspace = workspace self.resource = resource self.intersect_time = intersect_time @@ -348,6 +351,8 @@ class AzureLogsQuery: payload["dashboardTime"] = self.dashboard_time if self.time_column is not None: payload["timeColumn"] = self.time_column + if self.basic_logs_query is not None: + payload["basicLogsQuery"] = self.basic_logs_query if self.workspace is not None: payload["workspace"] = self.workspace if self.resource is not None: @@ -370,6 +375,8 @@ class AzureLogsQuery: args["dashboard_time"] = data["dashboardTime"] if "timeColumn" in data: args["time_column"] = data["timeColumn"] + if "basicLogsQuery" in data: + args["basic_logs_query"] = data["basicLogsQuery"] if "workspace" in data: args["workspace"] = data["workspace"] if "resource" in 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/dashboard.py b/python/grafana_foundation_sdk/models/dashboard.py index ca13b1d..f497b5f 100644 --- a/python/grafana_foundation_sdk/models/dashboard.py +++ b/python/grafana_foundation_sdk/models/dashboard.py @@ -64,7 +64,7 @@ class Dashboard: # Snapshot options. They are present only if the dashboard is a snapshot. snapshot: typing.Optional['Snapshot'] - def __init__(self, id_val: typing.Optional[int] = None, uid: typing.Optional[str] = None, title: typing.Optional[str] = None, description: typing.Optional[str] = None, revision: typing.Optional[int] = None, gnet_id: typing.Optional[str] = None, tags: typing.Optional[list[str]] = None, timezone: typing.Optional[str] = "browser", editable: typing.Optional[bool] = True, graph_tooltip: typing.Optional['DashboardCursorSync'] = None, time: typing.Optional['DashboardDashboardTime'] = None, timepicker: typing.Optional['TimePickerConfig'] = None, fiscal_year_start_month: typing.Optional[int] = 0, live_now: typing.Optional[bool] = None, week_start: typing.Optional[str] = None, refresh: typing.Optional[str] = None, schema_version: int = 36, version: typing.Optional[int] = None, panels: typing.Optional[list[typing.Union['Panel', 'RowPanel']]] = None, templating: typing.Optional['DashboardDashboardTemplating'] = None, annotations: typing.Optional['AnnotationContainer'] = None, links: typing.Optional[list['DashboardLink']] = None, snapshot: typing.Optional['Snapshot'] = None): + def __init__(self, id_val: typing.Optional[int] = None, uid: typing.Optional[str] = None, title: typing.Optional[str] = None, description: typing.Optional[str] = None, revision: typing.Optional[int] = None, gnet_id: typing.Optional[str] = None, tags: typing.Optional[list[str]] = None, timezone: typing.Optional[str] = "browser", editable: typing.Optional[bool] = True, graph_tooltip: typing.Optional['DashboardCursorSync'] = None, time: typing.Optional['DashboardDashboardTime'] = None, timepicker: typing.Optional['TimePickerConfig'] = None, fiscal_year_start_month: typing.Optional[int] = 0, live_now: typing.Optional[bool] = None, week_start: typing.Optional[str] = None, refresh: typing.Optional[str] = None, schema_version: int = 39, version: typing.Optional[int] = None, panels: typing.Optional[list[typing.Union['Panel', 'RowPanel']]] = None, templating: typing.Optional['DashboardDashboardTemplating'] = None, annotations: typing.Optional['AnnotationContainer'] = None, links: typing.Optional[list['DashboardLink']] = None, snapshot: typing.Optional['Snapshot'] = None): self.id_val = id_val self.uid = uid self.title = title diff --git a/python/grafana_foundation_sdk/models/expr.py b/python/grafana_foundation_sdk/models/expr.py index 5dd1737..bcd9dbf 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[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} + 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} return cogruntime.DataqueryConfig( identifier="__expr__", from_json_hook=lambda data: decoding_map[data["type"]].from_json(data), 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/pyproject.toml b/python/pyproject.toml index b60a7cf..a6d7a19 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ keywords = [ "traces", "metrics" ] -version = "1717160644!next" +version = "1717454090!next" dependencies = [] requires-python = ">=3.11" classifiers = [ diff --git a/typescript/package.json b/typescript/package.json index f1c488f..8ce3ca3 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@grafana/grafana-foundation-sdk", - "version": "next-cogv0.0.x.1717160644", + "version": "next-cogv0.0.x.1717454090", "description": "A set of tools, types and libraries for building and manipulating Grafana objects.", "keywords": [ "observability", diff --git a/typescript/src/azuremonitor/azureLogsQueryBuilder.gen.ts b/typescript/src/azuremonitor/azureLogsQueryBuilder.gen.ts index d5f715f..89a006f 100644 --- a/typescript/src/azuremonitor/azureLogsQueryBuilder.gen.ts +++ b/typescript/src/azuremonitor/azureLogsQueryBuilder.gen.ts @@ -45,6 +45,12 @@ export class AzureLogsQueryBuilder implements cog.Builder (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/dashboard/types.gen.ts b/typescript/src/dashboard/types.gen.ts index 32427a8..f6b228d 100644 --- a/typescript/src/dashboard/types.gen.ts +++ b/typescript/src/dashboard/types.gen.ts @@ -73,7 +73,7 @@ export const defaultDashboard = (): Dashboard => ({ editable: true, graphTooltip: DashboardCursorSync.Off, fiscalYearStartMonth: 0, - schemaVersion: 36, + schemaVersion: 39, templating: { }, annotations: defaultAnnotationContainer(), diff --git a/typescript/src/stat/panelBuilder.gen.ts b/typescript/src/stat/panelBuilder.gen.ts index 9b2cf22..f281f03 100644 --- a/typescript/src/stat/panelBuilder.gen.ts +++ b/typescript/src/stat/panelBuilder.gen.ts @@ -394,6 +394,14 @@ export class PanelBuilder implements cog.Builder { return this; } + showPercentChange(showPercentChange: boolean): this { + if (!this.internal.options) { + this.internal.options = stat.defaultOptions(); + } + this.internal.options.showPercentChange = showPercentChange; + return this; + } + reduceOptions(reduceOptions: cog.Builder): this { if (!this.internal.options) { this.internal.options = stat.defaultOptions(); @@ -412,11 +420,11 @@ export class PanelBuilder implements cog.Builder { return this; } - showPercentChange(showPercentChange: boolean): this { + percentChangeColorMode(percentChangeColorMode: common.PercentChangeColorMode): this { if (!this.internal.options) { this.internal.options = stat.defaultOptions(); } - this.internal.options.showPercentChange = showPercentChange; + this.internal.options.percentChangeColorMode = percentChangeColorMode; return this; } diff --git a/typescript/src/stat/types.gen.ts b/typescript/src/stat/types.gen.ts index 46f8f58..3e7c57a 100644 --- a/typescript/src/stat/types.gen.ts +++ b/typescript/src/stat/types.gen.ts @@ -9,9 +9,10 @@ export interface Options { justifyMode: common.BigValueJustifyMode; textMode: common.BigValueTextMode; wideLayout: boolean; + showPercentChange: boolean; reduceOptions: common.ReduceDataOptions; text?: common.VizTextDisplayOptions; - showPercentChange: boolean; + percentChangeColorMode: common.PercentChangeColorMode; orientation: common.VizOrientation; } @@ -21,8 +22,9 @@ export const defaultOptions = (): Options => ({ justifyMode: common.BigValueJustifyMode.Auto, textMode: common.BigValueTextMode.Auto, wideLayout: true, - reduceOptions: common.defaultReduceDataOptions(), showPercentChange: false, + reduceOptions: common.defaultReduceDataOptions(), + percentChangeColorMode: common.PercentChangeColorMode.Standard, orientation: common.VizOrientation.Auto, }); ```