// 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{CreateWaasPolicyDetails: waas.CreateWaasPolicyDetails{Domain: common.String("EXAMPLE-domain-Value"),
		FreeformTags: map[string]string{"EXAMPLE_KEY_DKVyR": "EXAMPLE_VALUE_9pyNYuflFUzGrecxmgX9"},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_Laodq": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(5968)}}}},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_rAmVt": waas.Origin{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(26807),
			HttpsPort: common.Int(44247)}},
		AdditionalDomains: []string{"EXAMPLE--Value"},
		CompartmentId:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		PolicyConfig: &waas.PolicyConfig{LoadBalancingMethod: waas.RoundRobinLoadBalancingMethod{},
			ClientAddressHeader:     waas.PolicyConfigClientAddressHeaderXRealIp,
			IsBehindCdn:             common.Bool(false),
			IsCacheControlRespected: common.Bool(true),
			IsSniEnabled:            common.Bool(false),
			TlsProtocols:            []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
			WebsocketPathPrefixes:   []string{"EXAMPLE--Value"},
			CertificateId:           common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			CipherGroup:             waas.PolicyConfigCipherGroupDefault,
			HealthChecks: &waas.HealthCheck{ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_g8Tjw": "EXAMPLE_VALUE_hLqYWjIOsuhjYiiU15mR"},
				IsEnabled:                  common.Bool(false),
				IsResponseTextCheckEnabled: common.Bool(true),
				Method:                     waas.HealthCheckMethodGet,
				UnhealthyThreshold:         common.Int(15),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				HealthyThreshold:           common.Int(18),
				IntervalInSeconds:          common.Int(6),
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(40)},
			IsHttpsEnabled:             common.Bool(false),
			IsHttpsForced:              common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(false),
			IsResponseBufferingEnabled: common.Bool(true)},
		WafConfig: &waas.WafConfigDetails{OriginGroups: []string{"EXAMPLE--Value"},
			AccessRules: []waas.AccessRule{waas.AccessRule{BlockResponseCode: common.Int(717),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				Action:                    waas.AccessRuleActionBlock,
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				Name:                      common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BlockAction:        waas.AccessRuleBlockActionShowErrorPage}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCount: common.Int(5689),
				MaxAddressCountExpirationInSeconds: common.Int(331856),
				Action:                             waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:          common.Int(419335),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(894),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold:                    common.Int(610454),
				FailureThresholdExpirationInSeconds: common.Int(195457),
				IsEnabled:                           common.Bool(false)},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(326492),
				InteractionThreshold: common.Int(51),
				IsEnabled:            common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(3937),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(444),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-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")},
				IsNatEnabled:             common.Bool(true),
				RecordingPeriodInSeconds: common.Int(1652),
				FailureThreshold:         common.Int(797774)},
			JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(125636),
				AreRedirectsChallenged: common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(104),
					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"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value")},
				FailureThreshold: common.Int(885146),
				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.JsChallengeActionDetect,
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}}},
			ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				IsResponseInspected:           common.Bool(false),
				MaxArgumentCount:              common.Int(2553),
				MaxResponseSizeInKiB:          common.Int(1446),
				MaxTotalNameLengthOfArguments: common.Int(179548),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
				BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(968),
				MaxNameLengthPerArgument:      common.Int(134771),
				RecommendationsPeriodInDays:   common.Int(6)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{MaxDelayedCountPerAddress: common.Int(5997),
				AllowedRatePerAddress: common.Int(4489),
				BlockResponseCode:     common.Int(851),
				IsEnabled:             common.Bool(false)},
			CachingRules: []waas.CachingRule{waas.CachingRule{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.CachingRuleCriteriaConditionIs}},
				IsClientCachingEnabled: common.Bool(true),
				Key:                    common.String("EXAMPLE-key-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{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(144373),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value")}},
			Origin: common.String("EXAMPLE-origin-Value")},
		DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_kN95B": map[string]interface{}{"EXAMPLE_KEY_6J8Pa": "EXAMPLE--Value"}},
		DisplayName: common.String("EXAMPLE-displayName-Value")},
		OpcRequestId:  common.String("D8TDWCWFLCRC8WLMJWI2<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}

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