// 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{WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("RW75SQK8LIZEGANNOKRL<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
			Addresses: []string{"EXAMPLE--Value"},
			Name:      common.String("EXAMPLE-name-Value")}},
			CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(false),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value"),
				Action:                 waas.CachingRuleActionBypassCache,
				CachingDuration:        common.String("EXAMPLE-cachingDuration-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{IsEnabled: common.Bool(true),
				MaxAddressCount:                    common.Int(9481),
				MaxAddressCountExpirationInSeconds: common.Int(49346),
				Action:                             waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:          common.Int(224166),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(917),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
				FailureThreshold:                    common.Int(714445),
				FailureThresholdExpirationInSeconds: common.Int(145060)},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(225623),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(721),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				FailureThreshold: common.Int(532936),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                              waas.HumanInteractionChallengeActionBlock,
				FailureThresholdExpirationInSeconds: common.Int(30160),
				InteractionThreshold:                common.Int(90),
				IsEnabled:                           common.Bool(true),
				IsNatEnabled:                        common.Bool(true),
				RecordingPeriodInSeconds:            common.Int(5825)},
			ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxResponseSizeInKiB:          common.Int(1372),
				MaxTotalNameLengthOfArguments: common.Int(354276),
				RecommendationsPeriodInDays:   common.Int(92),
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:             common.Int(869),
				IsResponseInspected:           common.Bool(false),
				MaxArgumentCount:              common.Int(8055),
				MaxNameLengthPerArgument:      common.Int(80120),
				MediaTypes:                    []string{"EXAMPLE--Value"}},
			AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Name:                       common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockAction:                waas.AccessRuleBlockActionSetResponseCode,
				BlockResponseCode:          common.Int(553),
				BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
				CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
				RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
				Action:                     waas.AccessRuleActionBypass,
				BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
				BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpInList,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}}}},
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionBlock,
				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")}},
			Origin: common.String("EXAMPLE-origin-Value"),
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Name: common.String("EXAMPLE-name-Value"),
				Action:      waas.ThreatFeedActionBlock,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{FooterText: common.String("EXAMPLE-footerText-Value"),
				HeaderText:                 common.String("EXAMPLE-headerText-Value"),
				SessionExpirationInSeconds: common.Int(39032),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value"),
				Url:                        common.String("EXAMPLE-url-Value"),
				FailureMessage:             common.String("EXAMPLE-failureMessage-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgs,
				Exclusions: []string{"EXAMPLE--Value"}}},
				Id:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
				Action: waas.CustomProtectionRuleSettingActionDetect}},
			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")}},
			JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
				FailureThreshold: common.Int(448539),
				IsNatEnabled:     common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.JsChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(349379),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(151),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition:       waas.AccessRuleCriteriaConditionCountryIs,
					IsCaseSensitive: common.Bool(false)}},
				IsEnabled: common.Bool(true)},
			AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
				MaxDelayedCountPerAddress: common.Int(351),
				AllowedRatePerAddress:     common.Int(2332),
				BlockResponseCode:         common.Int(432)},
			OriginGroups: []string{"EXAMPLE--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)
}