From f8755dbf32e91c10a36f82fef2164ac89634c610 Mon Sep 17 00:00:00 2001 From: Spencer Witt Date: Fri, 26 Jul 2024 08:15:49 -0500 Subject: [PATCH 1/2] add webhook event log retention policy to provider --- docs/resources/system_configuration.md | 6 ++- fusionauth/resource_system_configuration.go | 54 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/docs/resources/system_configuration.md b/docs/resources/system_configuration.md index cdd0ecf..aaaf350 100644 --- a/docs/resources/system_configuration.md +++ b/docs/resources/system_configuration.md @@ -44,4 +44,8 @@ resource "fusionauth_system_configuration" "example" { * `ui_configuration` - (Optional) - `header_color` - (Optional) A hexadecimal color to override the default menu color in the user interface. - `logo_url` - (Optional) A URL of a logo to override the default FusionAuth logo in the user interface. - - `menu_font_color` - (Optional) A hexadecimal color to override the default menu font color in the user interface. \ No newline at end of file + - `menu_font_color` - (Optional) A hexadecimal color to override the default menu font color in the user interface. +* `webhook_event_log_configuration` - (Optional) + - `delete` - (Optional) + * `enabled` - (Optional) Whether or not FusionAuth should delete the webhook event logs based upon this configuration. When true the webhookEventLogConfiguration.delete.numberOfDaysToRetain will be used to identify webhook event logs that are eligible for deletion. When this value is set to false webhook event logs will be preserved forever. + * `number_of_days_to_retain` - (Optional) The number of days to retain webhook event logs. diff --git a/fusionauth/resource_system_configuration.go b/fusionauth/resource_system_configuration.go index d970082..cd02417 100644 --- a/fusionauth/resource_system_configuration.go +++ b/fusionauth/resource_system_configuration.go @@ -187,6 +187,39 @@ func resourceSystemConfiguration() *schema.Resource { }, }, }, + "webhook_event_log_configuration": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Computed: true, + ConfigMode: schema.SchemaConfigModeAttr, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "delete": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConfigMode: schema.SchemaConfigModeAttr, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether or not FusionAuth should delete the webhook event logs based upon this configuration. When true the webhookEventLogConfiguration.delete.numberOfDaysToRetain will be used to identify webhook event logs that are eligible for deletion. When this value is set to false webhook event logs will be preserved forever.", + }, + "number_of_days_to_retain": { + Type: schema.TypeInt, + Optional: true, + Default: 365, + Description: "The number of days to retain webhook event logs.", + }, + }, + }, + }, + }, + }, + }, }, } } @@ -304,6 +337,13 @@ func buildSystemConfigurationRequest(data *schema.ResourceData) fusionauth.Syste sc.SystemConfiguration.UiConfiguration.MenuFontColor = v.(string) } + if v, ok := data.GetOk("webhook_event_log_configuration.0.delete.0.enabled"); ok { + sc.SystemConfiguration.WebhookEventLogConfiguration.Delete.Enabled = v.(bool) + } + if v, ok := data.GetOk("webhook_event_log_configuration.0.delete.0.number_of_days_to_retain"); ok { + sc.SystemConfiguration.WebhookEventLogConfiguration.Delete.NumberOfDaysToRetain = v.(int) + } + return sc } @@ -375,6 +415,20 @@ func buildResourceFromSystemConfiguration(sc fusionauth.SystemConfiguration, dat return diag.Errorf("system_configuration.ui_configuration: %s", err.Error()) } + err = data.Set("webhook_event_log_configuration", []map[string]interface{}{ + { + "delete": []map[string]interface{}{ + { + "enabled": sc.WebhookEventLogConfiguration.Delete.Enabled, + "number_of_days_to_retain": sc.WebhookEventLogConfiguration.Delete.NumberOfDaysToRetain, + }, + }, + }, + }) + if err != nil { + return diag.Errorf("system_configuration.webhook_event_log_configuration: %s", err.Error()) + } + return nil } From 38da19d5aef916dd7745f08018e69346effaa87c Mon Sep 17 00:00:00 2001 From: Spencer Witt Date: Thu, 17 Oct 2024 15:51:26 -0500 Subject: [PATCH 2/2] add WebhookEventLogConfiguration to DefaultSystemConfiguration --- fusionauth/resource_system_configuration.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fusionauth/resource_system_configuration.go b/fusionauth/resource_system_configuration.go index cd02417..22c9fb2 100644 --- a/fusionauth/resource_system_configuration.go +++ b/fusionauth/resource_system_configuration.go @@ -479,6 +479,13 @@ func getDefaultSystemConfigurationRequest() fusionauth.SystemConfigurationReques }, }, ReportTimezone: "America/Denver", + WebhookEventLogConfiguration: fusionauth.WebhookEventLogConfiguration{ + Delete: fusionauth.DeleteConfiguration{ + Enableable: fusionauth.Enableable{ + Enabled: false, + }, + }, + }, }, } }