diff --git a/datadog/resource_datadog_dashboard.go b/datadog/resource_datadog_dashboard.go index 5cea958ba1..d7d45ecd61 100644 --- a/datadog/resource_datadog_dashboard.go +++ b/datadog/resource_datadog_dashboard.go @@ -4491,6 +4491,58 @@ func getQueryTableRequestSchema() map[string]*schema.Schema { ValidateDiagFunc: validators.ValidateEnumValue(datadogV1.NewTableWidgetCellDisplayModeFromValue), }, }, + "text_formats": { + Description: "Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change.", + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "text_format": { + Description: "The text format to apply to the items in a table widget column.", + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "match": { + Type: schema.TypeList, + MaxItems: 1, + Required: true, + Description: "Match rule for the table widget text format.", + Elem: &schema.Resource{ + Schema: getTableWidgetTextFormatMatchSchema(), + }, + }, + "palette": { + Description: "The color palette to apply.", + Type: schema.TypeString, + ValidateDiagFunc: validators.ValidateEnumValue(datadogV1.NewTableWidgetTextFormatPaletteFromValue), + Optional: true, + }, + "replace": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Match rule for the table widget text format.", + Elem: &schema.Resource{ + Schema: getTableWidgetTextFormatReplaceSchema(), + }, + }, + "custom_bg_color": { + Description: "The custom color palette to apply to the background.", + Type: schema.TypeString, + Optional: true, + }, + "custom_fg_color": { + Description: "The custom color palette to apply to the foreground text.", + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, } } func buildDatadogQueryTableRequests(terraformRequests *[]interface{}) *[]datadogV1.TableWidgetRequest { @@ -4581,6 +4633,19 @@ func buildDatadogQueryTableRequests(terraformRequests *[]interface{}) *[]datadog } datadogQueryTableRequest.CellDisplayMode = datadogCellDisplayMode } + if v, ok := terraformRequest["text_formats"].([]interface{}); ok && len(v) != 0 { + datadogQueryTableRequest.TextFormats = make([][]datadogV1.TableWidgetTextFormatRule, len(v)) + for i, w := range v { + if c, ok := w.(map[string]interface{}); ok { + if textFormat, ok := c["text_format"].([]interface{}); ok && len(textFormat) > 0 { + datadogQueryTableRequest.TextFormats[i] = *buildDatadogQueryTableTextFormat(&textFormat) + } + } else { + datadogQueryTableRequest.TextFormats[i] = []datadogV1.TableWidgetTextFormatRule{} + } + } + } + datadogRequests[i] = *datadogQueryTableRequest } return &datadogRequests @@ -4641,11 +4706,134 @@ func buildTerraformQueryTableRequests(datadogQueryTableRequests *[]datadogV1.Tab } terraformRequest["cell_display_mode"] = terraformCellDisplayMode } + if v, ok := datadogRequest.GetTextFormatsOk(); ok { + terraformTextFormats := make([]map[string][]map[string]interface{}, len(*v)) + for i, textFormat := range *v { + test := buildTerraformQueryTableTextFormat(&textFormat) + terraformTextFormats[i] = make(map[string][]map[string]interface{}) + terraformTextFormats[i]["text_format"] = *test + } + terraformRequest["text_formats"] = terraformTextFormats + } terraformRequests[i] = terraformRequest } return &terraformRequests } +// Query Table Widget Text Format Helpers +func buildDatadogQueryTableTextFormat(terraformQueryTableTextFormat *[]interface{}) *[]datadogV1.TableWidgetTextFormatRule { + datadogQueryTableTextFormat := make([]datadogV1.TableWidgetTextFormatRule, len(*terraformQueryTableTextFormat)) + for j, textFormatRule := range *terraformQueryTableTextFormat { + terraformTextFormatRule := textFormatRule.(map[string]interface{}) + + match, _ := terraformTextFormatRule["match"].([]interface{}) + terraformTextFormatMatch := match[0].(map[string]interface{}) + datadogMatch := datadogV1.NewTableWidgetTextFormatMatch(datadogV1.TableWidgetTextFormatMatchType(terraformTextFormatMatch["type"].(string)), terraformTextFormatMatch["value"].(string)) + datadogTextFormatRule := datadogV1.NewTableWidgetTextFormatRule(*datadogMatch) + // Optional + + if v, ok := terraformTextFormatRule["replace"].([]interface{}); ok && len(v) > 0 { + if replace, ok := v[0].(map[string]interface{}); ok { + if w, ok := replace["type"].(string); ok && len(w) != 0 { + switch w { + case "all": + datadogReplace := datadogV1.NewTableWidgetTextFormatReplaceAll(datadogV1.TABLEWIDGETTEXTFORMATREPLACEALLTYPE_ALL, replace["with"].(string)) + datadogTextFormatRule.SetReplace(datadogV1.TableWidgetTextFormatReplaceAllAsTableWidgetTextFormatReplace(datadogReplace)) + case "substring": + datadogReplace := datadogV1.NewTableWidgetTextFormatReplaceSubstring(replace["substring"].(string), datadogV1.TABLEWIDGETTEXTFORMATREPLACESUBSTRINGTYPE_SUBSTRING, replace["with"].(string)) + datadogTextFormatRule.SetReplace(datadogV1.TableWidgetTextFormatReplaceSubstringAsTableWidgetTextFormatReplace(datadogReplace)) + } + } + } + } + if v, ok := terraformTextFormatRule["palette"].(string); ok && len(v) != 0 { + datadogTextFormatRule.SetPalette(datadogV1.TableWidgetTextFormatPalette(v)) + } else { + datadogTextFormatRule.Palette = nil + } + if v, ok := terraformTextFormatRule["custom_bg_color"].(string); ok && len(v) != 0 { + datadogTextFormatRule.SetCustomBgColor(v) + } + if v, ok := terraformTextFormatRule["custom_fg_color"].(string); ok && len(v) != 0 { + datadogTextFormatRule.SetCustomFgColor(v) + } + datadogQueryTableTextFormat[j] = *datadogTextFormatRule + } + return &datadogQueryTableTextFormat +} +func buildTerraformQueryTableTextFormat(datadogQueryTableTextFormat *[]datadogV1.TableWidgetTextFormatRule) *[]map[string]interface{} { + terraformQueryTableTextFormat := make([]map[string]interface{}, len(*datadogQueryTableTextFormat)) + for i, datadogQueryTableTextFormatRule := range *datadogQueryTableTextFormat { + terraformQueryTableTextFormatRule := map[string]interface{}{} + // Required params + match := make(map[string]interface{}) + match["type"] = datadogQueryTableTextFormatRule.GetMatch().Type + match["value"] = datadogQueryTableTextFormatRule.GetMatch().Value + terraformQueryTableTextFormatRule["match"] = []interface{}{match} + // Optional params + if v, ok := datadogQueryTableTextFormatRule.GetReplaceOk(); ok { + if v.TableWidgetTextFormatReplaceAll != nil { + replace := make(map[string]interface{}) + replace["type"] = v.TableWidgetTextFormatReplaceAll.Type + replace["with"] = v.TableWidgetTextFormatReplaceAll.With + terraformQueryTableTextFormatRule["replace"] = []interface{}{replace} + } + if v.TableWidgetTextFormatReplaceSubstring != nil { + replace := make(map[string]interface{}) + replace["type"] = v.TableWidgetTextFormatReplaceSubstring.Type + replace["with"] = v.TableWidgetTextFormatReplaceSubstring.With + replace["substring"] = v.TableWidgetTextFormatReplaceSubstring.Substring + terraformQueryTableTextFormatRule["replace"] = []interface{}{replace} + } + } + if v, ok := datadogQueryTableTextFormatRule.GetPaletteOk(); ok { + terraformQueryTableTextFormatRule["palette"] = v + } + if v, ok := datadogQueryTableTextFormatRule.GetCustomBgColorOk(); ok { + terraformQueryTableTextFormatRule["custom_bg_color"] = v + } + if v, ok := datadogQueryTableTextFormatRule.GetCustomFgColorOk(); ok { + terraformQueryTableTextFormatRule["custom_fg_color"] = v + } + terraformQueryTableTextFormat[i] = terraformQueryTableTextFormatRule + } + return &terraformQueryTableTextFormat +} +func getTableWidgetTextFormatMatchSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Description: "Match or compare option.", + Type: schema.TypeString, + ValidateDiagFunc: validators.ValidateEnumValue(datadogV1.NewTableWidgetTextFormatMatchTypeFromValue), + Required: true, + }, + "value": { + Description: "Table Widget Match String.", + Type: schema.TypeString, + Required: true, + }, + } +} +func getTableWidgetTextFormatReplaceSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Description: "Table widget text format replace all type.", + Type: schema.TypeString, + Required: true, + }, + "with": { + Description: "Table Widget Match String.", + Type: schema.TypeString, + Required: true, + }, + "substring": { + Description: "Text that will be replaced. Must be used with type `substring`.", + Type: schema.TypeString, + Optional: true, + }, + } +} + // // Scatterplot Widget Definition helpers // diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.freeze new file mode 100644 index 0000000000..1a9db8d56c --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.freeze @@ -0,0 +1 @@ +2024-10-03T10:24:53.730398-04:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.yaml new file mode 100644 index 0000000000..7fe1fe1da0 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats.yaml @@ -0,0 +1,215 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 949 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: | + {"description":"Created using the Datadog provider in Terraform","id":"","layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727965493","widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard + method: POST + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"9r6-ipc-jz3","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/9r6-ipc-jz3/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":3745615959553530}],"notify_list":[],"created_at":"2024-10-03T14:24:56.762159+00:00","modified_at":"2024-10-03T14:24:56.762159+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 263.838584ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/9r6-ipc-jz3 + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"9r6-ipc-jz3","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/9r6-ipc-jz3/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":3745615959553530}],"notify_list":[],"created_at":"2024-10-03T14:24:56.762159+00:00","modified_at":"2024-10-03T14:24:56.762159+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 98.213666ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/9r6-ipc-jz3 + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"9r6-ipc-jz3","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/9r6-ipc-jz3/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":3745615959553530}],"notify_list":[],"created_at":"2024-10-03T14:24:56.762159+00:00","modified_at":"2024-10-03T14:24:56.762159+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 81.12275ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/9r6-ipc-jz3 + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"9r6-ipc-jz3","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/9r6-ipc-jz3/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":3745615959553530}],"notify_list":[],"created_at":"2024-10-03T14:24:56.762159+00:00","modified_at":"2024-10-03T14:24:56.762159+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 85.740333ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/9r6-ipc-jz3 + method: DELETE + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"deleted_dashboard_id":"9r6-ipc-jz3"} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 144.309541ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/9r6-ipc-jz3 + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"errors":["Dashboard with ID 9r6-ipc-jz3 not found"]}' + headers: + Content-Type: + - application/json + status: 404 Not Found + code: 404 + duration: 70.260458ms diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.freeze b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.freeze new file mode 100644 index 0000000000..56a8081975 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.freeze @@ -0,0 +1 @@ +2024-10-03T10:24:53.730387-04:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.yaml b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.yaml new file mode 100644 index 0000000000..af6e817cf1 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogDashboardQueryTableWithTextFormats_import.yaml @@ -0,0 +1,215 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 956 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: | + {"description":"Created using the Datadog provider in Terraform","id":"","layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats_import-local-1727965493","widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard + method: POST + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"4h4-p9d-iej","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats_import-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/4h4-p9d-iej/tf-testaccdatadogdashboardquerytablewithtextformatsimport-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":1028124560894413}],"notify_list":[],"created_at":"2024-10-03T14:24:56.747277+00:00","modified_at":"2024-10-03T14:24:56.747277+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 241.355083ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/4h4-p9d-iej + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"4h4-p9d-iej","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats_import-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/4h4-p9d-iej/tf-testaccdatadogdashboardquerytablewithtextformatsimport-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":1028124560894413}],"notify_list":[],"created_at":"2024-10-03T14:24:56.747277+00:00","modified_at":"2024-10-03T14:24:56.747277+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 89.8825ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/4h4-p9d-iej + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"4h4-p9d-iej","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats_import-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/4h4-p9d-iej/tf-testaccdatadogdashboardquerytablewithtextformatsimport-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":1028124560894413}],"notify_list":[],"created_at":"2024-10-03T14:24:56.747277+00:00","modified_at":"2024-10-03T14:24:56.747277+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 96.1435ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/4h4-p9d-iej + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"id":"4h4-p9d-iej","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats_import-local-1727965493","description":"Created using the Datadog provider in Terraform","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/4h4-p9d-iej/tf-testaccdatadogdashboardquerytablewithtextformatsimport-local-1727965493","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":1028124560894413}],"notify_list":[],"created_at":"2024-10-03T14:24:56.747277+00:00","modified_at":"2024-10-03T14:24:56.747277+00:00","template_variable_presets":[],"tags":[]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 114.2895ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/4h4-p9d-iej + method: DELETE + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: | + {"deleted_dashboard_id":"4h4-p9d-iej"} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 149.892709ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.datadoghq.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v1/dashboard/4h4-p9d-iej + method: GET + response: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + transfer_encoding: + - chunked + trailer: {} + content_length: -1 + uncompressed: true + body: '{"errors":["Dashboard with ID 4h4-p9d-iej not found"]}' + headers: + Content-Type: + - application/json + status: 404 Not Found + code: 404 + duration: 73.733625ms diff --git a/datadog/tests/resource_datadog_dashboard_query_table_test.go b/datadog/tests/resource_datadog_dashboard_query_table_test.go index d19fdb3580..384ee39bd5 100644 --- a/datadog/tests/resource_datadog_dashboard_query_table_test.go +++ b/datadog/tests/resource_datadog_dashboard_query_table_test.go @@ -219,6 +219,69 @@ resource "datadog_dashboard" "query_table_dashboard" { } ` +const datadogDashboardQueryTableConfigWithTextFormats = ` +resource "datadog_dashboard" "query_table_dashboard" { + title = "{{uniq}}" + description = "Created using the Datadog provider in Terraform" + layout_type = "ordered" + + widget { + query_table_definition { + title_size = "16" + title = "this is hyung" + title_align = "right" + live_span = "1d" + request { + aggregator = "max" + q = "avg:system.cpu.user{account:prod} by {service, team}" + alias = "cpu user" + limit = 25 + order = "desc" + cell_display_mode = ["number"] + text_formats { + text_format { + match { + type = "is" + value = "test" + } + palette = "black_on_light_yellow" + replace { + type = "all" + with = "test" + } + } + text_format { + match { + type = "is" + value = "versus" + } + } + } + text_formats { + text_format { + match { + type = "is" + value = "apple" + } + palette = "custom_bg" + custom_bg_color = "#632CA6" + } + text_format { + match { + type = "is" + value = "orange" + } + palette = "custom_text" + custom_fg_color = "#632CA6" + } + } + } + has_search_bar = "auto" + } + } +} +` + var datadogDashboardQueryTableAsserts = []string{ "widget.0.query_table_definition.0.live_span = 1d", "widget.0.query_table_definition.0.request.1.order =", @@ -315,6 +378,42 @@ var datadogDashboardQueryTableFormulaAsserts = []string{ "widget.2.query_table_definition.0.request.0.query.0.apm_resource_stats_query.0.primary_tag_value = abc", } +var datadogDashboardQueryTableWithTextFormatsAsserts = []string{ + "title = {{uniq}}", + "description = Created using the Datadog provider in Terraform", + "layout_type = ordered", + "widget.0.query_table_definition.0.title_size = 16", + "widget.0.query_table_definition.0.title = this is hyung", + "widget.0.query_table_definition.0.title_align = right", + "widget.0.query_table_definition.0.live_span = 1d", + "widget.0.query_table_definition.0.request.0.aggregator = max", + "widget.0.query_table_definition.0.request.0.q = avg:system.cpu.user{account:prod} by {service, team}", + "widget.0.query_table_definition.0.request.0.alias = cpu user", + "widget.0.query_table_definition.0.request.0.limit = 25", + "widget.0.query_table_definition.0.request.0.order = desc", + "widget.0.query_table_definition.0.request.0.cell_display_mode.0 = number", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.match.0.type = is", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.match.0.value = test", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.palette = black_on_light_yellow", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.replace.0.type = all", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.replace.0.with = test", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.custom_bg_color = ", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.0.custom_fg_color = ", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.1.match.0.type = is", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.1.match.0.value = versus", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.1.palette = ", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.1.custom_bg_color = ", + "widget.0.query_table_definition.0.request.0.text_formats.0.text_format.1.custom_fg_color = ", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.0.match.0.type = is", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.0.match.0.value = apple", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.0.palette = custom_bg", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.0.custom_bg_color = #632CA6", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.1.match.0.type = is", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.1.match.0.value = orange", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.1.palette = custom_text", + "widget.0.query_table_definition.0.request.0.text_formats.1.text_format.1.custom_fg_color = #632CA6", +} + func TestAccDatadogDashboardQueryTable(t *testing.T) { testAccDatadogDashboardWidgetUtil(t, datadogDashboardQueryTableConfig, "datadog_dashboard.query_table_dashboard", datadogDashboardQueryTableAsserts) } @@ -330,3 +429,11 @@ func TestAccDatadogDashboardQueryTableFormula(t *testing.T) { func TestAccDatadogDashboardQueryTableFormula_import(t *testing.T) { testAccDatadogDashboardWidgetUtilImport(t, datadogDashboardQueryTableFormulaConfig, "datadog_dashboard.query_table_dashboard") } + +func TestAccDatadogDashboardQueryTableWithTextFormats(t *testing.T) { + testAccDatadogDashboardWidgetUtil(t, datadogDashboardQueryTableConfigWithTextFormats, "datadog_dashboard.query_table_dashboard", datadogDashboardQueryTableWithTextFormatsAsserts) +} + +func TestAccDatadogDashboardQueryTableWithTextFormats_import(t *testing.T) { + testAccDatadogDashboardWidgetUtilImport(t, datadogDashboardQueryTableConfigWithTextFormats, "datadog_dashboard.query_table_dashboard") +} diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md index f5dff4e999..f28023fa51 100644 --- a/docs/resources/dashboard.md +++ b/docs/resources/dashboard.md @@ -5182,6 +5182,7 @@ Optional: - `query` (Block List) (see [below for nested schema](#nestedblock--widget--group_definition--widget--query_table_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--query_table_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--query_table_definition--request--security_query)) +- `text_formats` (Block List) Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change. (see [below for nested schema](#nestedblock--widget--group_definition--widget--query_table_definition--request--text_formats)) ### Nested Schema for `widget.group_definition.widget.query_table_definition.request.apm_query` @@ -5745,6 +5746,51 @@ Optional: + +### Nested Schema for `widget.group_definition.widget.query_table_definition.request.text_formats` + +Optional: + +- `text_format` (Block List) The text format to apply to the items in a table widget column. (see [below for nested schema](#nestedblock--widget--group_definition--widget--query_table_definition--request--text_formats--text_format)) + + +### Nested Schema for `widget.group_definition.widget.query_table_definition.request.text_formats.text_format` + +Required: + +- `match` (Block List, Min: 1, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--group_definition--widget--query_table_definition--request--text_formats--text_format--match)) + +Optional: + +- `custom_bg_color` (String) The custom color palette to apply to the background. +- `custom_fg_color` (String) The custom color palette to apply to the foreground text. +- `palette` (String) The color palette to apply. Valid values are `white_on_red`, `white_on_yellow`, `white_on_green`, `black_on_light_red`, `black_on_light_yellow`, `black_on_light_green`, `red_on_white`, `yellow_on_white`, `green_on_white`, `custom_bg`, `custom_text`. +- `replace` (Block List, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--group_definition--widget--query_table_definition--request--text_formats--text_format--replace)) + + +### Nested Schema for `widget.group_definition.widget.query_table_definition.request.text_formats.text_format.match` + +Required: + +- `type` (String) Match or compare option. Valid values are `is`, `is_not`, `contains`, `does_not_contain`, `starts_with`, `ends_with`. +- `value` (String) Table Widget Match String. + + + +### Nested Schema for `widget.group_definition.widget.query_table_definition.request.text_formats.text_format.replace` + +Required: + +- `type` (String) Table widget text format replace all type. +- `with` (String) Table Widget Match String. + +Optional: + +- `substring` (String) Text that will be replaced. Must be used with type `substring`. + + + + @@ -8441,6 +8487,7 @@ Optional: - `query` (Block List) (see [below for nested schema](#nestedblock--widget--group_definition--widget--split_graph_definition--source_widget_definition--query_table_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--split_graph_definition--source_widget_definition--query_table_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--split_graph_definition--source_widget_definition--query_table_definition--request--security_query)) +- `text_formats` (Block List) Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change. (see [below for nested schema](#nestedblock--widget--group_definition--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats)) ### Nested Schema for `widget.group_definition.widget.split_graph_definition.source_widget_definition.query_table_definition.request.apm_query` @@ -9004,6 +9051,51 @@ Optional: + +### Nested Schema for `widget.group_definition.widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats` + +Optional: + +- `text_format` (Block List) The text format to apply to the items in a table widget column. (see [below for nested schema](#nestedblock--widget--group_definition--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format)) + + +### Nested Schema for `widget.group_definition.widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format` + +Required: + +- `match` (Block List, Min: 1, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--group_definition--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format--match)) + +Optional: + +- `custom_bg_color` (String) The custom color palette to apply to the background. +- `custom_fg_color` (String) The custom color palette to apply to the foreground text. +- `palette` (String) The color palette to apply. Valid values are `white_on_red`, `white_on_yellow`, `white_on_green`, `black_on_light_red`, `black_on_light_yellow`, `black_on_light_green`, `red_on_white`, `yellow_on_white`, `green_on_white`, `custom_bg`, `custom_text`. +- `replace` (Block List, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--group_definition--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format--replace)) + + +### Nested Schema for `widget.group_definition.widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format.match` + +Required: + +- `type` (String) Match or compare option. Valid values are `is`, `is_not`, `contains`, `does_not_contain`, `starts_with`, `ends_with`. +- `value` (String) Table Widget Match String. + + + +### Nested Schema for `widget.group_definition.widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format.replace` + +Required: + +- `type` (String) Table widget text format replace all type. +- `with` (String) Table Widget Match String. + +Optional: + +- `substring` (String) Text that will be replaced. Must be used with type `substring`. + + + + @@ -16912,6 +17004,7 @@ Optional: - `query` (Block List) (see [below for nested schema](#nestedblock--widget--query_table_definition--request--query)) - `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--rum_query)) - `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--security_query)) +- `text_formats` (Block List) Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats)) ### Nested Schema for `widget.query_table_definition.request.apm_query` @@ -17475,6 +17568,51 @@ Optional: + +### Nested Schema for `widget.query_table_definition.request.text_formats` + +Optional: + +- `text_format` (Block List) The text format to apply to the items in a table widget column. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format)) + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format` + +Required: + +- `match` (Block List, Min: 1, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format--match)) + +Optional: + +- `custom_bg_color` (String) The custom color palette to apply to the background. +- `custom_fg_color` (String) The custom color palette to apply to the foreground text. +- `palette` (String) The color palette to apply. Valid values are `white_on_red`, `white_on_yellow`, `white_on_green`, `black_on_light_red`, `black_on_light_yellow`, `black_on_light_green`, `red_on_white`, `yellow_on_white`, `green_on_white`, `custom_bg`, `custom_text`. +- `replace` (Block List, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format--replace)) + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format.match` + +Required: + +- `type` (String) Match or compare option. Valid values are `is`, `is_not`, `contains`, `does_not_contain`, `starts_with`, `ends_with`. +- `value` (String) Table Widget Match String. + + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format.replace` + +Required: + +- `type` (String) Table widget text format replace all type. +- `with` (String) Table Widget Match String. + +Optional: + +- `substring` (String) Text that will be replaced. Must be used with type `substring`. + + + + @@ -20171,6 +20309,7 @@ Optional: - `query` (Block List) (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--query)) - `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--rum_query)) - `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--security_query)) +- `text_formats` (Block List) Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats)) ### Nested Schema for `widget.split_graph_definition.source_widget_definition.query_table_definition.request.apm_query` @@ -20734,6 +20873,51 @@ Optional: + +### Nested Schema for `widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats` + +Optional: + +- `text_format` (Block List) The text format to apply to the items in a table widget column. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format)) + + +### Nested Schema for `widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format` + +Required: + +- `match` (Block List, Min: 1, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format--match)) + +Optional: + +- `custom_bg_color` (String) The custom color palette to apply to the background. +- `custom_fg_color` (String) The custom color palette to apply to the foreground text. +- `palette` (String) The color palette to apply. Valid values are `white_on_red`, `white_on_yellow`, `white_on_green`, `black_on_light_red`, `black_on_light_yellow`, `black_on_light_green`, `red_on_white`, `yellow_on_white`, `green_on_white`, `custom_bg`, `custom_text`. +- `replace` (Block List, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--query_table_definition--request--text_formats--text_format--replace)) + + +### Nested Schema for `widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format.match` + +Required: + +- `type` (String) Match or compare option. Valid values are `is`, `is_not`, `contains`, `does_not_contain`, `starts_with`, `ends_with`. +- `value` (String) Table Widget Match String. + + + +### Nested Schema for `widget.split_graph_definition.source_widget_definition.query_table_definition.request.text_formats.text_format.replace` + +Required: + +- `type` (String) Table widget text format replace all type. +- `with` (String) Table Widget Match String. + +Optional: + +- `substring` (String) Text that will be replaced. Must be used with type `substring`. + + + + diff --git a/docs/resources/powerpack.md b/docs/resources/powerpack.md index 8b27cda084..c3ba4b18ff 100644 --- a/docs/resources/powerpack.md +++ b/docs/resources/powerpack.md @@ -2944,6 +2944,7 @@ Optional: - `query` (Block List) (see [below for nested schema](#nestedblock--widget--query_table_definition--request--query)) - `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--rum_query)) - `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--security_query)) +- `text_formats` (Block List) Text formats define how to format text in table widget content. Multiple `text_formats` blocks are allowed using the structure below. This resource is in beta and is subject to change. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats)) ### Nested Schema for `widget.query_table_definition.request.apm_query` @@ -3507,6 +3508,51 @@ Optional: + +### Nested Schema for `widget.query_table_definition.request.text_formats` + +Optional: + +- `text_format` (Block List) The text format to apply to the items in a table widget column. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format)) + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format` + +Required: + +- `match` (Block List, Min: 1, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format--match)) + +Optional: + +- `custom_bg_color` (String) The custom color palette to apply to the background. +- `custom_fg_color` (String) The custom color palette to apply to the foreground text. +- `palette` (String) The color palette to apply. Valid values are `white_on_red`, `white_on_yellow`, `white_on_green`, `black_on_light_red`, `black_on_light_yellow`, `black_on_light_green`, `red_on_white`, `yellow_on_white`, `green_on_white`, `custom_bg`, `custom_text`. +- `replace` (Block List, Max: 1) Match rule for the table widget text format. (see [below for nested schema](#nestedblock--widget--query_table_definition--request--text_formats--text_format--replace)) + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format.match` + +Required: + +- `type` (String) Match or compare option. Valid values are `is`, `is_not`, `contains`, `does_not_contain`, `starts_with`, `ends_with`. +- `value` (String) Table Widget Match String. + + + +### Nested Schema for `widget.query_table_definition.request.text_formats.text_format.replace` + +Required: + +- `type` (String) Table widget text format replace all type. +- `with` (String) Table Widget Match String. + +Optional: + +- `substring` (String) Text that will be replaced. Must be used with type `substring`. + + + + diff --git a/go.sum b/go.sum index a389dcd668..c7f67f0706 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ 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.30.1-0.20240911195025-92128b15dc8c h1:+yokfxyjea3W7KpyCTeTIKqPFNeGEAubmI0RCO7sBdE= -github.com/DataDog/datadog-api-client-go/v2 v2.30.1-0.20240911195025-92128b15dc8c/go.mod h1:QKOu6vscsh87fMY1lHfLEmNSunyXImj8BUaUWJXOehc= github.com/DataDog/datadog-api-client-go/v2 v2.31.0 h1:JfJhYlHfLzvauI8u6h23smTooWYe6quNhhg9gpTszWY= github.com/DataDog/datadog-api-client-go/v2 v2.31.0/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=