// 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 ExampleCreateWaasPolicy() {
	// 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.CreateWaasPolicyRequest{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		CreateWaasPolicyDetails: waas.CreateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
			DisplayName: common.String("EXAMPLE-displayName-Value"),
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_DKVyR": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(37848),
				HttpsPort: common.Int(6291),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_pyNYu": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(3334)}}}},
			PolicyConfig: &waas.PolicyConfig{IsHttpsForced: common.Bool(false),
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				IsCacheControlRespected:    common.Bool(true),
				IsOriginCompressionEnabled: common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(true),
				LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
					ExpirationTimeInSeconds: common.Int(1.405185e+06),
					Name:                    common.String("EXAMPLE-name-Value")},
				CipherGroup: waas.PolicyConfigCipherGroupDefault,
				HealthChecks: &waas.HealthCheck{Headers: map[string]string{"EXAMPLE_KEY_5BD8T": "EXAMPLE_VALUE_dWCwfLCRC8wLmjWi22Wy"},
					HealthyThreshold:           common.Int(19),
					IsResponseTextCheckEnabled: common.Bool(true),
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(86),
					UnhealthyThreshold:         common.Int(3),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					IntervalInSeconds:          common.Int(11),
					IsEnabled:                  common.Bool(true),
					Method:                     waas.HealthCheckMethodGet},
				IsHttpsEnabled:      common.Bool(false),
				IsSniEnabled:        common.Bool(false),
				TlsProtocols:        []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
				ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXClientIp,
				IsBehindCdn:         common.Bool(true)},
			WafConfig: &waas.WafConfigDetails{DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(418697),
				FailureThresholdExpirationInSeconds: common.Int(413491),
				IsEnabled:                           common.Bool(true),
				MaxAddressCount:                     common.Int(8598),
				MaxAddressCountExpirationInSeconds:  common.Int(124844),
				Action:                              waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:           common.Int(47065),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:     common.Int(143),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage,
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")}},
				OriginGroups: []string{"EXAMPLE--Value"},
				ProtectionSettings: &waas.ProtectionSettings{MaxArgumentCount: common.Int(6938),
					MaxNameLengthPerArgument:      common.Int(25921),
					MaxTotalNameLengthOfArguments: common.Int(193170),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(831),
					IsResponseInspected:           common.Bool(true),
					MaxResponseSizeInKiB:          common.Int(865),
					RecommendationsPeriodInDays:   common.Int(38),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value")},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6780),
					BlockResponseCode:         common.Int(139),
					IsEnabled:                 common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(7575)},
				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{Condition: waas.CachingRuleCriteriaConditionIs,
						Value: common.String("EXAMPLE-value-Value")}}}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgs}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				JsChallenge: &waas.JsChallenge{FailureThreshold: common.Int(483830),
					IsEnabled: common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.JsChallengeActionBlock,
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlDoesNotStartWith,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockResponseCode:         common.Int(506),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						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"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
					IsNatEnabled:              common.Bool(true),
					ActionExpirationInSeconds: common.Int(217280),
					AreRedirectsChallenged:    common.Bool(false)},
				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")}},
				AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionShowCaptcha,
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotEndWith,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
					BlockResponseCode:          common.Int(835),
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
					Name:                       common.String("EXAMPLE-name-Value")}},
				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(131467),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(34863),
					InteractionThreshold: common.Int(18),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					ActionExpirationInSeconds: common.Int(369013),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(370),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
					FailureThreshold:         common.Int(783901),
					IsEnabled:                common.Bool(false),
					IsNatEnabled:             common.Bool(false),
					RecordingPeriodInSeconds: common.Int(3190),
					Action:                   waas.HumanInteractionChallengeActionBlock}},
			CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
			DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_5vdQN": map[string]interface{}{"EXAMPLE_KEY_NAKRP": "EXAMPLE--Value"}},
			Domain:        common.String("EXAMPLE-domain-Value"),
			FreeformTags:  map[string]string{"EXAMPLE_KEY_HqIeK": "EXAMPLE_VALUE_RhzFzk8kA5MErKcqPboz"}},
		OpcRequestId: common.String("YUQCZJNWK9KUKZO7ZIQS<unique_ID>")}

	// Send the request using the service client
	resp, err := client.CreateWaasPolicy(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}