// 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 ExampleCreateWebAppFirewallPolicy() {
// 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.CreateWebAppFirewallPolicyRequest{CreateWebAppFirewallPolicyDetails: waf.CreateWebAppFirewallPolicyDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_Rx7GO": "EXAMPLE_VALUE_8jqE50NDj69DwZ5bklKg"},
RequestAccessControl: &waf.RequestAccessControl{Rules: []waf.AccessControlRule{waf.AccessControlRule{ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
Name: common.String("EXAMPLE-name-Value")}},
DefaultActionName: common.String("EXAMPLE-defaultActionName-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(686),
ActionDurationInSeconds: common.Int(15998),
PeriodInSeconds: common.Int(77773)}},
Name: common.String("EXAMPLE-name-Value")}}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_jec9M": map[string]interface{}{"EXAMPLE_KEY_Jy6ti": "EXAMPLE--Value"}},
RequestProtection: &waf.RequestProtection{BodyInspectionSizeLimitExceededActionName: common.String("EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value"),
BodyInspectionSizeLimitInBytes: common.Int(827),
Rules: []waf.ProtectionRule{waf.ProtectionRule{ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxSingleArgumentLength: common.Int(542938),
MaxTotalArgumentLength: common.Int(1.3604205e+07),
AllowedHttpMethods: []string{"EXAMPLE--Value"},
MaxHttpRequestHeaderLength: common.Int(277616),
MaxHttpRequestHeaders: common.Int(995),
MaxNumberOfArguments: common.Int(6319)},
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{Version: common.Int(325),
ActionName: common.String("EXAMPLE-actionName-Value"),
CollaborativeActionThreshold: common.Int(374),
CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
Weight: common.Int(955)}},
Exclusions: &waf.ProtectionCapabilityExclusions{RequestCookies: []string{"EXAMPLE--Value"},
Args: []string{"EXAMPLE--Value"}},
Key: common.String("EXAMPLE-key-Value")}}}}},
ResponseAccessControl: &waf.ResponseAccessControl{Rules: []waf.AccessControlRule{waf.AccessControlRule{Name: common.String("EXAMPLE-name-Value"),
ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath}}},
ResponseProtection: &waf.ResponseProtection{Rules: []waf.ProtectionRule{waf.ProtectionRule{ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{CollaborativeActionThreshold: common.Int(946),
CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
Weight: common.Int(744)}},
Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
RequestCookies: []string{"EXAMPLE--Value"}},
Key: common.String("EXAMPLE-key-Value"),
Version: common.Int(473),
ActionName: common.String("EXAMPLE-actionName-Value")}},
ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxSingleArgumentLength: common.Int(228479),
MaxTotalArgumentLength: common.Int(1.3187639e+07),
AllowedHttpMethods: []string{"EXAMPLE--Value"},
MaxHttpRequestHeaderLength: common.Int(684735),
MaxHttpRequestHeaders: common.Int(701),
MaxNumberOfArguments: common.Int(5654)},
ActionName: common.String("EXAMPLE-actionName-Value"),
Condition: common.String("EXAMPLE-condition-Value"),
ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
IsBodyInspectionEnabled: common.Bool(true),
Name: common.String("EXAMPLE-name-Value")}}},
SystemTags: map[string]map[string]interface{}{"EXAMPLE_KEY_55q9y": map[string]interface{}{"EXAMPLE_KEY_cIcTR": "EXAMPLE--Value"}},
Actions: []waf.Action{waf.ReturnHttpResponseAction{Name: common.String("EXAMPLE-name-Value"),
Body: waf.DynamicHttpResponseBody{Template: common.String("EXAMPLE-template-Value")},
Code: common.Int(293),
Headers: []waf.ResponseHeader{waf.ResponseHeader{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}}}}},
OpcRequestId: common.String("CO4YQYV8CZFW2HE6FHKW<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateWebAppFirewallPolicy(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}