// 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{CachingRules: []waas.CachingRule{waas.CachingRule{Name: common.String("EXAMPLE-name-Value"),
			Action:                waas.CachingRuleActionCache,
			CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
			ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
			Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
				Value: common.String("EXAMPLE-value-Value")}},
			IsClientCachingEnabled: common.Bool(true),
			Key:                    common.String("EXAMPLE-key-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(592),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				FailureThresholdExpirationInSeconds: common.Int(159366),
				IsEnabled:                           common.Bool(true),
				IsNatEnabled:                        common.Bool(true),
				Action:                              waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds:           common.Int(423396),
				FailureThreshold:                    common.Int(274352),
				InteractionThreshold:                common.Int(17),
				RecordingPeriodInSeconds:            common.Int(4338),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			Origin: common.String("EXAMPLE-origin-Value"),
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionDetect,
				Description: common.String("EXAMPLE-description-Value"),
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
				Key:                common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"},
				Name:               common.String("EXAMPLE-name-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(342),
				IsEnabled:                 common.Bool(true),
				MaxDelayedCountPerAddress: common.Int(5175),
				AllowedRatePerAddress:     common.Int(3798)},
			Captchas: []waas.Captcha{waas.Captcha{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(349879),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value")}},
			OriginGroups: []string{"EXAMPLE--Value"},
			AccessRules: []waas.AccessRule{waas.AccessRule{ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIs,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				Action:                    waas.AccessRuleActionBlock,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
				BlockAction:               waas.AccessRuleBlockActionSetResponseCode,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:         common.Int(932),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Name:                      common.String("EXAMPLE-name-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(152),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold:                    common.Int(888273),
				FailureThresholdExpirationInSeconds: common.Int(239679),
				IsEnabled:                           common.Bool(true),
				MaxAddressCount:                     common.Int(7174),
				MaxAddressCountExpirationInSeconds:  common.Int(403675),
				Action:                              waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:           common.Int(49346)},
			GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
				IsEnabled: common.Bool(true),
				Key:       common.String("EXAMPLE-key-Value"),
				Name:      common.String("EXAMPLE-name-Value")}},
			JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(330296),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIsNot,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold:       common.Int(313648),
				IsEnabled:              common.Bool(true),
				IsNatEnabled:           common.Bool(false),
				AreRedirectsChallenged: common.Bool(false),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(765),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			ProtectionSettings: &waas.ProtectionSettings{RecommendationsPeriodInDays: common.Int(42),
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(979),
				MaxTotalNameLengthOfArguments: common.Int(217244),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPut},
				BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				IsResponseInspected:           common.Bool(true),
				MaxArgumentCount:              common.Int(1702),
				MaxNameLengthPerArgument:      common.Int(5725),
				MaxResponseSizeInKiB:          common.Int(681)},
			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")}},
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Description: common.String("EXAMPLE-description-Value"),
				Key:    common.String("EXAMPLE-key-Value"),
				Name:   common.String("EXAMPLE-name-Value"),
				Action: waas.ThreatFeedActionOff}},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("5SQK8LIZEGANNOKRLFGY<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)
}