grafana / cog

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

Do not generate builders IR if builder generation is disabled #431

Closed K-Phoen closed 3 months ago

K-Phoen commented 3 months ago

The title says it all :)

github-actions[bot] commented 3 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/timeinterval_builder_gen.go b/go/alerting/timeinterval_builder_gen.go index 3c5ef42..5cb84c4 100644 --- a/go/alerting/timeinterval_builder_gen.go +++ b/go/alerting/timeinterval_builder_gen.go @@ -45,8 +45,8 @@ func (builder *TimeIntervalBuilder) Name(name string) *TimeIntervalBuilder { return builder } -func (builder *TimeIntervalBuilder) TimeIntervals(timeIntervals []cog.Builder[TimeInterval]) *TimeIntervalBuilder { - timeIntervalsResources := make([]TimeInterval, 0, len(timeIntervals)) +func (builder *TimeIntervalBuilder) TimeIntervals(timeIntervals []cog.Builder[TimeIntervalItem]) *TimeIntervalBuilder { + timeIntervalsResources := make([]TimeIntervalItem, 0, len(timeIntervals)) for _, r1 := range timeIntervals { timeIntervalsDepth1, err := r1.Build() if err != nil { diff --git a/go/alerting/timeintervalitem_builder_gen.go b/go/alerting/timeintervalitem_builder_gen.go new file mode 100644 index 0000000..e5df78f --- /dev/null +++ b/go/alerting/timeintervalitem_builder_gen.go @@ -0,0 +1,88 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package alerting + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TimeIntervalItem] = (*TimeIntervalItemBuilder)(nil) + +type TimeIntervalItemBuilder struct { + internal *TimeIntervalItem + errors map[string]cog.BuildErrors +} + +func NewTimeIntervalItemBuilder() *TimeIntervalItemBuilder { + resource := &TimeIntervalItem{} + builder := &TimeIntervalItemBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *TimeIntervalItemBuilder) Build() (TimeIntervalItem, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TimeIntervalItem", err)...) + } + + if len(errs) != 0 { + return TimeIntervalItem{}, errs + } + + return *builder.internal, nil +} + +func (builder *TimeIntervalItemBuilder) DaysOfMonth(daysOfMonth []string) *TimeIntervalItemBuilder { + builder.internal.DaysOfMonth = daysOfMonth + + return builder +} + +func (builder *TimeIntervalItemBuilder) Location(location string) *TimeIntervalItemBuilder { + builder.internal.Location = &location + + return builder +} + +func (builder *TimeIntervalItemBuilder) Months(months []string) *TimeIntervalItemBuilder { + builder.internal.Months = months + + return builder +} + +func (builder *TimeIntervalItemBuilder) Times(times []cog.Builder[TimeIntervalTimeRange]) *TimeIntervalItemBuilder { + timesResources := make([]TimeIntervalTimeRange, 0, len(times)) + for _, r1 := range times { + timesDepth1, err := r1.Build() + if err != nil { + builder.errors["times"] = err.(cog.BuildErrors) + return builder + } + timesResources = append(timesResources, timesDepth1) + } + builder.internal.Times = timesResources + + return builder +} + +func (builder *TimeIntervalItemBuilder) Weekdays(weekdays []string) *TimeIntervalItemBuilder { + builder.internal.Weekdays = weekdays + + return builder +} + +func (builder *TimeIntervalItemBuilder) Years(years []string) *TimeIntervalItemBuilder { + builder.internal.Years = years + + return builder +} + +func (builder *TimeIntervalItemBuilder) applyDefaults() { +} diff --git a/go/alerting/timeintervaltimerange_builder_gen.go b/go/alerting/timeintervaltimerange_builder_gen.go new file mode 100644 index 0000000..6a03574 --- /dev/null +++ b/go/alerting/timeintervaltimerange_builder_gen.go @@ -0,0 +1,55 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package alerting + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TimeIntervalTimeRange] = (*TimeIntervalTimeRangeBuilder)(nil) + +type TimeIntervalTimeRangeBuilder struct { + internal *TimeIntervalTimeRange + errors map[string]cog.BuildErrors +} + +func NewTimeIntervalTimeRangeBuilder() *TimeIntervalTimeRangeBuilder { + resource := &TimeIntervalTimeRange{} + builder := &TimeIntervalTimeRangeBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *TimeIntervalTimeRangeBuilder) Build() (TimeIntervalTimeRange, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TimeIntervalTimeRange", err)...) + } + + if len(errs) != 0 { + return TimeIntervalTimeRange{}, errs + } + + return *builder.internal, nil +} + +func (builder *TimeIntervalTimeRangeBuilder) EndTime(endTime string) *TimeIntervalTimeRangeBuilder { + builder.internal.EndTime = &endTime + + return builder +} + +func (builder *TimeIntervalTimeRangeBuilder) StartTime(startTime string) *TimeIntervalTimeRangeBuilder { + builder.internal.StartTime = &startTime + + return builder +} + +func (builder *TimeIntervalTimeRangeBuilder) applyDefaults() { +} diff --git a/go/alerting/types_gen.go b/go/alerting/types_gen.go index 3f3142d..e697e7d 100644 --- a/go/alerting/types_gen.go +++ b/go/alerting/types_gen.go @@ -17,7 +17,14 @@ type Json any type MatchRegexps map[string]string -type MatchType int64 +type MatchType string + +const ( + MatchTypeEqual MatchType = "=" + MatchTypeNotEqual MatchType = "!=" + MatchTypeEqualRegex MatchType = "=~" + MatchTypeNotEqualRegex MatchType = "!~" +) type Matcher struct { Name *string `json:"Name,omitempty"` @@ -54,8 +61,22 @@ type RelativeTimeRange struct { } type TimeInterval struct { - Name *string `json:"name,omitempty"` - TimeIntervals []TimeInterval `json:"time_intervals,omitempty"` + Name *string `json:"name,omitempty"` + TimeIntervals []TimeIntervalItem `json:"time_intervals,omitempty"` +} + +type TimeIntervalItem struct { + DaysOfMonth []string `json:"days_of_month,omitempty"` + Location *string `json:"location,omitempty"` + Months []string `json:"months,omitempty"` + Times []TimeIntervalTimeRange `json:"times,omitempty"` + Weekdays []string `json:"weekdays,omitempty"` + Years []string `json:"years,omitempty"` +} + +type TimeIntervalTimeRange struct { + EndTime *string `json:"end_time,omitempty"` + StartTime *string `json:"start_time,omitempty"` } type RuleGroup struct { 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/alerting.jsonschema.json b/jsonschema/alerting.jsonschema.json index 08c2bbc..a21b323 100644 --- a/jsonschema/alerting.jsonschema.json +++ b/jsonschema/alerting.jsonschema.json @@ -16,7 +16,12 @@ } }, "MatchType": { - "type": "integer" + "enum": [ + "=", + "!=", + "=~", + "!~" + ] }, "Matcher": { "type": "object", @@ -95,8 +100,59 @@ "time_intervals": { "type": "array", "items": { - "$ref": "#/definitions/TimeInterval" + "$ref": "#/definitions/TimeIntervalItem" + } + } + } + }, + "TimeIntervalItem": { + "type": "object", + "additionalProperties": false, + "properties": { + "days_of_month": { + "type": "array", + "items": { + "type": "string" } + }, + "location": { + "type": "string" + }, + "months": { + "type": "array", + "items": { + "type": "string" + } + }, + "times": { + "type": "array", + "items": { + "$ref": "#/definitions/TimeIntervalTimeRange" + } + }, + "weekdays": { + "type": "array", + "items": { + "type": "string" + } + }, + "years": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "TimeIntervalTimeRange": { + "type": "object", + "additionalProperties": false, + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string" } } }, 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/alerting.openapi.json b/openapi/alerting.openapi.json index 0b1a7bf..90dcf61 100644 --- a/openapi/alerting.openapi.json +++ b/openapi/alerting.openapi.json @@ -24,7 +24,12 @@ } }, "MatchType": { - "type": "integer" + "enum": [ + "=", + "!=", + "=~", + "!~" + ] }, "Matcher": { "type": "object", @@ -103,8 +108,59 @@ "time_intervals": { "type": "array", "items": { - "$ref": "#/components/schemas/TimeInterval" + "$ref": "#/components/schemas/TimeIntervalItem" + } + } + } + }, + "TimeIntervalItem": { + "type": "object", + "additionalProperties": false, + "properties": { + "days_of_month": { + "type": "array", + "items": { + "type": "string" } + }, + "location": { + "type": "string" + }, + "months": { + "type": "array", + "items": { + "type": "string" + } + }, + "times": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TimeIntervalTimeRange" + } + }, + "weekdays": { + "type": "array", + "items": { + "type": "string" + } + }, + "years": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "TimeIntervalTimeRange": { + "type": "object", + "additionalProperties": false, + "properties": { + "end_time": { + "type": "string" + }, + "start_time": { + "type": "string" } } }, 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/alerting.py b/python/grafana_foundation_sdk/builders/alerting.py index 03a8759..91308f3 100644 --- a/python/grafana_foundation_sdk/builders/alerting.py +++ b/python/grafana_foundation_sdk/builders/alerting.py @@ -70,13 +70,74 @@ class TimeInterval(cogbuilder.Builder[alerting.TimeInterval]): return self - def time_intervals(self, time_intervals: list[cogbuilder.Builder[alerting.TimeInterval]]) -> typing.Self: + def time_intervals(self, time_intervals: list[cogbuilder.Builder[alerting.TimeIntervalItem]]) -> typing.Self: time_intervals_resources = [r1.build() for r1 in time_intervals] self._internal.time_intervals = time_intervals_resources return self +class TimeIntervalItem(cogbuilder.Builder[alerting.TimeIntervalItem]): + _internal: alerting.TimeIntervalItem + + def __init__(self): + self._internal = alerting.TimeIntervalItem() + + def build(self) -> alerting.TimeIntervalItem: + return self._internal + + def days_of_month(self, days_of_month: list[str]) -> typing.Self: + self._internal.days_of_month = days_of_month + + return self + + def location(self, location: str) -> typing.Self: + self._internal.location = location + + return self + + def months(self, months: list[str]) -> typing.Self: + self._internal.months = months + + return self + + def times(self, times: list[cogbuilder.Builder[alerting.TimeIntervalTimeRange]]) -> typing.Self: + times_resources = [r1.build() for r1 in times] + self._internal.times = times_resources + + return self + + def weekdays(self, weekdays: list[str]) -> typing.Self: + self._internal.weekdays = weekdays + + return self + + def years(self, years: list[str]) -> typing.Self: + self._internal.years = years + + return self + + +class TimeIntervalTimeRange(cogbuilder.Builder[alerting.TimeIntervalTimeRange]): + _internal: alerting.TimeIntervalTimeRange + + def __init__(self): + self._internal = alerting.TimeIntervalTimeRange() + + def build(self) -> alerting.TimeIntervalTimeRange: + return self._internal + + def end_time(self, end_time: str) -> typing.Self: + self._internal.end_time = end_time + + return self + + def start_time(self, start_time: str) -> typing.Self: + self._internal.start_time = start_time + + return self + + class RuleGroup(cogbuilder.Builder[alerting.RuleGroup]): _internal: alerting.RuleGroup 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..1979050 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 nodegraph from ..models import table +from ..models import timeseries +from ..models import statetimeline +from ..models import tempo from ..models import candlestick -from ..models import dashboardlist -from ..models import heatmap +from ..models import geomap +from ..models import parca +from ..models import azuremonitor +from ..models import barchart +from ..models import expr 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 news +from ..models import stat from ..models import bargauge -from ..models import canvas -from ..models import datagrid +from ..models import cloudwatch +from ..models import dashboardlist +from ..models import statushistory +from ..models import trend from ..models import googlecloudmonitoring +from ..models import nodegraph +from ..models import logs +from ..models import loki from ..models import annotationslist -from ..models import cloudwatch -from ..models import histogram -from ..models import tempo +from ..models import datagrid +from ..models import elasticsearch +from ..models import piechart from ..models import text -from ..models import geomap -from ..models import news -from ..models import statetimeline -from ..models import statushistory -from ..models import barchart -from ..models import parca -from ..models import stat -from ..models import timeseries -from ..models import expr +from ..models import xychart +from ..models import canvas +from ..models import gauge +from ..models import grafanapyroscope +from ..models import heatmap +from ..models import histogram from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/alerting.py b/python/grafana_foundation_sdk/models/alerting.py index 4c04f25..47d0075 100644 --- a/python/grafana_foundation_sdk/models/alerting.py +++ b/python/grafana_foundation_sdk/models/alerting.py @@ -1,6 +1,7 @@ # Code generated - EDITING IS FUTILE. DO NOT EDIT. import typing +import enum from ..cog import variants as cogvariants from ..cog import runtime as cogruntime @@ -15,7 +16,11 @@ Json: typing.TypeAlias = object MatchRegexps: typing.TypeAlias = dict[str, str] -MatchType: typing.TypeAlias = int +class MatchType(enum.StrEnum): + EQUAL = "=" + NOT_EQUAL = "!=" + EQUAL_REGEX = "=~" + NOT_EQUAL_REGEX = "!~" class Matcher: @@ -143,9 +148,9 @@ class RelativeTimeRange: class TimeInterval: name: typing.Optional[str] - time_intervals: typing.Optional[list['TimeInterval']] + time_intervals: typing.Optional[list['TimeIntervalItem']] - def __init__(self, name: typing.Optional[str] = None, time_intervals: typing.Optional[list['TimeInterval']] = None): + def __init__(self, name: typing.Optional[str] = None, time_intervals: typing.Optional[list['TimeIntervalItem']] = None): self.name = name self.time_intervals = time_intervals @@ -170,6 +175,88 @@ class TimeInterval: return cls(**args) +class TimeIntervalItem: + days_of_month: typing.Optional[list[str]] + location: typing.Optional[str] + months: typing.Optional[list[str]] + times: typing.Optional[list['TimeIntervalTimeRange']] + weekdays: typing.Optional[list[str]] + years: typing.Optional[list[str]] + + def __init__(self, days_of_month: typing.Optional[list[str]] = None, location: typing.Optional[str] = None, months: typing.Optional[list[str]] = None, times: typing.Optional[list['TimeIntervalTimeRange']] = None, weekdays: typing.Optional[list[str]] = None, years: typing.Optional[list[str]] = None): + self.days_of_month = days_of_month + self.location = location + self.months = months + self.times = times + self.weekdays = weekdays + self.years = years + + def to_json(self) -> dict[str, object]: + payload: dict[str, object] = { + } + if self.days_of_month is not None: + payload["days_of_month"] = self.days_of_month + if self.location is not None: + payload["location"] = self.location + if self.months is not None: + payload["months"] = self.months + if self.times is not None: + payload["times"] = self.times + if self.weekdays is not None: + payload["weekdays"] = self.weekdays + if self.years is not None: + payload["years"] = self.years + return payload + + @classmethod + def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: + args: dict[str, typing.Any] = {} + + if "days_of_month" in data: + args["days_of_month"] = data["days_of_month"] + if "location" in data: + args["location"] = data["location"] + if "months" in data: + args["months"] = data["months"] + if "times" in data: + args["times"] = data["times"] + if "weekdays" in data: + args["weekdays"] = data["weekdays"] + if "years" in data: + args["years"] = data["years"] + + return cls(**args) + + +class TimeIntervalTimeRange: + end_time: typing.Optional[str] + start_time: typing.Optional[str] + + def __init__(self, end_time: typing.Optional[str] = None, start_time: typing.Optional[str] = None): + self.end_time = end_time + self.start_time = start_time + + def to_json(self) -> dict[str, object]: + payload: dict[str, object] = { + } + if self.end_time is not None: + payload["end_time"] = self.end_time + if self.start_time is not None: + payload["start_time"] = self.start_time + return payload + + @classmethod + def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: + args: dict[str, typing.Any] = {} + + if "end_time" in data: + args["end_time"] = data["end_time"] + if "start_time" in data: + args["start_time"] = data["start_time"] + + return cls(**args) + + class RuleGroup: folder_uid: typing.Optional[str] # The interval, in seconds, at which all rules in the group are evaluated. 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/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/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..4d042cb 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ keywords = [ "traces", "metrics" ] -version = "1717160644!next" +version = "1717492743!next" dependencies = [] requires-python = ">=3.11" classifiers = [ diff --git a/typescript/package.json b/typescript/package.json index f1c488f..1df8be5 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.1717492743", "description": "A set of tools, types and libraries for building and manipulating Grafana objects.", "keywords": [ "observability", diff --git a/typescript/src/alerting/index.ts b/typescript/src/alerting/index.ts index d17bb7c..f1b0244 100644 --- a/typescript/src/alerting/index.ts +++ b/typescript/src/alerting/index.ts @@ -8,6 +8,10 @@ export * from './notificationTemplateBuilder.gen'; export type * from './notificationTemplateBuilder.gen'; export * from './timeIntervalBuilder.gen'; export type * from './timeIntervalBuilder.gen'; +export * from './timeIntervalItemBuilder.gen'; +export type * from './timeIntervalItemBuilder.gen'; +export * from './timeIntervalTimeRangeBuilder.gen'; +export type * from './timeIntervalTimeRangeBuilder.gen'; export * from './ruleGroupBuilder.gen'; export type * from './ruleGroupBuilder.gen'; export * from './ruleBuilder.gen'; diff --git a/typescript/src/alerting/timeIntervalBuilder.gen.ts b/typescript/src/alerting/timeIntervalBuilder.gen.ts index ade786e..401e153 100644 --- a/typescript/src/alerting/timeIntervalBuilder.gen.ts +++ b/typescript/src/alerting/timeIntervalBuilder.gen.ts @@ -19,7 +19,7 @@ export class TimeIntervalBuilder implements cog.Builder { return this; } - timeIntervals(timeIntervals: cog.Builder[]): this { + timeIntervals(timeIntervals: cog.Builder[]): this { const timeIntervalsResources = timeIntervals.map(builder1 => builder1.build()); this.internal.time_intervals = timeIntervalsResources; return this; diff --git a/typescript/src/alerting/timeIntervalItemBuilder.gen.ts b/typescript/src/alerting/timeIntervalItemBuilder.gen.ts new file mode 100644 index 0000000..d922ae4 --- /dev/null +++ b/typescript/src/alerting/timeIntervalItemBuilder.gen.ts @@ -0,0 +1,47 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +import * as cog from '../cog'; +import * as alerting from '../alerting'; + +export class TimeIntervalItemBuilder implements cog.Builder { + protected readonly internal: alerting.TimeIntervalItem; + + constructor() { + this.internal = alerting.defaultTimeIntervalItem(); + } + + build(): alerting.TimeIntervalItem { + return this.internal; + } + + daysOfMonth(daysOfMonth: string[]): this { + this.internal.days_of_month = daysOfMonth; + return this; + } + + location(location: string): this { + this.internal.location = location; + return this; + } + + months(months: string[]): this { + this.internal.months = months; + return this; + } + + times(times: cog.Builder[]): this { + const timesResources = times.map(builder1 => builder1.build()); + this.internal.times = timesResources; + return this; + } + + weekdays(weekdays: string[]): this { + this.internal.weekdays = weekdays; + return this; + } + + years(years: string[]): this { + this.internal.years = years; + return this; + } +} diff --git a/typescript/src/alerting/timeIntervalTimeRangeBuilder.gen.ts b/typescript/src/alerting/timeIntervalTimeRangeBuilder.gen.ts new file mode 100644 index 0000000..e7c1d9b --- /dev/null +++ b/typescript/src/alerting/timeIntervalTimeRangeBuilder.gen.ts @@ -0,0 +1,26 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +import * as cog from '../cog'; +import * as alerting from '../alerting'; + +export class TimeIntervalTimeRangeBuilder implements cog.Builder { + protected readonly internal: alerting.TimeIntervalTimeRange; + + constructor() { + this.internal = alerting.defaultTimeIntervalTimeRange(); + } + + build(): alerting.TimeIntervalTimeRange { + return this.internal; + } + + endTime(endTime: string): this { + this.internal.end_time = endTime; + return this; + } + + startTime(startTime: string): this { + this.internal.start_time = startTime; + return this; + } +} diff --git a/typescript/src/alerting/types.gen.ts b/typescript/src/alerting/types.gen.ts index c4b82aa..37afeb4 100644 --- a/typescript/src/alerting/types.gen.ts +++ b/typescript/src/alerting/types.gen.ts @@ -16,9 +16,14 @@ export type MatchRegexps = Record; export const defaultMatchRegexps = (): MatchRegexps => ({}); -export type MatchType = number; +export enum MatchType { + Equal = "=", + NotEqual = "!=", + EqualRegex = "=~", + NotEqualRegex = "!~", +} -export const defaultMatchType = (): MatchType => (0); +export const defaultMatchType = (): MatchType => (MatchType.Equal); export interface Matcher { Name?: string; @@ -73,12 +78,32 @@ export const defaultRelativeTimeRange = (): RelativeTimeRange => ({ export interface TimeInterval { name?: string; - time_intervals?: TimeInterval[]; + time_intervals?: TimeIntervalItem[]; } export const defaultTimeInterval = (): TimeInterval => ({ }); +export interface TimeIntervalItem { + days_of_month?: string[]; + location?: string; + months?: string[]; + times?: TimeIntervalTimeRange[]; + weekdays?: string[]; + years?: string[]; +} + +export const defaultTimeIntervalItem = (): TimeIntervalItem => ({ +}); + +export interface TimeIntervalTimeRange { + end_time?: string; + start_time?: string; +} + +export const defaultTimeIntervalTimeRange = (): TimeIntervalTimeRange => ({ +}); + export interface RuleGroup { folderUid?: string; // The interval, in seconds, at which all rules in the group are evaluated. 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, }); ```