// 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("HDDXDBRTXCGJELNIGB5W<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_tbqbF": map[string]interface{}{"EXAMPLE_KEY_FJKbP": "EXAMPLE--Value"}},
			DisplayName:  common.String("EXAMPLE-displayName-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_iFucB": "EXAMPLE_VALUE_BPQGvTcaJQE0UGrDYt8Z"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_egq6a": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(9024)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_071ou": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(26458),
				HttpsPort: common.Int(57164),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
				HealthChecks: &waas.HealthCheck{IsEnabled: common.Bool(true),
					IsResponseTextCheckEnabled: common.Bool(true),
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(5),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
					Headers:                    map[string]string{"EXAMPLE_KEY_pQ4rY": "EXAMPLE_VALUE_HRcT24Ud3S026rO3h9CO"},
					Method:                     waas.HealthCheckMethodHead,
					UnhealthyThreshold:         common.Int(16),
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					HealthyThreshold:           common.Int(7),
					IntervalInSeconds:          common.Int(112)},
				IsBehindCdn:                common.Bool(true),
				IsHttpsEnabled:             common.Bool(false),
				IsHttpsForced:              common.Bool(true),
				IsSniEnabled:               common.Bool(false),
				LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				IsCacheControlRespected:    common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(true),
				IsResponseBufferingEnabled: common.Bool(false),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12}},
			WafConfig: &waas.WafConfig{CachingRules: []waas.CachingRule{waas.CachingRule{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{Condition: waas.CachingRuleCriteriaConditionPartContains,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(false)}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(228643),
					FailureThresholdExpirationInSeconds: common.Int(106283),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(4470),
					MaxAddressCountExpirationInSeconds:  common.Int(17595),
					Action:                              waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds:           common.Int(76964),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-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"),
						BlockResponseCode:         common.Int(638),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockResponseCode:         common.Int(629)},
					FailureThreshold: common.Int(128541),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                              waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds:           common.Int(344739),
					FailureThresholdExpirationInSeconds: common.Int(228276),
					InteractionThreshold:                common.Int(12),
					IsEnabled:                           common.Bool(true),
					IsNatEnabled:                        common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(11711)},
				JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
					AreRedirectsChallenged:    common.Bool(false),
					FailureThreshold:          common.Int(524056),
					IsEnabled:                 common.Bool(false),
					IsNatEnabled:              common.Bool(false),
					ActionExpirationInSeconds: common.Int(22631),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:     common.Int(598),
						CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage,
						CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
						Name: common.String("EXAMPLE-name-Value")}},
				Origin: common.String("EXAMPLE-origin-Value"),
				ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Key: common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-Value"),
					Action:      waas.ThreatFeedActionDetect,
					Description: common.String("EXAMPLE-description-Value")}},
				AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode: common.Int(120),
					CaptchaTitle:      common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIsNot,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					Name:                 common.String("EXAMPLE-name-Value"),
					RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
					RedirectUrl:          common.String("EXAMPLE-redirectUrl-Value"),
					Action:               waas.AccessRuleActionAllow,
					CaptchaFooter:        common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:   common.String("EXAMPLE-captchaSubmitLabel-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
						Header: common.String("EXAMPLE-header-Value")}},
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockAction:           waas.AccessRuleBlockActionSetResponseCode,
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					BypassChallenges:      []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-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")}},
				OriginGroups: []string{"EXAMPLE--Value"},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
					Action: waas.CustomProtectionRuleSettingActionDetect,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgsNames}}}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6506),
					BlockResponseCode:         common.Int(783),
					IsEnabled:                 common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(9764)},
				Captchas: []waas.Captcha{waas.Captcha{FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
					FooterText:                 common.String("EXAMPLE-footerText-Value"),
					HeaderText:                 common.String("EXAMPLE-headerText-Value"),
					SessionExpirationInSeconds: common.Int(272276),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				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{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
					Key:                common.String("EXAMPLE-key-Value"),
					Labels:             []string{"EXAMPLE--Value"},
					ModSecurityRuleIds: []string{"EXAMPLE--Value"}}},
				ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(32759),
					RecommendationsPeriodInDays: common.Int(11),
					BlockAction:                 waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:          common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:   common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:       common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:           common.Int(434),
					MaxNameLengthPerArgument:    common.Int(113469),
					MaxResponseSizeInKiB:        common.Int(1493),
					MediaTypes:                  []string{"EXAMPLE--Value"},
					AllowedHttpMethods:          []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
					IsResponseInspected:         common.Bool(false),
					MaxArgumentCount:            common.Int(7364)},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}}},
			AdditionalDomains: []string{"EXAMPLE--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)
}