// 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("DDSCVVR9SRIWOSEDW8AJ<unique_ID>"),
		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(false),
			Key:                    common.String("EXAMPLE-key-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(237474),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
				Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgs,
					Exclusions: []string{"EXAMPLE--Value"}}}}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(214494),
				Action:                    waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(114029),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(695),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode},
				FailureThreshold:                    common.Int(561000),
				FailureThresholdExpirationInSeconds: common.Int(363976),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(668)},
			Origin: common.String("EXAMPLE-origin-Value"),
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Name: common.String("EXAMPLE-name-Value"),
				Action:      waas.ThreatFeedActionOff,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-Value")}},
			AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
				Name:                       common.String("EXAMPLE-name-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
				BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
				RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeFound,
				RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
				Action:                     waas.AccessRuleActionShowCaptcha,
				CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:          common.Int(244),
				BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}}}},
			GoodBots: []waas.GoodBot{waas.GoodBot{Key: common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value"),
				Description: common.String("EXAMPLE-description-Value"),
				IsEnabled:   common.Bool(false)}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(145846),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:     common.Int(978),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold: common.Int(701872),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				FailureThresholdExpirationInSeconds: common.Int(244657),
				InteractionThreshold:                common.Int(44),
				IsEnabled:                           common.Bool(false),
				IsNatEnabled:                        common.Bool(true),
				RecordingPeriodInSeconds:            common.Int(1162)},
			ProtectionSettings: &waas.ProtectionSettings{BlockResponseCode: common.Int(140),
				MaxArgumentCount:              common.Int(2721),
				MaxNameLengthPerArgument:      common.Int(133531),
				MaxTotalNameLengthOfArguments: common.Int(111291),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				IsResponseInspected:           common.Bool(false),
				MaxResponseSizeInKiB:          common.Int(1186),
				RecommendationsPeriodInDays:   common.Int(49),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-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.ProtectionRuleActionBlock}},
			AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(9879),
				AllowedRatePerAddress:     common.Int(600),
				BlockResponseCode:         common.Int(816)},
			JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotContain,
				IsCaseSensitive: common.Bool(false),
				Value:           common.String("EXAMPLE-value-Value")}},
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(419602),
				AreRedirectsChallenged:    common.Bool(false),
				FailureThreshold:          common.Int(681373),
				IsEnabled:                 common.Bool(true),
				IsNatEnabled:              common.Bool(false),
				Action:                    waas.JsChallengeActionBlock,
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(270),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")}},
			OriginGroups: []string{"EXAMPLE--Value"},
			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")}

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