grafana / cog

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

Add an option to skip index.ts files generation in Typescript #419

Closed K-Phoen closed 5 months ago

K-Phoen commented 5 months ago

Relates to #408

In some cases, we're really only interested in generating types. So let's support that in typescript too.

github-actions[bot] commented 5 months ago

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

### 🔎 Changes to `grafana-foundation-sdk@next+cog-v0.0.x` ```patch diff --git a/go/azuremonitor/azurelogsquery_builder_gen.go b/go/azuremonitor/azurelogsquery_builder_gen.go index 076f120..48a2d9a 100644 --- a/go/azuremonitor/azurelogsquery_builder_gen.go +++ b/go/azuremonitor/azurelogsquery_builder_gen.go @@ -75,6 +75,13 @@ func (builder *AzureLogsQueryBuilder) TimeColumn(timeColumn string) *AzureLogsQu return builder } +// If set to true the query will be run as a basic logs query +func (builder *AzureLogsQueryBuilder) BasicLogsQuery(basicLogsQuery bool) *AzureLogsQueryBuilder { + builder.internal.BasicLogsQuery = &basicLogsQuery + + return builder +} + // Workspace ID. This was removed in Grafana 8, but remains for backwards compat. func (builder *AzureLogsQueryBuilder) Workspace(workspace string) *AzureLogsQueryBuilder { builder.internal.Workspace = &workspace diff --git a/go/azuremonitor/types_gen.go b/go/azuremonitor/types_gen.go index 0e98f37..0e789fb 100644 --- a/go/azuremonitor/types_gen.go +++ b/go/azuremonitor/types_gen.go @@ -136,6 +136,8 @@ type AzureLogsQuery struct { DashboardTime *bool `json:"dashboardTime,omitempty"` // If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated TimeColumn *string `json:"timeColumn,omitempty"` + // If set to true the query will be run as a basic logs query + BasicLogsQuery *bool `json:"basicLogsQuery,omitempty"` // Workspace ID. This was removed in Grafana 8, but remains for backwards compat. Workspace *string `json:"workspace,omitempty"` // @deprecated Use resources instead diff --git a/go/common/types_gen.go b/go/common/types_gen.go index 6389be0..515fd60 100644 --- a/go/common/types_gen.go +++ b/go/common/types_gen.go @@ -492,6 +492,15 @@ const ( BigValueTextModeNone BigValueTextMode = "none" ) +// TODO docs +type PercentChangeColorMode string + +const ( + PercentChangeColorModeStandard PercentChangeColorMode = "standard" + PercentChangeColorModeInverted PercentChangeColorMode = "inverted" + PercentChangeColorModeSameAsValue PercentChangeColorMode = "same_as_value" +) + // TODO -- should not be table specific! // TODO docs type FieldTextAlignment string diff --git a/go/dashboard/constantvariable_builder_gen.go b/go/dashboard/constantvariable_builder_gen.go index a8148d8..62fd208 100644 --- a/go/dashboard/constantvariable_builder_gen.go +++ b/go/dashboard/constantvariable_builder_gen.go @@ -64,7 +64,7 @@ func (builder *ConstantVariableBuilder) Description(description string) *Constan } // Query used to fetch values for a variable -func (builder *ConstantVariableBuilder) Value(query StringOrAny) *ConstantVariableBuilder { +func (builder *ConstantVariableBuilder) Value(query StringOrMap) *ConstantVariableBuilder { builder.internal.Query = &query return builder diff --git a/go/dashboard/customvariable_builder_gen.go b/go/dashboard/customvariable_builder_gen.go index 2bc9bde..f6db129 100644 --- a/go/dashboard/customvariable_builder_gen.go +++ b/go/dashboard/customvariable_builder_gen.go @@ -71,7 +71,7 @@ func (builder *CustomVariableBuilder) Description(description string) *CustomVar } // Query used to fetch values for a variable -func (builder *CustomVariableBuilder) Values(query StringOrAny) *CustomVariableBuilder { +func (builder *CustomVariableBuilder) Values(query StringOrMap) *CustomVariableBuilder { builder.internal.Query = &query return builder diff --git a/go/dashboard/datasourcevariable_builder_gen.go b/go/dashboard/datasourcevariable_builder_gen.go index 20a7bd9..77cdec6 100644 --- a/go/dashboard/datasourcevariable_builder_gen.go +++ b/go/dashboard/datasourcevariable_builder_gen.go @@ -73,7 +73,7 @@ func (builder *DatasourceVariableBuilder) Description(description string) *Datas // Query used to fetch values for a variable func (builder *DatasourceVariableBuilder) Type(string string) *DatasourceVariableBuilder { if builder.internal.Query == nil { - builder.internal.Query = &StringOrAny{} + builder.internal.Query = &StringOrMap{} } builder.internal.Query.String = &string diff --git a/go/dashboard/intervalvariable_builder_gen.go b/go/dashboard/intervalvariable_builder_gen.go index e36586d..d2e618c 100644 --- a/go/dashboard/intervalvariable_builder_gen.go +++ b/go/dashboard/intervalvariable_builder_gen.go @@ -71,7 +71,7 @@ func (builder *IntervalVariableBuilder) Description(description string) *Interva } // Query used to fetch values for a variable -func (builder *IntervalVariableBuilder) Values(query StringOrAny) *IntervalVariableBuilder { +func (builder *IntervalVariableBuilder) Values(query StringOrMap) *IntervalVariableBuilder { builder.internal.Query = &query return builder diff --git a/go/dashboard/queryvariable_builder_gen.go b/go/dashboard/queryvariable_builder_gen.go index 38f0e13..9f2846b 100644 --- a/go/dashboard/queryvariable_builder_gen.go +++ b/go/dashboard/queryvariable_builder_gen.go @@ -71,7 +71,7 @@ func (builder *QueryVariableBuilder) Description(description string) *QueryVaria } // Query used to fetch values for a variable -func (builder *QueryVariableBuilder) Query(query StringOrAny) *QueryVariableBuilder { +func (builder *QueryVariableBuilder) Query(query StringOrMap) *QueryVariableBuilder { builder.internal.Query = &query return builder diff --git a/go/dashboard/textboxvariable_builder_gen.go b/go/dashboard/textboxvariable_builder_gen.go index 6fa6504..da3933f 100644 --- a/go/dashboard/textboxvariable_builder_gen.go +++ b/go/dashboard/textboxvariable_builder_gen.go @@ -71,7 +71,7 @@ func (builder *TextBoxVariableBuilder) Description(description string) *TextBoxV } // Query used to fetch values for a variable -func (builder *TextBoxVariableBuilder) DefaultValue(query StringOrAny) *TextBoxVariableBuilder { +func (builder *TextBoxVariableBuilder) DefaultValue(query StringOrMap) *TextBoxVariableBuilder { builder.internal.Query = &query return builder diff --git a/go/dashboard/types_gen.go b/go/dashboard/types_gen.go index 8efedaa..1dc4d83 100644 --- a/go/dashboard/types_gen.go +++ b/go/dashboard/types_gen.go @@ -149,7 +149,7 @@ type VariableModel struct { // Description of variable. It can be defined but `null`. Description *string `json:"description,omitempty"` // Query used to fetch values for a variable - Query *StringOrAny `json:"query,omitempty"` + Query *StringOrMap `json:"query,omitempty"` // Data source used to fetch values for a variable. It can be defined but `null`. Datasource *DataSourceRef `json:"datasource,omitempty"` // Shows current selected variable text/value on the dashboard @@ -995,24 +995,24 @@ func (resource *PanelOrRowPanel) UnmarshalJSON(raw []byte) error { return fmt.Errorf("could not unmarshal resource with `type = %v`", discriminator) } -type StringOrAny struct { - String *string `json:"String,omitempty"` - Any any `json:"Any,omitempty"` +type StringOrMap struct { + String *string `json:"String,omitempty"` + Map map[string]any `json:"Map,omitempty"` } -func (resource StringOrAny) MarshalJSON() ([]byte, error) { +func (resource StringOrMap) MarshalJSON() ([]byte, error) { if resource.String != nil { return json.Marshal(resource.String) } - if resource.Any != nil { - return json.Marshal(resource.Any) + if resource.Map != nil { + return json.Marshal(resource.Map) } return nil, fmt.Errorf("no value for disjunction of scalars") } -func (resource *StringOrAny) UnmarshalJSON(raw []byte) error { +func (resource *StringOrMap) UnmarshalJSON(raw []byte) error { if raw == nil { return nil } @@ -1029,13 +1029,13 @@ func (resource *StringOrAny) UnmarshalJSON(raw []byte) error { return nil } - // Any - var Any any - if err := json.Unmarshal(raw, &Any); err != nil { + // Map + var Map map[string]any + if err := json.Unmarshal(raw, &Map); err != nil { errList = append(errList, err) - resource.Any = nil + resource.Map = nil } else { - resource.Any = &Any + resource.Map = Map return nil } diff --git a/go/elasticsearch/dataquery_builder_gen.go b/go/elasticsearch/dataquery_builder_gen.go index ed381e5..51cb1c7 100644 --- a/go/elasticsearch/dataquery_builder_gen.go +++ b/go/elasticsearch/dataquery_builder_gen.go @@ -79,7 +79,7 @@ func (builder *DataqueryBuilder) Metrics(metrics []MetricAggregation) *Dataquery // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder { - builder.internal.RefId = &refId + builder.internal.RefId = refId return builder } diff --git a/go/elasticsearch/movingaverage_builder_gen.go b/go/elasticsearch/movingaverage_builder_gen.go index 83227e7..4420a1b 100644 --- a/go/elasticsearch/movingaverage_builder_gen.go +++ b/go/elasticsearch/movingaverage_builder_gen.go @@ -59,8 +59,8 @@ func (builder *MovingAverageBuilder) Id(id string) *MovingAverageBuilder { return builder } -func (builder *MovingAverageBuilder) Settings(settings any) *MovingAverageBuilder { - builder.internal.Settings = &settings +func (builder *MovingAverageBuilder) Settings(settings map[string]any) *MovingAverageBuilder { + builder.internal.Settings = settings return builder } diff --git a/go/elasticsearch/types_gen.go b/go/elasticsearch/types_gen.go index 240254e..c942c99 100644 --- a/go/elasticsearch/types_gen.go +++ b/go/elasticsearch/types_gen.go @@ -417,12 +417,12 @@ type MovingAverageHoltWintersModelSettings struct { // #MovingAverage's settings are overridden in types.ts type MovingAverage struct { - PipelineAgg *string `json:"pipelineAgg,omitempty"` - Field *string `json:"field,omitempty"` - Type string `json:"type"` - Id string `json:"id"` - Settings any `json:"settings,omitempty"` - Hide *bool `json:"hide,omitempty"` + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Field *string `json:"field,omitempty"` + Type string `json:"type"` + Id string `json:"id"` + Settings map[string]any `json:"settings,omitempty"` + Hide *bool `json:"hide,omitempty"` } type MovingFunction struct { @@ -510,7 +510,7 @@ type Dataquery struct { // A unique identifier for the query within the list of targets. // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. - RefId *string `json:"refId,omitempty"` + RefId string `json:"refId"` // If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. Hide *bool `json:"hide,omitempty"` // Specify the query flavor diff --git a/go/grafanapyroscope/dataquery_builder_gen.go b/go/grafanapyroscope/dataquery_builder_gen.go index 6283837..b2c91f6 100644 --- a/go/grafanapyroscope/dataquery_builder_gen.go +++ b/go/grafanapyroscope/dataquery_builder_gen.go @@ -42,7 +42,7 @@ func (builder *DataqueryBuilder) Build() (cogvariants.Dataquery, error) { // Specifies the query label selectors. func (builder *DataqueryBuilder) LabelSelector(labelSelector string) *DataqueryBuilder { - builder.internal.LabelSelector = &labelSelector + builder.internal.LabelSelector = labelSelector return builder } @@ -56,7 +56,7 @@ func (builder *DataqueryBuilder) SpanSelector(spanSelector []string) *DataqueryB // Specifies the type of profile to query. func (builder *DataqueryBuilder) ProfileTypeId(profileTypeId string) *DataqueryBuilder { - builder.internal.ProfileTypeId = &profileTypeId + builder.internal.ProfileTypeId = profileTypeId return builder } @@ -79,7 +79,7 @@ func (builder *DataqueryBuilder) MaxNodes(maxNodes int64) *DataqueryBuilder { // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder { - builder.internal.RefId = &refId + builder.internal.RefId = refId return builder } diff --git a/go/grafanapyroscope/types_gen.go b/go/grafanapyroscope/types_gen.go index 38b93fc..72ca853 100644 --- a/go/grafanapyroscope/types_gen.go +++ b/go/grafanapyroscope/types_gen.go @@ -18,19 +18,19 @@ const ( type Dataquery struct { // Specifies the query label selectors. - LabelSelector *string `json:"labelSelector,omitempty"` + LabelSelector string `json:"labelSelector"` // Specifies the query span selectors. SpanSelector []string `json:"spanSelector,omitempty"` // Specifies the type of profile to query. - ProfileTypeId *string `json:"profileTypeId,omitempty"` + ProfileTypeId string `json:"profileTypeId"` // Allows to group the results. - GroupBy []string `json:"groupBy,omitempty"` + GroupBy []string `json:"groupBy"` // Sets the maximum number of nodes in the flamegraph. MaxNodes *int64 `json:"maxNodes,omitempty"` // A unique identifier for the query within the list of targets. // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. - RefId *string `json:"refId,omitempty"` + RefId string `json:"refId"` // If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. Hide *bool `json:"hide,omitempty"` // Specify the query flavor diff --git a/go/loki/dataquery_builder_gen.go b/go/loki/dataquery_builder_gen.go index 4cb40da..103341c 100644 --- a/go/loki/dataquery_builder_gen.go +++ b/go/loki/dataquery_builder_gen.go @@ -42,7 +42,7 @@ func (builder *DataqueryBuilder) Build() (cogvariants.Dataquery, error) { // The LogQL query. func (builder *DataqueryBuilder) Expr(expr string) *DataqueryBuilder { - builder.internal.Expr = &expr + builder.internal.Expr = expr return builder } @@ -99,7 +99,7 @@ func (builder *DataqueryBuilder) Step(step string) *DataqueryBuilder { // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder { - builder.internal.RefId = &refId + builder.internal.RefId = refId return builder } diff --git a/go/loki/types_gen.go b/go/loki/types_gen.go index 0b9c169..fde967a 100644 --- a/go/loki/types_gen.go +++ b/go/loki/types_gen.go @@ -41,7 +41,7 @@ const ( type Dataquery struct { // The LogQL query. - Expr *string `json:"expr,omitempty"` + Expr string `json:"expr"` // Used to override the name of the series. LegendFormat *string `json:"legendFormat,omitempty"` // Used to limit the number of log rows returned. @@ -58,7 +58,7 @@ type Dataquery struct { // A unique identifier for the query within the list of targets. // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. - RefId *string `json:"refId,omitempty"` + RefId string `json:"refId"` // If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. Hide *bool `json:"hide,omitempty"` // Specify the query flavor diff --git a/go/parca/dataquery_builder_gen.go b/go/parca/dataquery_builder_gen.go index 5419d69..202ab34 100644 --- a/go/parca/dataquery_builder_gen.go +++ b/go/parca/dataquery_builder_gen.go @@ -42,14 +42,14 @@ func (builder *DataqueryBuilder) Build() (cogvariants.Dataquery, error) { // Specifies the query label selectors. func (builder *DataqueryBuilder) LabelSelector(labelSelector string) *DataqueryBuilder { - builder.internal.LabelSelector = &labelSelector + builder.internal.LabelSelector = labelSelector return builder } // Specifies the type of profile to query. func (builder *DataqueryBuilder) ProfileTypeId(profileTypeId string) *DataqueryBuilder { - builder.internal.ProfileTypeId = &profileTypeId + builder.internal.ProfileTypeId = profileTypeId return builder } @@ -58,7 +58,7 @@ func (builder *DataqueryBuilder) ProfileTypeId(profileTypeId string) *DataqueryB // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder { - builder.internal.RefId = &refId + builder.internal.RefId = refId return builder } diff --git a/go/parca/types_gen.go b/go/parca/types_gen.go index 6216bcb..bf22114 100644 --- a/go/parca/types_gen.go +++ b/go/parca/types_gen.go @@ -18,13 +18,13 @@ const ( type Dataquery struct { // Specifies the query label selectors. - LabelSelector *string `json:"labelSelector,omitempty"` + LabelSelector string `json:"labelSelector"` // Specifies the type of profile to query. - ProfileTypeId *string `json:"profileTypeId,omitempty"` + ProfileTypeId string `json:"profileTypeId"` // A unique identifier for the query within the list of targets. // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. - RefId *string `json:"refId,omitempty"` + RefId string `json:"refId"` // If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. Hide *bool `json:"hide,omitempty"` // Specify the query flavor diff --git a/go/prometheus/dataquery_builder_gen.go b/go/prometheus/dataquery_builder_gen.go index cb18d8d..a8fb43c 100644 --- a/go/prometheus/dataquery_builder_gen.go +++ b/go/prometheus/dataquery_builder_gen.go @@ -42,7 +42,7 @@ func (builder *DataqueryBuilder) Build() (cogvariants.Dataquery, error) { // The actual expression/query that will be evaluated by Prometheus func (builder *DataqueryBuilder) Expr(expr string) *DataqueryBuilder { - builder.internal.Expr = &expr + builder.internal.Expr = expr return builder } @@ -101,7 +101,7 @@ func (builder *DataqueryBuilder) IntervalFactor(intervalFactor float64) *Dataque // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. func (builder *DataqueryBuilder) RefId(refId string) *DataqueryBuilder { - builder.internal.RefId = &refId + builder.internal.RefId = refId return builder } diff --git a/go/prometheus/types_gen.go b/go/prometheus/types_gen.go index 0f0b6cb..55b5ead 100644 --- a/go/prometheus/types_gen.go +++ b/go/prometheus/types_gen.go @@ -25,7 +25,7 @@ const ( type Dataquery struct { // The actual expression/query that will be evaluated by Prometheus - Expr *string `json:"expr,omitempty"` + Expr string `json:"expr"` // Returns only the latest value that Prometheus has scraped for the requested time series Instant *bool `json:"instant,omitempty"` // Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series @@ -44,7 +44,7 @@ type Dataquery struct { // A unique identifier for the query within the list of targets. // In server side expressions, the refId is used as a variable name to identify results. // By default, the UI will assign A->Z; however setting meaningful names may be useful. - RefId *string `json:"refId,omitempty"` + RefId string `json:"refId"` // If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. Hide *bool `json:"hide,omitempty"` // Specify the query flavor diff --git a/go/stat/panel_builder_gen.go b/go/stat/panel_builder_gen.go index f3223dd..eaf3847 100644 --- a/go/stat/panel_builder_gen.go +++ b/go/stat/panel_builder_gen.go @@ -460,6 +460,15 @@ func (builder *PanelBuilder) WideLayout(wideLayout bool) *PanelBuilder { return builder } +func (builder *PanelBuilder) ShowPercentChange(showPercentChange bool) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).ShowPercentChange = showPercentChange + + return builder +} + func (builder *PanelBuilder) ReduceOptions(reduceOptions cog.Builder[common.ReduceDataOptions]) *PanelBuilder { if builder.internal.Options == nil { builder.internal.Options = &Options{} @@ -488,11 +497,11 @@ func (builder *PanelBuilder) Text(text cog.Builder[common.VizTextDisplayOptions] return builder } -func (builder *PanelBuilder) ShowPercentChange(showPercentChange bool) *PanelBuilder { +func (builder *PanelBuilder) PercentChangeColorMode(percentChangeColorMode common.PercentChangeColorMode) *PanelBuilder { if builder.internal.Options == nil { builder.internal.Options = &Options{} } - builder.internal.Options.(*Options).ShowPercentChange = showPercentChange + builder.internal.Options.(*Options).PercentChangeColorMode = percentChangeColorMode return builder } @@ -516,4 +525,5 @@ func (builder *PanelBuilder) applyDefaults() { builder.TextMode("auto") builder.WideLayout(true) builder.ShowPercentChange(false) + builder.PercentChangeColorMode("standard") } diff --git a/go/stat/types_gen.go b/go/stat/types_gen.go index dacf902..5f75c28 100644 --- a/go/stat/types_gen.go +++ b/go/stat/types_gen.go @@ -10,15 +10,16 @@ import ( ) type Options struct { - GraphMode common.BigValueGraphMode `json:"graphMode"` - ColorMode common.BigValueColorMode `json:"colorMode"` - JustifyMode common.BigValueJustifyMode `json:"justifyMode"` - TextMode common.BigValueTextMode `json:"textMode"` - WideLayout bool `json:"wideLayout"` - ReduceOptions common.ReduceDataOptions `json:"reduceOptions"` - Text *common.VizTextDisplayOptions `json:"text,omitempty"` - ShowPercentChange bool `json:"showPercentChange"` - Orientation common.VizOrientation `json:"orientation"` + GraphMode common.BigValueGraphMode `json:"graphMode"` + ColorMode common.BigValueColorMode `json:"colorMode"` + JustifyMode common.BigValueJustifyMode `json:"justifyMode"` + TextMode common.BigValueTextMode `json:"textMode"` + WideLayout bool `json:"wideLayout"` + ShowPercentChange bool `json:"showPercentChange"` + ReduceOptions common.ReduceDataOptions `json:"reduceOptions"` + Text *common.VizTextDisplayOptions `json:"text,omitempty"` + PercentChangeColorMode common.PercentChangeColorMode `json:"percentChangeColorMode"` + Orientation common.VizOrientation `json:"orientation"` } func VariantConfig() cogvariants.PanelcfgConfig { diff --git a/jsonschema/azuremonitor.jsonschema.json b/jsonschema/azuremonitor.jsonschema.json index d2d343e..3aa1d09 100644 --- a/jsonschema/azuremonitor.jsonschema.json +++ b/jsonschema/azuremonitor.jsonschema.json @@ -203,6 +203,10 @@ "type": "string", "description": "If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated" }, + "basicLogsQuery": { + "type": "boolean", + "description": "If set to true the query will be run as a basic logs query" + }, "workspace": { "type": "string", "description": "Workspace ID. This was removed in Grafana 8, but remains for backwards compat." diff --git a/jsonschema/common.jsonschema.json b/jsonschema/common.jsonschema.json index bd71a75..9a0163c 100644 --- a/jsonschema/common.jsonschema.json +++ b/jsonschema/common.jsonschema.json @@ -757,6 +757,14 @@ ], "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "FieldTextAlignment": { "enum": [ "auto", diff --git a/jsonschema/dashboard.jsonschema.json b/jsonschema/dashboard.jsonschema.json index 9165e9b..de6c3b4 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", @@ -311,7 +311,10 @@ }, { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object", + "additionalProperties": {} + } } ], "description": "Query used to fetch values for a variable" diff --git a/jsonschema/elasticsearch.jsonschema.json b/jsonschema/elasticsearch.jsonschema.json index 1a41040..f80edcc 100644 --- a/jsonschema/elasticsearch.jsonschema.json +++ b/jsonschema/elasticsearch.jsonschema.json @@ -1287,7 +1287,10 @@ }, "settings": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object", + "additionalProperties": {} + } }, "hide": { "type": "boolean" @@ -1591,6 +1594,9 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "refId" + ], "properties": { "alias": { "type": "string", diff --git a/jsonschema/grafanapyroscope.jsonschema.json b/jsonschema/grafanapyroscope.jsonschema.json index 889530d..d16c059 100644 --- a/jsonschema/grafanapyroscope.jsonschema.json +++ b/jsonschema/grafanapyroscope.jsonschema.json @@ -11,6 +11,12 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "labelSelector", + "profileTypeId", + "groupBy", + "refId" + ], "properties": { "labelSelector": { "type": "string", diff --git a/jsonschema/loki.jsonschema.json b/jsonschema/loki.jsonschema.json index 47170b9..9b5e7d4 100644 --- a/jsonschema/loki.jsonschema.json +++ b/jsonschema/loki.jsonschema.json @@ -31,6 +31,10 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "expr", + "refId" + ], "properties": { "expr": { "type": "string", diff --git a/jsonschema/parca.jsonschema.json b/jsonschema/parca.jsonschema.json index 03cd164..c1235f5 100644 --- a/jsonschema/parca.jsonschema.json +++ b/jsonschema/parca.jsonschema.json @@ -11,6 +11,11 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "labelSelector", + "profileTypeId", + "refId" + ], "properties": { "labelSelector": { "type": "string", diff --git a/jsonschema/prometheus.jsonschema.json b/jsonschema/prometheus.jsonschema.json index 74862ac..cd6e9ce 100644 --- a/jsonschema/prometheus.jsonschema.json +++ b/jsonschema/prometheus.jsonschema.json @@ -17,6 +17,10 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "expr", + "refId" + ], "properties": { "expr": { "type": "string", diff --git a/jsonschema/stat.jsonschema.json b/jsonschema/stat.jsonschema.json index 0fa8b86..eca0e1c 100644 --- a/jsonschema/stat.jsonschema.json +++ b/jsonschema/stat.jsonschema.json @@ -10,8 +10,9 @@ "justifyMode", "textMode", "wideLayout", - "reduceOptions", "showPercentChange", + "reduceOptions", + "percentChangeColorMode", "orientation" ], "properties": { @@ -35,15 +36,19 @@ "type": "boolean", "default": true }, + "showPercentChange": { + "type": "boolean", + "default": false + }, "reduceOptions": { "$ref": "#/definitions/ReduceDataOptions" }, "text": { "$ref": "#/definitions/VizTextDisplayOptions" }, - "showPercentChange": { - "type": "boolean", - "default": false + "percentChangeColorMode": { + "$ref": "#/definitions/PercentChangeColorMode", + "default": "standard" }, "orientation": { "$ref": "#/definitions/VizOrientation" @@ -128,6 +133,14 @@ }, "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "VizOrientation": { "enum": [ "auto", diff --git a/openapi/azuremonitor.openapi.json b/openapi/azuremonitor.openapi.json index 89bfca5..82454e4 100644 --- a/openapi/azuremonitor.openapi.json +++ b/openapi/azuremonitor.openapi.json @@ -212,6 +212,10 @@ "type": "string", "description": "If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated" }, + "basicLogsQuery": { + "type": "boolean", + "description": "If set to true the query will be run as a basic logs query" + }, "workspace": { "type": "string", "description": "Workspace ID. This was removed in Grafana 8, but remains for backwards compat." diff --git a/openapi/common.openapi.json b/openapi/common.openapi.json index e8bea4a..f03e8df 100644 --- a/openapi/common.openapi.json +++ b/openapi/common.openapi.json @@ -765,6 +765,14 @@ ], "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "FieldTextAlignment": { "enum": [ "auto", diff --git a/openapi/dashboard.openapi.json b/openapi/dashboard.openapi.json index daf7a9a..2ce70e5 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", @@ -318,7 +318,10 @@ }, { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object", + "additionalProperties": {} + } } ], "description": "Query used to fetch values for a variable" diff --git a/openapi/elasticsearch.openapi.json b/openapi/elasticsearch.openapi.json index 841a3fa..e26ad77 100644 --- a/openapi/elasticsearch.openapi.json +++ b/openapi/elasticsearch.openapi.json @@ -1296,7 +1296,10 @@ }, "settings": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object", + "additionalProperties": {} + } }, "hide": { "type": "boolean" @@ -1600,6 +1603,9 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "refId" + ], "properties": { "alias": { "type": "string", diff --git a/openapi/grafanapyroscope.openapi.json b/openapi/grafanapyroscope.openapi.json index 63a1786..bdd707d 100644 --- a/openapi/grafanapyroscope.openapi.json +++ b/openapi/grafanapyroscope.openapi.json @@ -20,6 +20,12 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "labelSelector", + "profileTypeId", + "groupBy", + "refId" + ], "properties": { "labelSelector": { "type": "string", diff --git a/openapi/loki.openapi.json b/openapi/loki.openapi.json index 128ca5d..ee37f2e 100644 --- a/openapi/loki.openapi.json +++ b/openapi/loki.openapi.json @@ -40,6 +40,10 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "expr", + "refId" + ], "properties": { "expr": { "type": "string", diff --git a/openapi/parca.openapi.json b/openapi/parca.openapi.json index 7fc1fb1..b8bc76e 100644 --- a/openapi/parca.openapi.json +++ b/openapi/parca.openapi.json @@ -20,6 +20,11 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "labelSelector", + "profileTypeId", + "refId" + ], "properties": { "labelSelector": { "type": "string", diff --git a/openapi/prometheus.openapi.json b/openapi/prometheus.openapi.json index b1cd52e..6c24f9b 100644 --- a/openapi/prometheus.openapi.json +++ b/openapi/prometheus.openapi.json @@ -26,6 +26,10 @@ "dataquery": { "type": "object", "additionalProperties": false, + "required": [ + "expr", + "refId" + ], "properties": { "expr": { "type": "string", diff --git a/openapi/stat.openapi.json b/openapi/stat.openapi.json index 46ade6a..11291c3 100644 --- a/openapi/stat.openapi.json +++ b/openapi/stat.openapi.json @@ -19,8 +19,9 @@ "justifyMode", "textMode", "wideLayout", - "reduceOptions", "showPercentChange", + "reduceOptions", + "percentChangeColorMode", "orientation" ], "properties": { @@ -44,15 +45,19 @@ "type": "boolean", "default": true }, + "showPercentChange": { + "type": "boolean", + "default": false + }, "reduceOptions": { "$ref": "#/components/schemas/ReduceDataOptions" }, "text": { "$ref": "#/components/schemas/VizTextDisplayOptions" }, - "showPercentChange": { - "type": "boolean", - "default": false + "percentChangeColorMode": { + "$ref": "#/components/schemas/PercentChangeColorMode", + "default": "standard" }, "orientation": { "$ref": "#/components/schemas/VizOrientation" @@ -137,6 +142,14 @@ }, "description": "TODO docs" }, + "PercentChangeColorMode": { + "enum": [ + "standard", + "inverted", + "same_as_value" + ], + "description": "TODO docs" + }, "VizOrientation": { "enum": [ "auto", diff --git a/python/grafana_foundation_sdk/builders/azuremonitor.py b/python/grafana_foundation_sdk/builders/azuremonitor.py index ba68ef2..7c26cae 100644 --- a/python/grafana_foundation_sdk/builders/azuremonitor.py +++ b/python/grafana_foundation_sdk/builders/azuremonitor.py @@ -387,6 +387,15 @@ class AzureLogsQuery(cogbuilder.Builder[azuremonitor.AzureLogsQuery]): return self + def basic_logs_query(self, basic_logs_query: bool) -> typing.Self: + """ + If set to true the query will be run as a basic logs query + """ + + self._internal.basic_logs_query = basic_logs_query + + return self + def workspace(self, workspace: str) -> typing.Self: """ Workspace ID. This was removed in Grafana 8, but remains for backwards compat. diff --git a/python/grafana_foundation_sdk/builders/dashboard.py b/python/grafana_foundation_sdk/builders/dashboard.py index 164ed31..754e1e7 100644 --- a/python/grafana_foundation_sdk/builders/dashboard.py +++ b/python/grafana_foundation_sdk/builders/dashboard.py @@ -1723,7 +1723,7 @@ class QueryVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def query(self, query: typing.Union[str, object]) -> typing.Self: + def query(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ @@ -1918,7 +1918,7 @@ class ConstantVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def value(self, query: typing.Union[str, object]) -> typing.Self: + def value(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ @@ -1979,7 +1979,7 @@ class DatasourceVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def type_val(self, query: typing.Union[str, object]) -> typing.Self: + def type_val(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ @@ -2086,7 +2086,7 @@ class IntervalVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def values(self, query: typing.Union[str, object]) -> typing.Self: + def values(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ @@ -2165,7 +2165,7 @@ class TextBoxVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def default_value(self, query: typing.Union[str, object]) -> typing.Self: + def default_value(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ @@ -2244,7 +2244,7 @@ class CustomVariable(cogbuilder.Builder[dashboard.VariableModel]): return self - def values(self, query: typing.Union[str, object]) -> typing.Self: + def values(self, query: typing.Union[str, dict[str, object]]) -> typing.Self: """ Query used to fetch values for a variable """ diff --git a/python/grafana_foundation_sdk/builders/elasticsearch.py b/python/grafana_foundation_sdk/builders/elasticsearch.py index db446b5..8e8e4d4 100644 --- a/python/grafana_foundation_sdk/builders/elasticsearch.py +++ b/python/grafana_foundation_sdk/builders/elasticsearch.py @@ -1155,7 +1155,7 @@ class MovingAverage(cogbuilder.Builder[elasticsearch.MovingAverage]): return self - def settings(self, settings: object) -> typing.Self: + def settings(self, settings: dict[str, object]) -> typing.Self: self._internal.settings = settings return self 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 576007f..3f06642 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 histogram from ..models import loki -from ..models import news -from ..models import stat -from ..models import azuremonitor -from ..models import bargauge -from ..models import googlecloudmonitoring -from ..models import xychart -from ..models import cloudwatch -from ..models import dashboardlist from ..models import nodegraph -from ..models import statetimeline -from ..models import table -from ..models import tempo -from ..models import candlestick -from ..models import annotationslist -from ..models import logs -from ..models import parca -from ..models import piechart -from ..models import barchart -from ..models import gauge +from ..models import prometheus +from ..models import debug from ..models import statushistory -from ..models import trend -from ..models import heatmap from ..models import datagrid -from ..models import elasticsearch -from ..models import geomap +from ..models import stat +from ..models import annotationslist +from ..models import news from ..models import grafanapyroscope -from ..models import histogram -from ..models import timeseries +from ..models import logs +from ..models import statetimeline +from ..models import xychart from ..models import expr +from ..models import barchart +from ..models import elasticsearch +from ..models import cloudwatch +from ..models import heatmap from ..models import canvas -from ..models import debug -from ..models import prometheus +from ..models import googlecloudmonitoring +from ..models import parca +from ..models import piechart +from ..models import trend +from ..models import bargauge +from ..models import candlestick +from ..models import dashboardlist +from ..models import gauge +from ..models import azuremonitor +from ..models import tempo from ..models import text +from ..models import timeseries +from ..models import geomap +from ..models import table from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/azuremonitor.py b/python/grafana_foundation_sdk/models/azuremonitor.py index 0769860..93942e6 100644 --- a/python/grafana_foundation_sdk/models/azuremonitor.py +++ b/python/grafana_foundation_sdk/models/azuremonitor.py @@ -318,6 +318,8 @@ class AzureLogsQuery: dashboard_time: typing.Optional[bool] # If dashboardTime is set to true this value dictates which column the time filter will be applied to. Defaults to the first tables timeSpan column, the first datetime column found, or TimeGenerated time_column: typing.Optional[str] + # If set to true the query will be run as a basic logs query + basic_logs_query: typing.Optional[bool] # Workspace ID. This was removed in Grafana 8, but remains for backwards compat. workspace: typing.Optional[str] # @deprecated Use resources instead @@ -325,12 +327,13 @@ class AzureLogsQuery: # @deprecated Use dashboardTime instead intersect_time: typing.Optional[bool] - def __init__(self, query: typing.Optional[str] = None, result_format: typing.Optional['ResultFormat'] = None, resources: typing.Optional[list[str]] = None, dashboard_time: typing.Optional[bool] = None, time_column: typing.Optional[str] = None, workspace: typing.Optional[str] = None, resource: typing.Optional[str] = None, intersect_time: typing.Optional[bool] = None): + def __init__(self, query: typing.Optional[str] = None, result_format: typing.Optional['ResultFormat'] = None, resources: typing.Optional[list[str]] = None, dashboard_time: typing.Optional[bool] = None, time_column: typing.Optional[str] = None, basic_logs_query: typing.Optional[bool] = None, workspace: typing.Optional[str] = None, resource: typing.Optional[str] = None, intersect_time: typing.Optional[bool] = None): self.query = query self.result_format = result_format self.resources = resources self.dashboard_time = dashboard_time self.time_column = time_column + self.basic_logs_query = basic_logs_query self.workspace = workspace self.resource = resource self.intersect_time = intersect_time @@ -348,6 +351,8 @@ class AzureLogsQuery: payload["dashboardTime"] = self.dashboard_time if self.time_column is not None: payload["timeColumn"] = self.time_column + if self.basic_logs_query is not None: + payload["basicLogsQuery"] = self.basic_logs_query if self.workspace is not None: payload["workspace"] = self.workspace if self.resource is not None: @@ -370,6 +375,8 @@ class AzureLogsQuery: args["dashboard_time"] = data["dashboardTime"] if "timeColumn" in data: args["time_column"] = data["timeColumn"] + if "basicLogsQuery" in data: + args["basic_logs_query"] = data["basicLogsQuery"] if "workspace" in data: args["workspace"] = data["workspace"] if "resource" in data: diff --git a/python/grafana_foundation_sdk/models/cloudwatch.py b/python/grafana_foundation_sdk/models/cloudwatch.py index 68ad69b..fac0fa9 100644 --- a/python/grafana_foundation_sdk/models/cloudwatch.py +++ b/python/grafana_foundation_sdk/models/cloudwatch.py @@ -332,7 +332,7 @@ class SQLExpression: if "select" in data: args["select"] = QueryEditorFunctionExpression.from_json(data["select"]) if "from" in data: - decoding_map: dict[str, typing.Union[typing.Type[QueryEditorFunctionExpression], typing.Type[QueryEditorPropertyExpression]]] = {"function": QueryEditorFunctionExpression, "property": QueryEditorPropertyExpression} + decoding_map: dict[str, typing.Union[typing.Type[QueryEditorPropertyExpression], typing.Type[QueryEditorFunctionExpression]]] = {"property": QueryEditorPropertyExpression, "function": QueryEditorFunctionExpression} args["from_val"] = decoding_map[data["from"]["type"]].from_json(data["from"]) if "where" in data: args["where"] = QueryEditorArrayExpression.from_json(data["where"]) @@ -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 b1232a9..3681ee3 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 @@ -403,7 +403,7 @@ class VariableModel: # Description of variable. It can be defined but `null`. description: typing.Optional[str] # Query used to fetch values for a variable - query: typing.Optional[typing.Union[str, object]] + query: typing.Optional[typing.Union[str, dict[str, object]]] # Data source used to fetch values for a variable. It can be defined but `null`. datasource: typing.Optional['DataSourceRef'] # Shows current selected variable text/value on the dashboard @@ -424,7 +424,7 @@ class VariableModel: # Named capture groups can be used to separate the display text and value. regex: typing.Optional[str] - def __init__(self, type_val: typing.Optional['VariableType'] = None, name: str = "", label: typing.Optional[str] = None, hide: typing.Optional['VariableHide'] = None, skip_url_sync: typing.Optional[bool] = False, description: typing.Optional[str] = None, query: typing.Optional[typing.Union[str, object]] = None, datasource: typing.Optional['DataSourceRef'] = None, current: typing.Optional['VariableOption'] = None, multi: typing.Optional[bool] = False, options: typing.Optional[list['VariableOption']] = None, refresh: typing.Optional['VariableRefresh'] = None, sort: typing.Optional['VariableSort'] = None, include_all: typing.Optional[bool] = False, all_value: typing.Optional[str] = None, regex: typing.Optional[str] = None): + def __init__(self, type_val: typing.Optional['VariableType'] = None, name: str = "", label: typing.Optional[str] = None, hide: typing.Optional['VariableHide'] = None, skip_url_sync: typing.Optional[bool] = False, description: typing.Optional[str] = None, query: typing.Optional[typing.Union[str, dict[str, object]]] = None, datasource: typing.Optional['DataSourceRef'] = None, current: typing.Optional['VariableOption'] = None, multi: typing.Optional[bool] = False, options: typing.Optional[list['VariableOption']] = None, refresh: typing.Optional['VariableRefresh'] = None, sort: typing.Optional['VariableSort'] = None, include_all: typing.Optional[bool] = False, all_value: typing.Optional[str] = None, regex: typing.Optional[str] = None): self.type_val = type_val if type_val is not None else VariableType.QUERY self.name = name self.label = label diff --git a/python/grafana_foundation_sdk/models/elasticsearch.py b/python/grafana_foundation_sdk/models/elasticsearch.py index e4b6799..cfb6c90 100644 --- a/python/grafana_foundation_sdk/models/elasticsearch.py +++ b/python/grafana_foundation_sdk/models/elasticsearch.py @@ -1573,10 +1573,10 @@ class MovingAverage: field: typing.Optional[str] type_val: typing.Literal["moving_avg"] id_val: str - settings: typing.Optional[object] + settings: typing.Optional[dict[str, object]] hide: typing.Optional[bool] - def __init__(self, pipeline_agg: typing.Optional[str] = None, field: typing.Optional[str] = None, id_val: str = "", settings: typing.Optional[object] = None, hide: typing.Optional[bool] = None): + def __init__(self, pipeline_agg: typing.Optional[str] = None, field: typing.Optional[str] = None, id_val: str = "", settings: typing.Optional[dict[str, object]] = None, hide: typing.Optional[bool] = None): self.pipeline_agg = pipeline_agg self.field = field self.type_val = "moving_avg" @@ -1913,7 +1913,7 @@ class Dataquery(cogvariants.Dataquery): # A unique identifier for the query within the list of targets. # In server side expressions, the refId is used as a variable name to identify results. # By default, the UI will assign A->Z; however setting meaningful names may be useful. - ref_id: typing.Optional[str] + ref_id: str # If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. hide: typing.Optional[bool] # Specify the query flavor @@ -1925,7 +1925,7 @@ class Dataquery(cogvariants.Dataquery): # TODO this shouldn't be unknown but DataSourceRef | null datasource: typing.Optional[object] - def __init__(self, alias: typing.Optional[str] = None, query: typing.Optional[str] = None, time_field: typing.Optional[str] = None, bucket_aggs: typing.Optional[list['BucketAggregation']] = None, metrics: typing.Optional[list['MetricAggregation']] = None, ref_id: typing.Optional[str] = None, hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): + def __init__(self, alias: typing.Optional[str] = None, query: typing.Optional[str] = None, time_field: typing.Optional[str] = None, bucket_aggs: typing.Optional[list['BucketAggregation']] = None, metrics: typing.Optional[list['MetricAggregation']] = None, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): self.alias = alias self.query = query self.time_field = time_field @@ -1938,6 +1938,7 @@ class Dataquery(cogvariants.Dataquery): def to_json(self) -> dict[str, object]: payload: dict[str, object] = { + "refId": self.ref_id, } if self.alias is not None: payload["alias"] = self.alias @@ -1949,8 +1950,6 @@ class Dataquery(cogvariants.Dataquery): payload["bucketAggs"] = self.bucket_aggs if self.metrics is not None: payload["metrics"] = self.metrics - if self.ref_id is not None: - payload["refId"] = self.ref_id if self.hide is not None: payload["hide"] = self.hide if self.query_type is not None: diff --git a/python/grafana_foundation_sdk/models/grafanapyroscope.py b/python/grafana_foundation_sdk/models/grafanapyroscope.py index daf46d7..5f0b982 100644 --- a/python/grafana_foundation_sdk/models/grafanapyroscope.py +++ b/python/grafana_foundation_sdk/models/grafanapyroscope.py @@ -14,19 +14,19 @@ class PyroscopeQueryType(enum.StrEnum): class Dataquery(cogvariants.Dataquery): # Specifies the query label selectors. - label_selector: typing.Optional[str] + label_selector: str # Specifies the query span selectors. span_selector: typing.Optional[list[str]] # Specifies the type of profile to query. - profile_type_id: typing.Optional[str] + profile_type_id: str # Allows to group the results. - group_by: typing.Optional[list[str]] + group_by: list[str] # Sets the maximum number of nodes in the flamegraph. max_nodes: typing.Optional[int] # A unique identifier for the query within the list of targets. # In server side expressions, the refId is used as a variable name to identify results. # By default, the UI will assign A->Z; however setting meaningful names may be useful. - ref_id: typing.Optional[str] + ref_id: str # If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. hide: typing.Optional[bool] # Specify the query flavor @@ -38,11 +38,11 @@ class Dataquery(cogvariants.Dataquery): # TODO this shouldn't be unknown but DataSourceRef | null datasource: typing.Optional[object] - def __init__(self, label_selector: typing.Optional[str] = "{}", span_selector: typing.Optional[list[str]] = None, profile_type_id: typing.Optional[str] = None, group_by: typing.Optional[list[str]] = None, max_nodes: typing.Optional[int] = None, ref_id: typing.Optional[str] = None, hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): + def __init__(self, label_selector: str = "{}", span_selector: typing.Optional[list[str]] = None, profile_type_id: str = "", group_by: typing.Optional[list[str]] = None, max_nodes: typing.Optional[int] = None, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): self.label_selector = label_selector self.span_selector = span_selector self.profile_type_id = profile_type_id - self.group_by = group_by + self.group_by = group_by if group_by is not None else [] self.max_nodes = max_nodes self.ref_id = ref_id self.hide = hide @@ -51,19 +51,15 @@ class Dataquery(cogvariants.Dataquery): def to_json(self) -> dict[str, object]: payload: dict[str, object] = { + "labelSelector": self.label_selector, + "profileTypeId": self.profile_type_id, + "groupBy": self.group_by, + "refId": self.ref_id, } - if self.label_selector is not None: - payload["labelSelector"] = self.label_selector if self.span_selector is not None: payload["spanSelector"] = self.span_selector - if self.profile_type_id is not None: - payload["profileTypeId"] = self.profile_type_id - if self.group_by is not None: - payload["groupBy"] = self.group_by if self.max_nodes is not None: payload["maxNodes"] = self.max_nodes - if self.ref_id is not None: - payload["refId"] = self.ref_id if self.hide is not None: payload["hide"] = self.hide if self.query_type is not None: diff --git a/python/grafana_foundation_sdk/models/loki.py b/python/grafana_foundation_sdk/models/loki.py index 664d87f..790e0a7 100644 --- a/python/grafana_foundation_sdk/models/loki.py +++ b/python/grafana_foundation_sdk/models/loki.py @@ -31,7 +31,7 @@ class LokiQueryDirection(enum.StrEnum): class Dataquery(cogvariants.Dataquery): # The LogQL query. - expr: typing.Optional[str] + expr: str # Used to override the name of the series. legend_format: typing.Optional[str] # Used to limit the number of log rows returned. @@ -48,7 +48,7 @@ class Dataquery(cogvariants.Dataquery): # A unique identifier for the query within the list of targets. # In server side expressions, the refId is used as a variable name to identify results. # By default, the UI will assign A->Z; however setting meaningful names may be useful. - ref_id: typing.Optional[str] + ref_id: str # If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel. hide: typing.Optional[bool] # Specify the query flavor @@ -60,7 +60,7 @@ class Dataquery(cogvariants.Dataquery): # TODO this shouldn't be unknown but DataSourceRef | null datasource: typing.Optional[object] - def __init__(self, expr: typing.Optional[str] = None, legend_format: typing.Optional[str] = None, max_lines: typing.Optional[int] = None, resolution: typing.Optional[int] = None, editor_mode: typing.Optional['QueryEditorMode'] = None, range_val: typing.Optional[bool] = None, instant: typing.Optional[bool] = None, step: typing.Optional[str] = None, ref_id: typing.Optional[str] = None, hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): + def __init__(self, expr: str = "", legend_format: typing.Optional[str] = None, max_lines: typing.Optional[int] = None, resolution: typing.Optional[int] = None, editor_mode: typing.Optional['QueryEditorMode'] = None, range_val: typing.Optional[bool] = None, instant: typing.Optional[bool] = None, step: typing.Optional[str] = None, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, datasource: typing.Optional[object] = None): self.expr = expr self.legend_format = legend_format self.max_lines = max_lines @@ -76,9 +76,9 @@ class Dataquery(cogvariants.Dataquery): def to_json(self) -> dict[str, object]: payload: dict[str, object] = { + "expr": self.expr, + "refId": self.ref_id, } - if self.expr is not None: - payload["expr"] = self.expr if self.legend_format is not None: payload["legendFormat"] = self.legend_format if self.max_lines is not None: @@ -93,8 +93,6 @@ class Dataquery(cogvariants.Dataquery): payload["instant"] = self.instant if self.step is not None: payload["step"] = self.step - if self.ref_id is not None: - payload["refId"] = self.ref_id if self.hide is not None: payload["hide"] = self.hide if self.query_type is not None: diff --git a/python/grafana_foundation_sdk/models/parca.py b/python/grafana_foundation_sdk/models/parca.py index 287e9ac..de72ada 100644 --- a/python/grafana_foundation_sdk/models/parca.py +++ b/python/grafana_foundation_sdk/models/parca.py @@ -14,13 +14,13 @@ class ParcaQueryType(enum.StrEnum): class Dataquery(cogvariants.Dataquery): # Specifies the query label selectors. - label_selector: typing.Optional[str] + label_selector: str # Specifies the type of profile to query. - profile_type_id: typing.Optional[str] + profile_type_id: str # A unique identifier for the query within the list of targets. # In server side expressions, the refId is used as a variable name to identify results. # By default, the UI will assign A->Z; however setting meaningful names may be useful. - ref_id: typing.Optional[str] + ref_id: str # If hide is set to true, Grafana will filter o...*[Comment body truncated]*