// 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("CRLBQR5CATRCLTJGJNGF<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{PolicyConfig: &waas.PolicyConfig{CipherGroup: waas.PolicyConfigCipherGroupDefault,
			IsHttpsEnabled:             common.Bool(false),
			IsHttpsForced:              common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(true),
			IsSniEnabled:               common.Bool(false),
			LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
			ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderTrueClientIp,
			HealthChecks: &waas.HealthCheck{HealthyThreshold: common.Int(14),
				IntervalInSeconds:          common.Int(115),
				TimeoutInSeconds:           common.Int(86),
				UnhealthyThreshold:         common.Int(15),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_FTgH4": "EXAMPLE_VALUE_buCcK0wlPCfsQeU3pSrI"},
				IsEnabled:                  common.Bool(false),
				IsResponseTextCheckEnabled: common.Bool(false),
				Method:                     waas.HealthCheckMethodHead,
				Path:                       common.String("EXAMPLE-path-Value")},
			IsBehindCdn:                common.Bool(false),
			IsCacheControlRespected:    common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(false),
			TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
			CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value")},
			WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				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.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				Action:                waas.AccessRuleActionBypass,
				BlockResponseCode:     common.Int(576),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				BlockAction:        waas.AccessRuleBlockActionSetResponseCode,
				CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Name:               common.String("EXAMPLE-name-Value"),
				RedirectUrl:        common.String("EXAMPLE-redirectUrl-Value")}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgsNames}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(173127),
					AreRedirectsChallenged: common.Bool(false),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockResponseCode:         common.Int(445),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIs,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:           waas.JsChallengeActionDetect,
					FailureThreshold: common.Int(470521),
					IsEnabled:        common.Bool(true),
					IsNatEnabled:     common.Bool(true)},
				Origin: common.String("EXAMPLE-origin-Value"),
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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.ProtectionRuleExclusionTargetArgs}},
					Key: common.String("EXAMPLE-key-Value")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
					Name:         common.String("EXAMPLE-name-Value"),
					AddressLists: []string{"EXAMPLE--Value"}}},
				CachingRules: []waas.CachingRule{waas.CachingRule{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(true),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value"),
					Action:                 waas.CachingRuleActionBypassCache}},
				Captchas: []waas.Captcha{waas.Captcha{Title: common.String("EXAMPLE-title-Value"),
					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(310256),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(165917),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(862),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
					FailureThresholdExpirationInSeconds: common.Int(388359),
					InteractionThreshold:                common.Int(74),
					RecordingPeriodInSeconds:            common.Int(10728),
					FailureThreshold:                    common.Int(356703),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-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.ThreatFeedActionOff}},
				GoodBots: []waas.GoodBot{waas.GoodBot{IsEnabled: common.Bool(true),
					Key:         common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-Value"),
					Description: common.String("EXAMPLE-description-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(5124),
					BlockResponseCode:         common.Int(471),
					IsEnabled:                 common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(8753)},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(372295),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockResponseCode:         common.Int(383),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
					FailureThreshold:                    common.Int(327638),
					FailureThresholdExpirationInSeconds: common.Int(275192),
					IsEnabled:                           common.Bool(false),
					MaxAddressCount:                     common.Int(7679),
					MaxAddressCountExpirationInSeconds:  common.Int(50398)},
				OriginGroups: []string{"EXAMPLE--Value"},
				ProtectionSettings: &waas.ProtectionSettings{MediaTypes: []string{"EXAMPLE--Value"},
					RecommendationsPeriodInDays:   common.Int(35),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					IsResponseInspected:           common.Bool(false),
					MaxArgumentCount:              common.Int(1097),
					MaxTotalNameLengthOfArguments: common.Int(302138),
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(295),
					MaxNameLengthPerArgument:      common.Int(97876),
					MaxResponseSizeInKiB:          common.Int(1603)}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_3Vfyf": map[string]interface{}{"EXAMPLE_KEY_slnBj": "EXAMPLE--Value"}},
			DisplayName:       common.String("EXAMPLE-displayName-Value"),
			FreeformTags:      map[string]string{"EXAMPLE_KEY_v5dYY": "EXAMPLE_VALUE_G8o0bDCmMIMAtdfYgEaL"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_bsWxq": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(9929)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_Nn7Gz": waas.Origin{HttpPort: common.Int(63523),
				HttpsPort: common.Int(63998),
				Uri:       common.String("EXAMPLE-uri-Value"),
				CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-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)
}