@@ -93,6 +93,63 @@ func ResourceComputeRegionSecurityPolicy() *schema.Resource {
9393 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.
9494Specifically, 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.` ,
9595 },
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+ "request_body_inspection_size" : {
135+ Type : schema .TypeString ,
136+ Optional : true ,
137+ ValidateFunc : verify .ValidateEnum ([]string {"8KB" , "16KB" , "32KB" , "48KB" , "64KB" , "" }),
138+ Description : `The maximum request size chosen by the customer with Waf enabled. Values supported are "8KB", "16KB, "32KB", "48KB" and "64KB".
139+ Values are case insensitive. Possible values: ["8KB", "16KB", "32KB", "48KB", "64KB"]` ,
140+ },
141+ "user_ip_request_headers" : {
142+ Type : schema .TypeSet ,
143+ Optional : true ,
144+ Description : `An optional list of case-insensitive request header names to use for resolving the callers client IP address.` ,
145+ Elem : & schema.Schema {
146+ Type : schema .TypeString ,
147+ },
148+ Set : schema .HashString ,
149+ },
150+ },
151+ },
152+ },
96153 "ddos_protection_config" : {
97154 Type : schema .TypeList ,
98155 Optional : true ,
@@ -713,6 +770,12 @@ func resourceComputeRegionSecurityPolicyCreate(d *schema.ResourceData, meta inte
713770 } else if v , ok := d .GetOkExists ("ddos_protection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (ddosProtectionConfigProp )) && (ok || ! reflect .DeepEqual (v , ddosProtectionConfigProp )) {
714771 obj ["ddosProtectionConfig" ] = ddosProtectionConfigProp
715772 }
773+ advancedOptionsConfigProp , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfig (d .Get ("advanced_options_config" ), d , config )
774+ if err != nil {
775+ return err
776+ } else if v , ok := d .GetOkExists ("advanced_options_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (advancedOptionsConfigProp )) && (ok || ! reflect .DeepEqual (v , advancedOptionsConfigProp )) {
777+ obj ["advancedOptionsConfig" ] = advancedOptionsConfigProp
778+ }
716779 userDefinedFieldsProp , err := expandComputeRegionSecurityPolicyUserDefinedFields (d .Get ("user_defined_fields" ), d , config )
717780 if err != nil {
718781 return err
@@ -848,6 +911,9 @@ func resourceComputeRegionSecurityPolicyRead(d *schema.ResourceData, meta interf
848911 if err := d .Set ("ddos_protection_config" , flattenComputeRegionSecurityPolicyDdosProtectionConfig (res ["ddosProtectionConfig" ], d , config )); err != nil {
849912 return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
850913 }
914+ if err := d .Set ("advanced_options_config" , flattenComputeRegionSecurityPolicyAdvancedOptionsConfig (res ["advancedOptionsConfig" ], d , config )); err != nil {
915+ return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
916+ }
851917 if err := d .Set ("self_link" , flattenComputeRegionSecurityPolicySelfLink (res ["selfLink" ], d , config )); err != nil {
852918 return fmt .Errorf ("Error reading RegionSecurityPolicy: %s" , err )
853919 }
@@ -901,6 +967,12 @@ func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta inte
901967 } else if v , ok := d .GetOkExists ("ddos_protection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , ddosProtectionConfigProp )) {
902968 obj ["ddosProtectionConfig" ] = ddosProtectionConfigProp
903969 }
970+ advancedOptionsConfigProp , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfig (d .Get ("advanced_options_config" ), d , config )
971+ if err != nil {
972+ return err
973+ } else if v , ok := d .GetOkExists ("advanced_options_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , advancedOptionsConfigProp )) {
974+ obj ["advancedOptionsConfig" ] = advancedOptionsConfigProp
975+ }
904976 userDefinedFieldsProp , err := expandComputeRegionSecurityPolicyUserDefinedFields (d .Get ("user_defined_fields" ), d , config )
905977 if err != nil {
906978 return err
@@ -935,6 +1007,10 @@ func resourceComputeRegionSecurityPolicyUpdate(d *schema.ResourceData, meta inte
9351007 updateMask = append (updateMask , "ddosProtectionConfig" )
9361008 }
9371009
1010+ if d .HasChange ("advanced_options_config" ) {
1011+ updateMask = append (updateMask , "advancedOptionsConfig" )
1012+ }
1013+
9381014 if d .HasChange ("user_defined_fields" ) {
9391015 updateMask = append (updateMask , "userDefinedFields" )
9401016 }
@@ -1099,6 +1175,66 @@ func flattenComputeRegionSecurityPolicyDdosProtectionConfigDdosProtection(v inte
10991175 return v
11001176}
11011177
1178+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1179+ if v == nil {
1180+ return nil
1181+ }
1182+ original := v .(map [string ]interface {})
1183+ if len (original ) == 0 {
1184+ return nil
1185+ }
1186+ transformed := make (map [string ]interface {})
1187+ transformed ["json_parsing" ] =
1188+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (original ["jsonParsing" ], d , config )
1189+ transformed ["json_custom_config" ] =
1190+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (original ["jsonCustomConfig" ], d , config )
1191+ transformed ["log_level" ] =
1192+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (original ["logLevel" ], d , config )
1193+ transformed ["user_ip_request_headers" ] =
1194+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (original ["userIpRequestHeaders" ], d , config )
1195+ transformed ["request_body_inspection_size" ] =
1196+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigRequestBodyInspectionSize (original ["requestBodyInspectionSize" ], d , config )
1197+ return []interface {}{transformed }
1198+ }
1199+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1200+ return v
1201+ }
1202+
1203+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1204+ if v == nil {
1205+ return nil
1206+ }
1207+ original := v .(map [string ]interface {})
1208+ if len (original ) == 0 {
1209+ return nil
1210+ }
1211+ transformed := make (map [string ]interface {})
1212+ transformed ["content_types" ] =
1213+ flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (original ["contentTypes" ], d , config )
1214+ return []interface {}{transformed }
1215+ }
1216+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1217+ if v == nil {
1218+ return v
1219+ }
1220+ return schema .NewSet (schema .HashString , v .([]interface {}))
1221+ }
1222+
1223+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1224+ return v
1225+ }
1226+
1227+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1228+ if v == nil {
1229+ return v
1230+ }
1231+ return schema .NewSet (schema .HashString , v .([]interface {}))
1232+ }
1233+
1234+ func flattenComputeRegionSecurityPolicyAdvancedOptionsConfigRequestBodyInspectionSize (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1235+ return v
1236+ }
1237+
11021238func flattenComputeRegionSecurityPolicySelfLink (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
11031239 return v
11041240}
@@ -1749,6 +1885,94 @@ func expandComputeRegionSecurityPolicyDdosProtectionConfigDdosProtection(v inter
17491885 return v , nil
17501886}
17511887
1888+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1889+ l := v .([]interface {})
1890+ if len (l ) == 0 || l [0 ] == nil {
1891+ return nil , nil
1892+ }
1893+ raw := l [0 ]
1894+ original := raw .(map [string ]interface {})
1895+ transformed := make (map [string ]interface {})
1896+
1897+ transformedJsonParsing , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (original ["json_parsing" ], d , config )
1898+ if err != nil {
1899+ return nil , err
1900+ } else if val := reflect .ValueOf (transformedJsonParsing ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1901+ transformed ["jsonParsing" ] = transformedJsonParsing
1902+ }
1903+
1904+ transformedJsonCustomConfig , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (original ["json_custom_config" ], d , config )
1905+ if err != nil {
1906+ return nil , err
1907+ } else if val := reflect .ValueOf (transformedJsonCustomConfig ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1908+ transformed ["jsonCustomConfig" ] = transformedJsonCustomConfig
1909+ }
1910+
1911+ transformedLogLevel , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (original ["log_level" ], d , config )
1912+ if err != nil {
1913+ return nil , err
1914+ } else if val := reflect .ValueOf (transformedLogLevel ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1915+ transformed ["logLevel" ] = transformedLogLevel
1916+ }
1917+
1918+ transformedUserIpRequestHeaders , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (original ["user_ip_request_headers" ], d , config )
1919+ if err != nil {
1920+ return nil , err
1921+ } else if val := reflect .ValueOf (transformedUserIpRequestHeaders ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1922+ transformed ["userIpRequestHeaders" ] = transformedUserIpRequestHeaders
1923+ }
1924+
1925+ transformedRequestBodyInspectionSize , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigRequestBodyInspectionSize (original ["request_body_inspection_size" ], d , config )
1926+ if err != nil {
1927+ return nil , err
1928+ } else if val := reflect .ValueOf (transformedRequestBodyInspectionSize ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1929+ transformed ["requestBodyInspectionSize" ] = transformedRequestBodyInspectionSize
1930+ }
1931+
1932+ return transformed , nil
1933+ }
1934+
1935+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonParsing (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1936+ return v , nil
1937+ }
1938+
1939+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1940+ l := v .([]interface {})
1941+ if len (l ) == 0 || l [0 ] == nil {
1942+ return nil , nil
1943+ }
1944+ raw := l [0 ]
1945+ original := raw .(map [string ]interface {})
1946+ transformed := make (map [string ]interface {})
1947+
1948+ transformedContentTypes , err := expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (original ["content_types" ], d , config )
1949+ if err != nil {
1950+ return nil , err
1951+ } else if val := reflect .ValueOf (transformedContentTypes ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1952+ transformed ["contentTypes" ] = transformedContentTypes
1953+ }
1954+
1955+ return transformed , nil
1956+ }
1957+
1958+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigJsonCustomConfigContentTypes (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1959+ v = v .(* schema.Set ).List ()
1960+ return v , nil
1961+ }
1962+
1963+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigLogLevel (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1964+ return v , nil
1965+ }
1966+
1967+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigUserIpRequestHeaders (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1968+ v = v .(* schema.Set ).List ()
1969+ return v , nil
1970+ }
1971+
1972+ func expandComputeRegionSecurityPolicyAdvancedOptionsConfigRequestBodyInspectionSize (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1973+ return v , nil
1974+ }
1975+
17521976func expandComputeRegionSecurityPolicyUserDefinedFields (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
17531977 l := v .([]interface {})
17541978 req := make ([]interface {}, 0 , len (l ))
0 commit comments