@@ -672,6 +672,31 @@ resource labels, and metric labels. This
672
672
field may not exceed 2048 Unicode characters
673
673
in length.` ,
674
674
},
675
+ "forecast_options" : {
676
+ Type : schema .TypeList ,
677
+ Optional : true ,
678
+ Description : `When this field is present, the 'MetricThreshold'
679
+ condition forecasts whether the time series is
680
+ predicted to violate the threshold within the
681
+ 'forecastHorizon'. When this field is not set, the
682
+ 'MetricThreshold' tests the current value of the
683
+ timeseries against the threshold.` ,
684
+ MaxItems : 1 ,
685
+ Elem : & schema.Resource {
686
+ Schema : map [string ]* schema.Schema {
687
+ "forecast_horizon" : {
688
+ Type : schema .TypeString ,
689
+ Required : true ,
690
+ Description : `The length of time into the future to forecast
691
+ whether a timeseries will violate the threshold.
692
+ If the predicted value is found to violate the
693
+ threshold, and the violation is observed in all
694
+ forecasts made for the Configured 'duration',
695
+ then the timeseries is considered to be failing.` ,
696
+ },
697
+ },
698
+ },
699
+ },
675
700
"threshold_value" : {
676
701
Type : schema .TypeFloat ,
677
702
Optional : true ,
@@ -1518,6 +1543,8 @@ func flattenMonitoringAlertPolicyConditionsConditionThreshold(v interface{}, d *
1518
1543
flattenMonitoringAlertPolicyConditionsConditionThresholdDenominatorAggregations (original ["denominatorAggregations" ], d , config )
1519
1544
transformed ["duration" ] =
1520
1545
flattenMonitoringAlertPolicyConditionsConditionThresholdDuration (original ["duration" ], d , config )
1546
+ transformed ["forecast_options" ] =
1547
+ flattenMonitoringAlertPolicyConditionsConditionThresholdForecastOptions (original ["forecastOptions" ], d , config )
1521
1548
transformed ["comparison" ] =
1522
1549
flattenMonitoringAlertPolicyConditionsConditionThresholdComparison (original ["comparison" ], d , config )
1523
1550
transformed ["trigger" ] =
@@ -1579,6 +1606,23 @@ func flattenMonitoringAlertPolicyConditionsConditionThresholdDuration(v interfac
1579
1606
return v
1580
1607
}
1581
1608
1609
+ func flattenMonitoringAlertPolicyConditionsConditionThresholdForecastOptions (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1610
+ if v == nil {
1611
+ return nil
1612
+ }
1613
+ original := v .(map [string ]interface {})
1614
+ if len (original ) == 0 {
1615
+ return nil
1616
+ }
1617
+ transformed := make (map [string ]interface {})
1618
+ transformed ["forecast_horizon" ] =
1619
+ flattenMonitoringAlertPolicyConditionsConditionThresholdForecastOptionsForecastHorizon (original ["forecastHorizon" ], d , config )
1620
+ return []interface {}{transformed }
1621
+ }
1622
+ func flattenMonitoringAlertPolicyConditionsConditionThresholdForecastOptionsForecastHorizon (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1623
+ return v
1624
+ }
1625
+
1582
1626
func flattenMonitoringAlertPolicyConditionsConditionThresholdComparison (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1583
1627
return v
1584
1628
}
@@ -2124,6 +2168,13 @@ func expandMonitoringAlertPolicyConditionsConditionThreshold(v interface{}, d tp
2124
2168
transformed ["duration" ] = transformedDuration
2125
2169
}
2126
2170
2171
+ transformedForecastOptions , err := expandMonitoringAlertPolicyConditionsConditionThresholdForecastOptions (original ["forecast_options" ], d , config )
2172
+ if err != nil {
2173
+ return nil , err
2174
+ } else if val := reflect .ValueOf (transformedForecastOptions ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2175
+ transformed ["forecastOptions" ] = transformedForecastOptions
2176
+ }
2177
+
2127
2178
transformedComparison , err := expandMonitoringAlertPolicyConditionsConditionThresholdComparison (original ["comparison" ], d , config )
2128
2179
if err != nil {
2129
2180
return nil , err
@@ -2233,6 +2284,29 @@ func expandMonitoringAlertPolicyConditionsConditionThresholdDuration(v interface
2233
2284
return v , nil
2234
2285
}
2235
2286
2287
+ func expandMonitoringAlertPolicyConditionsConditionThresholdForecastOptions (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2288
+ l := v .([]interface {})
2289
+ if len (l ) == 0 || l [0 ] == nil {
2290
+ return nil , nil
2291
+ }
2292
+ raw := l [0 ]
2293
+ original := raw .(map [string ]interface {})
2294
+ transformed := make (map [string ]interface {})
2295
+
2296
+ transformedForecastHorizon , err := expandMonitoringAlertPolicyConditionsConditionThresholdForecastOptionsForecastHorizon (original ["forecast_horizon" ], d , config )
2297
+ if err != nil {
2298
+ return nil , err
2299
+ } else if val := reflect .ValueOf (transformedForecastHorizon ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2300
+ transformed ["forecastHorizon" ] = transformedForecastHorizon
2301
+ }
2302
+
2303
+ return transformed , nil
2304
+ }
2305
+
2306
+ func expandMonitoringAlertPolicyConditionsConditionThresholdForecastOptionsForecastHorizon (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2307
+ return v , nil
2308
+ }
2309
+
2236
2310
func expandMonitoringAlertPolicyConditionsConditionThresholdComparison (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2237
2311
return v , nil
2238
2312
}
0 commit comments