// 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{OpcRequestId: common.String("OHKN92B6GJ1OTFATDMIB<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{PolicyConfig: &waas.PolicyConfig{IsResponseBufferingEnabled: common.Bool(false),
			CipherGroup:             waas.PolicyConfigCipherGroupDefault,
			IsBehindCdn:             common.Bool(false),
			IsCacheControlRespected: common.Bool(false),
			IsHttpsForced:           common.Bool(false),
			IsSniEnabled:            common.Bool(true),
			LoadBalancingMethod:     waas.RoundRobinLoadBalancingMethod{},
			TlsProtocols:            []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
			WebsocketPathPrefixes:   []string{"EXAMPLE--Value"},
			CertificateId:           common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			ClientAddressHeader:     waas.PolicyConfigClientAddressHeaderXClientIp,
			HealthChecks: &waas.HealthCheck{Path: common.String("EXAMPLE-path-Value"),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				HealthyThreshold:           common.Int(4),
				IsEnabled:                  common.Bool(true),
				Method:                     waas.HealthCheckMethodPost,
				TimeoutInSeconds:           common.Int(33),
				UnhealthyThreshold:         common.Int(4),
				Headers:                    map[string]string{"EXAMPLE_KEY_ocbyV": "EXAMPLE_VALUE_qxjkpKKd6Bmv5U4uYcgq"},
				IntervalInSeconds:          common.Int(88),
				IsResponseTextCheckEnabled: common.Bool(false)},
			IsHttpsEnabled:             common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(true)},
			WafConfig: &waas.WafConfig{CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetRequestCookieNames,
					Exclusions: []string{"EXAMPLE--Value"}}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(94517),
					FailureThresholdExpirationInSeconds: common.Int(163909),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(9823),
					MaxAddressCountExpirationInSeconds:  common.Int(261185),
					Action:                              waas.DeviceFingerprintChallengeActionBlock,
					ActionExpirationInSeconds:           common.Int(464),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-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"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(846),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")}},
				JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
					AreRedirectsChallenged: common.Bool(false),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockResponseCode:         common.Int(194),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:          common.Int(902032),
					IsNatEnabled:              common.Bool(true),
					ActionExpirationInSeconds: common.Int(334713),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIs,
						IsCaseSensitive: common.Bool(true),
						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")}},
				ProtectionSettings: &waas.ProtectionSettings{MaxArgumentCount: common.Int(5883),
					MaxTotalNameLengthOfArguments: common.Int(54728),
					BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:             common.Int(979),
					MaxNameLengthPerArgument:      common.Int(115931),
					MaxResponseSizeInKiB:          common.Int(1792),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					RecommendationsPeriodInDays:   common.Int(64),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					IsResponseInspected:           common.Bool(false)},
				CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionCache,
					CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
					ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
					Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
						Value: common.String("EXAMPLE-value-Value")}},
					IsClientCachingEnabled: common.Bool(false),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value")}},
				ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionOff,
					Description: common.String("EXAMPLE-description-Value"),
					Key:         common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-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{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					Action:                     waas.AccessRuleActionAllow,
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:          common.Int(528),
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:                waas.AccessRuleBlockActionSetResponseCode,
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					Name:                       common.String("EXAMPLE-name-Value"),
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeFound}},
				AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(6291),
					AllowedRatePerAddress:     common.Int(1846),
					BlockResponseCode:         common.Int(396)},
				Origin: common.String("EXAMPLE-origin-Value"),
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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"),
					Action:             waas.ProtectionRuleActionDetect}},
				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(1824),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				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{ActionExpirationInSeconds: common.Int(13625),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockResponseCode:         common.Int(490),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:                    common.Int(452668),
					FailureThresholdExpirationInSeconds: common.Int(187332),
					InteractionThreshold:                common.Int(44),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                   waas.HumanInteractionChallengeActionDetect,
					RecordingPeriodInSeconds: common.Int(14136)},
				OriginGroups: []string{"EXAMPLE--Value"}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_xuROr": map[string]interface{}{"EXAMPLE_KEY_erhf4": "EXAMPLE--Value"}},
			DisplayName:       common.String("EXAMPLE-displayName-Value"),
			FreeformTags:      map[string]string{"EXAMPLE_KEY_cgD8i": "EXAMPLE_VALUE_bn2KlCkiD59EAEvxgdi3"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_YcFAM": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(1318)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_PkcHJ": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(48836),
				HttpsPort: common.Int(64816),
				Uri:       common.String("EXAMPLE-uri-Value")}}},
		WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:      common.String("EXAMPLE-ifMatch-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)
}