@@ -188,6 +188,7 @@ type emailConfigsModel struct {
188188 AuthPassword types.String `tfsdk:"auth_password"`
189189 AuthUsername types.String `tfsdk:"auth_username"`
190190 From types.String `tfsdk:"from"`
191+ SendResolved types.Bool `tfsdk:"send_resolved"`
191192 Smarthost types.String `tfsdk:"smart_host"`
192193 To types.String `tfsdk:"to"`
193194}
@@ -197,36 +198,41 @@ var emailConfigsTypes = map[string]attr.Type{
197198 "auth_password" : types .StringType ,
198199 "auth_username" : types .StringType ,
199200 "from" : types .StringType ,
201+ "send_resolved" : types .BoolType ,
200202 "smart_host" : types .StringType ,
201203 "to" : types .StringType ,
202204}
203205
204206// Struct corresponding to Model.AlertConfig.receivers.opsGenieConfigs
205207type opsgenieConfigsModel struct {
206- ApiKey types.String `tfsdk:"api_key"`
207- ApiUrl types.String `tfsdk:"api_url"`
208- Tags types.String `tfsdk:"tags"`
209- Priority types.String `tfsdk:"priority"`
208+ ApiKey types.String `tfsdk:"api_key"`
209+ ApiUrl types.String `tfsdk:"api_url"`
210+ Tags types.String `tfsdk:"tags"`
211+ Priority types.String `tfsdk:"priority"`
212+ SendResolved types.Bool `tfsdk:"send_resolved"`
210213}
211214
212215var opsgenieConfigsTypes = map [string ]attr.Type {
213- "api_key" : types .StringType ,
214- "api_url" : types .StringType ,
215- "tags" : types .StringType ,
216- "priority" : types .StringType ,
216+ "api_key" : types .StringType ,
217+ "api_url" : types .StringType ,
218+ "tags" : types .StringType ,
219+ "priority" : types .StringType ,
220+ "send_resolved" : types .BoolType ,
217221}
218222
219223// Struct corresponding to Model.AlertConfig.receivers.webHooksConfigs
220224type webHooksConfigsModel struct {
221- Url types.String `tfsdk:"url"`
222- MsTeams types.Bool `tfsdk:"ms_teams"`
223- GoogleChat types.Bool `tfsdk:"google_chat"`
225+ Url types.String `tfsdk:"url"`
226+ MsTeams types.Bool `tfsdk:"ms_teams"`
227+ GoogleChat types.Bool `tfsdk:"google_chat"`
228+ SendResolved types.Bool `tfsdk:"send_resolved"`
224229}
225230
226231var webHooksConfigsTypes = map [string ]attr.Type {
227- "url" : types .StringType ,
228- "ms_teams" : types .BoolType ,
229- "google_chat" : types .BoolType ,
232+ "url" : types .StringType ,
233+ "ms_teams" : types .BoolType ,
234+ "google_chat" : types .BoolType ,
235+ "send_resolved" : types .BoolType ,
230236}
231237
232238var routeDescriptions = map [string ]string {
@@ -629,6 +635,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
629635 Description : "The sender email address. Must be a valid email address" ,
630636 Optional : true ,
631637 },
638+ "send_resolved" : schema.BoolAttribute {
639+ Description : "Whether to notify about resolved alerts." ,
640+ Optional : true ,
641+ },
632642 "smart_host" : schema.StringAttribute {
633643 Description : "The SMTP host through which emails are sent." ,
634644 Optional : true ,
@@ -664,6 +674,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
664674 Description : "Priority of the alert. " + utils .FormatPossibleValues ("P1" , "P2" , "P3" , "P4" , "P5" ),
665675 Optional : true ,
666676 },
677+ "send_resolved" : schema.BoolAttribute {
678+ Description : "Whether to notify about resolved alerts." ,
679+ Optional : true ,
680+ },
667681 },
668682 },
669683 },
@@ -695,6 +709,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
695709 Computed : true ,
696710 Default : booldefault .StaticBool (false ),
697711 },
712+ "send_resolved" : schema.BoolAttribute {
713+ Description : "Whether to notify about resolved alerts." ,
714+ Optional : true ,
715+ },
698716 },
699717 },
700718 },
@@ -1490,6 +1508,7 @@ func getMockAlertConfig(ctx context.Context) (alertConfigModel, error) {
14901508 mockEmailConfig , diags := types .ObjectValue (emailConfigsTypes , map [string ]attr.Value {
14911509 "to" :
types .
StringValue (
"[email protected] " ),
14921510 "smart_host" : types .StringValue ("smtp.gmail.com:587" ),
1511+ "send_resolved" : types .BoolValue (false ),
14931512 "from" :
types .
StringValue (
"[email protected] " ),
14941513 "auth_username" :
types .
StringValue (
"[email protected] " ),
14951514 "auth_password" : types .StringValue ("xxxxxxxxx" ),
@@ -1635,6 +1654,7 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
16351654 "auth_password" : types .StringPointerValue (emailConfig .AuthPassword ),
16361655 "auth_username" : types .StringPointerValue (emailConfig .AuthUsername ),
16371656 "from" : types .StringPointerValue (emailConfig .From ),
1657+ "send_resolved" : types .BoolPointerValue (emailConfig .SendResolved ),
16381658 "smart_host" : types .StringPointerValue (emailConfig .Smarthost ),
16391659 "to" : types .StringPointerValue (emailConfig .To ),
16401660 }
@@ -1650,10 +1670,11 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
16501670 if receiver .OpsgenieConfigs != nil {
16511671 for _ , opsgenieConfig := range * receiver .OpsgenieConfigs {
16521672 opsGenieConfigMap := map [string ]attr.Value {
1653- "api_key" : types .StringPointerValue (opsgenieConfig .ApiKey ),
1654- "api_url" : types .StringPointerValue (opsgenieConfig .ApiUrl ),
1655- "tags" : types .StringPointerValue (opsgenieConfig .Tags ),
1656- "priority" : types .StringPointerValue (opsgenieConfig .Priority ),
1673+ "api_key" : types .StringPointerValue (opsgenieConfig .ApiKey ),
1674+ "api_url" : types .StringPointerValue (opsgenieConfig .ApiUrl ),
1675+ "tags" : types .StringPointerValue (opsgenieConfig .Tags ),
1676+ "priority" : types .StringPointerValue (opsgenieConfig .Priority ),
1677+ "send_resolved" : types .BoolPointerValue (opsgenieConfig .SendResolved ),
16571678 }
16581679 opsGenieConfigModel , diags := types .ObjectValue (opsgenieConfigsTypes , opsGenieConfigMap )
16591680 if diags .HasError () {
@@ -1666,13 +1687,11 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
16661687 webhooksConfigList := []attr.Value {}
16671688 if receiver .WebHookConfigs != nil {
16681689 for _ , webhookConfig := range * receiver .WebHookConfigs {
1669- msTeamsValue := types .BoolPointerValue (webhookConfig .MsTeams )
1670- googleChatValue := types .BoolPointerValue (webhookConfig .GoogleChat )
1671-
16721690 webHookConfigsMap := map [string ]attr.Value {
1673- "url" : types .StringPointerValue (webhookConfig .Url ),
1674- "ms_teams" : msTeamsValue ,
1675- "google_chat" : googleChatValue ,
1691+ "url" : types .StringPointerValue (webhookConfig .Url ),
1692+ "ms_teams" : types .BoolPointerValue (webhookConfig .MsTeams ),
1693+ "google_chat" : types .BoolPointerValue (webhookConfig .GoogleChat ),
1694+ "send_resolved" : types .BoolPointerValue (webhookConfig .SendResolved ),
16761695 }
16771696 webHookConfigsModel , diags := types .ObjectValue (webHooksConfigsTypes , webHookConfigsMap )
16781697 if diags .HasError () {
@@ -1981,6 +2000,7 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
19812000 AuthPassword : conversion .StringValueToPointer (emailConfig .AuthPassword ),
19822001 AuthUsername : conversion .StringValueToPointer (emailConfig .AuthUsername ),
19832002 From : conversion .StringValueToPointer (emailConfig .From ),
2003+ SendResolved : conversion .BoolValueToPointer (emailConfig .SendResolved ),
19842004 Smarthost : conversion .StringValueToPointer (emailConfig .Smarthost ),
19852005 To : conversion .StringValueToPointer (emailConfig .To ),
19862006 })
@@ -1998,10 +2018,11 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
19982018 for i := range opsgenieConfigs {
19992019 opsgenieConfig := opsgenieConfigs [i ]
20002020 payloadOpsGenieConfigs = append (payloadOpsGenieConfigs , observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner {
2001- ApiKey : conversion .StringValueToPointer (opsgenieConfig .ApiKey ),
2002- ApiUrl : conversion .StringValueToPointer (opsgenieConfig .ApiUrl ),
2003- Tags : conversion .StringValueToPointer (opsgenieConfig .Tags ),
2004- Priority : conversion .StringValueToPointer (opsgenieConfig .Priority ),
2021+ ApiKey : conversion .StringValueToPointer (opsgenieConfig .ApiKey ),
2022+ ApiUrl : conversion .StringValueToPointer (opsgenieConfig .ApiUrl ),
2023+ Tags : conversion .StringValueToPointer (opsgenieConfig .Tags ),
2024+ Priority : conversion .StringValueToPointer (opsgenieConfig .Priority ),
2025+ SendResolved : conversion .BoolValueToPointer (opsgenieConfig .SendResolved ),
20052026 })
20062027 }
20072028 receiverPayload .OpsgenieConfigs = & payloadOpsGenieConfigs
@@ -2017,9 +2038,10 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
20172038 for i := range receiverWebHooksConfigs {
20182039 webHooksConfig := receiverWebHooksConfigs [i ]
20192040 payloadWebHooksConfigs = append (payloadWebHooksConfigs , observability.CreateAlertConfigReceiverPayloadWebHookConfigsInner {
2020- Url : conversion .StringValueToPointer (webHooksConfig .Url ),
2021- MsTeams : conversion .BoolValueToPointer (webHooksConfig .MsTeams ),
2022- GoogleChat : conversion .BoolValueToPointer (webHooksConfig .GoogleChat ),
2041+ Url : conversion .StringValueToPointer (webHooksConfig .Url ),
2042+ MsTeams : conversion .BoolValueToPointer (webHooksConfig .MsTeams ),
2043+ GoogleChat : conversion .BoolValueToPointer (webHooksConfig .GoogleChat ),
2044+ SendResolved : conversion .BoolValueToPointer (webHooksConfig .SendResolved ),
20232045 })
20242046 }
20252047 receiverPayload .WebHookConfigs = & payloadWebHooksConfigs
0 commit comments