// 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("X2TFAVUNSS0V8VN0HVFH<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{Origins: map[string]waas.Origin{"EXAMPLE_KEY_aNE7D": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(48352),
			HttpsPort: common.Int(20294),
			Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{IsBehindCdn: common.Bool(true),
				IsOriginCompressionEnabled: common.Bool(false),
				LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXClientIp,
				HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					HealthyThreshold:           common.Int(4),
					IntervalInSeconds:          common.Int(76),
					IsEnabled:                  common.Bool(true),
					Path:                       common.String("EXAMPLE-path-Value"),
					UnhealthyThreshold:         common.Int(6),
					Headers:                    map[string]string{"EXAMPLE_KEY_25ubu": "EXAMPLE_VALUE_tBaE9FfOVXbrUCeKD7Hq"},
					IsResponseTextCheckEnabled: common.Bool(true),
					Method:                     waas.HealthCheckMethodGet,
					TimeoutInSeconds:           common.Int(115)},
				IsCacheControlRespected:    common.Bool(false),
				IsHttpsEnabled:             common.Bool(false),
				IsHttpsForced:              common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(false),
				IsSniEnabled:               common.Bool(false),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				CipherGroup:                waas.PolicyConfigCipherGroupDefault},
			WafConfig: &waas.WafConfig{ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
				Key:                common.String("EXAMPLE-key-Value"),
				Labels:             []string{"EXAMPLE--Value"},
				ModSecurityRuleIds: []string{"EXAMPLE--Value"},
				Name:               common.String("EXAMPLE-name-Value"),
				Action:             waas.ProtectionRuleActionOff,
				Description:        common.String("EXAMPLE-description-Value")}},
				AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionBlock,
					BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					Name:                       common.String("EXAMPLE-name-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
					BlockResponseCode:          common.Int(126),
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotEndWith,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
					RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(380),
					IsEnabled:                 common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(9120),
					AllowedRatePerAddress:     common.Int(317)},
				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(47062),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
					ActionExpirationInSeconds: common.Int(5509),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockResponseCode:         common.Int(118),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
					IsEnabled:              common.Bool(true),
					IsNatEnabled:           common.Bool(false),
					AreRedirectsChallenged: common.Bool(false),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
						Value:     common.String("EXAMPLE-value-Value"),
						Condition: waas.AccessRuleCriteriaConditionUrlPartContains}},
					FailureThreshold: common.Int(702512),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")}},
				Origin: common.String("EXAMPLE-origin-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{Action: waas.CachingRuleActionCache,
					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(false),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-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.ProtectionRuleExclusionTargetArgs}}}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(215894),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(607),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
					FailureThreshold:                    common.Int(168491),
					FailureThresholdExpirationInSeconds: common.Int(175222),
					IsEnabled:                           common.Bool(false),
					MaxAddressCount:                     common.Int(9910),
					MaxAddressCountExpirationInSeconds:  common.Int(20763),
					Action:                              waas.DeviceFingerprintChallengeActionDetect},
				OriginGroups: []string{"EXAMPLE--Value"},
				ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionOff,
					Description: common.String("EXAMPLE-description-Value"),
					Key:         common.String("EXAMPLE-key-Value"),
					Name:        common.String("EXAMPLE-name-Value")}},
				GoodBots: []waas.GoodBot{waas.GoodBot{Name: common.String("EXAMPLE-name-Value"),
					Description: common.String("EXAMPLE-description-Value"),
					IsEnabled:   common.Bool(false),
					Key:         common.String("EXAMPLE-key-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(206321),
					FailureThreshold:                    common.Int(760792),
					FailureThresholdExpirationInSeconds: common.Int(31043),
					RecordingPeriodInSeconds:            common.Int(7937),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(792),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
					InteractionThreshold: common.Int(55),
					IsEnabled:            common.Bool(false),
					IsNatEnabled:         common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.HumanInteractionChallengeActionBlock},
				ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(210),
					MaxNameLengthPerArgument:      common.Int(143147),
					RecommendationsPeriodInDays:   common.Int(26),
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					IsResponseInspected:           common.Bool(true),
					MaxArgumentCount:              common.Int(9321),
					MaxResponseSizeInKiB:          common.Int(137),
					MaxTotalNameLengthOfArguments: common.Int(325987),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete}}},
			AdditionalDomains: []string{"EXAMPLE--Value"},
			DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_3YPKb": map[string]interface{}{"EXAMPLE_KEY_E4sJf": "EXAMPLE--Value"}},
			DisplayName:       common.String("EXAMPLE-displayName-Value"),
			FreeformTags:      map[string]string{"EXAMPLE_KEY_5s0NV": "EXAMPLE_VALUE_Ct71a4CjSRwIDZJprw3x"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_kRlN4": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(3910)}}}}}}

	// 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)
}