Skip to content

Commit

Permalink
[datadog_dashboard] Add support for sunburst widget request style (#2089
Browse files Browse the repository at this point in the history
)

* Add 'style' to sunburst requests

* Add style to test coverage

* Drop RBAC properties from sunburst tests

* Bump Go client to pull in new style property

* 'make fmt'

* Fix assert

* Update cassettes

* 'make docs'
  • Loading branch information
matt-miller-ddog authored Sep 1, 2023
1 parent e93932e commit 95e7746
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 33 deletions.
19 changes: 19 additions & 0 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5926,6 +5926,16 @@ func getSunburstRequestSchema() map[string]*schema.Schema {
// "query" and "formula" go together
"query": getFormulaQuerySchema(),
"formula": getFormulaSchema(),
// Settings specific to Sunburst requests
"style": {
Description: "Define style for the widget's request.",
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: &schema.Resource{
Schema: getWidgetRequestStyle(),
},
},
}
}

Expand Down Expand Up @@ -6070,6 +6080,11 @@ func buildDatadogSunburstRequests(terraformRequests *[]interface{}) *[]datadogV1
}
datadogSunburstRequest.SetFormulas(formulas)
}
if style, ok := terraformRequest["style"].([]interface{}); ok && len(style) > 0 {
if v, ok := style[0].(map[string]interface{}); ok && len(v) > 0 {
datadogSunburstRequest.Style = buildDatadogWidgetStyle(v)
}
}
datadogRequests[i] = *datadogSunburstRequest
}
return &datadogRequests
Expand Down Expand Up @@ -6109,6 +6124,10 @@ func buildTerraformSunburstRequests(datadogSunburstRequests *[]datadogV1.Sunburs
if v, ok := datadogRequest.GetFormulasOk(); ok {
terraformRequest["formula"] = buildTerraformFormula(v)
}
if v, ok := datadogRequest.GetStyleOk(); ok {
style := buildTerraformWidgetStyle(*v)
terraformRequest["style"] = []map[string]interface{}{style}
}
terraformRequests[i] = terraformRequest
}
return &terraformRequests
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:39.486019-04:00
2023-08-31T13:02:55.221453-04:00
24 changes: 12 additions & 12 deletions datadog/tests/cassettes/TestAccDatadogDashboardSunburst.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:39.144014-04:00
2023-08-31T13:02:55.221405-04:00
24 changes: 12 additions & 12 deletions datadog/tests/cassettes/TestAccDatadogDashboardSunburst_import.yaml

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions datadog/tests/resource_datadog_dashboard_sunburst_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ resource "datadog_dashboard" "sunburst_dashboard" {
title = "{{uniq}}"
description = "Created using the Datadog provider in Terraform"
layout_type = "ordered"
is_read_only = true
widget {
sunburst_definition {
request {
Expand All @@ -25,6 +24,9 @@ resource "datadog_dashboard" "sunburst_dashboard" {
aggregator = "sum"
}
}
style {
palette = "dog_classic"
}
}
hide_total = false
legend_inline {
Expand Down Expand Up @@ -97,13 +99,13 @@ var datadogDashboardSunburstAsserts = []string{
"description = Created using the Datadog provider in Terraform",
"layout_type = ordered",
"title = {{uniq}}",
"is_read_only = true",
"widget.0.sunburst_definition.0.request.0.formula.0.formula_expression = my_query_1 + my_query_2",
"widget.0.sunburst_definition.0.request.0.formula.0.alias = my ff query",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.data_source = metrics",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.query = avg:system.cpu.user{foo:bar} by {env}",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.name = my_query_1",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.aggregator = sum",
"widget.0.sunburst_definition.0.request.0.style.0.palette = dog_classic",
"widget.0.sunburst_definition.0.hide_total = false",
"widget.0.sunburst_definition.0.legend_inline.0.type = automatic",
"widget.0.sunburst_definition.0.legend_inline.0.hide_value = true",
Expand Down
22 changes: 20 additions & 2 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4625,7 +4625,7 @@ Required:

Required:

- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.
- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `trace_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.

Optional:

Expand Down Expand Up @@ -6954,6 +6954,7 @@ Optional:
- `query` (Block List) (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--query))
- `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--rum_query))
- `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--security_query))
- `style` (Block List, Max: 1) Define style for the widget's request. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--style))

<a id="nestedblock--widget--group_definition--widget--sunburst_definition--request--apm_query"></a>
### Nested Schema for `widget.group_definition.widget.sunburst_definition.request.apm_query`
Expand Down Expand Up @@ -7573,6 +7574,14 @@ Optional:



<a id="nestedblock--widget--group_definition--widget--sunburst_definition--request--style"></a>
### Nested Schema for `widget.group_definition.widget.sunburst_definition.request.style`

Optional:

- `palette` (String) A color palette to apply to the widget. The available options are available at: https://docs.datadoghq.com/dashboards/widgets/timeseries/#appearance.




<a id="nestedblock--widget--group_definition--widget--timeseries_definition"></a>
Expand Down Expand Up @@ -10283,7 +10292,7 @@ Required:

Required:

- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.
- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `trace_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.

Optional:

Expand Down Expand Up @@ -12612,6 +12621,7 @@ Optional:
- `query` (Block List) (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--query))
- `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--rum_query))
- `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--security_query))
- `style` (Block List, Max: 1) Define style for the widget's request. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--style))

<a id="nestedblock--widget--sunburst_definition--request--apm_query"></a>
### Nested Schema for `widget.sunburst_definition.request.apm_query`
Expand Down Expand Up @@ -13231,6 +13241,14 @@ Optional:



<a id="nestedblock--widget--sunburst_definition--request--style"></a>
### Nested Schema for `widget.sunburst_definition.request.style`

Optional:

- `palette` (String) A color palette to apply to the widget. The available options are available at: https://docs.datadoghq.com/dashboards/widgets/timeseries/#appearance.




<a id="nestedblock--widget--timeseries_definition"></a>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/terraform-providers/terraform-provider-datadog

require (
github.com/DataDog/datadog-api-client-go/v2 v2.16.0
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920
github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad
github.com/dnaeon/go-vcr v1.0.1
github.com/hashicorp/go-cleanhttp v0.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-api-client-go/v2 v2.16.0 h1:wwroXLmBlO5/o+uS1UxDpuMIkhIL6gJAu6m0ttGM5Yc=
github.com/DataDog/datadog-api-client-go/v2 v2.16.0/go.mod h1:uJd7G1BONVIyiVw684VMn2XYI1FfN1tx4bRGenAf2bo=
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920 h1:coE+poJvFIhpoUd044OQ1I/mHZntpVBvzcVWaXmpshk=
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920/go.mod h1:uJd7G1BONVIyiVw684VMn2XYI1FfN1tx4bRGenAf2bo=
github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down

0 comments on commit 95e7746

Please sign in to comment.