// 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("YI0SEPX11V9HO7B7MMPI<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_v2iRm": map[string]interface{}{"EXAMPLE_KEY_ETyiT": "EXAMPLE--Value"}},
			DisplayName:  common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_cJtzI": "EXAMPLE_VALUE_I3zcdiKfNeJsfa2RYfCo"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_LSceh": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(8154)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_oYjvM": waas.Origin{HttpPort: common.Int(30085),
				HttpsPort: common.Int(10628),
				Uri:       common.String("EXAMPLE-uri-Value"),
				CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}}}},
			PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				CipherGroup:         waas.PolicyConfigCipherGroupDefault,
				ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
				HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					HealthyThreshold:           common.Int(17),
					IntervalInSeconds:          common.Int(28),
					Method:                     waas.HealthCheckMethodGet,
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(3),
					Headers:                    map[string]string{"EXAMPLE_KEY_73Bon": "EXAMPLE_VALUE_3UOkr59ivsvb3krWzVdo"},
					IsEnabled:                  common.Bool(false),
					IsResponseTextCheckEnabled: common.Bool(true),
					UnhealthyThreshold:         common.Int(7)},
				IsCacheControlRespected:    common.Bool(true),
				IsHttpsForced:              common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(true),
				IsResponseBufferingEnabled: common.Bool(true),
				IsBehindCdn:                common.Bool(false),
				IsHttpsEnabled:             common.Bool(false),
				IsSniEnabled:               common.Bool(false),
				LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"}},
			WafConfig: &waas.WafConfig{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")}},
				OriginGroups: []string{"EXAMPLE--Value"},
				AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(2840),
					AllowedRatePerAddress:     common.Int(7015),
					BlockResponseCode:         common.Int(205)},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCount: common.Int(6350),
					MaxAddressCountExpirationInSeconds: common.Int(61491),
					Action:                             waas.DeviceFingerprintChallengeActionBlock,
					ActionExpirationInSeconds:          common.Int(62415),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockResponseCode:         common.Int(878),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
					FailureThreshold:                    common.Int(28161),
					FailureThresholdExpirationInSeconds: common.Int(239964),
					IsEnabled:                           common.Bool(true)},
				Origin: common.String("EXAMPLE-origin-Value"),
				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(172447)}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThreshold: common.Int(740801),
					FailureThresholdExpirationInSeconds: common.Int(243457),
					InteractionThreshold:                common.Int(76),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(4436),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(131272),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(485),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")}},
				Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
					AddressLists: []string{"EXAMPLE--Value"},
					Addresses:    []string{"EXAMPLE--Value"}}},
				ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(130229),
					MediaTypes:                  []string{"EXAMPLE--Value"},
					BlockAction:                 waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockResponseCode:           common.Int(648),
					MaxNameLengthPerArgument:    common.Int(149779),
					MaxResponseSizeInKiB:        common.Int(1011),
					RecommendationsPeriodInDays: common.Int(28),
					AllowedHttpMethods:          []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
					BlockErrorPageCode:          common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:   common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:       common.String("EXAMPLE-blockErrorPageMessage-Value"),
					IsResponseInspected:         common.Bool(true),
					MaxArgumentCount:            common.Int(3376)},
				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")}},
				AccessRules: []waas.AccessRule{waas.AccessRule{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIs,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
					RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
					BlockAction:          waas.AccessRuleBlockActionSetResponseCode,
					BlockErrorPageCode:   common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaHeader:        common.String("EXAMPLE-captchaHeader-Value"),
					RedirectUrl:          common.String("EXAMPLE-redirectUrl-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
						Value: common.String("EXAMPLE-value-Value")}},
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(612),
					BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					Name:                      common.String("EXAMPLE-name-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					Action:                    waas.AccessRuleActionDetect}},
				CachingRules: []waas.CachingRule{waas.CachingRule{CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
					ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
					Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
						Value: common.String("EXAMPLE-value-Value")}},
					IsClientCachingEnabled: common.Bool(true),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value"),
					Action:                 waas.CachingRuleActionCache}},
				JsChallenge: &waas.JsChallenge{ChallengeSettings: &waas.BlockChallengeSettings{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"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(824)},
					IsEnabled: common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.JsChallengeActionDetect,
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIsNot,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					FailureThreshold:          common.Int(962846),
					IsNatEnabled:              common.Bool(true),
					ActionExpirationInSeconds: common.Int(170953),
					AreRedirectsChallenged:    common.Bool(false)},
				ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionOff,
					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"},
					Name:               common.String("EXAMPLE-name-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)
}