// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
"github.com/oracle/oci-go-sdk/v65/waf"
)
func ExampleUpdateWebAppFirewallPolicy() {
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
client, err := waf.NewWafClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := waf.UpdateWebAppFirewallPolicyRequest{OpcRequestId: common.String("KU0N2OB9QFV8RW3HNNQH<unique_ID>"),
UpdateWebAppFirewallPolicyDetails: waf.UpdateWebAppFirewallPolicyDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_7r9pi": map[string]interface{}{"EXAMPLE_KEY_b5VtF": "EXAMPLE--Value"}},
RequestAccessControl: &waf.RequestAccessControl{DefaultActionName: common.String("EXAMPLE-defaultActionName-Value"),
Rules: []waf.AccessControlRule{waf.AccessControlRule{Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
Name: common.String("EXAMPLE-name-Value"),
ActionName: common.String("EXAMPLE-actionName-Value")}}},
RequestProtection: &waf.RequestProtection{BodyInspectionSizeLimitInBytes: common.Int(550),
Rules: []waf.ProtectionRule{waf.ProtectionRule{IsBodyInspectionEnabled: common.Bool(true),
Name: common.String("EXAMPLE-name-Value"),
ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{ActionName: common.String("EXAMPLE-actionName-Value"),
CollaborativeActionThreshold: common.Int(353),
CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
Weight: common.Int(633)}},
Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
RequestCookies: []string{"EXAMPLE--Value"}},
Key: common.String("EXAMPLE-key-Value"),
Version: common.Int(857)}},
ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{AllowedHttpMethods: []string{"EXAMPLE--Value"},
MaxHttpRequestHeaderLength: common.Int(632435),
MaxHttpRequestHeaders: common.Int(363),
MaxNumberOfArguments: common.Int(2548),
MaxSingleArgumentLength: common.Int(609874),
MaxTotalArgumentLength: common.Int(2.7698595e+07)},
ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath}},
BodyInspectionSizeLimitExceededActionName: common.String("EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value")},
RequestRateLimiting: &waf.RequestRateLimiting{Rules: []waf.RequestRateLimitingRule{waf.RequestRateLimitingRule{ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
Configurations: []waf.RequestRateLimitingConfiguration{waf.RequestRateLimitingConfiguration{RequestsLimit: common.Int(462),
ActionDurationInSeconds: common.Int(82347),
PeriodInSeconds: common.Int(36126)}},
Name: common.String("EXAMPLE-name-Value")}}},
ResponseAccessControl: &waf.ResponseAccessControl{Rules: []waf.AccessControlRule{waf.AccessControlRule{Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
Name: common.String("EXAMPLE-name-Value"),
ActionName: common.String("EXAMPLE-actionName-Value")}}},
Actions: []waf.Action{waf.ReturnHttpResponseAction{Body: waf.StaticTextHttpResponseBody{Text: common.String("EXAMPLE-text-Value")},
Code: common.Int(496),
Headers: []waf.ResponseHeader{waf.ResponseHeader{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Name: common.String("EXAMPLE-name-Value")}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_e0xj8": "EXAMPLE_VALUE_myCBl8ehFaVKq15MersG"},
ResponseProtection: &waf.ResponseProtection{Rules: []waf.ProtectionRule{waf.ProtectionRule{ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxHttpRequestHeaderLength: common.Int(814014),
MaxHttpRequestHeaders: common.Int(490),
MaxNumberOfArguments: common.Int(3827),
MaxSingleArgumentLength: common.Int(52546),
MaxTotalArgumentLength: common.Int(3.9334017e+07),
AllowedHttpMethods: []string{"EXAMPLE--Value"}},
ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
IsBodyInspectionEnabled: common.Bool(false),
Name: common.String("EXAMPLE-name-Value"),
ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{ActionName: common.String("EXAMPLE-actionName-Value"),
CollaborativeActionThreshold: common.Int(782),
CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
Weight: common.Int(782)}},
Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
RequestCookies: []string{"EXAMPLE--Value"}},
Key: common.String("EXAMPLE-key-Value"),
Version: common.Int(933)}}}}},
SystemTags: map[string]map[string]interface{}{"EXAMPLE_KEY_EOv6P": map[string]interface{}{"EXAMPLE_KEY_du7FG": "EXAMPLE--Value"}}},
WebAppFirewallPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-webAppFirewallPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-Value")}
// Send the request using the service client
resp, err := client.UpdateWebAppFirewallPolicy(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}