// 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{DisplayName: common.String("EXAMPLE-displayName-Value"),
		FreeformTags: map[string]string{"EXAMPLE_KEY_JwyfE": "EXAMPLE_VALUE_DG9sHdYtQhnmR3omQLE8"},
		ResponseAccessControl: &waf.ResponseAccessControl{Rules: []waf.AccessControlRule{waf.AccessControlRule{ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
			Name:       common.String("EXAMPLE-name-Value"),
			ActionName: common.String("EXAMPLE-actionName-Value"),
			Condition:  common.String("EXAMPLE-condition-Value")}}},
		Actions: []waf.Action{waf.ReturnHttpResponseAction{Code: common.Int(203),
			Headers: []waf.ResponseHeader{waf.ResponseHeader{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
			Name: common.String("EXAMPLE-name-Value"),
			Body: waf.StaticTextHttpResponseBody{Text: common.String("EXAMPLE-text-Value")}}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_SaA53": map[string]interface{}{"EXAMPLE_KEY_tOhJs": "EXAMPLE--Value"}},
		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}}},
		RequestProtection: &waf.RequestProtection{BodyInspectionSizeLimitExceededActionName: common.String("EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value"),
			BodyInspectionSizeLimitInBytes: common.Int(740),
			Rules: []waf.ProtectionRule{waf.ProtectionRule{ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{Key: common.String("EXAMPLE-key-Value"),
				Version:                      common.Int(729),
				ActionName:                   common.String("EXAMPLE-actionName-Value"),
				CollaborativeActionThreshold: common.Int(324),
				CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Key: common.String("EXAMPLE-key-Value"),
					Weight: common.Int(922)}},
				Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
					RequestCookies: []string{"EXAMPLE--Value"}}}},
				ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{AllowedHttpMethods: []string{"EXAMPLE--Value"},
					MaxHttpRequestHeaderLength: common.Int(28082),
					MaxHttpRequestHeaders:      common.Int(518),
					MaxNumberOfArguments:       common.Int(7800),
					MaxSingleArgumentLength:    common.Int(652013),
					MaxTotalArgumentLength:     common.Int(5.344678e+06)},
				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")}}},
		RequestRateLimiting: &waf.RequestRateLimiting{Rules: []waf.RequestRateLimitingRule{waf.RequestRateLimitingRule{Name: common.String("EXAMPLE-name-Value"),
			ActionName:        common.String("EXAMPLE-actionName-Value"),
			Condition:         common.String("EXAMPLE-condition-Value"),
			ConditionLanguage: waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
			Configurations: []waf.RequestRateLimitingConfiguration{waf.RequestRateLimitingConfiguration{ActionDurationInSeconds: common.Int(71995),
				PeriodInSeconds: common.Int(804),
				RequestsLimit:   common.Int(761)}}}}},
		ResponseProtection: &waf.ResponseProtection{Rules: []waf.ProtectionRule{waf.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
			ProtectionCapabilities: []waf.ProtectionCapability{waf.ProtectionCapability{ActionName: common.String("EXAMPLE-actionName-Value"),
				CollaborativeActionThreshold: common.Int(137),
				CollaborativeWeights: []waf.CollaborativeCapabilityWeightOverride{waf.CollaborativeCapabilityWeightOverride{Weight: common.Int(945),
					Key: common.String("EXAMPLE-key-Value")}},
				Exclusions: &waf.ProtectionCapabilityExclusions{Args: []string{"EXAMPLE--Value"},
					RequestCookies: []string{"EXAMPLE--Value"}},
				Key:     common.String("EXAMPLE-key-Value"),
				Version: common.Int(506)}},
			ProtectionCapabilitySettings: &waf.ProtectionCapabilitySettings{MaxNumberOfArguments: common.Int(2075),
				MaxSingleArgumentLength:    common.Int(182259),
				MaxTotalArgumentLength:     common.Int(3.0935969e+07),
				AllowedHttpMethods:         []string{"EXAMPLE--Value"},
				MaxHttpRequestHeaderLength: common.Int(394513),
				MaxHttpRequestHeaders:      common.Int(23)},
			ActionName:              common.String("EXAMPLE-actionName-Value"),
			Condition:               common.String("EXAMPLE-condition-Value"),
			ConditionLanguage:       waf.WebAppFirewallPolicyRuleConditionLanguageJmespath,
			IsBodyInspectionEnabled: common.Bool(true)}}},
		SystemTags: map[string]map[string]interface{}{"EXAMPLE_KEY_6OaRl": map[string]interface{}{"EXAMPLE_KEY_axD2N": "EXAMPLE--Value"}}},
		OpcRequestId:  common.String("5ONYFZETKXCUW6BLQNRP<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)
}