// 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{UpdateWafConfigDetails: waas.WafConfig{Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
		AddressLists: []string{"EXAMPLE--Value"},
		Addresses:    []string{"EXAMPLE--Value"}}},
		AddressRateLimiting: &waas.AddressRateLimiting{MaxDelayedCountPerAddress: common.Int(1380),
			AllowedRatePerAddress: common.Int(9781),
			BlockResponseCode:     common.Int(933),
			IsEnabled:             common.Bool(false)},
		CachingRules: []waas.CachingRule{waas.CachingRule{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"),
			ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
			Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartEndsWith,
				Value: common.String("EXAMPLE-value-Value")}}}},
		CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
			Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
			Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
		Captchas: []waas.Captcha{waas.Captcha{FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
			FooterText:                 common.String("EXAMPLE-footerText-Value"),
			HeaderText:                 common.String("EXAMPLE-headerText-Value"),
			SessionExpirationInSeconds: common.Int(405034),
			SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
			Title:                      common.String("EXAMPLE-title-Value"),
			Url:                        common.String("EXAMPLE-url-Value")}},
		GoodBots: []waas.GoodBot{waas.GoodBot{Name: common.String("EXAMPLE-name-Value"),
			Description: common.String("EXAMPLE-description-Value"),
			IsEnabled:   common.Bool(false),
			Key:         common.String("EXAMPLE-key-Value")}},
		JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(true),
			ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
				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"),
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:     common.Int(130)},
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
				Condition:       waas.AccessRuleCriteriaConditionIpNotInList,
				IsCaseSensitive: common.Bool(true)}},
			FailureThreshold: common.Int(392714),
			SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")},
			Action:                    waas.JsChallengeActionBlock,
			ActionExpirationInSeconds: common.Int(133046),
			IsEnabled:                 common.Bool(false),
			IsNatEnabled:              common.Bool(true)},
		ProtectionSettings: &waas.ProtectionSettings{RecommendationsPeriodInDays: common.Int(18),
			BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:             common.Int(370),
			IsResponseInspected:           common.Bool(false),
			MaxArgumentCount:              common.Int(3030),
			AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
			BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
			MaxNameLengthPerArgument:      common.Int(114126),
			MaxResponseSizeInKiB:          common.Int(413),
			MaxTotalNameLengthOfArguments: common.Int(5055),
			MediaTypes:                    []string{"EXAMPLE--Value"}},
		AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
			CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
			RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
			RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
			Action:                     waas.AccessRuleActionBypass,
			BlockResponseCode:          common.Int(301),
			BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
			CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
			Name:                       common.String("EXAMPLE-name-Value"),
			ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
			BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
			CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
				IsCaseSensitive: common.Bool(false),
				Value:           common.String("EXAMPLE-value-Value")}},
			BlockAction:               waas.AccessRuleBlockActionShowErrorPage,
			BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
			CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")}},
		Origin: common.String("EXAMPLE-origin-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.ProtectionRuleExclusionTargetRequestCookies}},
			Key:                common.String("EXAMPLE-key-Value"),
			Labels:             []string{"EXAMPLE--Value"},
			ModSecurityRuleIds: []string{"EXAMPLE--Value"},
			Name:               common.String("EXAMPLE-name-Value")}},
		ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Key: common.String("EXAMPLE-key-Value"),
			Name:        common.String("EXAMPLE-name-Value"),
			Action:      waas.ThreatFeedActionOff,
			Description: common.String("EXAMPLE-description-Value")}},
		DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
			BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockResponseCode:         common.Int(630),
			CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
			CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
			CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
			CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
			BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
			FailureThreshold:                    common.Int(376180),
			FailureThresholdExpirationInSeconds: common.Int(128772),
			IsEnabled:                           common.Bool(true),
			MaxAddressCount:                     common.Int(1116),
			MaxAddressCountExpirationInSeconds:  common.Int(138404),
			Action:                              waas.DeviceFingerprintChallengeActionDetect,
			ActionExpirationInSeconds:           common.Int(401966)},
		HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
			CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
			CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
			BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:         common.Int(490),
			CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
			CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
			FailureThreshold:                    common.Int(906077),
			FailureThresholdExpirationInSeconds: common.Int(106789),
			IsNatEnabled:                        common.Bool(false),
			RecordingPeriodInSeconds:            common.Int(4319),
			SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")},
			Action:                    waas.HumanInteractionChallengeActionDetect,
			ActionExpirationInSeconds: common.Int(91389),
			InteractionThreshold:      common.Int(70),
			IsEnabled:                 common.Bool(true)},
		OriginGroups: []string{"EXAMPLE--Value"}},
		WaasPolicyId:  common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("MPIUIPEV4VTCMEU9FX4W<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-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)
}