// 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("K13DANNNWEVEXOCBYVQX<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:  map[string]map[string]interface{}{"EXAMPLE_KEY_Cf9PD": map[string]interface{}{"EXAMPLE_KEY_AMhSS": "EXAMPLE--Value"}},
			DisplayName:  common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_r3jea": "EXAMPLE_VALUE_lPIV8p4sdLBPkcHJBYcF"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_a8sJA": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(7233)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_0wXa0": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Value: common.String("EXAMPLE-value-Value"),
				Name: common.String("EXAMPLE-name-Value")}},
				HttpPort:  common.Int(40912),
				HttpsPort: common.Int(922),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				HealthChecks: &waas.HealthCheck{ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
					Headers:                    map[string]string{"EXAMPLE_KEY_mDabW": "EXAMPLE_VALUE_6dfhDeEbKshwyMYmoYuR"},
					HealthyThreshold:           common.Int(17),
					IsResponseTextCheckEnabled: common.Bool(false),
					Method:                     waas.HealthCheckMethodPost,
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
					IntervalInSeconds:          common.Int(92),
					IsEnabled:                  common.Bool(false),
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(78),
					UnhealthyThreshold:         common.Int(14)},
				IsHttpsEnabled:             common.Bool(true),
				IsSniEnabled:               common.Bool(true),
				LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderClientIp,
				IsBehindCdn:                common.Bool(true),
				IsCacheControlRespected:    common.Bool(true),
				IsHttpsForced:              common.Bool(true),
				IsOriginCompressionEnabled: common.Bool(true),
				IsResponseBufferingEnabled: common.Bool(true)},
			WafConfig: &waas.WafConfig{ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
				Action:      waas.ProtectionRuleActionBlock,
				Description: common.String("EXAMPLE-description-Value"),
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetRequestCookies,
					Exclusions: []string{"EXAMPLE--Value"}}},
				Key:                common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"}}},
				ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					IsResponseInspected:           common.Bool(false),
					MaxArgumentCount:              common.Int(7731),
					MaxTotalNameLengthOfArguments: common.Int(117004),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					RecommendationsPeriodInDays:   common.Int(47),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(141),
					MaxNameLengthPerArgument:      common.Int(104496),
					MaxResponseSizeInKiB:          common.Int(443),
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value")},
				AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIs,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeFound,
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
					BlockResponseCode:          common.Int(385),
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					Action:                     waas.AccessRuleActionDetect,
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					Name:                       common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6521),
					BlockResponseCode:         common.Int(762),
					IsEnabled:                 common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(1957)},
				Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
					SessionExpirationInSeconds: common.Int(117682),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value"),
					FailureMessage:             common.String("EXAMPLE-failureMessage-Value"),
					FooterText:                 common.String("EXAMPLE-footerText-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(424525),
					IsEnabled:                          common.Bool(true),
					MaxAddressCount:                    common.Int(8508),
					MaxAddressCountExpirationInSeconds: common.Int(236838),
					Action:                             waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds:          common.Int(176696),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockResponseCode:         common.Int(317),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
					FailureThreshold: common.Int(384067)},
				OriginGroups: []string{"EXAMPLE--Value"},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgs}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				Origin: common.String("EXAMPLE-origin-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")}},
				CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionBypassCache,
					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")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThreshold: common.Int(967689),
					FailureThresholdExpirationInSeconds: common.Int(129524),
					ActionExpirationInSeconds:           common.Int(151395),
					InteractionThreshold:                common.Int(52),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(9293),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.HumanInteractionChallengeActionDetect,
					ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(468),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-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"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")}},
				JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(19477),
					FailureThreshold: common.Int(211591),
					IsEnabled:        common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                 waas.JsChallengeActionBlock,
					AreRedirectsChallenged: common.Bool(true),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
						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")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIsNot,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					IsNatEnabled: common.Bool(false)},
				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")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
					AddressLists: []string{"EXAMPLE--Value"},
					Addresses:    []string{"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)
}