@@ -93,6 +93,56 @@ func ResourceComputeRegionSecurityPolicy() *schema.Resource {
93
93
Description : `Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035.
94
94
Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.` ,
95
95
},
96
+ "advanced_options_config" : {
97
+ Type : schema .TypeList ,
98
+ Optional : true ,
99
+ Description : `Advanced Options Config of this security policy.` ,
100
+ MaxItems : 1 ,
101
+ Elem : & schema.Resource {
102
+ Schema : map [string ]* schema.Schema {
103
+ "json_custom_config" : {
104
+ Type : schema .TypeList ,
105
+ Optional : true ,
106
+ Description : `Custom configuration to apply the JSON parsing. Only applicable when JSON parsing is set to STANDARD.` ,
107
+ MaxItems : 1 ,
108
+ Elem : & schema.Resource {
109
+ Schema : map [string ]* schema.Schema {
110
+ "content_types" : {
111
+ Type : schema .TypeSet ,
112
+ Required : true ,
113
+ Description : `A list of custom Content-Type header values to apply the JSON parsing.` ,
114
+ Elem : & schema.Schema {
115
+ Type : schema .TypeString ,
116
+ },
117
+ Set : schema .HashString ,
118
+ },
119
+ },
120
+ },
121
+ },
122
+ "json_parsing" : {
123
+ Type : schema .TypeString ,
124
+ Optional : true ,
125
+ ValidateFunc : verify .ValidateEnum ([]string {"DISABLED" , "STANDARD" , "STANDARD_WITH_GRAPHQL" , "" }),
126
+ Description : `JSON body parsing. Supported values include: "DISABLED", "STANDARD", "STANDARD_WITH_GRAPHQL". Possible values: ["DISABLED", "STANDARD", "STANDARD_WITH_GRAPHQL"]` ,
127
+ },
128
+ "log_level" : {
129
+ Type : schema .TypeString ,
130
+ Optional : true ,
131
+ ValidateFunc : verify .ValidateEnum ([]string {"NORMAL" , "VERBOSE" , "" }),
132
+ Description : `Logging level. Supported values include: "NORMAL", "VERBOSE". Possible values: ["NORMAL", "VERBOSE"]` ,
133
+ },
134
+ "user_ip_request_headers" : {
135
+ Type : schema .TypeSet ,
136
+ Optional : true ,
137
+ Description : `An optional list of case-insensitive request header names to use for resolving the callers client IP address.` ,
138
+ Elem : & schema.Schema {
139
+ Type : schema .TypeString ,
140
+ },
141
+ Set : schema .HashString ,
142
+ },
143
+ },
144
+ },
145
+ },
96
146
"ddos_protection_config" : {
97
147
Type : schema .TypeList ,
98
148
Optional : true ,
@@ -713,6 +763,12 @@ func resourceComputeRegionSecurityPolicyCreate(d *schema.ResourceData, meta inte
713
763
} else if v , ok := d .GetOkExists ("ddos_protection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (ddosProtectionConfigProp )) && (ok || ! reflect .DeepEqual (v , ddosProtectionConfigProp )) {
714
764
obj ["ddosProtectionConfig" ] = ddosProtectionConfigProp
715
765
}
766
+ advancedOptionsConfigProp , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfig (d .Get ("advanced_options_config" ), d , config )
767
+ if err != nil {
768
+ return err
769
+ } else if v , ok := d .GetOkExists ("advanced_options_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (advancedOptionsConfigProp )) && (ok || ! reflect .DeepEqual (v , advancedOptionsConfigProp )) {
770
+ obj ["advancedOptionsConfig" ] = advancedOptionsConfigProp
771
+ }
716
772
userDefinedFieldsProp , err := expandComputeRegionSecurityPolicyUserDefinedFields (d .Get ("user_defined_fields" ), d , config )
717
773
if err != nil {
718
774
return err
@@ -848,6 +904,9 @@ func resourceComputeRegionSecurityPolicyRead(d *schema.ResourceData, meta interf
848
904
if err := d .Set ("ddos_protection_config" , flattenComputeRegionSecurityPolicyDdosProtectionConfig (res ["ddosProtectionConfig" ], d , config )); err != nil {
849
905
return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
850
906
}
907
+ if err := d .Set ("advanced_options_config" , flattenComputeRegionSecurityPolicyAdvancedOptionsConfig (res ["advancedOptionsConfig" ], d , config )); err != nil {
908
+ return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
909
+ }
851
910
if err := d .Set ("self_link" , flattenComputeRegionSecurityPolicySelfLink (res ["selfLink" ], d , config )); err != nil {
852
911
return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
853
912
}
@@ -901,6 +960,12 @@ func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta inte
901
960
} else if v , ok := d .GetOkExists ("ddos_protection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , ddosProtectionConfigProp )) {
902
961
obj ["ddosProtectionConfig" ] = ddosProtectionConfigProp
903
962
}
963
+ advancedOptionsConfigProp , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfig (d .Get ("advanced_options_config" ), d , config )
964
+ if err != nil {
965
+ return err
966
+ } else if v , ok := d .GetOkExists ("advanced_options_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , advancedOptionsConfigProp )) {
967
+ obj ["advancedOptionsConfig" ] = advancedOptionsConfigProp
968
+ }
904
969
userDefinedFieldsProp , err := expandComputeRegionSecurityPolicyUserDefinedFields (d .Get ("user_defined_fields" ), d , config )
905
970
if err != nil {
906
971
return err
@@ -935,6 +1000,10 @@ func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta inte
935
1000
updateMask = append (updateMask , "ddosProtectionConfig" )
936
1001
}
937
1002
1003
+ if d .HasChange ("advanced_options_config" ) {
1004
+ updateMask = append (updateMask , "advancedOptionsConfig" )
1005
+ }
1006
+
938
1007
if d .HasChange ("user_defined_fields" ) {
939
1008
updateMask = append (updateMask , "userDefinedFields" )
940
1009
}
@@ -1099,6 +1168,60 @@ func flattenComputeRegionSecurityPolicyDdosProtectionConfigDdosProtection(v inte
1099
1168
return v
1100
1169
}
1101
1170
1171
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1172
+ if v == nil {
1173
+ return nil
1174
+ }
1175
+ original := v .(map [string ]interface {})
1176
+ if len (original ) == 0 {
1177
+ return nil
1178
+ }
1179
+ transformed := make (map [string ]interface {})
1180
+ transformed ["json_parsing" ] =
1181
+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (original ["jsonParsing" ], d , config )
1182
+ transformed ["json_custom_config" ] =
1183
+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (original ["jsonCustomConfig" ], d , config )
1184
+ transformed ["log_level" ] =
1185
+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (original ["logLevel" ], d , config )
1186
+ transformed ["user_ip_request_headers" ] =
1187
+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (original ["userIpRequestHeaders" ], d , config )
1188
+ return []interface {}{transformed }
1189
+ }
1190
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1191
+ return v
1192
+ }
1193
+
1194
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1195
+ if v == nil {
1196
+ return nil
1197
+ }
1198
+ original := v .(map [string ]interface {})
1199
+ if len (original ) == 0 {
1200
+ return nil
1201
+ }
1202
+ transformed := make (map [string ]interface {})
1203
+ transformed ["content_types" ] =
1204
+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (original ["contentTypes" ], d , config )
1205
+ return []interface {}{transformed }
1206
+ }
1207
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1208
+ if v == nil {
1209
+ return v
1210
+ }
1211
+ return schema .NewSet (schema .HashString , v .([]interface {}))
1212
+ }
1213
+
1214
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1215
+ return v
1216
+ }
1217
+
1218
+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1219
+ if v == nil {
1220
+ return v
1221
+ }
1222
+ return schema .NewSet (schema .HashString , v .([]interface {}))
1223
+ }
1224
+
1102
1225
func flattenComputeRegionSecurityPolicySelfLink (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1103
1226
return v
1104
1227
}
@@ -1749,6 +1872,83 @@ func expandComputeRegionSecurityPolicyDdosProtectionConfigDdosProtection(v inter
1749
1872
return v , nil
1750
1873
}
1751
1874
1875
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1876
+ l := v .([]interface {})
1877
+ if len (l ) == 0 || l [0 ] == nil {
1878
+ return nil , nil
1879
+ }
1880
+ raw := l [0 ]
1881
+ original := raw .(map [string ]interface {})
1882
+ transformed := make (map [string ]interface {})
1883
+
1884
+ transformedJsonParsing , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (original ["json_parsing" ], d , config )
1885
+ if err != nil {
1886
+ return nil , err
1887
+ } else if val := reflect .ValueOf (transformedJsonParsing ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1888
+ transformed ["jsonParsing" ] = transformedJsonParsing
1889
+ }
1890
+
1891
+ transformedJsonCustomConfig , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (original ["json_custom_config" ], d , config )
1892
+ if err != nil {
1893
+ return nil , err
1894
+ } else if val := reflect .ValueOf (transformedJsonCustomConfig ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1895
+ transformed ["jsonCustomConfig" ] = transformedJsonCustomConfig
1896
+ }
1897
+
1898
+ transformedLogLevel , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (original ["log_level" ], d , config )
1899
+ if err != nil {
1900
+ return nil , err
1901
+ } else if val := reflect .ValueOf (transformedLogLevel ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1902
+ transformed ["logLevel" ] = transformedLogLevel
1903
+ }
1904
+
1905
+ transformedUserIpRequestHeaders , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (original ["user_ip_request_headers" ], d , config )
1906
+ if err != nil {
1907
+ return nil , err
1908
+ } else if val := reflect .ValueOf (transformedUserIpRequestHeaders ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1909
+ transformed ["userIpRequestHeaders" ] = transformedUserIpRequestHeaders
1910
+ }
1911
+
1912
+ return transformed , nil
1913
+ }
1914
+
1915
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1916
+ return v , nil
1917
+ }
1918
+
1919
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1920
+ l := v .([]interface {})
1921
+ if len (l ) == 0 || l [0 ] == nil {
1922
+ return nil , nil
1923
+ }
1924
+ raw := l [0 ]
1925
+ original := raw .(map [string ]interface {})
1926
+ transformed := make (map [string ]interface {})
1927
+
1928
+ transformedContentTypes , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (original ["content_types" ], d , config )
1929
+ if err != nil {
1930
+ return nil , err
1931
+ } else if val := reflect .ValueOf (transformedContentTypes ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1932
+ transformed ["contentTypes" ] = transformedContentTypes
1933
+ }
1934
+
1935
+ return transformed , nil
1936
+ }
1937
+
1938
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1939
+ v = v .(* schema.Set ).List ()
1940
+ return v , nil
1941
+ }
1942
+
1943
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1944
+ return v , nil
1945
+ }
1946
+
1947
+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1948
+ v = v .(* schema.Set ).List ()
1949
+ return v , nil
1950
+ }
1951
+
1752
1952
func expandComputeRegionSecurityPolicyUserDefinedFields (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1753
1953
l := v .([]interface {})
1754
1954
req := make ([]interface {}, 0 , len (l ))
0 commit comments