From 5b7f0093031f24521fb2a299988a9b91f5b60ffd Mon Sep 17 00:00:00 2001 From: rachel-molnar-swi <112575351+rachel-molnar-swi@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:20:31 -0800 Subject: [PATCH] SP-9630 add runbookLink to alerts (#120) * add runbookLink * runbookLink -> runbook_link * update documentation --- docs/resources/alert.md | 1 + docs/resources/uri.md | 2 +- docs/resources/website.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- internal/provider/alert_resource.go | 1 + internal/provider/alert_resource_test.go | 2 ++ internal/provider/alert_schema.go | 5 +++++ 8 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/resources/alert.md b/docs/resources/alert.md index 5e867fc..bf4d4f3 100644 --- a/docs/resources/alert.md +++ b/docs/resources/alert.md @@ -62,6 +62,7 @@ resource "swo_alert" "https_response_time" { - `description` (String) Alert description. - `enabled` (Boolean) True if the Alert should be evaluated. Default is `true`. +- `runbook_link` (String) A runbook is documentation of what steps to follow when something goes wrong. - `trigger_reset_actions` (Boolean) True if a notification should be sent when an active alert returns to normal. Default is false. Default is `false`. ### Read-Only diff --git a/docs/resources/uri.md b/docs/resources/uri.md index 3994a8c..a69470a 100644 --- a/docs/resources/uri.md +++ b/docs/resources/uri.md @@ -96,11 +96,11 @@ Required: - `location_options` (Attributes Set) The Website availability monitoring location options. (see [below for nested schema](#nestedatt--test_definitions--location_options)) - `test_from_location` (String) The location type to test from. Valid values are [`REGION`|`COUNTRY`|`CITY`]. +- `test_interval_in_seconds` (Number) The interval to test in seconds. Optional: - `platform_options` (Attributes) The platform options for this Uri check. (see [below for nested schema](#nestedatt--test_definitions--platform_options)) -- `test_interval_in_seconds` (Number) The interval to test in seconds. Default is `900`. Valid values are `60, 300, 600, 900, 1800, 3600, 7200, 14400` diff --git a/docs/resources/website.md b/docs/resources/website.md index 038a309..c7d9d09 100644 --- a/docs/resources/website.md +++ b/docs/resources/website.md @@ -117,7 +117,7 @@ Required: - `platform_options` (Attributes) The Website availability monitoring platform options. (see [below for nested schema](#nestedatt--monitoring--availability--platform_options)) - `protocols` (List of String) The Website availability monitoring protocols. - `test_from_location` (String) The Website availability monitoring test from location. Valid values are [`REGION`|`COUNTRY`|`CITY`]. -- `test_interval_in_seconds` (Number) The Website availability monitoring test interval in seconds. Valid values are `60, 300, 600, 900, 1800, 3600, 7200, 14400` +- `test_interval_in_seconds` (Number) The Website availability monitoring test interval in seconds. Valid values are 60, 300, 600, 900, 1800, 3600, 7200, 14400 Optional: diff --git a/go.mod b/go.mod index 7e35ffb..ccfa57f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/terraform-plugin-framework-validators v0.16.0 github.com/hashicorp/terraform-plugin-go v0.25.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 - github.com/solarwinds/swo-client-go v0.0.11 + github.com/solarwinds/swo-client-go v0.0.12 golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 ) diff --git a/go.sum b/go.sum index d437bd3..4800277 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/solarwinds/swo-client-go v0.0.11 h1:0vmqJ3HY2H55rRLKdwE6nsEMbbAVhyy7lEAXyh2a4F4= -github.com/solarwinds/swo-client-go v0.0.11/go.mod h1:qwmAfdCcUbpX1euHV2DziKwgGVnGw8obvOb8/JCStqM= +github.com/solarwinds/swo-client-go v0.0.12 h1:WuNQqemtAJ66lf5pm0hV+JHsl5K3wsJ39kQHZhzfn0Q= +github.com/solarwinds/swo-client-go v0.0.12/go.mod h1:qwmAfdCcUbpX1euHV2DziKwgGVnGw8obvOb8/JCStqM= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= diff --git a/internal/provider/alert_resource.go b/internal/provider/alert_resource.go index 74a7f3f..d3a9e05 100644 --- a/internal/provider/alert_resource.go +++ b/internal/provider/alert_resource.go @@ -145,6 +145,7 @@ func (model *alertResourceModel) toAlertDefinitionInput() swoClient.AlertDefinit Actions: model.toAlertActionInput(), TriggerResetActions: model.TriggerResetActions.ValueBoolPointer(), Condition: conditions, + RunbookLink: model.RunbookLink.ValueStringPointer(), } } diff --git a/internal/provider/alert_resource_test.go b/internal/provider/alert_resource_test.go index bfb95da..9796689 100644 --- a/internal/provider/alert_resource_test.go +++ b/internal/provider/alert_resource_test.go @@ -39,6 +39,7 @@ func TestAccAlertResource(t *testing.T) { resource.TestCheckResourceAttr("swo_alert.test", "conditions.0.exclude_tags.0.values.0", "test-service"), resource.TestCheckResourceAttr("swo_alert.test", "notifications.0", "123"), resource.TestCheckResourceAttr("swo_alert.test", "notifications.1", "456"), + resource.TestCheckResourceAttr("swo_alert.test", "runbook_link", "https://www.runbooklink.com"), ), }, // ImportState testing @@ -96,6 +97,7 @@ resource "swo_alert" "test" { }, ] notifications = ["123", "456"] + runbook_link = "https://www.runbooklink.com" } `, name) } diff --git a/internal/provider/alert_schema.go b/internal/provider/alert_schema.go index c594509..578a77c 100644 --- a/internal/provider/alert_schema.go +++ b/internal/provider/alert_schema.go @@ -22,6 +22,7 @@ type alertResourceModel struct { Conditions []alertConditionModel `tfsdk:"conditions"` Notifications []string `tfsdk:"notifications"` TriggerResetActions types.Bool `tfsdk:"trigger_reset_actions"` + RunbookLink types.String `tfsdk:"runbook_link"` } type alertConditionModel struct { @@ -159,6 +160,10 @@ func (r *alertResource) Schema(ctx context.Context, req resource.SchemaRequest, Required: true, ElementType: types.StringType, }, + "runbook_link": schema.StringAttribute{ + Description: "A runbook is documentation of what steps to follow when something goes wrong.", + Optional: true, + }, }, } }