// 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("VSNDV1BRMNARO9NPPYNP<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWafConfigDetails: waas.WafConfig{ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
			BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
			BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:             common.Int(783),
			MaxNameLengthPerArgument:      common.Int(49966),
			MediaTypes:                    []string{"EXAMPLE--Value"},
			BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
			IsResponseInspected:           common.Bool(true),
			MaxArgumentCount:              common.Int(3169),
			MaxResponseSizeInKiB:          common.Int(277),
			MaxTotalNameLengthOfArguments: common.Int(261620),
			RecommendationsPeriodInDays:   common.Int(30)},
			AccessRules: []waas.AccessRule{waas.AccessRule{BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:  common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
					Header: common.String("EXAMPLE-header-Value")}},
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockAction:               waas.AccessRuleBlockActionSetResponseCode,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:         common.Int(103),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				Name:                      common.String("EXAMPLE-name-Value"),
				Action:                    waas.AccessRuleActionBlock}},
			AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
				MaxDelayedCountPerAddress: common.Int(7290),
				AllowedRatePerAddress:     common.Int(793),
				BlockResponseCode:         common.Int(525)},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgs,
					Exclusions: []string{"EXAMPLE--Value"}}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			OriginGroups: []string{"EXAMPLE--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(249252),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value"),
				Url:                        common.String("EXAMPLE-url-Value")}},
			JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(307797),
				AreRedirectsChallenged: common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:         common.Int(123),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage},
				IsNatEnabled: common.Bool(true),
				Action:       waas.JsChallengeActionDetect,
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition:       waas.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(false)}},
				FailureThreshold: common.Int(96389),
				IsEnabled:        common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			Origin: common.String("EXAMPLE-origin-Value"),
			ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Key: common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"},
				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}}}},
			CachingRules: []waas.CachingRule{waas.CachingRule{CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(true),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value"),
				Action:                 waas.CachingRuleActionCache}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCount: common.Int(8836),
				MaxAddressCountExpirationInSeconds: common.Int(204551),
				Action:                             waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:          common.Int(136053),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-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(888),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold:                    common.Int(36881),
				FailureThresholdExpirationInSeconds: common.Int(259635),
				IsEnabled:                           common.Bool(true)},
			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")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(124353),
				IsEnabled:                 common.Bool(false),
				IsNatEnabled:              common.Bool(true),
				RecordingPeriodInSeconds:  common.Int(6248),
				Action:                    waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(253984),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(581),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				InteractionThreshold: common.Int(18),
				SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
					Name: common.String("EXAMPLE-name-Value")},
				FailureThreshold: common.Int(8067)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Name: common.String("EXAMPLE-name-Value"),
				Action:      waas.ThreatFeedActionBlock,
				Description: common.String("EXAMPLE-description-Value"),
				Key:         common.String("EXAMPLE-key-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)
}