// 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{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("HF4XUROROHKN92B6GJ1O<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(8411),
			BlockResponseCode:         common.Int(665),
			IsEnabled:                 common.Bool(true),
			MaxDelayedCountPerAddress: common.Int(1732)},
			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(339496),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetArgsNames}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{InteractionThreshold: common.Int(87),
				RecordingPeriodInSeconds: common.Int(13896),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(221050),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(697),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-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"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value")},
				IsEnabled:                           common.Bool(true),
				IsNatEnabled:                        common.Bool(true),
				FailureThreshold:                    common.Int(292599),
				FailureThresholdExpirationInSeconds: common.Int(424297)},
			Origin: common.String("EXAMPLE-origin-Value"),
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionOff,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value")}},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--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.CachingRuleActionCache,
				CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition: waas.CachingRuleCriteriaConditionIs}},
				IsClientCachingEnabled: common.Bool(true)}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(48967),
				IsEnabled:                          common.Bool(false),
				MaxAddressCount:                    common.Int(6501),
				MaxAddressCountExpirationInSeconds: common.Int(99645),
				Action:                             waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:          common.Int(298952),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(963),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha},
				FailureThreshold: common.Int(832414)},
			OriginGroups: []string{"EXAMPLE--Value"},
			AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionDetect,
				BlockAction:           waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpInList,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				Name: common.String("EXAMPLE-name-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
					Header: common.String("EXAMPLE-header-Value")}},
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockResponseCode:         common.Int(266),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")}},
			JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(42954),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(815),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold:       common.Int(598565),
				IsNatEnabled:           common.Bool(true),
				AreRedirectsChallenged: common.Bool(true),
				IsEnabled:              common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action: waas.JsChallengeActionDetect},
			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")}},
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
				Action:      waas.ProtectionRuleActionBlock,
				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"}}},
			ProtectionSettings: &waas.ProtectionSettings{MaxNameLengthPerArgument: common.Int(117546),
				MaxResponseSizeInKiB:          common.Int(1203),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPatch},
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxTotalNameLengthOfArguments: common.Int(314060),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(48),
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:             common.Int(870),
				IsResponseInspected:           common.Bool(true),
				MaxArgumentCount:              common.Int(8173)}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-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)
}