@@ -142,52 +142,20 @@ Format: organizations/{organization_id}.`,
142
142
Elem : & schema.Resource {
143
143
Schema : map [string ]* schema.Schema {
144
144
"severity_overrides" : {
145
- Type : schema .TypeList ,
145
+ Type : schema .TypeSet ,
146
146
Optional : true ,
147
147
Description : `The configuration for overriding threats actions by severity match.` ,
148
- Elem : & schema.Resource {
149
- Schema : map [string ]* schema.Schema {
150
- "action" : {
151
- Type : schema .TypeString ,
152
- Required : true ,
153
- ValidateFunc : verify .ValidateEnum ([]string {"ALERT" , "ALLOW" , "DEFAULT_ACTION" , "DENY" }),
154
- Description : `Threat action override. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]` ,
155
- },
156
- "severity" : {
157
- Type : schema .TypeString ,
158
- Required : true ,
159
- ValidateFunc : verify .ValidateEnum ([]string {"CRITICAL" , "HIGH" , "INFORMATIONAL" , "LOW" , "MEDIUM" }),
160
- Description : `Severity level to match. Possible values: ["CRITICAL", "HIGH", "INFORMATIONAL", "LOW", "MEDIUM"]` ,
161
- },
162
- },
163
- },
148
+ Elem : networksecuritySecurityProfileThreatPreventionProfileSeverityOverridesSchema (),
149
+ // Default schema.HashSchema is used.
164
150
},
165
151
"threat_overrides" : {
166
- Type : schema .TypeList ,
152
+ Type : schema .TypeSet ,
167
153
Optional : true ,
168
154
Description : `The configuration for overriding threats actions by threat id match.
169
155
If a threat is matched both by configuration provided in severity overrides
170
156
and threat overrides, the threat overrides action is applied.` ,
171
- Elem : & schema.Resource {
172
- Schema : map [string ]* schema.Schema {
173
- "action" : {
174
- Type : schema .TypeString ,
175
- Required : true ,
176
- ValidateFunc : verify .ValidateEnum ([]string {"ALERT" , "ALLOW" , "DEFAULT_ACTION" , "DENY" }),
177
- Description : `Threat action. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]` ,
178
- },
179
- "threat_id" : {
180
- Type : schema .TypeString ,
181
- Required : true ,
182
- Description : `Vendor-specific ID of a threat to override.` ,
183
- },
184
- "type" : {
185
- Type : schema .TypeString ,
186
- Computed : true ,
187
- Description : `Type of threat.` ,
188
- },
189
- },
190
- },
157
+ Elem : networksecuritySecurityProfileThreatPreventionProfileThreatOverridesSchema (),
158
+ // Default schema.HashSchema is used.
191
159
},
192
160
},
193
161
},
@@ -233,6 +201,48 @@ value before proceeding.`,
233
201
}
234
202
}
235
203
204
+ func networksecuritySecurityProfileThreatPreventionProfileSeverityOverridesSchema () * schema.Resource {
205
+ return & schema.Resource {
206
+ Schema : map [string ]* schema.Schema {
207
+ "action" : {
208
+ Type : schema .TypeString ,
209
+ Required : true ,
210
+ ValidateFunc : verify .ValidateEnum ([]string {"ALERT" , "ALLOW" , "DEFAULT_ACTION" , "DENY" }),
211
+ Description : `Threat action override. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]` ,
212
+ },
213
+ "severity" : {
214
+ Type : schema .TypeString ,
215
+ Required : true ,
216
+ ValidateFunc : verify .ValidateEnum ([]string {"CRITICAL" , "HIGH" , "INFORMATIONAL" , "LOW" , "MEDIUM" }),
217
+ Description : `Severity level to match. Possible values: ["CRITICAL", "HIGH", "INFORMATIONAL", "LOW", "MEDIUM"]` ,
218
+ },
219
+ },
220
+ }
221
+ }
222
+
223
+ func networksecuritySecurityProfileThreatPreventionProfileThreatOverridesSchema () * schema.Resource {
224
+ return & schema.Resource {
225
+ Schema : map [string ]* schema.Schema {
226
+ "action" : {
227
+ Type : schema .TypeString ,
228
+ Required : true ,
229
+ ValidateFunc : verify .ValidateEnum ([]string {"ALERT" , "ALLOW" , "DEFAULT_ACTION" , "DENY" }),
230
+ Description : `Threat action. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]` ,
231
+ },
232
+ "threat_id" : {
233
+ Type : schema .TypeString ,
234
+ Required : true ,
235
+ Description : `Vendor-specific ID of a threat to override.` ,
236
+ },
237
+ "type" : {
238
+ Type : schema .TypeString ,
239
+ Computed : true ,
240
+ Description : `Type of threat.` ,
241
+ },
242
+ },
243
+ }
244
+ }
245
+
236
246
func resourceNetworkSecuritySecurityProfileCreate (d * schema.ResourceData , meta interface {}) error {
237
247
var project string
238
248
config := meta .(* transport_tpg.Config )
@@ -638,14 +648,14 @@ func flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrid
638
648
return v
639
649
}
640
650
l := v .([]interface {})
641
- transformed := make ( []interface {}, 0 , len ( l ) )
651
+ transformed := schema . NewSet ( schema . HashResource ( networksecuritySecurityProfileThreatPreventionProfileSeverityOverridesSchema ()), []interface {}{} )
642
652
for _ , raw := range l {
643
653
original := raw .(map [string ]interface {})
644
654
if len (original ) < 1 {
645
655
// Do not include empty json objects coming back from the api
646
656
continue
647
657
}
648
- transformed = append ( transformed , map [string ]interface {}{
658
+ transformed . Add ( map [string ]interface {}{
649
659
"action" : flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesAction (original ["action" ], d , config ),
650
660
"severity" : flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesSeverity (original ["severity" ], d , config ),
651
661
})
@@ -665,14 +675,14 @@ func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides
665
675
return v
666
676
}
667
677
l := v .([]interface {})
668
- transformed := make ( []interface {}, 0 , len ( l ) )
678
+ transformed := schema . NewSet ( schema . HashResource ( networksecuritySecurityProfileThreatPreventionProfileThreatOverridesSchema ()), []interface {}{} )
669
679
for _ , raw := range l {
670
680
original := raw .(map [string ]interface {})
671
681
if len (original ) < 1 {
672
682
// Do not include empty json objects coming back from the api
673
683
continue
674
684
}
675
- transformed = append ( transformed , map [string ]interface {}{
685
+ transformed . Add ( map [string ]interface {}{
676
686
"action" : flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesAction (original ["action" ], d , config ),
677
687
"threat_id" : flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesThreatId (original ["threatId" ], d , config ),
678
688
"type" : flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesType (original ["type" ], d , config ),
@@ -780,6 +790,7 @@ func expandNetworkSecuritySecurityProfileThreatPreventionProfile(v interface{},
780
790
}
781
791
782
792
func expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrides (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
793
+ v = v .(* schema.Set ).List ()
783
794
l := v .([]interface {})
784
795
req := make ([]interface {}, 0 , len (l ))
785
796
for _ , raw := range l {
@@ -817,6 +828,7 @@ func expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverride
817
828
}
818
829
819
830
func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
831
+ v = v .(* schema.Set ).List ()
820
832
l := v .([]interface {})
821
833
req := make ([]interface {}, 0 , len (l ))
822
834
for _ , raw := range l {
0 commit comments