// 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("XKSOSDZDFIACXUVB9TBD<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{Origins: map[string]waas.Origin{"EXAMPLE_KEY_OroHk": waas.Origin{HttpsPort: common.Int(31817),
			Uri: common.String("EXAMPLE-uri-Value"),
			CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
			HttpPort: common.Int(9504)}},
			PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_7aQXl": "EXAMPLE_VALUE_8NnZZ2aaCYx9GhmON98V"},
				IsEnabled:                  common.Bool(true),
				Path:                       common.String("EXAMPLE-path-Value"),
				UnhealthyThreshold:         common.Int(13),
				HealthyThreshold:           common.Int(15),
				IntervalInSeconds:          common.Int(65),
				IsResponseTextCheckEnabled: common.Bool(true),
				Method:                     waas.HealthCheckMethodPost,
				TimeoutInSeconds:           common.Int(64)},
				IsBehindCdn:                common.Bool(true),
				IsHttpsEnabled:             common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(false),
				IsSniEnabled:               common.Bool(false),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXClientIp,
				IsCacheControlRespected:    common.Bool(true),
				IsHttpsForced:              common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(true),
				LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault},
			WafConfig: &waas.WafConfig{Captchas: []waas.Captcha{waas.Captcha{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"),
				HeaderText:                 common.String("EXAMPLE-headerText-Value"),
				SessionExpirationInSeconds: common.Int(16978)}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(319190),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(454),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
					FailureThreshold:                    common.Int(116602),
					FailureThresholdExpirationInSeconds: common.Int(150487),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(8923),
					MaxAddressCountExpirationInSeconds:  common.Int(303554)},
				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")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{MaxDelayedCountPerAddress: common.Int(8378),
					AllowedRatePerAddress: common.Int(5728),
					BlockResponseCode:     common.Int(503),
					IsEnabled:             common.Bool(false)},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
					ActionExpirationInSeconds: common.Int(426393),
					FailureThreshold:          common.Int(670652),
					InteractionThreshold:      common.Int(18),
					IsEnabled:                 common.Bool(false),
					IsNatEnabled:              common.Bool(true),
					RecordingPeriodInSeconds:  common.Int(13996),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(651),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
					FailureThresholdExpirationInSeconds: common.Int(394571),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")}},
				JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
					IsEnabled: common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.JsChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(44986),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(417),
						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"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					FailureThreshold: common.Int(392159),
					IsNatEnabled:     common.Bool(true)},
				OriginGroups: []string{"EXAMPLE--Value"},
				ProtectionSettings: &waas.ProtectionSettings{BlockResponseCode: common.Int(732),
					IsResponseInspected:           common.Bool(true),
					MaxArgumentCount:              common.Int(8398),
					MaxResponseSizeInKiB:          common.Int(924),
					MaxTotalNameLengthOfArguments: common.Int(142098),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					MaxNameLengthPerArgument:      common.Int(41284),
					RecommendationsPeriodInDays:   common.Int(59),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value")},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-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")}},
				CachingRules: []waas.CachingRule{waas.CachingRule{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,
					CachingDuration:        common.String("EXAMPLE-cachingDuration-Value"),
					ClientCachingDuration:  common.String("EXAMPLE-clientCachingDuration-Value")}},
				Origin: common.String("EXAMPLE-origin-Value"),
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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.ProtectionRuleExclusionTargetArgsNames}},
					Key:                common.String("EXAMPLE-key-Value"),
					Labels:             []string{"EXAMPLE--Value"},
					ModSecurityRuleIds: []string{"EXAMPLE--Value"}}},
				AccessRules: []waas.AccessRule{waas.AccessRule{BlockAction: waas.AccessRuleBlockActionSetResponseCode,
					BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
					Name:                       common.String("EXAMPLE-name-Value"),
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeFound,
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:          common.Int(665),
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					Action:                     waas.AccessRuleActionDetect,
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIsNot,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}}}}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_JzsYR": map[string]interface{}{"EXAMPLE_KEY_Up1r3": "EXAMPLE--Value"}},
			DisplayName:       common.String("EXAMPLE-displayName-Value"),
			FreeformTags:      map[string]string{"EXAMPLE_KEY_89tYm": "EXAMPLE_VALUE_O7upVMFjH2PNQfq72AZ1"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_92b6G": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(9822)}}}}},
		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)
}