grafana / cog

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

Add DashboardMeta schema #448

Closed spinillos closed 5 months ago

spinillos commented 5 months ago

Related: https://raintank-corp.slack.com/archives/C018SLDD5MW/p1718104998658489

It adds DashboardMeta schema.

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/alerting/recordrule_builder_gen.go b/go/alerting/recordrule_builder_gen.go new file mode 100644 index 0000000..55e8a10 --- /dev/null +++ b/go/alerting/recordrule_builder_gen.go @@ -0,0 +1,55 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package alerting + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[RecordRule] = (*RecordRuleBuilder)(nil) + +type RecordRuleBuilder struct { + internal *RecordRule + errors map[string]cog.BuildErrors +} + +func NewRecordRuleBuilder() *RecordRuleBuilder { + resource := &RecordRule{} + builder := &RecordRuleBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *RecordRuleBuilder) Build() (RecordRule, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("RecordRule", err)...) + } + + if len(errs) != 0 { + return RecordRule{}, errs + } + + return *builder.internal, nil +} + +func (builder *RecordRuleBuilder) From(from string) *RecordRuleBuilder { + builder.internal.From = from + + return builder +} + +func (builder *RecordRuleBuilder) Metric(metric string) *RecordRuleBuilder { + builder.internal.Metric = metric + + return builder +} + +func (builder *RecordRuleBuilder) applyDefaults() { +} diff --git a/go/alerting/rule_builder_gen.go b/go/alerting/rule_builder_gen.go index 6e66fe8..80c4122 100644 --- a/go/alerting/rule_builder_gen.go +++ b/go/alerting/rule_builder_gen.go @@ -156,6 +156,17 @@ func (builder *RuleBuilder) Provenance(provenance Provenance) *RuleBuilder { return builder } +func (builder *RuleBuilder) Record(record cog.Builder[RecordRule]) *RuleBuilder { + recordResource, err := record.Build() + if err != nil { + builder.errors["record"] = err.(cog.BuildErrors) + return builder + } + builder.internal.Record = &recordResource + + return builder +} + func (builder *RuleBuilder) RuleGroup(ruleGroup string) *RuleBuilder { if !(len([]rune(ruleGroup)) >= 1) { builder.errors["ruleGroup"] = cog.MakeBuildErrors("ruleGroup", errors.New("len([]rune(ruleGroup)) must be >= 1")) diff --git a/go/alerting/types_gen.go b/go/alerting/types_gen.go index f81d0b1..f1b30cd 100644 --- a/go/alerting/types_gen.go +++ b/go/alerting/types_gen.go @@ -165,12 +165,18 @@ type Rule struct { NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` OrgID int64 `json:"orgID"` Provenance *Provenance `json:"provenance,omitempty"` + Record *RecordRule `json:"record,omitempty"` RuleGroup string `json:"ruleGroup"` Title string `json:"title"` Uid *string `json:"uid,omitempty"` Updated *time.Time `json:"updated,omitempty"` } +type RecordRule struct { + From string `json:"from"` + Metric string `json:"metric"` +} + // RelativeTimeRange is the per query start and end time // for requests. type RelativeTimeRange struct { diff --git a/go/azuremonitor/azuremonitorquery_builder_gen.go b/go/azuremonitor/azuremonitorquery_builder_gen.go index 6affba5..5a912ac 100644 --- a/go/azuremonitor/azuremonitorquery_builder_gen.go +++ b/go/azuremonitor/azuremonitorquery_builder_gen.go @@ -152,6 +152,12 @@ func (builder *AzureMonitorQueryBuilder) Resource(resource string) *AzureMonitor return builder } +func (builder *AzureMonitorQueryBuilder) Region(region string) *AzureMonitorQueryBuilder { + builder.internal.Region = ®ion + + return builder +} + // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema @@ -162,10 +168,9 @@ func (builder *AzureMonitorQueryBuilder) Datasource(datasource any) *AzureMonito return builder } -// Azure Monitor query type. -// queryType: #AzureQueryType -func (builder *AzureMonitorQueryBuilder) Region(region string) *AzureMonitorQueryBuilder { - builder.internal.Region = ®ion +// Used only for exemplar queries from Prometheus +func (builder *AzureMonitorQueryBuilder) Query(query string) *AzureMonitorQueryBuilder { + builder.internal.Query = &query return builder } diff --git a/go/azuremonitor/types_gen.go b/go/azuremonitor/types_gen.go index 0e789fb..d795d9b 100644 --- a/go/azuremonitor/types_gen.go +++ b/go/azuremonitor/types_gen.go @@ -38,14 +38,14 @@ type AzureMonitorQuery struct { ResourceGroup *string `json:"resourceGroup,omitempty"` Namespace *string `json:"namespace,omitempty"` Resource *string `json:"resource,omitempty"` + Region *string `json:"region,omitempty"` // For mixed data sources the selected datasource is on the query level. // For non mixed scenarios this is undefined. // TODO find a better way to do this ^ that's friendly to schema // TODO this shouldn't be unknown but DataSourceRef | null Datasource any `json:"datasource,omitempty"` - // Azure Monitor query type. - // queryType: #AzureQueryType - Region *string `json:"region,omitempty"` + // Used only for exemplar queries from Prometheus + Query *string `json:"query,omitempty"` } func (resource AzureMonitorQuery) ImplementsDataqueryVariant() {} @@ -81,6 +81,7 @@ const ( AzureQueryTypeWorkspacesQuery AzureQueryType = "Azure Workspaces" AzureQueryTypeLocationsQuery AzureQueryType = "Azure Regions" AzureQueryTypeGrafanaTemplateVariableFn AzureQueryType = "Grafana Template Variable Function" + AzureQueryTypeTraceExemplar AzureQueryType = "traceql" ) type AzureMetricQuery struct { diff --git a/go/common/tableautocelloptions_builder_gen.go b/go/common/tableautocelloptions_builder_gen.go new file mode 100644 index 0000000..4177c9f --- /dev/null +++ b/go/common/tableautocelloptions_builder_gen.go @@ -0,0 +1,51 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package common + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TableAutoCellOptions] = (*TableAutoCellOptionsBuilder)(nil) + +// Auto mode table cell options +type TableAutoCellOptionsBuilder struct { + internal *TableAutoCellOptions + errors map[string]cog.BuildErrors +} + +func NewTableAutoCellOptionsBuilder() *TableAutoCellOptionsBuilder { + resource := &TableAutoCellOptions{} + builder := &TableAutoCellOptionsBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + builder.internal.Type = "auto" + + return builder +} + +func (builder *TableAutoCellOptionsBuilder) Build() (TableAutoCellOptions, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TableAutoCellOptions", err)...) + } + + if len(errs) != 0 { + return TableAutoCellOptions{}, errs + } + + return *builder.internal, nil +} + +func (builder *TableAutoCellOptionsBuilder) WrapText(wrapText bool) *TableAutoCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + +func (builder *TableAutoCellOptionsBuilder) applyDefaults() { +} diff --git a/go/common/tablecoloredbackgroundcelloptions_builder_gen.go b/go/common/tablecoloredbackgroundcelloptions_builder_gen.go index fd519e9..57fe80b 100644 --- a/go/common/tablecoloredbackgroundcelloptions_builder_gen.go +++ b/go/common/tablecoloredbackgroundcelloptions_builder_gen.go @@ -53,5 +53,11 @@ func (builder *TableColoredBackgroundCellOptionsBuilder) ApplyToRow(applyToRow b return builder } +func (builder *TableColoredBackgroundCellOptionsBuilder) WrapText(wrapText bool) *TableColoredBackgroundCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + func (builder *TableColoredBackgroundCellOptionsBuilder) applyDefaults() { } diff --git a/go/common/tablecolortextcelloptions_builder_gen.go b/go/common/tablecolortextcelloptions_builder_gen.go new file mode 100644 index 0000000..22edbc8 --- /dev/null +++ b/go/common/tablecolortextcelloptions_builder_gen.go @@ -0,0 +1,51 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package common + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[TableColorTextCellOptions] = (*TableColorTextCellOptionsBuilder)(nil) + +// Colored text cell options +type TableColorTextCellOptionsBuilder struct { + internal *TableColorTextCellOptions + errors map[string]cog.BuildErrors +} + +func NewTableColorTextCellOptionsBuilder() *TableColorTextCellOptionsBuilder { + resource := &TableColorTextCellOptions{} + builder := &TableColorTextCellOptionsBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + builder.internal.Type = "color-text" + + return builder +} + +func (builder *TableColorTextCellOptionsBuilder) Build() (TableColorTextCellOptions, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("TableColorTextCellOptions", err)...) + } + + if len(errs) != 0 { + return TableColorTextCellOptions{}, errs + } + + return *builder.internal, nil +} + +func (builder *TableColorTextCellOptionsBuilder) WrapText(wrapText bool) *TableColorTextCellOptionsBuilder { + builder.internal.WrapText = &wrapText + + return builder +} + +func (builder *TableColorTextCellOptionsBuilder) applyDefaults() { +} diff --git a/go/common/types_gen.go b/go/common/types_gen.go index 515fd60..2a884e4 100644 --- a/go/common/types_gen.go +++ b/go/common/types_gen.go @@ -697,12 +697,14 @@ type TableFooterOptions struct { // Auto mode table cell options type TableAutoCellOptions struct { - Type string `json:"type"` + Type string `json:"type"` + WrapText *bool `json:"wrapText,omitempty"` } // Colored text cell options type TableColorTextCellOptions struct { - Type string `json:"type"` + Type string `json:"type"` + WrapText *bool `json:"wrapText,omitempty"` } // Json view cell options @@ -773,15 +775,17 @@ type TableColoredBackgroundCellOptions struct { Type string `json:"type"` Mode *TableCellBackgroundDisplayMode `json:"mode,omitempty"` ApplyToRow *bool `json:"applyToRow,omitempty"` + WrapText *bool `json:"wrapText,omitempty"` } // Height of a table cell type TableCellHeight string const ( - TableCellHeightSm TableCellHeight = "sm" - TableCellHeightMd TableCellHeight = "md" - TableCellHeightLg TableCellHeight = "lg" + TableCellHeightSm TableCellHeight = "sm" + TableCellHeightMd TableCellHeight = "md" + TableCellHeightLg TableCellHeight = "lg" + TableCellHeightAuto TableCellHeight = "auto" ) // Table cell options. Each cell has a display mode diff --git a/go/dashboard/annotationactions_builder_gen.go b/go/dashboard/annotationactions_builder_gen.go new file mode 100644 index 0000000..f25b631 --- /dev/null +++ b/go/dashboard/annotationactions_builder_gen.go @@ -0,0 +1,61 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package dashboard + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[AnnotationActions] = (*AnnotationActionsBuilder)(nil) + +type AnnotationActionsBuilder struct { + internal *AnnotationActions + errors map[string]cog.BuildErrors +} + +func NewAnnotationActionsBuilder() *AnnotationActionsBuilder { + resource := &AnnotationActions{} + builder := &AnnotationActionsBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *AnnotationActionsBuilder) Build() (AnnotationActions, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("AnnotationActions", err)...) + } + + if len(errs) != 0 { + return AnnotationActions{}, errs + } + + return *builder.internal, nil +} + +func (builder *AnnotationActionsBuilder) CanAdd(canAdd bool) *AnnotationActionsBuilder { + builder.internal.CanAdd = &canAdd + + return builder +} + +func (builder *AnnotationActionsBuilder) CanDelete(canDelete bool) *AnnotationActionsBuilder { + builder.internal.CanDelete = &canDelete + + return builder +} + +func (builder *AnnotationActionsBuilder) CanEdit(canEdit bool) *AnnotationActionsBuilder { + builder.internal.CanEdit = &canEdit + + return builder +} + +func (builder *AnnotationActionsBuilder) applyDefaults() { +} diff --git a/go/dashboard/annotationpermission_builder_gen.go b/go/dashboard/annotationpermission_builder_gen.go new file mode 100644 index 0000000..d7d7ea3 --- /dev/null +++ b/go/dashboard/annotationpermission_builder_gen.go @@ -0,0 +1,65 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package dashboard + +import ( + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[AnnotationPermission] = (*AnnotationPermissionBuilder)(nil) + +type AnnotationPermissionBuilder struct { + internal *AnnotationPermission + errors map[string]cog.BuildErrors +} + +func NewAnnotationPermissionBuilder() *AnnotationPermissionBuilder { + resource := &AnnotationPermission{} + builder := &AnnotationPermissionBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *AnnotationPermissionBuilder) Build() (AnnotationPermission, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("AnnotationPermission", err)...) + } + + if len(errs) != 0 { + return AnnotationPermission{}, errs + } + + return *builder.internal, nil +} + +func (builder *AnnotationPermissionBuilder) Dashboard(dashboard cog.Builder[AnnotationActions]) *AnnotationPermissionBuilder { + dashboardResource, err := dashboard.Build() + if err != nil { + builder.errors["dashboard"] = err.(cog.BuildErrors) + return builder + } + builder.internal.Dashboard = &dashboardResource + + return builder +} + +func (builder *AnnotationPermissionBuilder) Organization(organization cog.Builder[AnnotationActions]) *AnnotationPermissionBuilder { + organizationResource, err := organization.Build() + if err != nil { + builder.errors["organization"] = err.(cog.BuildErrors) + return builder + } + builder.internal.Organization = &organizationResource + + return builder +} + +func (builder *AnnotationPermissionBuilder) applyDefaults() { +} diff --git a/go/dashboard/dashboardmeta_builder_gen.go b/go/dashboard/dashboardmeta_builder_gen.go new file mode 100644 index 0000000..2ca55cb --- /dev/null +++ b/go/dashboard/dashboardmeta_builder_gen.go @@ -0,0 +1,206 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. + +package dashboard + +import ( + "time" + + cog "github.com/grafana/grafana-foundation-sdk/go/cog" +) + +var _ cog.Builder[DashboardMeta] = (*DashboardMetaBuilder)(nil) + +type DashboardMetaBuilder struct { + internal *DashboardMeta + errors map[string]cog.BuildErrors +} + +func NewDashboardMetaBuilder() *DashboardMetaBuilder { + resource := &DashboardMeta{} + builder := &DashboardMetaBuilder{ + internal: resource, + errors: make(map[string]cog.BuildErrors), + } + + builder.applyDefaults() + + return builder +} + +func (builder *DashboardMetaBuilder) Build() (DashboardMeta, error) { + var errs cog.BuildErrors + + for _, err := range builder.errors { + errs = append(errs, cog.MakeBuildErrors("DashboardMeta", err)...) + } + + if len(errs) != 0 { + return DashboardMeta{}, errs + } + + return *builder.internal, nil +} + +func (builder *DashboardMetaBuilder) AnnotationsPermissions(annotationsPermissions cog.Builder[AnnotationPermission]) *DashboardMetaBuilder { + annotationsPermissionsResource, err := annotationsPermissions.Build() + if err != nil { + builder.errors["annotationsPermissions"] = err.(cog.BuildErrors) + return builder + } + builder.internal.AnnotationsPermissions = &annotationsPermissionsResource + + return builder +} + +func (builder *DashboardMetaBuilder) CanAdmin(canAdmin bool) *DashboardMetaBuilder { + builder.internal.CanAdmin = &canAdmin + + return builder +} + +func (builder *DashboardMetaBuilder) CanDelete(canDelete bool) *DashboardMetaBuilder { + builder.internal.CanDelete = &canDelete + + return builder +} + +func (builder *DashboardMetaBuilder) CanEdit(canEdit bool) *DashboardMetaBuilder { + builder.internal.CanEdit = &canEdit + + return builder +} + +func (builder *DashboardMetaBuilder) CanSave(canSave bool) *DashboardMetaBuilder { + builder.internal.CanSave = &canSave + + return builder +} + +func (builder *DashboardMetaBuilder) CanStar(canStar bool) *DashboardMetaBuilder { + builder.internal.CanStar = &canStar + + return builder +} + +func (builder *DashboardMetaBuilder) Created(created time.Time) *DashboardMetaBuilder { + builder.internal.Created = &created + + return builder +} + +func (builder *DashboardMetaBuilder) CreatedBy(createdBy string) *DashboardMetaBuilder { + builder.internal.CreatedBy = &createdBy + + return builder +} + +func (builder *DashboardMetaBuilder) Expires(expires time.Time) *DashboardMetaBuilder { + builder.internal.Expires = &expires + + return builder +} + +func (builder *DashboardMetaBuilder) FolderId(folderId int64) *DashboardMetaBuilder { + builder.internal.FolderId = &folderId + + return builder +} + +func (builder *DashboardMetaBuilder) FolderTitle(folderTitle string) *DashboardMetaBuilder { + builder.internal.FolderTitle = &folderTitle + + return builder +} + +func (builder *DashboardMetaBuilder) FolderUid(folderUid string) *DashboardMetaBuilder { + builder.internal.FolderUid = &folderUid + + return builder +} + +func (builder *DashboardMetaBuilder) FolderUrl(folderUrl string) *DashboardMetaBuilder { + builder.internal.FolderUrl = &folderUrl + + return builder +} + +func (builder *DashboardMetaBuilder) HasAcl(hasAcl bool) *DashboardMetaBuilder { + builder.internal.HasAcl = &hasAcl + + return builder +} + +func (builder *DashboardMetaBuilder) IsFolder(isFolder bool) *DashboardMetaBuilder { + builder.internal.IsFolder = &isFolder + + return builder +} + +func (builder *DashboardMetaBuilder) IsSnapshot(isSnapshot bool) *DashboardMetaBuilder { + builder.internal.IsSnapshot = &isSnapshot + + return builder +} + +func (builder *DashboardMetaBuilder) IsStarred(isStarred bool) *DashboardMetaBuilder { + builder.internal.IsStarred = &isStarred + + return builder +} + +func (builder *DashboardMetaBuilder) Provisioned(provisioned bool) *DashboardMetaBuilder { + builder.internal.Provisioned = &provisioned + + return builder +} + +func (builder *DashboardMetaBuilder) ProvisionedExternalId(provisionedExternalId string) *DashboardMetaBuilder { + builder.internal.ProvisionedExternalId = &provisionedExternalId + + return builder +} + +func (builder *DashboardMetaBuilder) PublicDashboardEnabled(publicDashboardEnabled bool) *DashboardMetaBuilder { + builder.internal.PublicDashboardEnabled = &publicDashboardEnabled + + return builder +} + +func (builder *DashboardMetaBuilder) Slug(slug string) *DashboardMetaBuilder { + builder.internal.Slug = &slug + + return builder +} + +func (builder *DashboardMetaBuilder) Type(typeArg string) *DashboardMetaBuilder { + builder.internal.Type = &typeArg + + return builder +} + +func (builder *DashboardMetaBuilder) Updated(updated time.Time) *DashboardMetaBuilder { + builder.internal.Updated = &updated + + return builder +} + +func (builder *DashboardMetaBuilder) UpdatedBy(updatedBy string) *DashboardMetaBuilder { + builder.internal.UpdatedBy = &updatedBy + + return builder +} + +func (builder *DashboardMetaBuilder) Url(url string) *DashboardMetaBuilder { + builder.internal.Url = &url + + return builder +} + +func (builder *DashboardMetaBuilder) Version(version int64) *DashboardMetaBuilder { + builder.internal.Version = &version + + return builder +} + +func (builder *DashboardMetaBuilder) applyDefaults() { +} diff --git a/go/dashboard/datasourcevariable_builder_gen.go b/go/dashboard/datasourcevariable_builder_gen.go index 77cdec6..15f6a78 100644 --- a/go/dashboard/datasourcevariable_builder_gen.go +++ b/go/dashboard/datasourcevariable_builder_gen.go @@ -71,11 +71,11 @@ func (builder *DatasourceVariableBuilder) Description(description string) *Datas } // Query used to fetch values for a variable -func (builder *DatasourceVariableBuilder) Type(string string) *DatasourceVariableBuilder { +func (builder *DatasourceVariableBuilder) Type(stringArg string) *DatasourceVariableBuilder { if builder.internal.Query == nil { builder.internal.Query = &StringOrMap{} } - builder.internal.Query.String = &string + builder.internal.Query.String = &stringArg return builder } diff --git a/go/dashboard/types_gen.go b/go/dashboard/types_gen.go index fef9956..74ce0d0 100644 --- a/go/dashboard/types_gen.go +++ b/go/dashboard/types_gen.go @@ -927,6 +927,46 @@ type RowPanel struct { Repeat *string `json:"repeat,omitempty"` } +type AnnotationActions struct { + CanAdd *bool `json:"canAdd,omitempty"` + CanDelete *bool `json:"canDelete,omitempty"` + CanEdit *bool `json:"canEdit,omitempty"` +} + +type AnnotationPermission struct { + Dashboard *AnnotationActions `json:"dashboard,omitempty"` + Organization *AnnotationActions `json:"organization,omitempty"` +} + +type DashboardMeta struct { + AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions,omitempty"` + CanAdmin *bool `json:"canAdmin,omitempty"` + CanDelete *bool `json:"canDelete,omitempty"` + CanEdit *bool `json:"canEdit,omitempty"` + CanSave *bool `json:"canSave,omitempty"` + CanStar *bool `json:"canStar,omitempty"` + Created *time.Time `json:"created,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + Expires *time.Time `json:"expires,omitempty"` + FolderId *int64 `json:"folderId,omitempty"` + FolderTitle *string `json:"folderTitle,omitempty"` + FolderUid *string `json:"folderUid,omitempty"` + FolderUrl *string `json:"folderUrl,omitempty"` + HasAcl *bool `json:"hasAcl,omitempty"` + IsFolder *bool `json:"isFolder,omitempty"` + IsSnapshot *bool `json:"isSnapshot,omitempty"` + IsStarred *bool `json:"isStarred,omitempty"` + Provisioned *bool `json:"provisioned,omitempty"` + ProvisionedExternalId *string `json:"provisionedExternalId,omitempty"` + PublicDashboardEnabled *bool `json:"publicDashboardEnabled,omitempty"` + Slug *string `json:"slug,omitempty"` + Type *string `json:"type,omitempty"` + Updated *time.Time `json:"updated,omitempty"` + UpdatedBy *string `json:"updatedBy,omitempty"` + Url *string `json:"url,omitempty"` + Version *int64 `json:"version,omitempty"` +} + type DataTransformerConfigTopic string const ( diff --git a/go/elasticsearch/inlinescript_builder_gen.go b/go/elasticsearch/inlinescript_builder_gen.go index cc49dde..f65a96c 100644 --- a/go/elasticsearch/inlinescript_builder_gen.go +++ b/go/elasticsearch/inlinescript_builder_gen.go @@ -39,8 +39,8 @@ func (builder *InlineScriptBuilder) Build() (InlineScript, error) { return *builder.internal, nil } -func (builder *InlineScriptBuilder) String(string string) *InlineScriptBuilder { - builder.internal.String = &string +func (builder *InlineScriptBuilder) String(stringArg string) *InlineScriptBuilder { + builder.internal.String = &stringArg return builder } diff --git a/go/elasticsearch/stringorstruct_builder_gen.go b/go/elasticsearch/stringorstruct_builder_gen.go index 2d2a01e..ef21877 100644 --- a/go/elasticsearch/stringorstruct_builder_gen.go +++ b/go/elasticsearch/stringorstruct_builder_gen.go @@ -39,8 +39,8 @@ func (builder *StringOrStructBuilder) Build() (StringOrStruct, error) { return *builder.internal, nil } -func (builder *StringOrStructBuilder) String(string string) *StringOrStructBuilder { - builder.internal.String = &string +func (builder *StringOrStructBuilder) String(stringArg string) *StringOrStructBuilder { + builder.internal.String = &stringArg return builder } diff --git a/go/heatmap/panel_builder_gen.go b/go/heatmap/panel_builder_gen.go index 9c62343..045788c 100644 --- a/go/heatmap/panel_builder_gen.go +++ b/go/heatmap/panel_builder_gen.go @@ -626,6 +626,16 @@ func (builder *PanelBuilder) ExemplarsColor(color string) *PanelBuilder { return builder } +// Controls which axis to allow selection on +func (builder *PanelBuilder) SelectionMode(selectionMode HeatmapSelectionMode) *PanelBuilder { + if builder.internal.Options == nil { + builder.internal.Options = &Options{} + } + builder.internal.Options.(*Options).SelectionMode = &selectionMode + + return builder +} + func (builder *PanelBuilder) ScaleDistribution(scaleDistribution cog.Builder[common.ScaleDistributionConfig]) *PanelBuilder { if builder.internal.FieldConfig == nil { builder.internal.FieldConfig = &dashboard.FieldConfigSource{} @@ -678,4 +688,5 @@ func (builder *PanelBuilder) applyDefaults() { builder.ShowValue("auto") builder.CellGap(1) builder.ExemplarsColor("rgba(255,0,255,0.7)") + builder.SelectionMode("x") } diff --git a/go/heatmap/types_gen.go b/go/heatmap/types_gen.go index 7938615..583f986 100644 --- a/go/heatmap/types_gen.go +++ b/go/heatmap/types_gen.go @@ -25,6 +25,15 @@ const ( HeatmapColorScaleExponential HeatmapColorScale = "exponential" ) +// Controls which axis to allow selection on +type HeatmapSelectionMode string + +const ( + HeatmapSelectionModeX HeatmapSelectionMode = "x" + HeatmapSelectionModeY HeatmapSelectionMode = "y" + HeatmapSelectionModeXy HeatmapSelectionMode = "xy" +) + // Controls various color options type HeatmapColorOptions struct { // Sets the color mode @@ -152,6 +161,8 @@ type Options struct { Tooltip HeatmapTooltip `json:"tooltip"` // Controls exemplar options Exemplars ExemplarConfig `json:"exemplars"` + // Controls which axis to allow selection on + SelectionMode *HeatmapSelectionMode `json:"selectionMode,omitempty"` } type FieldConfig struct { diff --git a/jsonschema/alerting.jsonschema.json b/jsonschema/alerting.jsonschema.json index f17d52d..bb926f0 100644 --- a/jsonschema/alerting.jsonschema.json +++ b/jsonschema/alerting.jsonschema.json @@ -299,6 +299,9 @@ "provenance": { "$ref": "#/definitions/Provenance" }, + "record": { + "$ref": "#/definitions/RecordRule" + }, "ruleGroup": { "type": "string", "minLength": 1, @@ -320,6 +323,22 @@ } } }, + "RecordRule": { + "type": "object", + "additionalProperties": false, + "required": [ + "from", + "metric" + ], + "properties": { + "from": { + "type": "string" + }, + "metric": { + "type": "string" + } + } + }, "RelativeTimeRange": { "type": "object", "additionalProperties": false, diff --git a/jsonschema/azuremonitor.jsonschema.json b/jsonschema/azuremonitor.jsonschema.json index 3aa1d09..983c6d1 100644 --- a/jsonschema/azuremonitor.jsonschema.json +++ b/jsonschema/azuremonitor.jsonschema.json @@ -61,14 +61,17 @@ "resource": { "type": "string" }, + "region": { + "type": "string" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "region": { + "query": { "type": "string", - "description": "Azure Monitor query type.\nqueryType: #AzureQueryType" + "description": "Used only for exemplar queries from Prometheus" } } }, @@ -85,7 +88,8 @@ "Azure Metric Names", "Azure Workspaces", "Azure Regions", - "Grafana Template Variable Function" + "Grafana Template Variable Function", + "traceql" ], "description": "Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated" }, diff --git a/jsonschema/common.jsonschema.json b/jsonschema/common.jsonschema.json index 9a0163c..ec9b99e 100644 --- a/jsonschema/common.jsonschema.json +++ b/jsonschema/common.jsonschema.json @@ -1123,6 +1123,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -1137,6 +1140,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" @@ -1347,6 +1353,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -1355,7 +1364,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, diff --git a/jsonschema/dashboard.jsonschema.json b/jsonschema/dashboard.jsonschema.json index 28d29c3..e220ac1 100644 --- a/jsonschema/dashboard.jsonschema.json +++ b/jsonschema/dashboard.jsonschema.json @@ -1379,6 +1379,120 @@ } }, "description": "Row panel" + }, + "AnnotationActions": { + "type": "object", + "additionalProperties": false, + "properties": { + "canAdd": { + "type": "boolean" + }, + "canDelete": { + "type": "boolean" + }, + "canEdit": { + "type": "boolean" + } + } + }, + "AnnotationPermission": { + "type": "object", + "additionalProperties": false, + "properties": { + "dashboard": { + "$ref": "#/definitions/AnnotationActions" + }, + "organization": { + "$ref": "#/definitions/AnnotationActions" + } + } + }, + "DashboardMeta": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotationsPermissions": { + "$ref": "#/definitions/AnnotationPermission" + }, + "canAdmin": { + "type": "boolean" + }, + "canDelete": { + "type": "boolean" + }, + "canEdit": { + "type": "boolean" + }, + "canSave": { + "type": "boolean" + }, + "canStar": { + "type": "boolean" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "createdBy": { + "type": "string" + }, + "expires": { + "type": "string", + "format": "date-time" + }, + "folderId": { + "type": "integer" + }, + "folderTitle": { + "type": "string" + }, + "folderUid": { + "type": "string" + }, + "folderUrl": { + "type": "string" + }, + "hasAcl": { + "type": "boolean" + }, + "isFolder": { + "type": "boolean" + }, + "isSnapshot": { + "type": "boolean" + }, + "isStarred": { + "type": "boolean" + }, + "provisioned": { + "type": "boolean" + }, + "provisionedExternalId": { + "type": "string" + }, + "publicDashboardEnabled": { + "type": "boolean" + }, + "slug": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updated": { + "type": "string", + "format": "date-time" + }, + "updatedBy": { + "type": "string" + }, + "url": { + "type": "string" + }, + "version": { + "type": "integer" + } + } } } } \ No newline at end of file diff --git a/jsonschema/heatmap.jsonschema.json b/jsonschema/heatmap.jsonschema.json index a0e8d5e..ee7a168 100644 --- a/jsonschema/heatmap.jsonschema.json +++ b/jsonschema/heatmap.jsonschema.json @@ -15,6 +15,14 @@ ], "description": "Controls the color scale of the heatmap" }, + "HeatmapSelectionMode": { + "enum": [ + "x", + "y", + "xy" + ], + "description": "Controls which axis to allow selection on" + }, "HeatmapColorOptions": { "type": "object", "additionalProperties": false, @@ -308,6 +316,11 @@ "default": { "color": "rgba(255,0,255,0.7)" } + }, + "selectionMode": { + "$ref": "#/definitions/HeatmapSelectionMode", + "description": "Controls which axis to allow selection on", + "default": "x" } } }, diff --git a/jsonschema/table.jsonschema.json b/jsonschema/table.jsonschema.json index 09387da..4ac0b57 100644 --- a/jsonschema/table.jsonschema.json +++ b/jsonschema/table.jsonschema.json @@ -105,7 +105,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -218,6 +219,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -386,6 +390,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -400,6 +407,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" diff --git a/openapi/alerting.openapi.json b/openapi/alerting.openapi.json index c47f39c..9d6de84 100644 --- a/openapi/alerting.openapi.json +++ b/openapi/alerting.openapi.json @@ -307,6 +307,9 @@ "provenance": { "$ref": "#/components/schemas/Provenance" }, + "record": { + "$ref": "#/components/schemas/RecordRule" + }, "ruleGroup": { "type": "string", "minLength": 1, @@ -328,6 +331,22 @@ } } }, + "RecordRule": { + "type": "object", + "additionalProperties": false, + "required": [ + "from", + "metric" + ], + "properties": { + "from": { + "type": "string" + }, + "metric": { + "type": "string" + } + } + }, "RelativeTimeRange": { "type": "object", "additionalProperties": false, diff --git a/openapi/azuremonitor.openapi.json b/openapi/azuremonitor.openapi.json index 82454e4..571ef1a 100644 --- a/openapi/azuremonitor.openapi.json +++ b/openapi/azuremonitor.openapi.json @@ -70,14 +70,17 @@ "resource": { "type": "string" }, + "region": { + "type": "string" + }, "datasource": { "type": "object", "additionalProperties": {}, "description": "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" }, - "region": { + "query": { "type": "string", - "description": "Azure Monitor query type.\nqueryType: #AzureQueryType" + "description": "Used only for exemplar queries from Prometheus" } } }, @@ -94,7 +97,8 @@ "Azure Metric Names", "Azure Workspaces", "Azure Regions", - "Grafana Template Variable Function" + "Grafana Template Variable Function", + "traceql" ], "description": "Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated" }, diff --git a/openapi/common.openapi.json b/openapi/common.openapi.json index f03e8df..914e6b8 100644 --- a/openapi/common.openapi.json +++ b/openapi/common.openapi.json @@ -1131,6 +1131,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -1145,6 +1148,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" @@ -1355,6 +1361,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -1363,7 +1372,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, diff --git a/openapi/dashboard.openapi.json b/openapi/dashboard.openapi.json index a7ec373..3a9a83f 100644 --- a/openapi/dashboard.openapi.json +++ b/openapi/dashboard.openapi.json @@ -1386,6 +1386,120 @@ } }, "description": "Row panel" + }, + "AnnotationActions": { + "type": "object", + "additionalProperties": false, + "properties": { + "canAdd": { + "type": "boolean" + }, + "canDelete": { + "type": "boolean" + }, + "canEdit": { + "type": "boolean" + } + } + }, + "AnnotationPermission": { + "type": "object", + "additionalProperties": false, + "properties": { + "dashboard": { + "$ref": "#/components/schemas/AnnotationActions" + }, + "organization": { + "$ref": "#/components/schemas/AnnotationActions" + } + } + }, + "DashboardMeta": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotationsPermissions": { + "$ref": "#/components/schemas/AnnotationPermission" + }, + "canAdmin": { + "type": "boolean" + }, + "canDelete": { + "type": "boolean" + }, + "canEdit": { + "type": "boolean" + }, + "canSave": { + "type": "boolean" + }, + "canStar": { + "type": "boolean" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "createdBy": { + "type": "string" + }, + "expires": { + "type": "string", + "format": "date-time" + }, + "folderId": { + "type": "integer" + }, + "folderTitle": { + "type": "string" + }, + "folderUid": { + "type": "string" + }, + "folderUrl": { + "type": "string" + }, + "hasAcl": { + "type": "boolean" + }, + "isFolder": { + "type": "boolean" + }, + "isSnapshot": { + "type": "boolean" + }, + "isStarred": { + "type": "boolean" + }, + "provisioned": { + "type": "boolean" + }, + "provisionedExternalId": { + "type": "string" + }, + "publicDashboardEnabled": { + "type": "boolean" + }, + "slug": { + "type": "string" + }, + "type": { + "type": "string" + }, + "updated": { + "type": "string", + "format": "date-time" + }, + "updatedBy": { + "type": "string" + }, + "url": { + "type": "string" + }, + "version": { + "type": "integer" + } + } } } } diff --git a/openapi/heatmap.openapi.json b/openapi/heatmap.openapi.json index 80cb0b9..b6d4cb4 100644 --- a/openapi/heatmap.openapi.json +++ b/openapi/heatmap.openapi.json @@ -24,6 +24,14 @@ ], "description": "Controls the color scale of the heatmap" }, + "HeatmapSelectionMode": { + "enum": [ + "x", + "y", + "xy" + ], + "description": "Controls which axis to allow selection on" + }, "HeatmapColorOptions": { "type": "object", "additionalProperties": false, @@ -317,6 +325,11 @@ "default": { "color": "rgba(255,0,255,0.7)" } + }, + "selectionMode": { + "$ref": "#/components/schemas/HeatmapSelectionMode", + "description": "Controls which axis to allow selection on", + "default": "x" } } }, diff --git a/openapi/table.openapi.json b/openapi/table.openapi.json index 930cc90..d42ed0e 100644 --- a/openapi/table.openapi.json +++ b/openapi/table.openapi.json @@ -114,7 +114,8 @@ "enum": [ "sm", "md", - "lg" + "lg", + "auto" ], "description": "Height of a table cell" }, @@ -227,6 +228,9 @@ "type": { "type": "string", "const": "auto" + }, + "wrapText": { + "type": "boolean" } }, "description": "Auto mode table cell options" @@ -395,6 +399,9 @@ }, "applyToRow": { "type": "boolean" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored background cell options" @@ -409,6 +416,9 @@ "type": { "type": "string", "const": "color-text" + }, + "wrapText": { + "type": "boolean" } }, "description": "Colored text cell options" diff --git a/python/grafana_foundation_sdk/builders/alerting.py b/python/grafana_foundation_sdk/builders/alerting.py index eaa3d84..4b1ea99 100644 --- a/python/grafana_foundation_sdk/builders/alerting.py +++ b/python/grafana_foundation_sdk/builders/alerting.py @@ -374,6 +374,12 @@ class Rule(cogbuilder.Builder[alerting.Rule]): return self + def record(self, record: cogbuilder.Builder[alerting.RecordRule]) -> typing.Self: + record_resource = record.build() + self._internal.record = record_resource + + return self + def rule_group(self, rule_group: str) -> typing.Self: if not len(rule_group) >= 1: raise ValueError("len(rule_group) must be >= 1") @@ -407,6 +413,26 @@ class Rule(cogbuilder.Builder[alerting.Rule]): return self +class RecordRule(cogbuilder.Builder[alerting.RecordRule]): + _internal: alerting.RecordRule + + def __init__(self): + self._internal = alerting.RecordRule() + + def build(self) -> alerting.RecordRule: + return self._internal + + def from_val(self, from_val: str) -> typing.Self: + self._internal.from_val = from_val + + return self + + def metric(self, metric: str) -> typing.Self: + self._internal.metric = metric + + return self + + class NotificationPolicy(cogbuilder.Builder[alerting.NotificationPolicy]): """ A Route is a node that contains definitions of how to handle alerts. This is modified diff --git a/python/grafana_foundation_sdk/builders/azuremonitor.py b/python/grafana_foundation_sdk/builders/azuremonitor.py index 7c26cae..a9e2529 100644 --- a/python/grafana_foundation_sdk/builders/azuremonitor.py +++ b/python/grafana_foundation_sdk/builders/azuremonitor.py @@ -130,6 +130,11 @@ class AzureMonitorQuery(cogbuilder.Builder[azuremonitor.AzureMonitorQuery]): return self + def region(self, region: str) -> typing.Self: + self._internal.region = region + + return self + def datasource(self, datasource: object) -> typing.Self: """ For mixed data sources the selected datasource is on the query level. @@ -142,13 +147,12 @@ class AzureMonitorQuery(cogbuilder.Builder[azuremonitor.AzureMonitorQuery]): return self - def region(self, region: str) -> typing.Self: + def query(self, query: str) -> typing.Self: """ - Azure Monitor query type. - queryType: #AzureQueryType + Used only for exemplar queries from Prometheus """ - self._internal.region = region + self._internal.query = query return self diff --git a/python/grafana_foundation_sdk/builders/common.py b/python/grafana_foundation_sdk/builders/common.py index 2c145b1..ad060e0 100644 --- a/python/grafana_foundation_sdk/builders/common.py +++ b/python/grafana_foundation_sdk/builders/common.py @@ -1283,6 +1283,46 @@ class TableFooterOptions(cogbuilder.Builder[common.TableFooterOptions]): return self +class TableAutoCellOptions(cogbuilder.Builder[common.TableAutoCellOptions]): + """ + Auto mode table cell options + """ + + _internal: common.TableAutoCellOptions + + def __init__(self): + self._internal = common.TableAutoCellOptions() + self._internal.type_val = "auto" + + def build(self) -> common.TableAutoCellOptions: + return self._internal + + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + + +class TableColorTextCellOptions(cogbuilder.Builder[common.TableColorTextCellOptions]): + """ + Colored text cell options + """ + + _internal: common.TableColorTextCellOptions + + def __init__(self): + self._internal = common.TableColorTextCellOptions() + self._internal.type_val = "color-text" + + def build(self) -> common.TableColorTextCellOptions: + return self._internal + + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + + class TableBarGaugeCellOptions(cogbuilder.Builder[common.TableBarGaugeCellOptions]): """ Gauge cell options @@ -1523,6 +1563,11 @@ class TableColoredBackgroundCellOptions(cogbuilder.Builder[common.TableColoredBa return self + def wrap_text(self, wrap_text: bool) -> typing.Self: + self._internal.wrap_text = wrap_text + + return self + class DataSourceRef(cogbuilder.Builder[common.DataSourceRef]): _internal: common.DataSourceRef diff --git a/python/grafana_foundation_sdk/builders/dashboard.py b/python/grafana_foundation_sdk/builders/dashboard.py index ddec2e5..d93cb42 100644 --- a/python/grafana_foundation_sdk/builders/dashboard.py +++ b/python/grafana_foundation_sdk/builders/dashboard.py @@ -1528,6 +1528,194 @@ class Row(cogbuilder.Builder[dashboard.RowPanel]): return self +class AnnotationActions(cogbuilder.Builder[dashboard.AnnotationActions]): + _internal: dashboard.AnnotationActions + + def __init__(self): + self._internal = dashboard.AnnotationActions() + + def build(self) -> dashboard.AnnotationActions: + return self._internal + + def can_add(self, can_add: bool) -> typing.Self: + self._internal.can_add = can_add + + return self + + def can_delete(self, can_delete: bool) -> typing.Self: + self._internal.can_delete = can_delete + + return self + + def can_edit(self, can_edit: bool) -> typing.Self: + self._internal.can_edit = can_edit + + return self + + +class AnnotationPermission(cogbuilder.Builder[dashboard.AnnotationPermission]): + _internal: dashboard.AnnotationPermission + + def __init__(self): + self._internal = dashboard.AnnotationPermission() + + def build(self) -> dashboard.AnnotationPermission: + return self._internal + + def dashboard_permissions(self, dashboard: cogbuilder.Builder[dashboard.AnnotationActions]) -> typing.Self: + dashboard_resource = dashboard.build() + self._internal.dashboard = dashboard_resource + + return self + + def organization_permissions(self, organization: cogbuilder.Builder[dashboard.AnnotationActions]) -> typing.Self: + organization_resource = organization.build() + self._internal.organization = organization_resource + + return self + + +class DashboardMeta(cogbuilder.Builder[dashboard.DashboardMeta]): + _internal: dashboard.DashboardMeta + + def __init__(self): + self._internal = dashboard.DashboardMeta() + + def build(self) -> dashboard.DashboardMeta: + return self._internal + + def annotations_permissions(self, annotations_permissions: cogbuilder.Builder[dashboard.AnnotationPermission]) -> typing.Self: + annotations_permissions_resource = annotations_permissions.build() + self._internal.annotations_permissions = annotations_permissions_resource + + return self + + def can_admin(self, can_admin: bool) -> typing.Self: + self._internal.can_admin = can_admin + + return self + + def can_delete(self, can_delete: bool) -> typing.Self: + self._internal.can_delete = can_delete + + return self + + def can_edit(self, can_edit: bool) -> typing.Self: + self._internal.can_edit = can_edit + + return self + + def can_save(self, can_save: bool) -> typing.Self: + self._internal.can_save = can_save + + return self + + def can_star(self, can_star: bool) -> typing.Self: + self._internal.can_star = can_star + + return self + + def created(self, created: str) -> typing.Self: + self._internal.created = created + + return self + + def created_by(self, created_by: str) -> typing.Self: + self._internal.created_by = created_by + + return self + + def expires(self, expires: str) -> typing.Self: + self._internal.expires = expires + + return self + + def folder_id(self, folder_id: int) -> typing.Self: + self._internal.folder_id = folder_id + + return self + + def folder_title(self, folder_title: str) -> typing.Self: + self._internal.folder_title = folder_title + + return self + + def folder_uid(self, folder_uid: str) -> typing.Self: + self._internal.folder_uid = folder_uid + + return self + + def folder_url(self, folder_url: str) -> typing.Self: + self._internal.folder_url = folder_url + + return self + + def has_acl(self, has_acl: bool) -> typing.Self: + self._internal.has_acl = has_acl + + return self + + def is_folder(self, is_folder: bool) -> typing.Self: + self._internal.is_folder = is_folder + + return self + + def is_snapshot(self, is_snapshot: bool) -> typing.Self: + self._internal.is_snapshot = is_snapshot + + return self + + def is_starred(self, is_starred: bool) -> typing.Self: + self._internal.is_starred = is_starred + + return self + + def provisioned(self, provisioned: bool) -> typing.Self: + self._internal.provisioned = provisioned + + return self + + def provisioned_external_id(self, provisioned_external_id: str) -> typing.Self: + self._internal.provisioned_external_id = provisioned_external_id + + return self + + def public_dashboard_enabled(self, public_dashboard_enabled: bool) -> typing.Self: + self._internal.public_dashboard_enabled = public_dashboard_enabled + + return self + + def slug(self, slug: str) -> typing.Self: + self._internal.slug = slug + + return self + + def type_val(self, type_val: str) -> typing.Self: + self._internal.type_val = type_val + + return self + + def updated(self, updated: str) -> typing.Self: + self._internal.updated = updated + + return self + + def updated_by(self, updated_by: str) -> typing.Self: + self._internal.updated_by = updated_by + + return self + + def url(self, url: str) -> typing.Self: + self._internal.url = url + + return self + + def version(self, version: int) -> typing.Self: + self._internal.version = version + + return self + + class DashboardDashboardTemplating(cogbuilder.Builder[dashboard.DashboardDashboardTemplating]): _internal: dashboard.DashboardDashboardTemplating diff --git a/python/grafana_foundation_sdk/builders/heatmap.py b/python/grafana_foundation_sdk/builders/heatmap.py index fc6d8af..9546e30 100644 --- a/python/grafana_foundation_sdk/builders/heatmap.py +++ b/python/grafana_foundation_sdk/builders/heatmap.py @@ -717,6 +717,18 @@ class Panel(cogbuilder.Builder[dashboard.Panel]): return self + def selection_mode(self, selection_mode: heatmap.HeatmapSelectionMode) -> typing.Self: + """ + Controls which axis to allow selection on + """ + + if self._internal.options is None: + self._internal.options = heatmap.Options() + assert isinstance(self._internal.options, heatmap.Options) + self._internal.options.selection_mode = selection_mode + + return self + def scale_distribution(self, scale_distribution: cogbuilder.Builder[common.ScaleDistributionConfig]) -> typing.Self: if self._internal.field_config is None: self._internal.field_config = dashboard.FieldConfigSource() diff --git a/python/grafana_foundation_sdk/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py index ea5481d..5fc3fa1 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 dashboardlist +from ..models import xychart +from ..models import cloudwatch from ..models import debug -from ..models import histogram -from ..models import stat -from ..models import tempo -from ..models import expr -from ..models import barchart -from ..models import datagrid from ..models import grafanapyroscope -from ..models import heatmap -from ..models import nodegraph -from ..models import cloudwatch +from ..models import statetimeline +from ..models import table from ..models import text -from ..models import timeseries -from ..models import canvas +from ..models import barchart from ..models import googlecloudmonitoring +from ..models import histogram +from ..models import nodegraph +from ..models import piechart from ..models import loki -from ..models import trend +from ..models import tempo +from ..models import candlestick +from ..models import gauge +from ..models import heatmap from ..models import statushistory -from ..models import prometheus from ..models import annotationslist -from ..models import statetimeline -from ..models import bargauge -from ..models import gauge -from ..models import logs -from ..models import azuremonitor -from ..models import candlestick -from ..models import elasticsearch -from ..models import piechart -from ..models import xychart from ..models import geomap +from ..models import logs +from ..models import prometheus +from ..models import timeseries +from ..models import bargauge +from ..models import canvas +from ..models import datagrid from ..models import news from ..models import parca -from ..models import table +from ..models import stat +from ..models import trend +from ..models import expr +from ..models import azuremonitor +from ..models import elasticsearch +from ..models import dashboardlist from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/alerting.py b/python/grafana_foundation_sdk/models/alerting.py index 4cf34db..8c51475 100644 --- a/python/grafana_foundation_sdk/models/alerting.py +++ b/python/grafana_foundation_sdk/models/alerting.py @@ -363,12 +363,13 @@ class Rule: notification_settings: typing.Optional['NotificationSettings'] org_id: int provenance: typing.Optional['Provenance'] + record: typing.Optional['RecordRule'] rule_group: str title: str uid: typing.Optional[str] updated: typing.Optional[str] - def __init__(self, annotations: typing.Optional[dict[str, str]] = None, condition: str = "", data: typing.Optional[list['Query']] = None, exec_err_state: typing.Optional[typing.Literal["OK", "Alerting", "Error"]] = None, folder_uid: str = "", for_val: str = "", id_val: typing.Optional[int] = None, is_paused: typing.Optional[bool] = None, labels: typing.Optional[dict[str, str]] = None, no_data_state: typing.Optional[typing.Literal["Alerting", "NoData", "OK"]] = None, notification_settings: typing.Optional['NotificationSettings'] = None, org_id: int = 0, provenance: typing.Optional['Provenance'] = None, rule_group: str = "", title: str = "", uid: typing.Optional[str] = None, updated: typing.Optional[str] = None): + def __init__(self, annotations: typing.Optional[dict[str, str]] = None, condition: str = "", data: typing.Optional[list['Query']] = None, exec_err_state: typing.Optional[typing.Literal["OK", "Alerting", "Error"]] = None, folder_uid: str = "", for_val: str = "", id_val: typing.Optional[int] = None, is_paused: typing.Optional[bool] = None, labels: typing.Optional[dict[str, str]] = None, no_data_state: typing.Optional[typing.Literal["Alerting", "NoData", "OK"]] = None, notification_settings: typing.Optional['NotificationSettings'] = None, org_id: int = 0, provenance: typing.Optional['Provenance'] = None, record: typing.Optional['RecordRule'] = None, rule_group: str = "", title: str = "", uid: typing.Optional[str] = None, updated: typing.Optional[str] = None): self.annotations = annotations self.condition = condition self.data = data if data is not None else [] @@ -382,6 +383,7 @@ class Rule: self.notification_settings = notification_settings self.org_id = org_id self.provenance = provenance + self.record = record self.rule_group = rule_group self.title = title self.uid = uid @@ -411,6 +413,8 @@ class Rule: payload["notification_settings"] = self.notification_settings if self.provenance is not None: payload["provenance"] = self.provenance + if self.record is not None: + payload["record"] = self.record if self.uid is not None: payload["uid"] = self.uid if self.updated is not None: @@ -447,6 +451,8 @@ class Rule: args["org_id"] = data["orgID"] if "provenance" in data: args["provenance"] = data["provenance"] + if "record" in data: + args["record"] = RecordRule.from_json(data["record"]) if "ruleGroup" in data: args["rule_group"] = data["ruleGroup"] if "title" in data: @@ -459,6 +465,33 @@ class Rule: return cls(**args) +class RecordRule: + from_val: str + metric: str + + def __init__(self, from_val: str = "", metric: str = ""): + self.from_val = from_val + self.metric = metric + + def to_json(self) -> dict[str, object]: + payload: dict[str, object] = { + "from": self.from_val, + "metric": self.metric, + } + return payload + + @classmethod + def from_json(cls, data: dict[str, typing.Any]) -> typing.Self: + args: dict[str, typing.Any] = {} + + if "from" in data: + args["from_val"] = data["from"] + if "metric" in data: + args["metric"] = data["metric"] + + return cls(**args) + + class RelativeTimeRange: """ RelativeTimeRange is the per query start and end time diff --git a/python/grafana_foundation_sdk/models/azuremonitor.py b/python/grafana_foundation_sdk/models/azuremonitor.py index 93942e6..caec76d 100644 --- a/python/grafana_foundation_sdk/models/azuremonitor.py +++ b/python/grafana_foundation_sdk/models/azuremonitor.py @@ -34,16 +34,16 @@ class AzureMonitorQuery(cogvariants.Dataquery): resource_group: typing.Optional[str] namespace: typing.Optional[str] resource: typing.Optional[str] + region: typing.Optional[str] # For mixed data sources the selected datasource is on the query level. # For non mixed scenarios this is undefined. # TODO find a better way to do this ^ that's friendly to schema # TODO this shouldn't be unknown but DataSourceRef | null datasource: typing.Optional[object] - # Azure Monitor query type. - # queryType: #AzureQueryType - region: typing.Optional[str] + # Used only for exemplar queries from Prometheus + query: typing.Optional[str] - def __init__(self, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, subscription: typing.Optional[str] = None, subscriptions: typing.Optional[list[str]] = None, azure_monitor: typing.Optional['AzureMetricQuery'] = None, azure_log_analytics: typing.Optional['AzureLogsQuery'] = None, azure_resource_graph: typing.Optional['AzureResourceGraphQuery'] = None, azure_traces: typing.Optional['AzureTracesQuery'] = None, grafana_template_variable_fn: typing.Optional['GrafanaTemplateVariableQuery'] = None, resource_group: typing.Optional[str] = None, namespace: typing.Optional[str] = None, resource: typing.Optional[str] = None, datasource: typing.Optional[object] = None, region: typing.Optional[str] = None): + def __init__(self, ref_id: str = "", hide: typing.Optional[bool] = None, query_type: typing.Optional[str] = None, subscription: typing.Optional[str] = None, subscriptions: typing.Optional[list[str]] = None, azure_monitor: typing.Optional['AzureMetricQuery'] = None, azure_log_analytics: typing.Optional['AzureLogsQuery'] = None, azure_resource_graph: typing.Optional['AzureResourceGraphQuery'] = None, azure_traces: typing.Optional['AzureTracesQuery'] = None, grafana_template_variable_fn: typing.Optional['GrafanaTemplateVariableQuery'] = None, resource_group: typing.Optional[str] = None, namespace: typing.Optional[str] = None, resource: typing.Optional[str] = None, region: typing.Optional[str] = None, datasource: typing.Optional[object] = None, query: typing.Optional[str] = None): self.ref_id = ref_id self.hide = hide self.query_type = query_type @@ -57,8 +57,9 @@ class AzureMonitorQuery(cogvariants.Dataquery): self.resource_group = resource_group self.namespace = namespace self.resource = resource - self.datasource = datasource self.region = region + self.datasource = datasource + self.query = query def to_json(self) -> dict[str, object]: payload: dict[str, object] = { @@ -88,10 +89,12 @@ class AzureMonitorQuery(cogvariants.Dataquery): payload["namespace"] = self.namespace if self.resource is not None: payload["resource"] = self.resource - ...*[Comment body truncated]*