// 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{OpcRequestId: common.String("ALXSUU6IVQNJYLVDQIUC<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
			Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
			Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(347182),
				FailureThreshold:     common.Int(77036),
				InteractionThreshold: common.Int(10),
				IsEnabled:            common.Bool(false),
				IsNatEnabled:         common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action: waas.HumanInteractionChallengeActionDetect,
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(375),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
				FailureThresholdExpirationInSeconds: common.Int(345315),
				RecordingPeriodInSeconds:            common.Int(400)},
			AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				Name:                      common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockAction:               waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				Action:             waas.AccessRuleActionShowCaptcha,
				BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BypassChallenges:   []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaFooter:      common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockResponseCode:  common.Int(673),
				RedirectUrl:        common.String("EXAMPLE-redirectUrl-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(528),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode},
				FailureThreshold:                    common.Int(260964),
				FailureThresholdExpirationInSeconds: common.Int(243177),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(8130),
				MaxAddressCountExpirationInSeconds:  common.Int(401961),
				Action:                              waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:           common.Int(29690)},
			ProtectionSettings: &waas.ProtectionSettings{MaxNameLengthPerArgument: common.Int(87361),
				MaxResponseSizeInKiB:          common.Int(1824),
				MaxTotalNameLengthOfArguments: common.Int(227848),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(850),
				IsResponseInspected:           common.Bool(true),
				RecommendationsPeriodInDays:   common.Int(76),
				BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				MaxArgumentCount:              common.Int(7859)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(5552),
				AllowedRatePerAddress:     common.Int(9729),
				BlockResponseCode:         common.Int(299)},
			GoodBots: []waas.GoodBot{waas.GoodBot{IsEnabled: common.Bool(true),
				Key:         common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value"),
				Description: common.String("EXAMPLE-description-Value")}},
			JsChallenge: &waas.JsChallenge{SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(15393),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(385),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha},
				FailureThreshold:       common.Int(194961),
				Action:                 waas.JsChallengeActionDetect,
				AreRedirectsChallenged: common.Bool(true),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition:       waas.AccessRuleCriteriaConditionUrlIsNot,
					IsCaseSensitive: common.Bool(true)}},
				IsEnabled:    common.Bool(false),
				IsNatEnabled: common.Bool(false)},
			Origin: common.String("EXAMPLE-origin-Value"),
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionBlock,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value")}},
			CachingRules: []waas.CachingRule{waas.CachingRule{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")}},
				IsClientCachingEnabled: common.Bool(true)}},
			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(84507),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Description: common.String("EXAMPLE-description-Value"),
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetArgs}},
				Key:                common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"},
				Name:               common.String("EXAMPLE-name-Value"),
				Action:             waas.ProtectionRuleActionDetect}}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:      common.String("EXAMPLE-ifMatch-Value")}

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