// 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{OpcRequestId: common.String("QLLGAWNANUIAPPLNDORH<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		CreateWebAppFirewallPolicyDetails: waf.CreateWebAppFirewallPolicyDetails{RequestProtection: &waf.RequestProtection{BodyInspectionSizeLimitExceededActionName: common.String("EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value"),
			BodyInspectionSizeLimitInBytes: common.Int(761),
			Rules: []waf.ProtectionRule{waf.ProtectionRule{IsBodyInspectionEnabled: common.Bool(false),
				Name: common.String("EXAMPLE-name-Value"),
				ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{ActionName: common.String("EXAMPLE-actionName-Value"),
					CollaborativeActionThreshold: common.Int(214),
					CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
						Weight: common.Int(166)}},
					Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
						RequestCookies: []string{"EXAMPLE--Value"}},
					Key:     common.String("EXAMPLE-key-Value"),
					Version: common.Int(216)}},
				ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxSingleArgumentLength: common.Int(929668),
					MaxTotalArgumentLength:     common.Int(2.1760867e+07),
					AllowedHttpMethods:         []string{"EXAMPLE--Value"},
					MaxHttpRequestHeaderLength: common.Int(650931),
					MaxHttpRequestHeaders:      common.Int(819),
					MaxNumberOfArguments:       common.Int(3039)},
				ActionName:        common.String("EXAMPLE-actionName-Value"),
				Condition:         common.String("EXAMPLE-condition-Value"),
				ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath}}},
			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(101),
					ActionDurationInSeconds: common.Int(20738),
					PeriodInSeconds:         common.Int(59420)}},
				Name: common.String("EXAMPLE-name-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")}}},
			ResponseProtection: &waf.ResponseProtection{Rules: []waf.ProtectionRule{waf.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
				ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{CollaborativeActionThreshold: common.Int(796),
					CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
						Weight: common.Int(207)}},
					Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
						RequestCookies: []string{"EXAMPLE--Value"}},
					Key:        common.String("EXAMPLE-key-Value"),
					Version:    common.Int(249),
					ActionName: common.String("EXAMPLE-actionName-Value")}},
				ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxSingleArgumentLength: common.Int(382361),
					MaxTotalArgumentLength:     common.Int(5.1642692e+07),
					AllowedHttpMethods:         []string{"EXAMPLE--Value"},
					MaxHttpRequestHeaderLength: common.Int(337192),
					MaxHttpRequestHeaders:      common.Int(298),
					MaxNumberOfArguments:       common.Int(2163)},
				ActionName:              common.String("EXAMPLE-actionName-Value"),
				Condition:               common.String("EXAMPLE-condition-Value"),
				ConditionLanguage:       waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
				IsBodyInspectionEnabled: common.Bool(true)}}},
			Actions:       []waf.Action{waf.CheckAction{Name: common.String("EXAMPLE-name-Value")}},
			DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_eA4jB": map[string]interface{}{"EXAMPLE_KEY_T5bef": "EXAMPLE--Value"}},
			FreeformTags:  map[string]string{"EXAMPLE_KEY_PBYg3": "EXAMPLE_VALUE_4CAOmqntlm2vFmTPFFBp"},
			SystemTags:    map[string]map[string]interface{}{"EXAMPLE_KEY_4vRld": map[string]interface{}{"EXAMPLE_KEY_vaL69": "EXAMPLE--Value"}},
			CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
			DisplayName:   common.String("EXAMPLE-displayName-Value"),
			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")}}}

	// 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)
}