// 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_e6P9U": "EXAMPLE_VALUE_raroIR4YRGVND0jnInuT"},
		PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			CipherGroup:                waas.PolicyConfigCipherGroupDefault,
			IsBehindCdn:                common.Bool(false),
			IsCacheControlRespected:    common.Bool(true),
			IsHttpsEnabled:             common.Bool(false),
			IsOriginCompressionEnabled: common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(true),
			LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
				ExpirationTimeInSeconds: common.Int(1.3580847e+07),
				Name:                    common.String("EXAMPLE-name-Value")},
			ClientAddressHeader: waas.PolicyConfigClientAddressHeaderClientIp,
			HealthChecks: &waas.HealthCheck{Method: waas.HealthCheckMethodPost,
				Path:                       common.String("EXAMPLE-path-Value"),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				Headers:                    map[string]string{"EXAMPLE_KEY_hnOMv": "EXAMPLE_VALUE_5dYYG8o0bDCmMIMAtdfY"},
				HealthyThreshold:           common.Int(9),
				IsResponseTextCheckEnabled: common.Bool(false),
				TimeoutInSeconds:           common.Int(114),
				UnhealthyThreshold:         common.Int(2),
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				IntervalInSeconds:          common.Int(15),
				IsEnabled:                  common.Bool(false)},
			IsHttpsForced:         common.Bool(false),
			IsSniEnabled:          common.Bool(false),
			TlsProtocols:          []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
			WebsocketPathPrefixes: []string{"EXAMPLE--Value"}},
		AdditionalDomains: []string{"EXAMPLE--Value"},
		DisplayName:       common.String("EXAMPLE-displayName-Value"),
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_XcGJe": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Weight: common.Int(172),
			Origin: common.String("EXAMPLE-origin-Value")}}}},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_DXDbR": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(45200),
			HttpsPort: common.Int(38063),
			Uri:       common.String("EXAMPLE-uri-Value")}},
		WafConfig: &waas.WafConfigDetails{OriginGroups: []string{"EXAMPLE--Value"},
			AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeFound,
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition:       waas.AccessRuleCriteriaConditionIpIs,
					IsCaseSensitive: common.Bool(false)}},
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				Action:                    waas.AccessRuleActionDetect,
				BlockResponseCode:         common.Int(713),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Name:                      common.String("EXAMPLE-name-Value"),
				BlockAction:               waas.AccessRuleBlockActionSetResponseCode}},
			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.ProtectionRuleExclusionTargetRequestCookies}}}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(192),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
				FailureThreshold:                    common.Int(621850),
				InteractionThreshold:                common.Int(51),
				IsEnabled:                           common.Bool(true),
				IsNatEnabled:                        common.Bool(true),
				Action:                              waas.HumanInteractionChallengeActionDetect,
				FailureThresholdExpirationInSeconds: common.Int(41532),
				RecordingPeriodInSeconds:            common.Int(1744),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(14825)},
			Origin: common.String("EXAMPLE-origin-Value"),
			ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxArgumentCount:              common.Int(2957),
				MaxResponseSizeInKiB:          common.Int(1316),
				MaxTotalNameLengthOfArguments: common.Int(70956),
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockResponseCode:             common.Int(203),
				IsResponseInspected:           common.Bool(false),
				MaxNameLengthPerArgument:      common.Int(75610),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(68)},
			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(8470),
				AllowedRatePerAddress: common.Int(7401),
				BlockResponseCode:     common.Int(219),
				IsEnabled:             common.Bool(true)},
			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.CachingRuleCriteriaConditionPartEndsWith,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(true)}},
			Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(267710),
				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")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(9288),
				Action:                    waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(219836),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:     common.Int(294),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage},
				FailureThreshold:                    common.Int(449467),
				FailureThresholdExpirationInSeconds: common.Int(139878),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(8846)},
			JsChallenge: &waas.JsChallenge{FailureThreshold: common.Int(69899),
				IsEnabled:                 common.Bool(false),
				Action:                    waas.JsChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(198669),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				IsNatEnabled: common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				AreRedirectsChallenged: common.Bool(false),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(178)}}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_0R0ZN": map[string]interface{}{"EXAMPLE_KEY_4R25j": "EXAMPLE--Value"}}},
		OpcRequestId:  common.String("JPCXBUKXW6TTXQ0BMJNQ<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)
}