@@ -672,6 +672,31 @@ resource labels, and metric labels. This
672672field may not exceed 2048 Unicode characters
673673in length.` ,
674674 },
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+ },
675700 "threshold_value" : {
676701 Type : schema .TypeFloat ,
677702 Optional : true ,
@@ -1518,6 +1543,8 @@ func flattenMonitoringAlertPolicyConditionsConditionThreshold(v interface{}, d *
15181543 flattenMonitoringAlertPolicyConditionsConditionThresholdDenominatorAggregations (original ["denominatorAggregations" ], d , config )
15191544 transformed ["duration" ] =
15201545 flattenMonitoringAlertPolicyConditionsConditionThresholdDuration (original ["duration" ], d , config )
1546+ transformed ["forecast_options" ] =
1547+ flattenMonitoringAlertPolicyConditionsConditionThresholdForecastOptions (original ["forecastOptions" ], d , config )
15211548 transformed ["comparison" ] =
15221549 flattenMonitoringAlertPolicyConditionsConditionThresholdComparison (original ["comparison" ], d , config )
15231550 transformed ["trigger" ] =
@@ -1579,6 +1606,23 @@ func flattenMonitoringAlertPolicyConditionsConditionThresholdDuration(v interfac
15791606 return v
15801607}
15811608
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+
15821626func flattenMonitoringAlertPolicyConditionsConditionThresholdComparison (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
15831627 return v
15841628}
@@ -2124,6 +2168,13 @@ func expandMonitoringAlertPolicyConditionsConditionThreshold(v interface{}, d tp
21242168 transformed ["duration" ] = transformedDuration
21252169 }
21262170
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+
21272178 transformedComparison , err := expandMonitoringAlertPolicyConditionsConditionThresholdComparison (original ["comparison" ], d , config )
21282179 if err != nil {
21292180 return nil , err
@@ -2233,6 +2284,29 @@ func expandMonitoringAlertPolicyConditionsConditionThresholdDuration(v interface
22332284 return v , nil
22342285}
22352286
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+
22362310func expandMonitoringAlertPolicyConditionsConditionThresholdComparison (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
22372311 return v , nil
22382312}
0 commit comments