Skip to content

Commit

Permalink
[datadog_synthetics_test] Add support for force_delete_dependencies
Browse files Browse the repository at this point in the history
… field (#2474)

* bump go client

* Document force delete dep field

* fix docs
  • Loading branch information
skarimo authored Jul 3, 2024
1 parent 8e82a25 commit 1b04587
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
9 changes: 9 additions & 0 deletions datadog/resource_datadog_synthetics_test_.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func resourceDatadogSyntheticsTest() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"force_delete_dependencies": {
Description: "A boolean indicating whether this synthetics test can be deleted even if it's referenced by other resources (for example, SLOs and composite monitors).",
Type: schema.TypeBool,
Optional: true,
},
}
},
}
Expand Down Expand Up @@ -1481,6 +1486,10 @@ func resourceDatadogSyntheticsTestDelete(ctx context.Context, d *schema.Resource
auth := providerConf.Auth

syntheticsDeleteTestsPayload := datadogV1.SyntheticsDeleteTestsPayload{PublicIds: []string{d.Id()}}
if d.Get("force_delete_dependencies").(bool) {
syntheticsDeleteTestsPayload.SetForceDeleteDependencies(true)
}

if _, httpResponse, err := apiInstances.GetSyntheticsApiV1().DeleteTests(auth, syntheticsDeleteTestsPayload); err != nil {
// The resource is assumed to still exist, and all prior state is preserved.
return utils.TranslateClientErrorDiag(err, httpResponse, "error deleting synthetics test")
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Email notifications can be sent to specific users by using the same `@username`
- `query` (String) The monitor query to notify on. Note this is not the same query you see in the UI and the syntax is different depending on the monitor type, please see the [API Reference](https://docs.datadoghq.com/api/v1/monitors/#create-a-monitor) for details. `terraform plan` will validate query contents unless `validate` is set to `false`.

**Note:** APM latency data is now available as Distribution Metrics. Existing monitors have been migrated automatically but all terraformed monitors can still use the existing metrics. We strongly recommend updating monitor definitions to query the new metrics. To learn more, or to see examples of how to update your terraform definitions to utilize the new distribution metrics, see the [detailed doc](https://docs.datadoghq.com/tracing/guide/ddsketch_trace_metrics/).
- `type` (String) The type of the monitor. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API [documentation page](https://docs.datadoghq.com/api/v1/monitors/#create-a-monitor). Note: The monitor type cannot be changed after a monitor is created. Valid values are `composite`, `event alert`, `log alert`, `metric alert`, `process alert`, `query alert`, `rum alert`, `service check`, `synthetics alert`, `trace-analytics alert`, `slo alert`, `event-v2 alert`, `audit alert`, `ci-pipelines alert`, `ci-tests alert`, `error-tracking alert`, `database-monitoring alert`.
- `type` (String) The type of the monitor. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API [documentation page](https://docs.datadoghq.com/api/v1/monitors/#create-a-monitor). Note: The monitor type cannot be changed after a monitor is created. Valid values are `composite`, `event alert`, `log alert`, `metric alert`, `process alert`, `query alert`, `rum alert`, `service check`, `synthetics alert`, `trace-analytics alert`, `slo alert`, `event-v2 alert`, `audit alert`, `ci-pipelines alert`, `ci-tests alert`, `error-tracking alert`, `database-monitoring alert`, `network-performance alert`.

### Optional

Expand Down Expand Up @@ -164,7 +164,7 @@ Optional:
Required:

- `compute` (Block List, Min: 1) The compute options. (see [below for nested schema](#nestedblock--variables--event_query--compute))
- `data_source` (String) The data source for event platform-based queries. Valid values are `rum`, `ci_pipelines`, `ci_tests`, `audit`, `events`, `logs`, `spans`, `database_queries`.
- `data_source` (String) The data source for event platform-based queries. Valid values are `rum`, `ci_pipelines`, `ci_tests`, `audit`, `events`, `logs`, `spans`, `database_queries`, `network_performance_queries`.
- `name` (String) The name of query for use in formulas.
- `search` (Block List, Min: 1, Max: 1) The search options. (see [below for nested schema](#nestedblock--variables--event_query--search))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/synthetics_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ resource "datadog_synthetics_test" "grpc" {
- `browser_variable` (Block List) Variables used for a browser test steps. Multiple `variable` blocks are allowed with the structure below. (see [below for nested schema](#nestedblock--browser_variable))
- `config_variable` (Block List) Variables used for the test configuration. Multiple `config_variable` blocks are allowed with the structure below. (see [below for nested schema](#nestedblock--config_variable))
- `device_ids` (List of String) Required if `type = "browser"`. Array with the different device IDs used to run the test. Valid values are `laptop_large`, `tablet`, `mobile_small`, `chrome.laptop_large`, `chrome.tablet`, `chrome.mobile_small`, `firefox.laptop_large`, `firefox.tablet`, `firefox.mobile_small`, `edge.laptop_large`, `edge.tablet`, `edge.mobile_small`.
- `force_delete_dependencies` (Boolean) A boolean indicating whether this synthetics test can be deleted even if it's referenced by other resources (for example, SLOs and composite monitors).
- `message` (String) A message to include with notifications for this synthetics test. Email notifications can be sent to specific users by using the same `@username` notation as events. Defaults to `""`.
- `options_list` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options_list))
- `request_basicauth` (Block List, Max: 1) The HTTP basic authentication credentials. Exactly one nested block is allowed with the structure below. (see [below for nested schema](#nestedblock--request_basicauth))
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.27.1-0.20240701174731-9480122efd1b
github.com/DataDog/datadog-api-client-go/v2 v2.27.1-0.20240702193001-5be31030f81f
github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.5.0
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.27.1-0.20240701174731-9480122efd1b h1:ssoDSdT9nLHw3qrEsIRaiaZU0i8G3KjoSeN5PZEFiHQ=
github.com/DataDog/datadog-api-client-go/v2 v2.27.1-0.20240701174731-9480122efd1b/go.mod h1:QKOu6vscsh87fMY1lHfLEmNSunyXImj8BUaUWJXOehc=
github.com/DataDog/datadog-api-client-go/v2 v2.27.1-0.20240702193001-5be31030f81f h1:AumHuk9MFo0HOVV9H/zsk96WB1nGg4NyavFSlzR/nlE=
github.com/DataDog/datadog-api-client-go/v2 v2.27.1-0.20240702193001-5be31030f81f/go.mod h1:QKOu6vscsh87fMY1lHfLEmNSunyXImj8BUaUWJXOehc=
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 1b04587

Please sign in to comment.