Skip to content

Commit

Permalink
Add dashboard_filters_enabled attribute to `databricks_sql_dashboar…
Browse files Browse the repository at this point in the history
…d` resource (databricks#2725)

When `dashboard_filters_enabled` is set to `true` then filters are shown on the SQL
Dashboard level. In this case, the `databricks_sql_widget` should have following block to use it:

```
  parameter {
    type   = "dashboard-level"
    name   = "Limit"
    map_to = "Limit"
  }
```

This fixes databricks#2172
  • Loading branch information
alexott committed Oct 4, 2023
1 parent b00148b commit 364512f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 8 additions & 7 deletions sql/api/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import "encoding/json"

// Dashboard ...
type Dashboard struct {
ID string `json:"id"`
Name string `json:"name"`
Tags []string `json:"tags,omitempty"`
Widgets []json.RawMessage `json:"widgets,omitempty"`
Parent string `json:"parent,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Tags []string `json:"tags,omitempty"`
Widgets []json.RawMessage `json:"widgets,omitempty"`
Parent string `json:"parent,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
DashboardFiltersEnabled bool `json:"dashboard_filters_enabled,omitempty"`
}
13 changes: 8 additions & 5 deletions sql/resource_sql_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (

// DashboardEntity defines the parameters that can be set in the resource.
type DashboardEntity struct {
Name string `json:"name"`
Tags []string `json:"tags,omitempty"`
Parent string `json:"parent,omitempty" tf:"suppress_diff,force_new"`
CreatedAt string `json:"created_at,omitempty" tf:"computed"`
UpdatedAt string `json:"updated_at,omitempty" tf:"computed"`
Name string `json:"name"`
Tags []string `json:"tags,omitempty"`
Parent string `json:"parent,omitempty" tf:"suppress_diff,force_new"`
CreatedAt string `json:"created_at,omitempty" tf:"computed"`
UpdatedAt string `json:"updated_at,omitempty" tf:"computed"`
DashboardFiltersEnabled bool `json:"dashboard_filters_enabled,omitempty"`
}

func (d *DashboardEntity) toAPIObject(schema map[string]*schema.Schema, data *schema.ResourceData) (*api.Dashboard, error) {
Expand All @@ -28,6 +29,7 @@ func (d *DashboardEntity) toAPIObject(schema map[string]*schema.Schema, data *sc
ad.Name = d.Name
ad.Tags = append([]string{}, d.Tags...)
ad.Parent = d.Parent
ad.DashboardFiltersEnabled = d.DashboardFiltersEnabled

return &ad, nil
}
Expand All @@ -39,6 +41,7 @@ func (d *DashboardEntity) fromAPIObject(ad *api.Dashboard, schema map[string]*sc
d.Parent = ad.Parent
d.UpdatedAt = ad.UpdatedAt
d.CreatedAt = ad.CreatedAt
d.DashboardFiltersEnabled = ad.DashboardFiltersEnabled

// Pass to ResourceData.
if err := common.StructToData(*d, schema, data); err != nil {
Expand Down

0 comments on commit 364512f

Please sign in to comment.