// 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("CYX9GHMON98VJ2B0GYA6<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_ZZ2aa": map[string]interface{}{"EXAMPLE_KEY_Xl8Nn": "EXAMPLE--Value"}},
			DisplayName:  common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_Gj1ot": "EXAMPLE_VALUE_fAtdmiBzRoNCaLVhe7aQ"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_5U4uY": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(4354)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_Kd6Bm": waas.Origin{HttpsPort: common.Int(48718),
				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(40777)}},
			PolicyConfig: &waas.PolicyConfig{IsOriginCompressionEnabled: common.Bool(true),
				IsResponseBufferingEnabled: common.Bool(true),
				IsCacheControlRespected:    common.Bool(false),
				IsHttpsForced:              common.Bool(true),
				IsSniEnabled:               common.Bool(true),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				IsBehindCdn:                common.Bool(true),
				IsHttpsEnabled:             common.Bool(false),
				HealthChecks: &waas.HealthCheck{HealthyThreshold: common.Int(6),
					IntervalInSeconds:          common.Int(47),
					IsEnabled:                  common.Bool(false),
					TimeoutInSeconds:           common.Int(34),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					Method:                     waas.HealthCheckMethodPost,
					Path:                       common.String("EXAMPLE-path-Value"),
					UnhealthyThreshold:         common.Int(10),
					Headers:                    map[string]string{"EXAMPLE_KEY_F0W34": "EXAMPLE_VALUE_W6C8MUKGcELCY4fIlJC7"},
					IsResponseTextCheckEnabled: common.Bool(true)},
				LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
				ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXClientIp,
				CertificateId:       common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				CipherGroup:         waas.PolicyConfigCipherGroupDefault},
			WafConfig: &waas.WafConfig{JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold: common.Int(65688),
				IsNatEnabled:     common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.JsChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(194402),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:         common.Int(905),
					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")},
				IsEnabled: common.Bool(true)},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(242),
					IsEnabled:                 common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(1676),
					AllowedRatePerAddress:     common.Int(144)},
				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(148758),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(774),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
					FailureThresholdExpirationInSeconds: common.Int(157132),
					InteractionThreshold:                common.Int(91),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(944),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(83034),
					FailureThreshold:          common.Int(23505)},
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Labels: []string{"EXAMPLE--Value"},
					ModSecurityRuleIds: []string{"EXAMPLE--Value"},
					Name:               common.String("EXAMPLE-name-Value"),
					Action:             waas.ProtectionRuleActionOff,
					Description:        common.String("EXAMPLE-description-Value"),
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
					Key: common.String("EXAMPLE-key-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}},
				AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionRedirect,
					BlockAction: waas.AccessRuleBlockActionSetResponseCode,
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
						Value: common.String("EXAMPLE-value-Value")}},
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					Name:                      common.String("EXAMPLE-name-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
					RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(520),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIsNot,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}}}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(355031),
					IsEnabled:                          common.Bool(false),
					MaxAddressCount:                    common.Int(1122),
					MaxAddressCountExpirationInSeconds: common.Int(125988),
					Action:                             waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds:          common.Int(272385),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-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"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(803)},
					FailureThreshold: common.Int(413252)},
				Origin: common.String("EXAMPLE-origin-Value"),
				ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					IsResponseInspected:           common.Bool(true),
					MaxNameLengthPerArgument:      common.Int(84342),
					MaxArgumentCount:              common.Int(7022),
					MaxResponseSizeInKiB:          common.Int(352),
					MaxTotalNameLengthOfArguments: common.Int(257418),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(140),
					RecommendationsPeriodInDays:   common.Int(93)},
				CachingRules: []waas.CachingRule{waas.CachingRule{IsClientCachingEnabled: common.Bool(true),
					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{Value: common.String("EXAMPLE-value-Value"),
						Condition: waas.CachingRuleCriteriaConditionPartEndsWith}}}},
				OriginGroups: []string{"EXAMPLE--Value"},
				GoodBots: []waas.GoodBot{waas.GoodBot{Name: common.String("EXAMPLE-name-Value"),
					Description: common.String("EXAMPLE-description-Value"),
					IsEnabled:   common.Bool(true),
					Key:         common.String("EXAMPLE-key-Value")}}},
			AdditionalDomains: []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)
}