@@ -30,6 +30,7 @@ import (
3030
3131 "github.com/hashicorp/terraform-provider-google/google/tpgresource"
3232 transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
33+ "github.com/hashicorp/terraform-provider-google/google/verify"
3334)
3435
3536func ResourceSecurityCenterMuteConfig () * schema.Resource {
@@ -78,6 +79,22 @@ project = Y scope, it might not match any findings.`,
7879 Optional : true ,
7980 Description : `A description of the mute config.` ,
8081 },
82+ "expiry_time" : {
83+ Type : schema .TypeString ,
84+ Optional : true ,
85+ Description : `Optional. The expiry of the mute config. Only applicable for dynamic configs.
86+ If the expiry is set, when the config expires, it is removed from all findings.
87+
88+ A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to
89+ nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".` ,
90+ },
91+ "type" : {
92+ Type : schema .TypeString ,
93+ Optional : true ,
94+ ValidateFunc : verify .ValidateEnum ([]string {"MUTE_CONFIG_TYPE_UNSPECIFIED" , "STATIC" , "DYNAMIC" , "" }),
95+ Description : `The type of the mute config, which determines what type of mute state the config affects. Default value: "DYNAMIC" Possible values: ["MUTE_CONFIG_TYPE_UNSPECIFIED", "STATIC", "DYNAMIC"]` ,
96+ Default : "DYNAMIC" ,
97+ },
8198 "create_time" : {
8299 Type : schema .TypeString ,
83100 Computed : true ,
@@ -131,6 +148,18 @@ func resourceSecurityCenterMuteConfigCreate(d *schema.ResourceData, meta interfa
131148 } else if v , ok := d .GetOkExists ("filter" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (filterProp )) && (ok || ! reflect .DeepEqual (v , filterProp )) {
132149 obj ["filter" ] = filterProp
133150 }
151+ typeProp , err := expandSecurityCenterMuteConfigType (d .Get ("type" ), d , config )
152+ if err != nil {
153+ return err
154+ } else if v , ok := d .GetOkExists ("type" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (typeProp )) && (ok || ! reflect .DeepEqual (v , typeProp )) {
155+ obj ["type" ] = typeProp
156+ }
157+ expiryTimeProp , err := expandSecurityCenterMuteConfigExpiryTime (d .Get ("expiry_time" ), d , config )
158+ if err != nil {
159+ return err
160+ } else if v , ok := d .GetOkExists ("expiry_time" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (expiryTimeProp )) && (ok || ! reflect .DeepEqual (v , expiryTimeProp )) {
161+ obj ["expiryTime" ] = expiryTimeProp
162+ }
134163
135164 url , err := tpgresource .ReplaceVars (d , config , "{{SecurityCenterBasePath}}{{parent}}/muteConfigs?muteConfigId={{mute_config_id}}" )
136165 if err != nil {
@@ -225,6 +254,12 @@ func resourceSecurityCenterMuteConfigRead(d *schema.ResourceData, meta interface
225254 if err := d .Set ("most_recent_editor" , flattenSecurityCenterMuteConfigMostRecentEditor (res ["mostRecentEditor" ], d , config )); err != nil {
226255 return fmt .Errorf ("Error reading MuteConfig: %s" , err )
227256 }
257+ if err := d .Set ("type" , flattenSecurityCenterMuteConfigType (res ["type" ], d , config )); err != nil {
258+ return fmt .Errorf ("Error reading MuteConfig: %s" , err )
259+ }
260+ if err := d .Set ("expiry_time" , flattenSecurityCenterMuteConfigExpiryTime (res ["expiryTime" ], d , config )); err != nil {
261+ return fmt .Errorf ("Error reading MuteConfig: %s" , err )
262+ }
228263
229264 return nil
230265}
@@ -251,6 +286,18 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa
251286 } else if v , ok := d .GetOkExists ("filter" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , filterProp )) {
252287 obj ["filter" ] = filterProp
253288 }
289+ typeProp , err := expandSecurityCenterMuteConfigType (d .Get ("type" ), d , config )
290+ if err != nil {
291+ return err
292+ } else if v , ok := d .GetOkExists ("type" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , typeProp )) {
293+ obj ["type" ] = typeProp
294+ }
295+ expiryTimeProp , err := expandSecurityCenterMuteConfigExpiryTime (d .Get ("expiry_time" ), d , config )
296+ if err != nil {
297+ return err
298+ } else if v , ok := d .GetOkExists ("expiry_time" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , expiryTimeProp )) {
299+ obj ["expiryTime" ] = expiryTimeProp
300+ }
254301
255302 url , err := tpgresource .ReplaceVars (d , config , "{{SecurityCenterBasePath}}{{name}}" )
256303 if err != nil {
@@ -268,6 +315,14 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa
268315 if d .HasChange ("filter" ) {
269316 updateMask = append (updateMask , "filter" )
270317 }
318+
319+ if d .HasChange ("type" ) {
320+ updateMask = append (updateMask , "type" )
321+ }
322+
323+ if d .HasChange ("expiry_time" ) {
324+ updateMask = append (updateMask , "expiryTime" )
325+ }
271326 // updateMask is a URL parameter but not present in the schema, so ReplaceVars
272327 // won't set it
273328 url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -407,10 +462,26 @@ func flattenSecurityCenterMuteConfigMostRecentEditor(v interface{}, d *schema.Re
407462 return v
408463}
409464
465+ func flattenSecurityCenterMuteConfigType (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
466+ return v
467+ }
468+
469+ func flattenSecurityCenterMuteConfigExpiryTime (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
470+ return v
471+ }
472+
410473func expandSecurityCenterMuteConfigDescription (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
411474 return v , nil
412475}
413476
414477func expandSecurityCenterMuteConfigFilter (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
415478 return v , nil
416479}
480+
481+ func expandSecurityCenterMuteConfigType (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
482+ return v , nil
483+ }
484+
485+ func expandSecurityCenterMuteConfigExpiryTime (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
486+ return v , nil
487+ }
0 commit comments