grafana / cog

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

Terraform: Remove dashes from package name #519

Closed spinillos closed 2 months ago

spinillos commented 2 months ago

It removes dashes from Terraform package names.

github-actions[bot] commented 2 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/notificationpolicy_builder_gen.go b/go/alerting/notificationpolicy_builder_gen.go index 6e5da26..6feca2c 100644 --- a/go/alerting/notificationpolicy_builder_gen.go +++ b/go/alerting/notificationpolicy_builder_gen.go @@ -41,6 +41,14 @@ func (builder *NotificationPolicyBuilder) Build() (NotificationPolicy, error) { return *builder.internal, nil } +// A Route is a node that contains definitions of how to handle alerts. This is modified +// from the upstream alertmanager in that it adds the ObjectMatchers property. +func (builder *NotificationPolicyBuilder) ActiveTimeIntervals(activeTimeIntervals []string) *NotificationPolicyBuilder { + builder.internal.ActiveTimeIntervals = activeTimeIntervals + + return builder +} + // A Route is a node that contains definitions of how to handle alerts. This is modified // from the upstream alertmanager in that it adds the ObjectMatchers property. func (builder *NotificationPolicyBuilder) Continue(continueArg bool) *NotificationPolicyBuilder { diff --git a/go/alerting/notificationtemplate_builder_gen.go b/go/alerting/notificationtemplate_builder_gen.go index 7087deb..2af7cac 100644 --- a/go/alerting/notificationtemplate_builder_gen.go +++ b/go/alerting/notificationtemplate_builder_gen.go @@ -57,5 +57,11 @@ func (builder *NotificationTemplateBuilder) Template(template string) *Notificat return builder } +func (builder *NotificationTemplateBuilder) Version(version string) *NotificationTemplateBuilder { + builder.internal.Version = &version + + return builder +} + func (builder *NotificationTemplateBuilder) applyDefaults() { } diff --git a/go/alerting/types_gen.go b/go/alerting/types_gen.go index e4205d0..89f5def 100644 --- a/go/alerting/types_gen.go +++ b/go/alerting/types_gen.go @@ -141,6 +141,7 @@ type NotificationTemplate struct { Name *string `json:"name,omitempty"` Provenance *Provenance `json:"provenance,omitempty"` Template *string `json:"template,omitempty"` + Version *string `json:"version,omitempty"` } type ObjectMatcher []string @@ -191,6 +192,9 @@ type RelativeTimeRange struct { // A Route is a node that contains definitions of how to handle alerts. This is modified // from the upstream alertmanager in that it adds the ObjectMatchers property. type NotificationPolicy struct { + // A Route is a node that contains definitions of how to handle alerts. This is modified + // from the upstream alertmanager in that it adds the ObjectMatchers property. + ActiveTimeIntervals []string `json:"active_time_intervals,omitempty"` // A Route is a node that contains definitions of how to handle alerts. This is modified // from the upstream alertmanager in that it adds the ObjectMatchers property. Continue *bool `json:"continue,omitempty"` diff --git a/go/dashboard/types_gen.go b/go/dashboard/types_gen.go index a95bc16..6bb90ae 100644 --- a/go/dashboard/types_gen.go +++ b/go/dashboard/types_gen.go @@ -291,6 +291,7 @@ const ( VariableTypeTextbox VariableType = "textbox" VariableTypeCustom VariableType = "custom" VariableTypeSystem VariableType = "system" + VariableTypeSnapshot VariableType = "snapshot" ) // Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value. diff --git a/go/expr/types_gen.go b/go/expr/types_gen.go index f154a57..3d0826d 100644 --- a/go/expr/types_gen.go +++ b/go/expr/types_gen.go @@ -676,8 +676,9 @@ const ( type TypeClassicConditionsType string const ( - TypeClassicConditionsTypeAnd TypeClassicConditionsType = "and" - TypeClassicConditionsTypeOr TypeClassicConditionsType = "or" + TypeClassicConditionsTypeAnd TypeClassicConditionsType = "and" + TypeClassicConditionsTypeOr TypeClassicConditionsType = "or" + TypeClassicConditionsTypeLogicOr TypeClassicConditionsType = "logic-or" ) type TypeThresholdType string diff --git a/go/logs/panel_builder_gen.go b/go/logs/panel_builder_gen.go index b3880c7..2fcdccc 100644 --- a/go/logs/panel_builder_gen.go +++ b/go/logs/panel_builder_gen.go @@ -542,6 +542,33 @@ func (builder *PanelBuilder) OnClickFilterOutString(onClickFilterOutString any) return builder } +func (builder *PanelBuilder) OnClickShowField(onClickShowField any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickShowField = &onClickShowField + + return builder +} + +func (builder *PanelBuilder) OnClickHideField(onClickHideField any) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).OnClickHideField = &onClickHideField + + return builder +} + +func (builder *PanelBuilder) DisplayedFields(displayedFields []string) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).DisplayedFields = displayedFields + + 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 b79fc6a..baa6855 100644 --- a/go/logs/types_gen.go +++ b/go/logs/types_gen.go @@ -20,11 +20,14 @@ type Options struct { 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"` + 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"` + OnClickShowField any `json:"onClickShowField,omitempty"` + OnClickHideField any `json:"onClickHideField,omitempty"` + DisplayedFields []string `json:"displayedFields,omitempty"` } func VariantConfig() variants.PanelcfgConfig { diff --git a/go/statetimeline/panel_builder_gen.go b/go/statetimeline/panel_builder_gen.go index fb9edc2..ef438e2 100644 --- a/go/statetimeline/panel_builder_gen.go +++ b/go/statetimeline/panel_builder_gen.go @@ -449,6 +449,16 @@ func (builder *PanelBuilder) MergeValues(mergeValues bool) *PanelBuilder { return builder } +// Controls value alignment on the timelines +func (builder *PanelBuilder) AlignValue(alignValue common.TimelineValueAlignment) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).AlignValue = &alignValue + + return builder +} + func (builder *PanelBuilder) Legend(legend cog.Builder[common.VizLegendOptions]) *PanelBuilder { if builder.internal.Options == nil { builder.internal.Options = &Options{} @@ -486,12 +496,16 @@ func (builder *PanelBuilder) Timezone(timezone []common.TimeZone) *PanelBuilder return builder } -// Controls value alignment on the timelines -func (builder *PanelBuilder) AlignValue(alignValue common.TimelineValueAlignment) *PanelBuilder { +// Enables pagination when > 0 +func (builder *PanelBuilder) PerPage(perPage float64) *PanelBuilder { + if !(perPage >= 1) { + builder.errors["perPage"] = cog.MakeBuildErrors("perPage", errors.New("perPage must be >= 1")) + return builder + } if builder.internal.Options == nil { builder.internal.Options = &Options{} } - builder.internal.Options.(*Options).AlignValue = &alignValue + builder.internal.Options.(*Options).PerPage = &perPage return builder } @@ -553,6 +567,7 @@ func (builder *PanelBuilder) applyDefaults() { builder.RowHeight(0.9) builder.MergeValues(true) builder.AlignValue("left") + builder.PerPage(20) builder.LineWidth(0) builder.FillOpacity(70) } diff --git a/go/statetimeline/types_gen.go b/go/statetimeline/types_gen.go index 305599d..14095c4 100644 --- a/go/statetimeline/types_gen.go +++ b/go/statetimeline/types_gen.go @@ -15,12 +15,14 @@ type Options struct { // Controls the row height RowHeight float64 `json:"rowHeight"` // Merge equal consecutive values - MergeValues *bool `json:"mergeValues,omitempty"` - Legend common.VizLegendOptions `json:"legend"` - Tooltip common.VizTooltipOptions `json:"tooltip"` - Timezone []common.TimeZone `json:"timezone,omitempty"` + MergeValues *bool `json:"mergeValues,omitempty"` // Controls value alignment on the timelines AlignValue *common.TimelineValueAlignment `json:"alignValue,omitempty"` + Legend common.VizLegendOptions `json:"legend"` + Tooltip common.VizTooltipOptions `json:"tooltip"` + Timezone []common.TimeZone `json:"timezone,omitempty"` + // Enables pagination when > 0 + PerPage *float64 `json:"perPage,omitempty"` } type FieldConfig struct { diff --git a/java/gradle.properties b/java/gradle.properties index 26ea477..74c71c4 100644 --- a/java/gradle.properties +++ b/java/gradle.properties @@ -1 +1 @@ -grafanaFoundationSDKVersion=next-1722522306 +grafanaFoundationSDKVersion=next-1724751689 diff --git a/java/src/main/java/com/grafana/foundation/alerting/NotificationPolicy.java b/java/src/main/java/com/grafana/foundation/alerting/NotificationPolicy.java index 2680962..6e72c67 100644 --- a/java/src/main/java/com/grafana/foundation/alerting/NotificationPolicy.java +++ b/java/src/main/java/com/grafana/foundation/alerting/NotificationPolicy.java @@ -12,6 +12,10 @@ import com.fasterxml.jackson.databind.ObjectWriter; // A Route is a node that contains definitions of how to handle alerts. This is modified // from the upstream alertmanager in that it adds the ObjectMatchers property. public class NotificationPolicy { + // A Route is a node that contains definitions of how to handle alerts. This is modified + // from the upstream alertmanager in that it adds the ObjectMatchers property. + @JsonProperty("active_time_intervals") + public List activeTimeIntervals; // A Route is a node that contains definitions of how to handle alerts. This is modified // from the upstream alertmanager in that it adds the ObjectMatchers property. @JsonProperty("continue") @@ -77,6 +81,11 @@ public class NotificationPolicy { public Builder() { this.internal = new NotificationPolicy(); } + public Builder activeTimeIntervals(List activeTimeIntervals) { + this.internal.activeTimeIntervals = activeTimeIntervals; + return this; + } + public Builder continueArg(Boolean continueArg) { this.internal.continueArg = continueArg; return this; diff --git a/java/src/main/java/com/grafana/foundation/alerting/NotificationTemplate.java b/java/src/main/java/com/grafana/foundation/alerting/NotificationTemplate.java index 508f3a1..cd57282 100644 --- a/java/src/main/java/com/grafana/foundation/alerting/NotificationTemplate.java +++ b/java/src/main/java/com/grafana/foundation/alerting/NotificationTemplate.java @@ -13,7 +13,9 @@ public class NotificationTemplate { @JsonProperty("provenance") public String provenance; @JsonProperty("template") - public String template; + public String template; + @JsonProperty("version") + public String version; public String toJSON() throws JsonProcessingException { ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); @@ -41,6 +43,11 @@ public class NotificationTemplate { this.internal.template = template; return this; } + + public Builder version(String version) { + this.internal.version = version; + return this; + } public NotificationTemplate build() { return this.internal; } diff --git a/java/src/main/java/com/grafana/foundation/common/Constants.java b/java/src/main/java/com/grafana/foundation/common/Constants.java index be9af52..cc841b4 100644 --- a/java/src/main/java/com/grafana/foundation/common/Constants.java +++ b/java/src/main/java/com/grafana/foundation/common/Constants.java @@ -3,6 +3,6 @@ package com.grafana.foundation.common; public class Constants { - public static final String TimeZoneBrowser = "browser"; public static final String TimeZoneUtc = "utc"; + public static final String TimeZoneBrowser = "browser"; } diff --git a/java/src/main/java/com/grafana/foundation/dashboard/VariableType.java b/java/src/main/java/com/grafana/foundation/dashboard/VariableType.java index 6c61345..dec7e8e 100644 --- a/java/src/main/java/com/grafana/foundation/dashboard/VariableType.java +++ b/java/src/main/java/com/grafana/foundation/dashboard/VariableType.java @@ -26,6 +26,7 @@ public enum VariableType { TEXTBOX("textbox"), CUSTOM("custom"), SYSTEM("system"), + SNAPSHOT("snapshot"), _EMPTY(""); private final String value; diff --git a/java/src/main/java/com/grafana/foundation/expr/TypeClassicConditionsType.java b/java/src/main/java/com/grafana/foundation/expr/TypeClassicConditionsType.java index ae5daef..fdafbcf 100644 --- a/java/src/main/java/com/grafana/foundation/expr/TypeClassicConditionsType.java +++ b/java/src/main/java/com/grafana/foundation/expr/TypeClassicConditionsType.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonValue; public enum TypeClassicConditionsType { AND("and"), OR("or"), + LOGIC_OR("logic-or"), _EMPTY(""); private final String value; diff --git a/java/src/main/java/com/grafana/foundation/logs/Options.java b/java/src/main/java/com/grafana/foundation/logs/Options.java index 6170125..8b4ec92 100644 --- a/java/src/main/java/com/grafana/foundation/logs/Options.java +++ b/java/src/main/java/com/grafana/foundation/logs/Options.java @@ -4,6 +4,7 @@ package com.grafana.foundation.logs; import com.grafana.foundation.common.LogsSortOrder; import com.grafana.foundation.common.LogsDedupStrategy; +import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -38,7 +39,13 @@ public class Options { @JsonProperty("onClickFilterString") public Object onClickFilterString; @JsonProperty("onClickFilterOutString") - public Object onClickFilterOutString; + public Object onClickFilterOutString; + @JsonProperty("onClickShowField") + public Object onClickShowField; + @JsonProperty("onClickHideField") + public Object onClickHideField; + @JsonProperty("displayedFields") + public List displayedFields; public String toJSON() throws JsonProcessingException { ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); diff --git a/java/src/main/java/com/grafana/foundation/logs/PanelBuilder.java b/java/src/main/java/com/grafana/foundation/logs/PanelBuilder.java index b0c93fb..be02dfb 100644 --- a/java/src/main/java/com/grafana/foundation/logs/PanelBuilder.java +++ b/java/src/main/java/com/grafana/foundation/logs/PanelBuilder.java @@ -4,12 +4,12 @@ package com.grafana.foundation.logs; import com.grafana.foundation.common.LogsSortOrder; import com.grafana.foundation.common.LogsDedupStrategy; +import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.grafana.foundation.dashboard.Panel; -import java.util.List; import com.grafana.foundation.cog.variants.Dataquery; import java.util.LinkedList; import com.grafana.foundation.dashboard.DataSourceRef; @@ -383,6 +383,33 @@ public class PanelBuilder implements com.grafana.foundation.cog.Builder { this.internal.options = optionsResource; return this; } + public PanelBuilder onClickShowField(Object onClickShowField) { + if (this.internal.options == null) { + this.internal.options = new com.grafana.foundation.logs.Options(); + } + com.grafana.foundation.logs.Options optionsResource = (com.grafana.foundation.logs.Options) this.internal.options; + optionsResource.onClickShowField = onClickShowField; + this.internal.options = optionsResource; + return this; + } + public PanelBuilder onClickHideField(Object onClickHideField) { + if (this.internal.options == null) { + this.internal.options = new com.grafana.foundation.logs.Options(); + } + com.grafana.foundation.logs.Options optionsResource = (com.grafana.foundation.logs.Options) this.internal.options; + optionsResource.onClickHideField = onClickHideField; + this.internal.options = optionsResource; + return this; + } + public PanelBuilder displayedFields(List displayedFields) { + if (this.internal.options == null) { + this.internal.options = new com.grafana.foundation.logs.Options(); + } + com.grafana.foundation.logs.Options optionsResource = (com.grafana.foundation.logs.Options) this.internal.options; + optionsResource.displayedFields = displayedFields; + this.internal.options = optionsResource; + return this; + } public Panel build() { return this.internal; diff --git a/java/src/main/java/com/grafana/foundation/statetimeline/Options.java b/java/src/main/java/com/grafana/foundation/statetimeline/Options.java index 8f4eedc..1c2ed88 100644 --- a/java/src/main/java/com/grafana/foundation/statetimeline/Options.java +++ b/java/src/main/java/com/grafana/foundation/statetimeline/Options.java @@ -3,10 +3,10 @@ package com.grafana.foundation.statetimeline; import com.grafana.foundation.common.VisibilityMode; +import com.grafana.foundation.common.TimelineValueAlignment; import com.grafana.foundation.common.VizLegendOptions; import com.grafana.foundation.common.VizTooltipOptions; import java.util.List; -import com.grafana.foundation.common.TimelineValueAlignment; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -21,16 +21,19 @@ public class Options { public Double rowHeight; // Merge equal consecutive values @JsonProperty("mergeValues") - public Boolean mergeValues; + public Boolean mergeValues; + // Controls value alignment on the timelines + @JsonProperty("alignValue") + public TimelineValueAlignment alignValue; @JsonProperty("legend") public VizLegendOptions legend; @JsonProperty("tooltip") public VizTooltipOptions tooltip; @JsonProperty("timezone") public List timezone; - // Controls value alignment on the timelines - @JsonProperty("alignValue") - public TimelineValueAlignment alignValue; + // Enables pagination when > 0 + @JsonProperty("perPage") + public Double perPage; public String toJSON() throws JsonProcessingException { ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); diff --git a/java/src/main/java/com/grafana/foundation/statetimeline/PanelBuilder.java b/java/src/main/java/com/grafana/foundation/statetimeline/PanelBuilder.java index 067a82e..4c634a5 100644 --- a/java/src/main/java/com/grafana/foundation/statetimeline/PanelBuilder.java +++ b/java/src/main/java/com/grafana/foundation/statetimeline/PanelBuilder.java @@ -3,10 +3,10 @@ package com.grafana.foundation.statetimeline; import com.grafana.foundation.common.VisibilityMode; +import com.grafana.foundation.common.TimelineValueAlignment; import com.grafana.foundation.common.VizLegendOptions; import com.grafana.foundation.common.VizTooltipOptions; import java.util.List; -import com.grafana.foundation.common.TimelineValueAlignment; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -39,6 +39,7 @@ public class PanelBuilder implements com.grafana.foundation.cog.Builder { this.rowHeight(0.9); this.mergeValues(true); this.alignValue(TimelineValueAlignment.LEFT); + this.perPage(20.0); this.lineWidth(0); this.fillOpacity(70); } @@ -296,6 +297,15 @@ public class PanelBuilder implements com.grafana.foundation.cog.Builder { this.internal.options = optionsResource; return this; } + public PanelBuilder alignValue(TimelineValueAlignment alignValue) { + if (this.internal.options == null) { + this.internal.options = new com.grafana.foundation.statetimeline.Options(); + } + com.grafana.foundation.statetimeline.Options optionsResource = (com.grafana.foundation.statetimeline.Options) this.internal.options; + optionsResource.alignValue = alignValue; + this.internal.options = optionsResource; + return this; + } public PanelBuilder legend(com.grafana.foundation.cog.Builder legend) { if (this.internal.options == null) { this.internal.options = new com.grafana.foundation.statetimeline.Options(); @@ -323,12 +333,15 @@ public class PanelBuilder implements com.grafana.foundation.cog.Builder { this.internal.options = optionsResource; return this; } - public PanelBuilder alignValue(TimelineValueAlignment alignValue) { + public PanelBuilder perPage(Double perPage) { + if (!(perPage >= 1)) { + throw new IllegalArgumentException("perPage must be >= 1"); + } if (this.internal.options == null) { this.internal.options = new com.grafana.foundation.statetimeline.Options(); } com.grafana.foundation.statetimeline.Options optionsResource = (com.grafana.foundation.statetimeline.Options) this.internal.options; - optionsResource.alignValue = alignValue; + optionsResource.perPage = perPage; this.internal.options = optionsResource; return this; } diff --git a/jsonschema/alerting.jsonschema.json b/jsonschema/alerting.jsonschema.json index bb926f0..e4b5d3a 100644 --- a/jsonschema/alerting.jsonschema.json +++ b/jsonschema/alerting.jsonschema.json @@ -209,6 +209,9 @@ }, "template": { "type": "string" + }, + "version": { + "type": "string" } } }, @@ -358,6 +361,13 @@ "type": "object", "additionalProperties": false, "properties": { + "active_time_intervals": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A Route is a node that contains definitions of how to handle alerts. This is modified\nfrom the upstream alertmanager in that it adds the ObjectMatchers property." + }, "continue": { "type": "boolean", "description": "A Route is a node that contains definitions of how to handle alerts. This is modified\nfrom the upstream alertmanager in that it adds the ObjectMatchers property." diff --git a/jsonschema/dashboard.jsonschema.json b/jsonschema/dashboard.jsonschema.json index 78923dc..a1454e7 100644 --- a/jsonschema/dashboard.jsonschema.json +++ b/jsonschema/dashboard.jsonschema.json @@ -537,7 +537,8 @@ "interval", "textbox", "custom", - "system" + "system", + "snapshot" ], "description": "Dashboard variable type\n`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.\n`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).\n`constant`: \tDefine a hidden constant.\n`datasource`: Quickly change the data source for an entire dashboard.\n`interval`: Interval variables represent time spans.\n`textbox`: Display a free text input field with an optional default value.\n`custom`: Define the variable options manually using a comma-separated list.\n`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables" }, diff --git a/jsonschema/expr.jsonschema.json b/jsonschema/expr.jsonschema.json index 0edafd9..7179f7a 100644 --- a/jsonschema/expr.jsonschema.json +++ b/jsonschema/expr.jsonschema.json @@ -500,7 +500,8 @@ "type": { "enum": [ "and", - "or" + "or", + "logic-or" ] } } diff --git a/jsonschema/logs.jsonschema.json b/jsonschema/logs.jsonschema.json index bcf9764..9cdf0f8 100644 --- a/jsonschema/logs.jsonschema.json +++ b/jsonschema/logs.jsonschema.json @@ -63,6 +63,20 @@ "onClickFilterOutString": { "type": "object", "additionalProperties": {} + }, + "onClickShowField": { + "type": "object", + "additionalProperties": {} + }, + "onClickHideField": { + "type": "object", + "additionalProperties": {} + }, + "displayedFields": { + "type": "array", + "items": { + "type": "string" + } } } }, diff --git a/jsonschema/statetimeline.jsonschema.json b/jsonschema/statetimeline.jsonschema.json index 7547899..f7490ec 100644 --- a/jsonschema/statetimeline.jsonschema.json +++ b/jsonschema/statetimeline.jsonschema.json @@ -27,6 +27,11 @@ "description": "Merge equal consecutive values", "default": true }, + "alignValue": { + "$ref": "#/definitions/TimelineValueAlignment", + "description": "Controls value alignment on the timelines", + "default": "left" + }, "legend": { "$ref": "#/definitions/VizLegendOptions" }, @@ -39,10 +44,11 @@ "$ref": "#/definitions/TimeZone" } }, - "alignValue": { - "$ref": "#/definitions/TimelineValueAlignment", - "description": "Controls value alignment on the timelines", - "default": "left" + "perPage": { + "type": "number", + "minimum": 1, + "description": "Enables pagination when \u003e 0", + "default": 20 } } }, @@ -73,6 +79,14 @@ ], "description": "TODO docs" }, + "TimelineValueAlignment": { + "enum": [ + "center", + "left", + "right" + ], + "description": "Controls the value alignment in the TimelineChart component" + }, "VizLegendOptions": { "type": "object", "additionalProperties": false, @@ -146,14 +160,6 @@ "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, - "TimelineValueAlignment": { - "enum": [ - "center", - "left", - "right" - ], - "description": "Controls the value alignment in the TimelineChart component" - }, "HideSeriesConfig": { "type": "object", "additionalProperties": false, diff --git a/openapi/alerting.openapi.json b/openapi/alerting.openapi.json index 9d6de84..ac08e52 100644 --- a/openapi/alerting.openapi.json +++ b/openapi/alerting.openapi.json @@ -217,6 +217,9 @@ }, "template": { "type": "string" + }, + "version": { + "type": "string" } } }, @@ -366,6 +369,13 @@ "type": "object", "additionalProperties": false, "properties": { + "active_time_intervals": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A Route is a node that contains definitions of how to handle alerts. This is modified\nfrom the upstream alertmanager in that it adds the ObjectMatchers property." + }, "continue": { "type": "boolean", "description": "A Route is a node that contains definitions of how to handle alerts. This is modified\nfrom the upstream alertmanager in that it adds the ObjectMatchers property." diff --git a/openapi/dashboard.openapi.json b/openapi/dashboard.openapi.json index 91548cc..ab92de9 100644 --- a/openapi/dashboard.openapi.json +++ b/openapi/dashboard.openapi.json @@ -544,7 +544,8 @@ "interval", "textbox", "custom", - "system" + "system", + "snapshot" ], "description": "Dashboard variable type\n`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.\n`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).\n`constant`: \tDefine a hidden constant.\n`datasource`: Quickly change the data source for an entire dashboard.\n`interval`: Interval variables represent time spans.\n`textbox`: Display a free text input field with an optional default value.\n`custom`: Define the variable options manually using a comma-separated list.\n`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables" }, diff --git a/openapi/expr.openapi.json b/openapi/expr.openapi.json index 68b8893..266fef1 100644 --- a/openapi/expr.openapi.json +++ b/openapi/expr.openapi.json @@ -508,7 +508,8 @@ "type": { "enum": [ "and", - "or" + "or", + "logic-or" ] } } diff --git a/openapi/logs.openapi.json b/openapi/logs.openapi.json index bc26d8e..9dbff17 100644 --- a/openapi/logs.openapi.json +++ b/openapi/logs.openapi.json @@ -72,6 +72,20 @@ "onClickFilterOutString": { "type": "object", "additionalProperties": {} + }, + "onClickShowField": { + "type": "object", + "additionalProperties": {} + }, + "onClickHideField": { + "type": "object", + "additionalProperties": {} + }, + "displayedFields": { + "type": "array", + "items": { + "type": "string" + } } } }, diff --git a/openapi/statetimeline.openapi.json b/openapi/statetimeline.openapi.json index 2b91df9..2b91221 100644 --- a/openapi/statetimeline.openapi.json +++ b/openapi/statetimeline.openapi.json @@ -36,6 +36,11 @@ "description": "Merge equal consecutive values", "default": true }, + "alignValue": { + "$ref": "#/components/schemas/TimelineValueAlignment", + "description": "Controls value alignment on the timelines", + "default": "left" + }, "legend": { "$ref": "#/components/schemas/VizLegendOptions" }, @@ -48,10 +53,11 @@ "$ref": "#/components/schemas/TimeZone" } }, - "alignValue": { - "$ref": "#/components/schemas/TimelineValueAlignment", - "description": "Controls value alignment on the timelines", - "default": "left" + "perPage": { + "type": "number", + "minimum": 1, + "description": "Enables pagination when \u003e 0", + "default": 20 } } }, @@ -82,6 +88,14 @@ ], "description": "TODO docs" }, + "TimelineValueAlignment": { + "enum": [ + "center", + "left", + "right" + ], + "description": "Controls the value alignment in the TimelineChart component" + }, "VizLegendOptions": { "type": "object", "additionalProperties": false, @@ -155,14 +169,6 @@ "type": "string", "description": "A specific timezone from https://en.wikipedia.org/wiki/Tz_database" }, - "TimelineValueAlignment": { - "enum": [ - "center", - "left", - "right" - ], - "description": "Controls the value alignment in the TimelineChart component" - }, "HideSeriesConfig": { "type": "object", "additionalProperties": false, diff --git a/php/src/Alerting/NotificationPolicy.php b/php/src/Alerting/NotificationPolicy.php index 3c2a3bc..e5a1dd0 100644 --- a/php/src/Alerting/NotificationPolicy.php +++ b/php/src/Alerting/NotificationPolicy.php @@ -8,6 +8,13 @@ namespace Grafana\Foundation\Alerting; */ class NotificationPolicy implements \JsonSerializable { + /** + * A Route is a node that contains definitions of how to handle alerts. This is modified + * from the upstream alertmanager in that it adds the ObjectMatchers property. + * @var array|null + */ + public ?array $activeTimeIntervals; + /** * A Route is a node that contains definitions of how to handle alerts. This is modified * from the upstream alertmanager in that it adds the ObjectMatchers property. @@ -94,6 +101,7 @@ class NotificationPolicy implements \JsonSerializable public ?array $routes; /** + * @param array|null $activeTimeIntervals * @param bool|null $continue * @param array|null $groupBy * @param string|null $groupInterval @@ -108,8 +116,9 @@ class NotificationPolicy implements \JsonSerializable * @param string|null $repeatInterval * @param array<\Grafana\Foundation\Alerting\NotificationPolicy>|null $routes */ - public function __construct(?bool $continue = null, ?array $groupBy = null, ?string $groupInterval = null, ?string $groupWait = null, ?array $match = null, ?array $matchRe = null, ?array $matchers = null, ?array $muteTimeIntervals = null, ?array $objectMatchers = null, ?string $provenance = null, ?string $receiver = null, ?string $repeatInterval = null, ?array $routes = null) + public function __construct(?array $activeTimeIntervals = null, ?bool $continue = null, ?array $groupBy = null, ?string $groupInterval = null, ?string $groupWait = null, ?array $match = null, ?array $matchRe = null, ?array $matchers = null, ?array $muteTimeIntervals = null, ?array $objectMatchers = null, ?string $provenance = null, ?string $receiver = null, ?string $repeatInterval = null, ?array $routes = null) { + $this->activeTimeIntervals = $activeTimeIntervals; $this->continue = $continue; $this->groupBy = $groupBy; $this->groupInterval = $groupInterval; @@ -130,9 +139,10 @@ class NotificationPolicy implements \JsonSerializable */ public static function fromArray(array $inputData): self { - /** @var array{continue?: bool, group_by?: array, group_interval?: string, group_wait?: string, match?: array, match_re?: array, matchers?: array, mute_time_intervals?: array, object_matchers?: array>, provenance?: string, receiver?: string, repeat_interval?: string, routes?: array} $inputData */ + /** @var array{active_time_intervals?: array, continue?: bool, group_by?: array, group_interval?: string, group_wait?: string, match?: array, match_re?: array, matchers?: array, mute_time_intervals?: array, object_matchers?: array>, provenance?: string, receiver?: string, repeat_interval?: string, routes?: array} $inputData */ $data = $inputData; return new self( + activeTimeIntervals: $data["active_time_intervals"] ?? null, continue: $data["continue"] ?? null, groupBy: $data["group_by"] ?? null, groupInterval: $data["group_interval"] ?? null, @@ -150,7 +160,7 @@ class NotificationPolicy implements \JsonSerializable receiver: $data["receiver"] ?? null, repeatInterval: $data["repeat_interval"] ?? null, routes: array_filter(array_map((function($input) { - /** @var array{continue?: bool, group_by?: array, group_interval?: string, group_wait?: string, match?: array, match_re?: array, matchers?: array, mute_time_intervals?: array, object_matchers?: array>, provenance?: string, receiver?: string, repeat_interval?: string, routes?: array} */ + /** @var array{active_time_intervals?: array, continue?: bool, group_by?: array, group_interval?: string, group_wait?: string, match?: array, match_re?: array, matchers?: array, mute_time_intervals?: array, object_matchers?: array>, provenance?: string, receiver?: string, repeat_interval?: string, routes?: array} */ $val = $input; return \Grafana\Foundation\Alerting\NotificationPolicy::fromArray($val); }), $data["routes"] ?? [])), @@ -168,6 +178,9 @@ class NotificationPolicy implements \JsonSerializable "object_matchers" => $this->objectMatchers, "provenance" => $this->provenance, ]; + if (isset($this->activeTimeIntervals)) { + $data["active_time_intervals"] = $this->activeTimeIntervals; + } if (isset($this->continue)) { $data["continue"] = $this->continue; } diff --git a/php/src/Alerting/NotificationPolicyBuilder.php b/php/src/Alerting/NotificationPolicyBuilder.php index c024b2c..57cefc4 100644 --- a/php/src/Alerting/NotificationPolicyBuilder.php +++ b/php/src/Alerting/NotificationPolicyBuilder.php @@ -24,6 +24,17 @@ class NotificationPolicyBuilder implements \Grafana\Foundation\Cog\Builder return $this->internal; } + /** + * A Route is a node that contains definitions of how to handle alerts. This is modified + * from the upstream alertmanager in that it adds the ObjectMatchers property. + * @param array $activeTimeIntervals + */ + public function activeTimeIntervals(array $activeTimeIntervals): static + { + $this->internal->activeTimeIntervals = $activeTimeIntervals; + + return $this; + } /** * A Route is a node that contains definitions of how to handle alerts. This is modified * from the upstream alertmanager in that it adds the ObjectMatchers property. diff --git a/php/src/Alerting/NotificationTemplate.php b/php/src/Alerting/NotificationTemplate.php index e914c7a..19e9790 100644 --- a/php/src/Alerting/NotificationTemplate.php +++ b/php/src/Alerting/NotificationTemplate.php @@ -10,16 +10,20 @@ class NotificationTemplate implements \JsonSerializable public ?string $template; + public ?string $version; + /** * @param string|null $name * @param string|null $provenance * @param string|null $template + * @param string|null $version */ - public function __construct(?string $name = null, ?string $provenance = null, ?string $template = null) + public function __construct(?string $name = null, ?string $provenance = null, ?string $template = null, ?string $version = null) { $this->name = $name; $this->provenance = $provenance ?: ""; $this->template = $template; + $this->version = $version; } /** @@ -27,12 +31,13 @@ class NotificationTemplate implements \JsonSerializable */ public static function fromArray(array $inputData): self { - /** @var array{name?: string, provenance?: string, template?: string} $inputData */ + /** @var array{name?: string, provenance?: string, template?: string, version?: string} $inputData */ $data = $inputData; return new self( name: $data["name"] ?? null, provenance: $data["provenance"] ?? null, template: $data["template"] ?? null, + version: $data["version"] ?? null, ); } @@ -50,6 +55,9 @@ class NotificationTemplate implements \JsonSerializable if (isset($this->template)) { $data["template"] = $this->template; } + if (isset($this->version)) { + $data["version"] = $this->version; + } return $data; } } diff --git a/php/src/Alerting/NotificationTemplateBuilder.php b/php/src/Alerting/NotificationTemplateBuilder.php index 7ab6d93..1f48d27 100644 --- a/php/src/Alerting/NotificationTemplateBuilder.php +++ b/php/src/Alerting/NotificationTemplateBuilder.php @@ -40,5 +40,11 @@ class NotificationTemplateBuilder implements \Grafana\Foundation\Cog\Builder return $this; } + public function version(string $version): static + { + $this->internal->version = $version; + + return $this; + } } diff --git a/php/src/Azuremonitor/AzureMonitorQuery.php b/php/src/Azuremonitor/AzureMonitorQuery.php index d7854cb..e7cb79d 100644 --- a/php/src/Azuremonitor/AzureMonitorQuery.php +++ b/php/src/Azuremonitor/AzureMonitorQuery.php @@ -159,26 +159,26 @@ class AzureMonitorQuery implements \JsonSerializable, \Grafana\Foundation\Cog\Da \assert(is_array($input), 'expected disjunction value to be an array'); switch ($input["kind"]) { - case "AppInsightsMetricNameQuery": - return AppInsightsMetricNameQuery::fromArray($input); + case "ResourceGroupsQuery": + return ResourceGroupsQuery::fromArray($input); case "ResourceNamesQuery": return ResourceNamesQuery::fromArray($input); - case "SubscriptionsQuery": - return SubscriptionsQuery::fromArray($input); - case "UnknownQuery": - return UnknownQuery::fromArray($input); - case "MetricNamesQuery": - return MetricNamesQuery::fromArray($input); case "MetricNamespaceQuery": return MetricNamespaceQuery::fromArray($input); case "MetricDefinitionsQuery": return MetricDefinitionsQuery::fromArray($input); + case "AppInsightsMetricNameQuery": + return AppInsightsMetricNameQuery::fromArray($input); + case "SubscriptionsQuery": + return SubscriptionsQuery::fromArray($input); case "WorkspacesQuery": return WorkspacesQuery::fromArray($input); + case "UnknownQuery": + return UnknownQuery::fromArray($input); + case "MetricNamesQuery": + return MetricNamesQuery::fromArray($input); case "AppInsightsGroupByQuery": return AppInsightsGroupByQuery::fromArray($input); - case "ResourceGroupsQuery": - return ResourceGroupsQuery::fromArray($input); default: throw new \ValueError('can not parse disjunction from array'); } diff --git a/php/src/Cloudwatch/VariantConfig.php b/php/src/Cloudwatch/VariantConfig.php index 0e16d2d..54991a9 100644 --- a/php/src/Cloudwatch/VariantConfig.php +++ b/php/src/Cloudwatch/VariantConfig.php @@ -12,12 +12,12 @@ final class VariantConfig \assert(is_array($input), 'expected disjunction value to be an array'); switch ($input["queryMode"]) { - case "Annotations": - return CloudWatchAnnotationQuery::fromArray($input); case "Metrics": return CloudWatchMetricsQuery::fromArray($input); case "Logs": return CloudWatchLogsQuery::fromArray($input); + case "Annotations": + return CloudWatchAnnotationQuery::fromArray($input); default: throw new \ValueError('can not parse disjunction from array'); } diff --git a/php/src/Common/TableFieldOptions.php b/php/src/Common/TableFieldOptions.php index ba49fbe..b568213 100644 --- a/php/src/Common/TableFieldOptions.php +++ b/php/src/Common/TableFieldOptions.php @@ -78,12 +78,6 @@ class TableFieldOptions implements \JsonSerializable \assert(is_array($input), 'expected disjunction value to be an array'); switch ($input["type"]) { - case "json-view": - return TableJsonViewCellOptions::fromArray($input); - case "auto": - return TableAutoCellOptions::fromArray($input); - case "sparkline": - return TableSparklineCellOptions::fromArray($input); case "gauge": return TableBarGaugeCellOptions::fromArray($input); case "color-background": @@ -94,6 +88,12 @@ class TableFieldOptions implements \JsonSerializable return TableImageCellOptions::fromArray($input); case "data-links": return TableDataLinksCellOptions::fromArray($input); + case "json-view": + return TableJsonViewCellOptions::fromArray($input); + case "auto": + return TableAutoCellOptions::fromArray($input); + case "sparkline": + return TableSparklineCellOptions::fromArray($input); default: throw new \ValueError('can not parse disjunction from array'); } diff --git a/php/src/Dashboard/VariableType.php b/php/src/Dashboard/VariableType.php index 62f1c1d..f4f2de2 100644 --- a/php/src/Dashboard/VariableType.php +++ b/php/src/Dashboard/VariableType.php @@ -110,6 +110,15 @@ final class VariableType implements \JsonSerializable, \Stringable { return self::$instances["system"]; } + public static function snapshot(): self + { + if (!isset(self::$instances["snapshot"])) { + self::$instances["snapshot"] = new self("snapshot"); + } + + return self::$instances["snapshot"]; + } + public static function fromValue(string $value): self { if ($value === "query") { @@ -148,6 +157,10 @@ final class VariableType implements \JsonSerializable, \Stringable { return self::system(); } + if ($value === "snapshot") { + return self::snapshot(); + } + throw new \UnexpectedValueException("Value '$value' is not part of the enum VariableType"); } diff --git a/php/src/Elasticsearch/Dataquery.php b/php/src/Elasticsearch/Dataquery.php index 452f02c..87b91b8 100644 --- a/php/src/Elasticsearch/Dataquery.php +++ b/php/src/Elasticsearch/Dataquery.php @@ -97,8 +97,6 @@ class Dataquery implements \JsonSerializable, \Grafana\Foundation\Cog\Dataquery \assert(is_array($input), 'expected disjunction value to be an array'); switch ($input["type"]) { - case "histogram": - return Histogram::fromArray($input); case "terms": return Terms::fromArray($input); case "filters": @@ -109,6 +107,8 @@ class Dataquery implements \JsonSerializable, \Grafana\Foundation\Cog\Dataquery return Nested::fromArray($input); case "date_histogram": return DateHistogram::fromArray($input); + case "histogram": + return Histogram::fromArray($input); default: throw new \ValueError('can not parse disjunction from array'); } @@ -119,40 +119,40 @@ class Dataquery implements \JsonSerializable, \Grafana\Foundation\Cog\Dataquery switch ($input["type"]) { case "cumulative_sum": return CumulativeSum::fromArray($input); - case "moving_fn": - return MovingFunction::fromArray($input); - case "moving_avg": - return MovingAverage::fromArray($input); + case "avg": + return Average::fromArray($input); case "derivative": return Derivative::fromArray($input); - case "sum": - return Sum::fromArray($input); case "count": return Count::fromArray($input); + case "min": + return Min::fromArray($input); + case "sum": + return Sum::fromArray($input); + case "rate": + return Rate::fromArray($input); + case "percentiles": + return Percentiles::fromArray($input); case "extended_stats": return ExtendedStats::fromArray($input); + case "logs": + return Logs::fromArray($input); case "top_metrics": return TopMetrics::fromArray($input); - case "percentiles": - return Percentiles::fromArray($input); - case "rate": - return Rate::fromArray($input); - case "min": - return Min::fromArray($input); - case "raw_document": - return RawDocument::fromArray($input); - case "max": - return Max::fromArray($input); case "cardinality": return UniqueCount::fromArray($input); case "raw_data": return RawData::fromArray($input); + case "max": + return Max::fromArray($input); + case "moving_avg": + return MovingAverage::fromArray($input); case "serial_diff": return SerialDiff::fromArray($input); - case "avg": - return Average::fromArray($input); - case "logs": - return Logs::fromArray($input); + case "raw_document": + return RawDocument::fromArray($input); + case "moving_fn": + return MovingFunction::fromArray($input); case "bucket_script": return BucketScript::fromArray($input); default: diff --git a/php/src/Expr/TypeClassicConditionsType.php b/php/src/Expr/TypeClassicConditionsType.php index b33583e..4e16e26 100644 --- a/php/src/Expr/TypeClassicConditionsType.php +++ b/php/src/Expr/TypeClassicConditionsType.php @@ -36,6 +36,15 @@ final class TypeClassicConditionsType implements \JsonSerializable, \Stringable return self::$instances["Or"]; } + public static function logicOr(): self + { + if (!isset(self::$instances["LogicOr"])) { + self::$instances["LogicOr"] = new self("logic-or"); + } + + return self::$instances["LogicOr"]; + } + public static function fromValue(string $value): self { if ($value === "and") { @@ -46,6 +55,10 @@ final class TypeClassicConditionsType implements \JsonSerializable, \Stringable return self::or(); } + if ($value === "logic-or") { + return self::logicOr(); + } + throw new \UnexpectedValueException("Value '$value' is not part of the enum TypeClassicConditionsType"); } diff --git a/php/src/Expr/VariantConfig.php b/php/src/Expr/VariantConfig.php index a313278..710d51e 100644 --- a/php/src/Expr/VariantConfig.php +++ b/php/src/Expr/VariantConfig.php @@ -12,10 +12,6 @@ final class VariantConfig \assert(is_array($input), 'expected disjunction value to be an array'); switch ($input["type"]) { - case "math": - return TypeMath::fromArray($input); - case "reduce": - return TypeReduce::fromArray($input); case "resample": return TypeResample::fromArray($input); case "classic_conditions": @@ -24,6 +20,10 @@ final class VariantConfig return TypeThreshold::fromArray($input); case "sql": return TypeSql::fromArray($input); + case "math": + return TypeMath::fromArray($input); + case "reduce": + return TypeReduce::fromArray($input); default: throw new \ValueError('can not parse disjunction from array'); } diff --git a/php/src/Logs/Options.php b/php/src/Logs/Options.php index da8da83..6798dba 100644 --- a/php/src/Logs/Options.php +++ b/php/src/Logs/Options.php @@ -48,6 +48,21 @@ class Options implements \JsonSerializable */ public $onClickFilterOutString; + /** + * @var mixed|null + */ + public $onClickShowField; + + /** + * @var mixed|null + */ + public $onClickHideField; + + /** + * @var array|null + */ + public ?array $displayedFields; + /** * @param bool|null $showLabels * @param bool|null $showCommonLabels @@ -63,8 +78,11 @@ class Options implements \JsonSerializable * @param mixed|null $isFilterLabelActive * @param mixed|null $onClickFilterString * @param mixed|null $onClickFilterOutString + * @param mixed|null $onClickShowField + * @param mixed|null $onClickHideField + * @param array|null $displayedFields */ - public function __construct(?bool $showLabels = null, ?bool $showCommonLabels = null, ?bool $showTime = null, ?bool $showLogContextToggle = null, ?bool $wrapLogMessage = null, ?bool $prettifyLogMessage = null, ?bool $enableLogDetails = null, ?\Grafana\Foundation\Common\LogsSortOrder $sortOrder = null, ?\Grafana\Foundation\Common\LogsDedupStrategy $dedupStrategy = null, $onClickFilterLabel = null, $onClickFilterOutLabel = null, $isFilterLabelActive = null, $onClickFilterString = null, $onClickFilterOutString = null) + public function __construct(?bool $showLabels = null, ?bool $showCommonLabels = null, ?bool $showTime = null, ?bool $showLogContextToggle = null, ?bool $wrapLogMessage = null, ?bool $prettifyLogMessage = null, ?bool $enableLogDetails = null, ?\Grafana\Foundation\Common\LogsSortOrder $sortOrder = null, ?\Grafana\Foundation\Common\LogsDedupStrategy $dedupStrategy = null, $onClickFilterLabel = null, $onClickFilterOutLabel = null, $isFilterLabelActive = null, $onClickFilterString = null, $onClickFilterOutString = null, $onClickShowField = null, $onClickHideField = null, ?array $displayedFields = null) { $this->showLabels = $showLabels ?: false; $this->showCommonLabels = $showCommonLabels ?: false; @@ -80,6 +98,9 @@ class Options implements \JsonSerializable $this->isFilterLabelActive = $isFilterLabelActive; $this->onClickFilterString = $onClickFilterString; $this->onClickFilterOutString = $onClickFilterOutString; + $this->onClickShowField = $onClickShowField; + $this->onClickHideField = $onClickHideField; + $this->displayedFields = $displayedFields; } /** @@ -87,7 +108,7 @@ class Options implements \JsonSerializable */ public static function fromArray(array $inputData): self { - /** @var array{showLabels?: bool, showCommonLabels?: bool, showTime?: bool, showLogContextToggle?: bool, wrapLogMessage?: bool, prettifyLogMessage?: bool, enableLogDetails?: bool, sortOrder?: string, dedupStrategy?: string, onClickFilterLabel?: mixed, onClickFilterOutLabel?: mixed, isFilterLabelActive?: mixed, onClickFilterString?: mixed, onClickFilterOutString?: mixed} $inputData */ + /** @var array{showLabels?: bool, showCommonLabels?: bool, showTime?: bool, showLogContextToggle?: bool, wrapLogMessage?: bool, prettifyLogMessage?: bool, enableLogDetails?: bool, sortOrder?: string, dedupStrategy?: string, onClickFilterLabel?: mixed, onClickFilterOutLabel?: mixed, isFilterLabelActive?: mixed, onClickFilterString?: mixed, onClickFilterOutString?: mixed, onClickShowField?: mixed, onClickHideField?: mixed, displayedFields?: array} $inputData */ $data = $inputData; return new self( showLabels: $data["showLabels"] ?? null, @@ -104,6 +125,9 @@ class Options implements \JsonSerializable isFilterLabelActive: $data["isFilterLabelActive"] ?? null, onClickFilterString: $data["onClickFilterString"] ?? null, onClickFilterOutString: $data["onClickFilterOutString"] ?? null, + onClickShowField: $data["onClickShowField"] ?? null, + onClickHideField: $data["onClickHideField"] ?? null, + displayedFields: $data["displayedFields"] ?? null, ); } @@ -138,6 +162,15 @@ class Options implements \JsonSerializable if (isset($this->onClickFilterOutString)) { $data["onClickFilterOutString"] = $this->onClickFilterOutString; } + if (isset($this->onClickShowField)) { + $data["onClickShowField"] = $this->onClickShowField; + } + if (isset($this->onClickHideField)) { + $data["onClickHideField"] = $this->onClickHideField; + } + if (isset($this->displayedFields)) { + $data["displayedFields"] = $this->displayedFields; + } return $data; } } diff --git a/php/src/Logs/PanelBuilder.php b/php/src/Logs/PanelBuilder.php index 0fb07c7..caff9f6 100644 --- a/php/src/Logs/PanelBuilder.php +++ b/php/src/Logs/PanelBuilder.php @@ -626,5 +626,44 @@ class PanelBuilder implements \Grafana\Foundation\Cog\Builder return $this; } + /** + * @param mixed $onClickShowField + */ + public function onClickShowField( $onClickShowField): static + { + if ($this->internal->options === null) { + $this->internal->options = new \Grafana\Foundation\Logs\Options(); + } + assert($this->internal->options instanceof \Grafana\Foundation\Logs\Options); + $this->internal->options->onClickShowField = $onClickShowField; + + return $this; + } + /** + * @param mixed $onClickHideField + */ + public function onClickHideField( $onClickHideField): static + { + if ($this->internal->options === null) { + $this->internal->options = new \Grafana\Foundation\Logs\Options(); + } + assert($this->internal->options instanceof \Grafana\Foundation\Logs\Options); + $this->internal->options->onClickHideField = $onClickHideField; + + return $this; + } + /** + * @param array $displayedFields + */ + public function displayedFields(array $displayedFields): static + { + if ($this->internal->options === null) { + $this->internal->options = new \Grafana\Foundation\Logs\Options(); + } + assert($this->internal->options instanceof \Grafana\Foundation\Logs\Options); + $this->internal->options->displayedFields = $displayedFields; + + return $this; + } } diff --git a/php/src/Statetimeline/Options.php b/php/src/Statetimeline/Options.php index 6c4f259..85c4c56 100644 --- a/php/src/Statetimeline/Options.php +++ b/php/src/Statetimeline/Options.php @@ -19,6 +19,11 @@ class Options implements \JsonSerializable */ public ?bool $mergeValues; + /** + * Controls value alignment on the timelines + */ + public ?\Grafana\Foundation\Common\TimelineValueAlignment $alignValue; + public \Grafana\Foundation\Common\VizLegendOptions $legend; public \Grafana\Foundation\Common\VizTooltipOptions $tooltip; @@ -29,28 +34,30 @@ class Options implements \JsonSerializable public ?array $timezone; /** - * Controls value alignment on the timelines + * Enables pagination when > 0 */ - public ?\Grafana\Foundation\Common\TimelineValueAlignment $alignValue; + public ?float $perPage; /** * @param \Grafana\Foundation\Common\VisibilityMode|null $showValue * @param float|null $rowHeight * @param bool|null $mergeValues + * @param \Grafana\Foundation\Common\TimelineValueAlignment|null $alignValue * @param \Grafana\Foundation\Common\VizLegendOptions|null $legend * @param \Grafana\Foundation\Common\VizTooltipOptions|null $tooltip * @param array|null $timezone - * @param \Grafana\Foundation\Common\TimelineValueAlignment|null $alignValue + * @param float|null $perPage */ - public function __construct(?\Grafana\Foundation\Common\VisibilityMode $showValue = null, ?float $rowHeight = null, ?bool $mergeValues = null, ?\Grafana\Foundation\Common\VizLegendOptions $legend = null, ?\Grafana\Foundation\Common\VizTooltipOptions $tooltip = null, ?array $timezone = null, ?\Grafana\Foundation\Common\TimelineValueAlignment $alignValue = null) + public function __construct(?\Grafana\Foundation\Common\VisibilityMode $showValue = null, ?float $rowHeight = null, ?bool $mergeValues = null, ?\Grafana\Foundation\Common\TimelineValueAlignment $alignValue = null, ?\Grafana\Foundation\Common\VizLegendOptions $legend = null, ?\Grafana\Foundation\Common\VizTooltipOptions $tooltip = null, ?array $timezone = null, ?float $perPage = null) { $this->showValue = $showValue ?: \Grafana\Foundation\Common\VisibilityMode::auto(); $this->rowHeight = $rowHeight ?: 0.9; $this->mergeValues = $mergeValues; + $this->alignValue = $alignValue; $this->legend = $legend ?: new \Grafana\Foundation\Common\VizLegendOptions(); $this->tooltip = $tooltip ?: new \Grafana\Foundation\Common\VizTooltipOptions(); $this->timezone = $timezone; - $this->alignValue = $alignValue; + $this->perPage = $perPage; } /** @@ -58,12 +65,13 @@ class Options implements \JsonSerializable */ public static function fromArray(array $inputData): self { - /** @var array{showValue?: string, rowHeight?: float, mergeValues?: bool, legend?: mixed, tooltip?: mixed, timezone?: array, alignValue?: string} $inputData */ + /** @var array{showValue?: string, rowHeight?: float, mergeValues?: bool, alignValue?: string, legend?: mixed, tooltip?: mixed, timezone?: array, perPage?: float} $inputData */ $data = $inputData; return new self( showValue: isset($data["showValue"]) ? (function($input) { return \Grafana\Foundation\Common\VisibilityMode::fromValue($input); })($data["showValue"]) : null, rowHeight: $data["rowHeight"] ?? null, mergeValues: $data["mergeValues"] ?? null, + alignValue: isset($data["alignValue"]) ? (function($input) { return \Grafana\Foundation\Common\TimelineValueAlignment::fromValue($input); })($data["alignValue"]) : null, legend: isset($data["legend"]) ? (function($input) { /** @var array{displayMode?: string, placement?: string, showLegend?: bool, asTable?: bool, isVisible?: bool, sortBy?: string, sortDesc?: bool, width?: float, calcs?: array} */ $val = $input; @@ -75,7 +83,7 @@ class Options implements \JsonSerializable return \Grafana\Foundation\Common\VizTooltipOptions::fromArray($val); })($data["tooltip"]) : null, timezone: $data["timezone"] ?? null, - alignValue: isset($data["alignValue"]) ? (function($input) { return \Grafana\Foundation\Common\TimelineValueAlignment::fromValue($input); })($data["alignValue"]) : null, + perPage: $data["perPage"] ?? null, ); } @@ -93,11 +101,14 @@ class Options implements \JsonSerializable if (isset($this->mergeValues)) { $data["mergeValues"] = $this->mergeValues; } + if (isset($this->alignValue)) { + $data["alignValue"] = $this->alignValue; + } if (isset($this->timezone)) { $data["timezone"] = $this->timezone; } - if (isset($this->alignValue)) { - $data["alignValue"] = $this->alignValue; + if (isset($this->perPage)) { + $data["perPage"] = $this->perPage; } return $data; } diff --git a/php/src/Statetimeline/PanelBuilder.php b/php/src/Statetimeline/PanelBuilder.php index ba53ce8..bf8fe55 100644 --- a/php/src/Statetimeline/PanelBuilder.php +++ b/php/src/Statetimeline/PanelBuilder.php @@ -512,6 +512,19 @@ class PanelBuilder implements \Grafana\Foundation\Cog\Builder return $this; } + /** + * Controls value alignment on the timelines + */ + public function alignValue(\Grafana\Foundation\Common\TimelineValueAlignment $alignValue): static + { + if ($this->internal->options === null) { + $this->internal->options = new \Grafana\Foundation\Statetimeline\Options(); + } + assert($this->internal->options instanceof \Grafana\Foundation\Statetimeline\Options); + $this->internal->options->alignValue = $alignValue; + + return $this; + } /** * @param \Grafana\Foundation\Cog\Builder<\Grafana\Foundation\Common\VizLegendOptions> $legend */ @@ -554,15 +567,18 @@ class PanelBuilder implements \Grafana\Foundation\Cog\Builder return $this; } /** - * Controls value alignment on the timelines + * Enables pagination when > 0 */ - public function alignValue(\Grafana\Foundation\Common\TimelineValueAlignment $alignValue): static - { + public function perPage(float $perPage): static + { + if (!($perPage >= 1)) ...*[Comment body truncated]*
Duologic commented 2 months ago

~I'm not sure how to review this, can you show what will change?~ nevermind, see the example now.