@@ -30,6 +30,7 @@ import (
30
30
31
31
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
32
32
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
33
+ "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify"
33
34
)
34
35
35
36
func ResourceSecurityCenterMuteConfig () * schema.Resource {
@@ -78,6 +79,22 @@ project = Y scope, it might not match any findings.`,
78
79
Optional : true ,
79
80
Description : `A description of the mute config.` ,
80
81
},
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
+ },
81
98
"create_time" : {
82
99
Type : schema .TypeString ,
83
100
Computed : true ,
@@ -131,6 +148,18 @@ func resourceSecurityCenterMuteConfigCreate(d *schema.ResourceData, meta interfa
131
148
} else if v , ok := d .GetOkExists ("filter" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (filterProp )) && (ok || ! reflect .DeepEqual (v , filterProp )) {
132
149
obj ["filter" ] = filterProp
133
150
}
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
+ }
134
163
135
164
url , err := tpgresource .ReplaceVars (d , config , "{{SecurityCenterBasePath}}{{parent}}/muteConfigs?muteConfigId={{mute_config_id}}" )
136
165
if err != nil {
@@ -225,6 +254,12 @@ func resourceSecurityCenterMuteConfigRead(d *schema.ResourceData, meta interface
225
254
if err := d .Set ("most_recent_editor" , flattenSecurityCenterMuteConfigMostRecentEditor (res ["mostRecentEditor" ], d , config )); err != nil {
226
255
return fmt .Errorf ("Error reading MuteConfig: %s" , err )
227
256
}
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
+ }
228
263
229
264
return nil
230
265
}
@@ -251,6 +286,18 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa
251
286
} else if v , ok := d .GetOkExists ("filter" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , filterProp )) {
252
287
obj ["filter" ] = filterProp
253
288
}
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
+ }
254
301
255
302
url , err := tpgresource .ReplaceVars (d , config , "{{SecurityCenterBasePath}}{{name}}" )
256
303
if err != nil {
@@ -268,6 +315,14 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa
268
315
if d .HasChange ("filter" ) {
269
316
updateMask = append (updateMask , "filter" )
270
317
}
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
+ }
271
326
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
272
327
// won't set it
273
328
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -407,10 +462,26 @@ func flattenSecurityCenterMuteConfigMostRecentEditor(v interface{}, d *schema.Re
407
462
return v
408
463
}
409
464
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
+
410
473
func expandSecurityCenterMuteConfigDescription (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
411
474
return v , nil
412
475
}
413
476
414
477
func expandSecurityCenterMuteConfigFilter (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
415
478
return v , nil
416
479
}
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