// 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("B7MMPIUIPEV4VTCMEU9F<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{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(89920),
			SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
			Title:                      common.String("EXAMPLE-title-Value"),
			Url:                        common.String("EXAMPLE-url-Value")}},
			Origin:       common.String("EXAMPLE-origin-Value"),
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:             common.Int(626),
				IsResponseInspected:           common.Bool(false),
				MaxResponseSizeInKiB:          common.Int(789),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPatch},
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxArgumentCount:              common.Int(873),
				MaxNameLengthPerArgument:      common.Int(121261),
				MaxTotalNameLengthOfArguments: common.Int(259118),
				RecommendationsPeriodInDays:   common.Int(38)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(1115),
				BlockResponseCode:         common.Int(648),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(7864)},
			CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionBypassCache,
				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),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(401966),
				Action:                    waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(195356),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(445),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-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")},
				FailureThreshold:                    common.Int(169612),
				FailureThresholdExpirationInSeconds: common.Int(247999),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(28)},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(201),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode},
				FailureThresholdExpirationInSeconds: common.Int(28890),
				InteractionThreshold:                common.Int(61),
				RecordingPeriodInSeconds:            common.Int(9573),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(348560),
				FailureThreshold:          common.Int(359688),
				IsEnabled:                 common.Bool(true),
				IsNatEnabled:              common.Bool(false),
				Action:                    waas.HumanInteractionChallengeActionDetect},
			AccessRules: []waas.AccessRule{waas.AccessRule{Name: common.String("EXAMPLE-name-Value"),
				Action:                     waas.AccessRuleActionBlock,
				BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:          common.Int(638),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
				BlockAction:                waas.AccessRuleBlockActionSetResponseCode,
				BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
				CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
				RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeFound,
				BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
				RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
				BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}}}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			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(203480),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold:       common.Int(134967),
				IsEnabled:              common.Bool(false),
				AreRedirectsChallenged: common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-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"),
					BlockResponseCode:         common.Int(632),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode},
				IsNatEnabled: common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					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.ProtectionRuleExclusionTargetRequestCookieNames}},
				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{Action: waas.ThreatFeedActionOff,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-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)
}