// 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 ExampleUpdateWaasPolicy() {
	// 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.UpdateWaasPolicyRequest{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("Y5JFNFZNYOTRPWITLXVX<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DisplayName: common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_mNEr2": "EXAMPLE_VALUE_0V8z04tk9BPlgF2FVUYq"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_sMGsM": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(1578)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_qNoUi": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(58438),
				HttpsPort: common.Int(10036),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
				WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
				CipherGroup:           waas.PolicyConfigCipherGroupDefault,
				ClientAddressHeader:   waas.PolicyConfigClientAddressHeaderXClientIp,
				HealthChecks: &waas.HealthCheck{HealthyThreshold: common.Int(17),
					IsEnabled:                  common.Bool(true),
					Method:                     waas.HealthCheckMethodHead,
					UnhealthyThreshold:         common.Int(19),
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					IntervalInSeconds:          common.Int(85),
					IsResponseTextCheckEnabled: common.Bool(true),
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(116),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
					Headers:                    map[string]string{"EXAMPLE_KEY_BGQwz": "EXAMPLE_VALUE_BclZ86VUi97JkFsodQeV"}},
				IsBehindCdn:                common.Bool(true),
				IsCacheControlRespected:    common.Bool(false),
				IsHttpsForced:              common.Bool(false),
				LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				IsHttpsEnabled:             common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(true),
				IsSniEnabled:               common.Bool(false)},
			WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				Name:                      common.String("EXAMPLE-name-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				Action:                    waas.AccessRuleActionRedirect,
				BlockAction:               waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeMovedPermanently,
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				BlockResponseCode: common.Int(703)}},
				Origin: common.String("EXAMPLE-origin-Value"),
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(9663),
					BlockResponseCode:         common.Int(385),
					IsEnabled:                 common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(5634)},
				CachingRules: []waas.CachingRule{waas.CachingRule{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"),
					Name:                   common.String("EXAMPLE-name-Value"),
					Action:                 waas.CachingRuleActionCache}},
				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(418914),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(389785),
					FailureThresholdExpirationInSeconds: common.Int(78335),
					InteractionThreshold:                common.Int(39),
					IsEnabled:                           common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(519),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.HumanInteractionChallengeActionDetect,
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-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(963),
						CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value")},
					FailureThreshold: common.Int(53663),
					IsNatEnabled:     common.Bool(false)},
				JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(231194),
					AreRedirectsChallenged:    common.Bool(false),
					FailureThreshold:          common.Int(184416),
					IsNatEnabled:              common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockResponseCode:         common.Int(273),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIsNot,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					IsEnabled: common.Bool(false)},
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Labels: []string{"EXAMPLE--Value"},
					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.ProtectionRuleExclusionTargetRequestCookies}},
					Key: common.String("EXAMPLE-key-Value")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(722)},
					FailureThreshold:                    common.Int(249121),
					FailureThresholdExpirationInSeconds: common.Int(43675),
					IsEnabled:                           common.Bool(false),
					MaxAddressCount:                     common.Int(3275),
					MaxAddressCountExpirationInSeconds:  common.Int(320471),
					Action:                              waas.DeviceFingerprintChallengeActionBlock,
					ActionExpirationInSeconds:           common.Int(425016)},
				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")}},
				ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(260),
					IsResponseInspected:           common.Bool(false),
					MaxArgumentCount:              common.Int(6785),
					MaxTotalNameLengthOfArguments: common.Int(213694),
					RecommendationsPeriodInDays:   common.Int(70),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPropfind},
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					MaxNameLengthPerArgument:      common.Int(33541),
					MaxResponseSizeInKiB:          common.Int(187),
					MediaTypes:                    []string{"EXAMPLE--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")}},
				OriginGroups: []string{"EXAMPLE--Value"}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_qzJ2P": map[string]interface{}{"EXAMPLE_KEY_UcezX": "EXAMPLE--Value"}}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value")}

	// Send the request using the service client
	resp, err := client.UpdateWaasPolicy(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}