// 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{WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId:  common.String("O5MKUU6GKPDPTGYPPF4N<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{PolicyConfig: &waas.PolicyConfig{CipherGroup: waas.PolicyConfigCipherGroupDefault,
			ClientAddressHeader:     waas.PolicyConfigClientAddressHeaderXForwardedFor,
			IsBehindCdn:             common.Bool(false),
			IsCacheControlRespected: common.Bool(false),
			IsHttpsEnabled:          common.Bool(false),
			IsSniEnabled:            common.Bool(false),
			LoadBalancingMethod:     waas.IpHashLoadBalancingMethod{},
			TlsProtocols:            []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
			CertificateId:           common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			HealthChecks: &waas.HealthCheck{Headers: map[string]string{"EXAMPLE_KEY_TcaJQ": "EXAMPLE_VALUE_E0UGrDYt8ZFJKbPtbqbF"},
				IsEnabled:                  common.Bool(false),
				Method:                     waas.HealthCheckMethodPost,
				HealthyThreshold:           common.Int(1),
				IntervalInSeconds:          common.Int(10),
				IsResponseTextCheckEnabled: common.Bool(false),
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(57),
				UnhealthyThreshold:         common.Int(6),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value")},
			IsHttpsForced:              common.Bool(false),
			IsOriginCompressionEnabled: common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(true),
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"}},
			WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
				CaptchaTitle:     common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				Action:                waas.AccessRuleActionBlock,
				BlockAction:           waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:     common.Int(445),
				Name:                  common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeMovedPermanently}},
				GoodBots: []waas.GoodBot{waas.GoodBot{IsEnabled: common.Bool(false),
					Key:         common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-Value"),
					Description: common.String("EXAMPLE-description-Value")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
					Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartContains,
						Value: common.String("EXAMPLE-value-Value")}},
					IsClientCachingEnabled: common.Bool(false),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value"),
					Action:                 waas.CachingRuleActionBypassCache,
					CachingDuration:        common.String("EXAMPLE-cachingDuration-Value")}},
				Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(15723),
					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")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(107364),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:     common.Int(573),
						CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
						CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:                    common.Int(834325),
					FailureThresholdExpirationInSeconds: common.Int(2561),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(7301),
					MaxAddressCountExpirationInSeconds:  common.Int(238033),
					Action:                              waas.DeviceFingerprintChallengeActionBlock},
				OriginGroups: []string{"EXAMPLE--Value"},
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionDetect,
					Description: common.String("EXAMPLE-description-Value"),
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgsNames,
						Exclusions: []string{"EXAMPLE--Value"}}},
					Key:                common.String("EXAMPLE-key-Value"),
					Labels:             []string{"EXAMPLE--Value"},
					ModSecurityRuleIds: []string{"EXAMPLE--Value"},
					Name:               common.String("EXAMPLE-name-Value")}},
				ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Name: common.String("EXAMPLE-name-Value"),
					Action:      waas.ThreatFeedActionOff,
					Description: common.String("EXAMPLE-description-Value"),
					Key:         common.String("EXAMPLE-key-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(7601),
					AllowedRatePerAddress:     common.Int(3888),
					BlockResponseCode:         common.Int(972)},
				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")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(218068),
					FailureThresholdExpirationInSeconds: common.Int(401233),
					InteractionThreshold:                common.Int(6),
					IsEnabled:                           common.Bool(false),
					IsNatEnabled:                        common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(429),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:         common.Int(241593),
					RecordingPeriodInSeconds: common.Int(8791),
					Action:                   waas.HumanInteractionChallengeActionDetect},
				Origin: common.String("EXAMPLE-origin-Value"),
				ProtectionSettings: &waas.ProtectionSettings{MaxArgumentCount: common.Int(1376),
					MaxResponseSizeInKiB:          common.Int(2019),
					MaxTotalNameLengthOfArguments: common.Int(110475),
					RecommendationsPeriodInDays:   common.Int(70),
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:             common.Int(403),
					MaxNameLengthPerArgument:      common.Int(86226),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					IsResponseInspected:           common.Bool(false)},
				JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
					AreRedirectsChallenged: common.Bool(true),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockResponseCode:         common.Int(696),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-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")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(true),
						Value:     common.String("EXAMPLE-value-Value"),
						Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotEndWith}},
					FailureThreshold:          common.Int(556728),
					IsNatEnabled:              common.Bool(false),
					ActionExpirationInSeconds: common.Int(191542),
					IsEnabled:                 common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")}}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_LVvy7": map[string]interface{}{"EXAMPLE_KEY_qHWyn": "EXAMPLE--Value"}},
			DisplayName:       common.String("EXAMPLE-displayName-Value"),
			FreeformTags:      map[string]string{"EXAMPLE_KEY_r5Cat": "EXAMPLE_VALUE_RCLtJgjNgFRZX0ECDEBA"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_CfsQe": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(8378)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_cK0wl": waas.Origin{HttpPort: common.Int(60071),
				HttpsPort: common.Int(39779),
				Uri:       common.String("EXAMPLE-uri-Value"),
				CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-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)
}