// 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/waas"
)

func ExampleUpdateWafConfig() {
	// 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 := waas.NewWaasClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).

	req := waas.UpdateWafConfigRequest{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
			Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
			Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(133791),
				IsEnabled:                          common.Bool(false),
				MaxAddressCount:                    common.Int(6301),
				MaxAddressCountExpirationInSeconds: common.Int(360411),
				Action:                             waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:          common.Int(425349),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(744),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage},
				FailureThreshold: common.Int(702956)},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(28057),
				MediaTypes:                  []string{"EXAMPLE--Value"},
				BlockErrorPageCode:          common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:       common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxArgumentCount:            common.Int(3509),
				MaxNameLengthPerArgument:    common.Int(80981),
				RecommendationsPeriodInDays: common.Int(87),
				AllowedHttpMethods:          []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
				BlockAction:                 waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageDescription:   common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:           common.Int(267),
				IsResponseInspected:         common.Bool(false),
				MaxResponseSizeInKiB:        common.Int(1390)},
			CachingRules: []waas.CachingRule{waas.CachingRule{IsClientCachingEnabled: common.Bool(true),
				Key:                   common.String("EXAMPLE-key-Value"),
				Name:                  common.String("EXAMPLE-name-Value"),
				Action:                waas.CachingRuleActionBypassCache,
				CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartContains,
					Value: common.String("EXAMPLE-value-Value")}}}},
			JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(80882),
				AreRedirectsChallenged:    common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:     common.Int(172),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold: common.Int(682266),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIsNot,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				IsEnabled:    common.Bool(true),
				IsNatEnabled: common.Bool(false)},
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Description: common.String("EXAMPLE-description-Value"),
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
				Key:                common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"},
				Name:               common.String("EXAMPLE-name-Value"),
				Action:             waas.ProtectionRuleActionOff}},
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionDetect,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value")}},
			AccessRules: []waas.AccessRule{waas.AccessRule{BlockAction: waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				BlockResponseCode:  common.Int(678),
				CaptchaHeader:      common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:       common.String("EXAMPLE-captchaTitle-Value"),
				RedirectUrl:        common.String("EXAMPLE-redirectUrl-Value"),
				CaptchaFooter:      common.String("EXAMPLE-captchaFooter-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIsNot,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				Name:                  common.String("EXAMPLE-name-Value"),
				Action:                waas.AccessRuleActionDetect,
				BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeFound}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(300656),
				InteractionThreshold:      common.Int(67),
				IsEnabled:                 common.Bool(true),
				IsNatEnabled:              common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(606),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
				FailureThreshold:                    common.Int(599606),
				FailureThresholdExpirationInSeconds: common.Int(271092),
				RecordingPeriodInSeconds:            common.Int(11977)},
			Origin: common.String("EXAMPLE-origin-Value"),
			Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
				AddressLists: []string{"EXAMPLE--Value"},
				Addresses:    []string{"EXAMPLE--Value"}}},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(8310),
				BlockResponseCode:         common.Int(270),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(2294)},
			GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
				IsEnabled: common.Bool(false),
				Key:       common.String("EXAMPLE-key-Value"),
				Name:      common.String("EXAMPLE-name-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{Title: common.String("EXAMPLE-title-Value"),
				Url:                        common.String("EXAMPLE-url-Value"),
				FailureMessage:             common.String("EXAMPLE-failureMessage-Value"),
				FooterText:                 common.String("EXAMPLE-footerText-Value"),
				HeaderText:                 common.String("EXAMPLE-headerText-Value"),
				SessionExpirationInSeconds: common.Int(125477),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("DBUNP2D5AVULLWA9B9U0<unique_ID>")}

	// Send the request using the service client
	resp, err := client.UpdateWafConfig(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}