@@ -745,6 +745,32 @@ name is limited to 512 Unicode characters.`,
745
745
Optional : true ,
746
746
Description : `If an alert policy that was active has no data for this long, any open incidents will close.` ,
747
747
},
748
+ "notification_channel_strategy" : {
749
+ Type : schema .TypeList ,
750
+ Optional : true ,
751
+ Description : `Control over how the notification channels in 'notification_channels'
752
+ are notified when this alert fires, on a per-channel basis.` ,
753
+ Elem : & schema.Resource {
754
+ Schema : map [string ]* schema.Schema {
755
+ "notification_channel_names" : {
756
+ Type : schema .TypeList ,
757
+ Optional : true ,
758
+ Description : `The notification channels that these settings apply to. Each of these
759
+ correspond to the name field in one of the NotificationChannel objects
760
+ referenced in the notification_channels field of this AlertPolicy. The format is
761
+ 'projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]'` ,
762
+ Elem : & schema.Schema {
763
+ Type : schema .TypeString ,
764
+ },
765
+ },
766
+ "renotify_interval" : {
767
+ Type : schema .TypeString ,
768
+ Optional : true ,
769
+ Description : `The frequency at which to send reminder notifications for open incidents.` ,
770
+ },
771
+ },
772
+ },
773
+ },
748
774
"notification_rate_limit" : {
749
775
Type : schema .TypeList ,
750
776
Optional : true ,
@@ -1682,6 +1708,8 @@ func flattenMonitoringAlertPolicyAlertStrategy(v interface{}, d *schema.Resource
1682
1708
flattenMonitoringAlertPolicyAlertStrategyNotificationRateLimit (original ["notificationRateLimit" ], d , config )
1683
1709
transformed ["auto_close" ] =
1684
1710
flattenMonitoringAlertPolicyAlertStrategyAutoClose (original ["autoClose" ], d , config )
1711
+ transformed ["notification_channel_strategy" ] =
1712
+ flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategy (original ["notificationChannelStrategy" ], d , config )
1685
1713
return []interface {}{transformed }
1686
1714
}
1687
1715
func flattenMonitoringAlertPolicyAlertStrategyNotificationRateLimit (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -1705,6 +1733,33 @@ func flattenMonitoringAlertPolicyAlertStrategyAutoClose(v interface{}, d *schema
1705
1733
return v
1706
1734
}
1707
1735
1736
+ func flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategy (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1737
+ if v == nil {
1738
+ return v
1739
+ }
1740
+ l := v .([]interface {})
1741
+ transformed := make ([]interface {}, 0 , len (l ))
1742
+ for _ , raw := range l {
1743
+ original := raw .(map [string ]interface {})
1744
+ if len (original ) < 1 {
1745
+ // Do not include empty json objects coming back from the api
1746
+ continue
1747
+ }
1748
+ transformed = append (transformed , map [string ]interface {}{
1749
+ "notification_channel_names" : flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyNotificationChannelNames (original ["notificationChannelNames" ], d , config ),
1750
+ "renotify_interval" : flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyRenotifyInterval (original ["renotifyInterval" ], d , config ),
1751
+ })
1752
+ }
1753
+ return transformed
1754
+ }
1755
+ func flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyNotificationChannelNames (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1756
+ return v
1757
+ }
1758
+
1759
+ func flattenMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyRenotifyInterval (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1760
+ return v
1761
+ }
1762
+
1708
1763
func flattenMonitoringAlertPolicyUserLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1709
1764
return v
1710
1765
}
@@ -2355,6 +2410,13 @@ func expandMonitoringAlertPolicyAlertStrategy(v interface{}, d tpgresource.Terra
2355
2410
transformed ["autoClose" ] = transformedAutoClose
2356
2411
}
2357
2412
2413
+ transformedNotificationChannelStrategy , err := expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategy (original ["notification_channel_strategy" ], d , config )
2414
+ if err != nil {
2415
+ return nil , err
2416
+ } else if val := reflect .ValueOf (transformedNotificationChannelStrategy ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2417
+ transformed ["notificationChannelStrategy" ] = transformedNotificationChannelStrategy
2418
+ }
2419
+
2358
2420
return transformed , nil
2359
2421
}
2360
2422
@@ -2385,6 +2447,43 @@ func expandMonitoringAlertPolicyAlertStrategyAutoClose(v interface{}, d tpgresou
2385
2447
return v , nil
2386
2448
}
2387
2449
2450
+ func expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategy (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2451
+ l := v .([]interface {})
2452
+ req := make ([]interface {}, 0 , len (l ))
2453
+ for _ , raw := range l {
2454
+ if raw == nil {
2455
+ continue
2456
+ }
2457
+ original := raw .(map [string ]interface {})
2458
+ transformed := make (map [string ]interface {})
2459
+
2460
+ transformedNotificationChannelNames , err := expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyNotificationChannelNames (original ["notification_channel_names" ], d , config )
2461
+ if err != nil {
2462
+ return nil , err
2463
+ } else if val := reflect .ValueOf (transformedNotificationChannelNames ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2464
+ transformed ["notificationChannelNames" ] = transformedNotificationChannelNames
2465
+ }
2466
+
2467
+ transformedRenotifyInterval , err := expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyRenotifyInterval (original ["renotify_interval" ], d , config )
2468
+ if err != nil {
2469
+ return nil , err
2470
+ } else if val := reflect .ValueOf (transformedRenotifyInterval ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2471
+ transformed ["renotifyInterval" ] = transformedRenotifyInterval
2472
+ }
2473
+
2474
+ req = append (req , transformed )
2475
+ }
2476
+ return req , nil
2477
+ }
2478
+
2479
+ func expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyNotificationChannelNames (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2480
+ return v , nil
2481
+ }
2482
+
2483
+ func expandMonitoringAlertPolicyAlertStrategyNotificationChannelStrategyRenotifyInterval (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2484
+ return v , nil
2485
+ }
2486
+
2388
2487
func expandMonitoringAlertPolicyUserLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
2389
2488
if v == nil {
2390
2489
return map [string ]string {}, nil
0 commit comments