// 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{ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionDetect,
		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")}},
		ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(250410),
			MediaTypes:                  []string{"EXAMPLE--Value"},
			BlockAction:                 waas.ProtectionSettingsBlockActionShowErrorPage,
			BlockErrorPageCode:          common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockResponseCode:           common.Int(328),
			IsResponseInspected:         common.Bool(false),
			RecommendationsPeriodInDays: common.Int(27),
			AllowedHttpMethods:          []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
			BlockErrorPageDescription:   common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:       common.String("EXAMPLE-blockErrorPageMessage-Value"),
			MaxArgumentCount:            common.Int(8269),
			MaxNameLengthPerArgument:    common.Int(25390),
			MaxResponseSizeInKiB:        common.Int(397)},
		CachingRules: []waas.CachingRule{waas.CachingRule{Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
			Condition: waas.CachingRuleCriteriaConditionPartEndsWith}},
			IsClientCachingEnabled: common.Bool(false),
			Key:                    common.String("EXAMPLE-key-Value"),
			Name:                   common.String("EXAMPLE-name-Value"),
			Action:                 waas.CachingRuleActionCache,
			CachingDuration:        common.String("EXAMPLE-cachingDuration-Value"),
			ClientCachingDuration:  common.String("EXAMPLE-clientCachingDuration-Value")}},
		JsChallenge: &waas.JsChallenge{SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
			Name: common.String("EXAMPLE-name-Value")},
			Action:                    waas.JsChallengeActionDetect,
			ActionExpirationInSeconds: common.Int(284196),
			AreRedirectsChallenged:    common.Bool(false),
			ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:         common.Int(185),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
			IsEnabled:    common.Bool(false),
			IsNatEnabled: common.Bool(false),
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
				IsCaseSensitive: common.Bool(true),
				Value:           common.String("EXAMPLE-value-Value")}},
			FailureThreshold: common.Int(934969)},
		AddressRateLimiting: &waas.AddressRateLimiting{MaxDelayedCountPerAddress: common.Int(399),
			AllowedRatePerAddress: common.Int(9800),
			BlockResponseCode:     common.Int(265),
			IsEnabled:             common.Bool(true)},
		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(111600),
			SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
			Title:                      common.String("EXAMPLE-title-Value")}},
		Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
			Addresses: []string{"EXAMPLE--Value"},
			Name:      common.String("EXAMPLE-name-Value")}},
		GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
			IsEnabled: common.Bool(false),
			Key:       common.String("EXAMPLE-key-Value"),
			Name:      common.String("EXAMPLE-name-Value")}},
		HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
			IsEnabled:                common.Bool(false),
			RecordingPeriodInSeconds: common.Int(2871),
			SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
				Name: common.String("EXAMPLE-name-Value")},
			ActionExpirationInSeconds: common.Int(127172),
			ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-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.BlockChallengeSettingsBlockActionSetResponseCode,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:         common.Int(915)},
			FailureThreshold:                    common.Int(257753),
			FailureThresholdExpirationInSeconds: common.Int(259041),
			InteractionThreshold:                common.Int(52),
			IsNatEnabled:                        common.Bool(true)},
		OriginGroups: []string{"EXAMPLE--Value"},
		ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionBlock,
			Description: common.String("EXAMPLE-description-Value"),
			Key:         common.String("EXAMPLE-key-Value"),
			Name:        common.String("EXAMPLE-name-Value")}},
		AccessRules: []waas.AccessRule{waas.AccessRule{BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
			RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeFound,
			Action:                waas.AccessRuleActionAllow,
			CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
			RedirectUrl:           common.String("EXAMPLE-redirectUrl-Value"),
			BlockAction:           waas.AccessRuleBlockActionSetResponseCode,
			BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:     common.Int(647),
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartContains,
				IsCaseSensitive: common.Bool(true),
				Value:           common.String("EXAMPLE-value-Value")}},
			ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
			CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
			CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
			CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
			Name:                      common.String("EXAMPLE-name-Value"),
			BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")}},
		CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
			Target: waas.ProtectionRuleExclusionTargetArgsNames}},
			Id:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
			Action: waas.CustomProtectionRuleSettingActionBlock}},
		DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionBlock,
			ActionExpirationInSeconds: common.Int(295624),
			ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:     common.Int(983),
				CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockAction:           waas.BlockChallengeSettingsBlockActionShowCaptcha,
				BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
				CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value")},
			FailureThreshold:                    common.Int(721616),
			FailureThresholdExpirationInSeconds: common.Int(22169),
			IsEnabled:                           common.Bool(false),
			MaxAddressCount:                     common.Int(4304),
			MaxAddressCountExpirationInSeconds:  common.Int(61384)},
		Origin: common.String("EXAMPLE-origin-Value")},
		WaasPolicyId:  common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("RSHSTWVRZ1UKU5HUABWU<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)
}