// 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("SWGM7OKCSVHTU3UZBQGV<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{ModSecurityRuleIds: []string{"EXAMPLE--Value"},
			Name:        common.String("EXAMPLE-name-Value"),
			Action:      waas.ProtectionRuleActionDetect,
			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"}}},
			AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
				BypassChallenges:     []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaTitle:         common.String("EXAMPLE-captchaTitle-Value"),
				Name:                 common.String("EXAMPLE-name-Value"),
				RedirectUrl:          common.String("EXAMPLE-redirectUrl-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				BlockAction:           waas.AccessRuleBlockActionShowErrorPage,
				BlockResponseCode:     common.Int(356),
				CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
				Action:                waas.AccessRuleActionShowCaptcha,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")}},
			GoodBots: []waas.GoodBot{waas.GoodBot{IsEnabled: common.Bool(false),
				Key:         common.String("EXAMPLE-key-Value"),
				Name:        common.String("EXAMPLE-name-Value"),
				Description: common.String("EXAMPLE-description-Value")}},
			Origin: common.String("EXAMPLE-origin-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}},
			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.CachingRuleCriteriaConditionPartEndsWith,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(true),
				Key:                    common.String("EXAMPLE-key-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(328155),
				FailureThresholdExpirationInSeconds: common.Int(379773),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(6338),
				MaxAddressCountExpirationInSeconds:  common.Int(353685),
				Action:                              waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:           common.Int(241965),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(586),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{RecordingPeriodInSeconds: common.Int(8163),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds:           common.Int(11773),
				FailureThresholdExpirationInSeconds: common.Int(286404),
				IsNatEnabled:                        common.Bool(false),
				Action:                              waas.HumanInteractionChallengeActionBlock,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(834),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
				FailureThreshold:     common.Int(411168),
				InteractionThreshold: common.Int(63),
				IsEnabled:            common.Bool(false)},
			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(52),
				BlockResponseCode:         common.Int(551),
				IsEnabled:                 common.Bool(true),
				MaxDelayedCountPerAddress: common.Int(3153)},
			JsChallenge: &waas.JsChallenge{IsNatEnabled: common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.JsChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(120234),
				AreRedirectsChallenged:    common.Bool(false),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIsNot,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(933),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-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")},
				FailureThreshold: common.Int(888538),
				IsEnabled:        common.Bool(true)},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(610),
				IsResponseInspected:           common.Bool(true),
				MaxNameLengthPerArgument:      common.Int(37295),
				MaxResponseSizeInKiB:          common.Int(464),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsHead},
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				MaxArgumentCount:              common.Int(4177),
				MaxTotalNameLengthOfArguments: common.Int(122829),
				RecommendationsPeriodInDays:   common.Int(21)},
			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(20473),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgsNames,
					Exclusions: []string{"EXAMPLE--Value"}}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-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)
}