// 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("NK1Z6OBEFOLQSEES5FET<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:  map[string]map[string]interface{}{"EXAMPLE_KEY_k8aqv": map[string]interface{}{"EXAMPLE_KEY_US3KE": "EXAMPLE--Value"}},
			DisplayName:  common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_ekQk4": "EXAMPLE_VALUE_LPfJXjgDoR6l48Sql0jP"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_20V8z": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(3926)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_V5mNE": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(39461),
				HttpsPort: common.Int(36922),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{IsSniEnabled: common.Bool(false),
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				IsBehindCdn:                common.Bool(true),
				IsResponseBufferingEnabled: common.Bool(false),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXRealIp,
				HealthChecks: &waas.HealthCheck{ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
					IntervalInSeconds:          common.Int(7),
					IsResponseTextCheckEnabled: common.Bool(true),
					Method:                     waas.HealthCheckMethodGet,
					Path:                       common.String("EXAMPLE-path-Value"),
					UnhealthyThreshold:         common.Int(1),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
					Headers:                    map[string]string{"EXAMPLE_KEY_qzJ2P": "EXAMPLE_VALUE_y5JfnFZnyotrpwITLXVx"},
					HealthyThreshold:           common.Int(15),
					IsEnabled:                  common.Bool(true),
					TimeoutInSeconds:           common.Int(101)},
				IsHttpsForced:              common.Bool(false),
				LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				IsCacheControlRespected:    common.Bool(true),
				IsHttpsEnabled:             common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(false)},
			WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:     common.Int(612),
				CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIsNot,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
				RedirectUrl:          common.String("EXAMPLE-redirectUrl-Value"),
				Action:               waas.AccessRuleActionBlock,
				BlockErrorPageCode:   common.String("EXAMPLE-blockErrorPageCode-Value"),
				CaptchaTitle:         common.String("EXAMPLE-captchaTitle-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
					Header: common.String("EXAMPLE-header-Value")}},
				BlockAction:      waas.AccessRuleBlockActionSetResponseCode,
				BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
				CaptchaFooter:    common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:    common.String("EXAMPLE-captchaHeader-Value"),
				Name:             common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6182),
					BlockResponseCode:         common.Int(188),
					IsEnabled:                 common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(6841)},
				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)}},
				OriginGroups: []string{"EXAMPLE--Value"},
				ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionDetect,
					Description: common.String("EXAMPLE-description-Value"),
					Key:         common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-Value")}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
					Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgsNames}}}},
				Origin: common.String("EXAMPLE-origin-Value"),
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(823),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:                    common.Int(912916),
					FailureThresholdExpirationInSeconds: common.Int(420750),
					IsEnabled:                           common.Bool(false),
					MaxAddressCount:                     common.Int(9116),
					MaxAddressCountExpirationInSeconds:  common.Int(175613),
					Action:                              waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds:           common.Int(128817)},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{RecordingPeriodInSeconds: common.Int(11369),
					Action:                    waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(382577),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockResponseCode:         common.Int(140),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-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")},
					FailureThreshold:                    common.Int(46050),
					InteractionThreshold:                common.Int(28),
					FailureThresholdExpirationInSeconds: common.Int(126674),
					IsEnabled:                           common.Bool(false),
					IsNatEnabled:                        common.Bool(false),
					SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
						Name: common.String("EXAMPLE-name-Value")}},
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Description: common.String("EXAMPLE-description-Value"),
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgsNames}},
					Key:                common.String("EXAMPLE-key-Value"),
					Labels:             []string{"EXAMPLE--Value"},
					ModSecurityRuleIds: []string{"EXAMPLE--Value"},
					Name:               common.String("EXAMPLE-name-Value"),
					Action:             waas.ProtectionRuleActionDetect}},
				ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					MaxArgumentCount:              common.Int(1081),
					MaxResponseSizeInKiB:          common.Int(1220),
					MaxTotalNameLengthOfArguments: common.Int(14438),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:             common.Int(959),
					IsResponseInspected:           common.Bool(true),
					MaxNameLengthPerArgument:      common.Int(56305),
					RecommendationsPeriodInDays:   common.Int(42),
					BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value")},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				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(183468),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-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")}},
				JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
					IsEnabled:        common.Bool(true),
					FailureThreshold: common.Int(887975),
					IsNatEnabled:     common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.JsChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(339971),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:           waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:     common.Int(737),
						CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
						Condition:       waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
						IsCaseSensitive: common.Bool(true)}}}}},
		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)
}