// 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{RequestProtection: &waf.RequestProtection{BodyInspectionSizeLimitExceededActionName: common.String("EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value"),
		BodyInspectionSizeLimitInBytes: common.Int(883),
		Rules: []waf.ProtectionRule{waf.ProtectionRule{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{CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
				Weight: common.Int(259)}},
				Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
					RequestCookies: []string{"EXAMPLE--Value"}},
				Key:                          common.String("EXAMPLE-key-Value"),
				Version:                      common.Int(862),
				ActionName:                   common.String("EXAMPLE-actionName-Value"),
				CollaborativeActionThreshold: common.Int(547)}},
			ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxTotalArgumentLength: common.Int(5.7716155e+07),
				AllowedHttpMethods:         []string{"EXAMPLE--Value"},
				MaxHttpRequestHeaderLength: common.Int(144090),
				MaxHttpRequestHeaders:      common.Int(111),
				MaxNumberOfArguments:       common.Int(6231),
				MaxSingleArgumentLength:    common.Int(746525)}}}},
		RequestRateLimiting: &waf.RequestRateLimiting{Rules: []waf.RequestRateLimitingRule{waf.RequestRateLimitingRule{Configurations: []waf.RequestRateLimitingConfiguration{waf.RequestRateLimitingConfiguration{ActionDurationInSeconds: common.Int(80246),
			PeriodInSeconds: common.Int(66051),
			RequestsLimit:   common.Int(906)}},
			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{IsBodyInspectionEnabled: common.Bool(true),
			Name: common.String("EXAMPLE-name-Value"),
			ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{CollaborativeActionThreshold: common.Int(780),
				CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
					Weight: common.Int(828)}},
				Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
					RequestCookies: []string{"EXAMPLE--Value"}},
				Key:        common.String("EXAMPLE-key-Value"),
				Version:    common.Int(534),
				ActionName: common.String("EXAMPLE-actionName-Value")}},
			ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxTotalArgumentLength: common.Int(5.9458922e+07),
				AllowedHttpMethods:         []string{"EXAMPLE--Value"},
				MaxHttpRequestHeaderLength: common.Int(428355),
				MaxHttpRequestHeaders:      common.Int(577),
				MaxNumberOfArguments:       common.Int(287),
				MaxSingleArgumentLength:    common.Int(896122)},
			ActionName:        common.String("EXAMPLE-actionName-Value"),
			Condition:         common.String("EXAMPLE-condition-Value"),
			ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath}}},
		Actions:       []waf.Action{waf.AllowAction{Name: common.String("EXAMPLE-name-Value")}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_q4JR2": map[string]interface{}{"EXAMPLE_KEY_e4APt": "EXAMPLE--Value"}},
		DisplayName:   common.String("EXAMPLE-displayName-Value"),
		ResponseAccessControl: &waf.ResponseAccessControl{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")}}},
		SystemTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_C8bCO": map[string]interface{}{"EXAMPLE_KEY_hUANb": "EXAMPLE--Value"}},
		FreeformTags: map[string]string{"EXAMPLE_KEY_x0H1Z": "EXAMPLE_VALUE_GZjzxZLnJAi6CcRh6yzf"},
		RequestAccessControl: &waf.RequestAccessControl{DefaultActionName: common.String("EXAMPLE-defaultActionName-Value"),
			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}}}},
		OpcRequestId:  common.String("BGAFNE0XJ8MYCBL8EHFA<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)
}