// 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{CachingRules: []waas.CachingRule{waas.CachingRule{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"),
		Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartContains,
			Value: common.String("EXAMPLE-value-Value")}},
		IsClientCachingEnabled: common.Bool(true)}},
		CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
			Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetArgsNames}},
			Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-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.ThreatFeedActionBlock}},
		DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
			CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
			CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
			CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
			BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
			BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:         common.Int(723),
			CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
			FailureThreshold:                    common.Int(43908),
			FailureThresholdExpirationInSeconds: common.Int(329357),
			IsEnabled:                           common.Bool(true),
			MaxAddressCount:                     common.Int(9827),
			MaxAddressCountExpirationInSeconds:  common.Int(62501),
			Action:                              waas.DeviceFingerprintChallengeActionBlock,
			ActionExpirationInSeconds:           common.Int(259562)},
		HumanInteractionChallenge: &waas.HumanInteractionChallenge{InteractionThreshold: common.Int(93),
			FailureThresholdExpirationInSeconds: common.Int(23559),
			IsEnabled:                           common.Bool(false),
			IsNatEnabled:                        common.Bool(true),
			RecordingPeriodInSeconds:            common.Int(13466),
			SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
				Name: common.String("EXAMPLE-name-Value")},
			Action:                    waas.HumanInteractionChallengeActionBlock,
			ActionExpirationInSeconds: common.Int(285811),
			ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(152)},
			FailureThreshold: common.Int(230840)},
		Origin: common.String("EXAMPLE-origin-Value"),
		ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockResponseCode:             common.Int(665),
			IsResponseInspected:           common.Bool(true),
			MaxResponseSizeInKiB:          common.Int(676),
			MaxTotalNameLengthOfArguments: common.Int(71286),
			RecommendationsPeriodInDays:   common.Int(33),
			AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
			BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
			MaxArgumentCount:              common.Int(9311),
			MaxNameLengthPerArgument:      common.Int(119705),
			MediaTypes:                    []string{"EXAMPLE--Value"},
			BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode},
		AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(4507),
			BlockResponseCode:         common.Int(170),
			IsEnabled:                 common.Bool(false),
			MaxDelayedCountPerAddress: common.Int(309)},
		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(299863),
			SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
			Title:                      common.String("EXAMPLE-title-Value"),
			Url:                        common.String("EXAMPLE-url-Value")}},
		JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(true),
			ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockResponseCode:         common.Int(494),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIsNot,
				IsCaseSensitive: common.Bool(false),
				Value:           common.String("EXAMPLE-value-Value")}},
			IsEnabled: common.Bool(false),
			SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")},
			ActionExpirationInSeconds: common.Int(356527),
			FailureThreshold:          common.Int(208681),
			IsNatEnabled:              common.Bool(false),
			Action:                    waas.JsChallengeActionDetect},
		OriginGroups: []string{"EXAMPLE--Value"},
		Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
			Addresses: []string{"EXAMPLE--Value"},
			Name:      common.String("EXAMPLE-name-Value")}},
		AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
			RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeFound,
			BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BypassChallenges:      []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
			CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
			Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
				IsCaseSensitive: common.Bool(true),
				Value:           common.String("EXAMPLE-value-Value")}},
			Name:               common.String("EXAMPLE-name-Value"),
			RedirectUrl:        common.String("EXAMPLE-redirectUrl-Value"),
			Action:             waas.AccessRuleActionRedirect,
			BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
			CaptchaHeader:      common.String("EXAMPLE-captchaHeader-Value"),
			CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
			ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
			BlockAction:       waas.AccessRuleBlockActionSetResponseCode,
			BlockResponseCode: common.Int(756),
			CaptchaTitle:      common.String("EXAMPLE-captchaTitle-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")}},
		ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
			Action:      waas.ProtectionRuleActionOff,
			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"}}}},
		WaasPolicyId:  common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("HJYIIU15MRAUWRY2C6U6<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)
}