@@ -188,6 +188,7 @@ type emailConfigsModel struct {
188
188
AuthPassword types.String `tfsdk:"auth_password"`
189
189
AuthUsername types.String `tfsdk:"auth_username"`
190
190
From types.String `tfsdk:"from"`
191
+ SendResolved types.Bool `tfsdk:"send_resolved"`
191
192
Smarthost types.String `tfsdk:"smart_host"`
192
193
To types.String `tfsdk:"to"`
193
194
}
@@ -197,36 +198,41 @@ var emailConfigsTypes = map[string]attr.Type{
197
198
"auth_password" : types .StringType ,
198
199
"auth_username" : types .StringType ,
199
200
"from" : types .StringType ,
201
+ "send_resolved" : types .BoolType ,
200
202
"smart_host" : types .StringType ,
201
203
"to" : types .StringType ,
202
204
}
203
205
204
206
// Struct corresponding to Model.AlertConfig.receivers.opsGenieConfigs
205
207
type 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"`
210
213
}
211
214
212
215
var 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 ,
217
221
}
218
222
219
223
// Struct corresponding to Model.AlertConfig.receivers.webHooksConfigs
220
224
type 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"`
224
229
}
225
230
226
231
var 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 ,
230
236
}
231
237
232
238
var routeDescriptions = map [string ]string {
@@ -629,6 +635,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
629
635
Description : "The sender email address. Must be a valid email address" ,
630
636
Optional : true ,
631
637
},
638
+ "send_resolved" : schema.BoolAttribute {
639
+ Description : "Whether to notify about resolved alerts." ,
640
+ Optional : true ,
641
+ },
632
642
"smart_host" : schema.StringAttribute {
633
643
Description : "The SMTP host through which emails are sent." ,
634
644
Optional : true ,
@@ -664,6 +674,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
664
674
Description : "Priority of the alert. " + utils .FormatPossibleValues ("P1" , "P2" , "P3" , "P4" , "P5" ),
665
675
Optional : true ,
666
676
},
677
+ "send_resolved" : schema.BoolAttribute {
678
+ Description : "Whether to notify about resolved alerts." ,
679
+ Optional : true ,
680
+ },
667
681
},
668
682
},
669
683
},
@@ -695,6 +709,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
695
709
Computed : true ,
696
710
Default : booldefault .StaticBool (false ),
697
711
},
712
+ "send_resolved" : schema.BoolAttribute {
713
+ Description : "Whether to notify about resolved alerts." ,
714
+ Optional : true ,
715
+ },
698
716
},
699
717
},
700
718
},
@@ -1490,6 +1508,7 @@ func getMockAlertConfig(ctx context.Context) (alertConfigModel, error) {
1490
1508
mockEmailConfig , diags := types .ObjectValue (emailConfigsTypes , map [string ]attr.Value {
1491
1509
"to" :
types .
StringValue (
"[email protected] " ),
1492
1510
"smart_host" : types .StringValue ("smtp.gmail.com:587" ),
1511
+ "send_resolved" : types .BoolValue (false ),
1493
1512
"from" :
types .
StringValue (
"[email protected] " ),
1494
1513
"auth_username" :
types .
StringValue (
"[email protected] " ),
1495
1514
"auth_password" : types .StringValue ("xxxxxxxxx" ),
@@ -1635,6 +1654,7 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
1635
1654
"auth_password" : types .StringPointerValue (emailConfig .AuthPassword ),
1636
1655
"auth_username" : types .StringPointerValue (emailConfig .AuthUsername ),
1637
1656
"from" : types .StringPointerValue (emailConfig .From ),
1657
+ "send_resolved" : types .BoolPointerValue (emailConfig .SendResolved ),
1638
1658
"smart_host" : types .StringPointerValue (emailConfig .Smarthost ),
1639
1659
"to" : types .StringPointerValue (emailConfig .To ),
1640
1660
}
@@ -1650,10 +1670,11 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
1650
1670
if receiver .OpsgenieConfigs != nil {
1651
1671
for _ , opsgenieConfig := range * receiver .OpsgenieConfigs {
1652
1672
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 ),
1657
1678
}
1658
1679
opsGenieConfigModel , diags := types .ObjectValue (opsgenieConfigsTypes , opsGenieConfigMap )
1659
1680
if diags .HasError () {
@@ -1666,13 +1687,11 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
1666
1687
webhooksConfigList := []attr.Value {}
1667
1688
if receiver .WebHookConfigs != nil {
1668
1689
for _ , webhookConfig := range * receiver .WebHookConfigs {
1669
- msTeamsValue := types .BoolPointerValue (webhookConfig .MsTeams )
1670
- googleChatValue := types .BoolPointerValue (webhookConfig .GoogleChat )
1671
-
1672
1690
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 ),
1676
1695
}
1677
1696
webHookConfigsModel , diags := types .ObjectValue (webHooksConfigsTypes , webHookConfigsMap )
1678
1697
if diags .HasError () {
@@ -1981,6 +2000,7 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
1981
2000
AuthPassword : conversion .StringValueToPointer (emailConfig .AuthPassword ),
1982
2001
AuthUsername : conversion .StringValueToPointer (emailConfig .AuthUsername ),
1983
2002
From : conversion .StringValueToPointer (emailConfig .From ),
2003
+ SendResolved : conversion .BoolValueToPointer (emailConfig .SendResolved ),
1984
2004
Smarthost : conversion .StringValueToPointer (emailConfig .Smarthost ),
1985
2005
To : conversion .StringValueToPointer (emailConfig .To ),
1986
2006
})
@@ -1998,10 +2018,11 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
1998
2018
for i := range opsgenieConfigs {
1999
2019
opsgenieConfig := opsgenieConfigs [i ]
2000
2020
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 ),
2005
2026
})
2006
2027
}
2007
2028
receiverPayload .OpsgenieConfigs = & payloadOpsGenieConfigs
@@ -2017,9 +2038,10 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
2017
2038
for i := range receiverWebHooksConfigs {
2018
2039
webHooksConfig := receiverWebHooksConfigs [i ]
2019
2040
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 ),
2023
2045
})
2024
2046
}
2025
2047
receiverPayload .WebHookConfigs = & payloadWebHooksConfigs
0 commit comments